class Chef::Knife::OciServerList

List OCI instances. Note that this lists all instances in a compartment, not just those that are set up as Chef nodes.

Public Instance Methods

run() click to toggle source
# File lib/chef/knife/oci_server_list.rb, line 25
def run
  options = {}
  options[:limit] = config[:limit] if config[:limit]

  columns = ['Display Name', 'State', 'ID']

  list_for_display = config[:format] == 'summary' ? bold(columns) : []
  list_data, last_response = get_display_results(options) do |client_options|
    response = compute_client.list_instances(compartment_id, client_options)

    items = response_to_list(response) do |item|
      [item.display_name,
       item.lifecycle_state,
       item.id]
    end
    [response, items]
  end
  list_for_display += list_data

  display_list_from_array(list_for_display, columns.length)
  warn_if_page_is_truncated(last_response)
end