Class: Chef::Knife::OciServerShow
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::OciServerShow
- Includes:
- OciCommonOptions, OciHelper, OciHelperShow
- Defined in:
- lib/chef/knife/oci_server_show.rb
Overview
List details of a particular OCI instance.
Instance Method Summary collapse
Methods included from OciCommonOptions
Methods included from OciHelperShow
#add_server_details, #add_vnic_details, #display_server_info, #lookup_compartment_name, #lookup_image_name, #lookup_vcn_name, #show_value
Methods included from OciHelper
#_non_summary_list, #_summary_list, #bold, #check_can_access_instance, #compartment_id, #compute_client, #config_file_location, #config_file_profile, #confirm, #display_list_from_array, #error_and_exit, #get_display_results, #identity_client, #network_client, #next_page_token, #oci_config, #response_to_list, #validate_required_params, #warn_if_page_is_truncated
Instance Method Details
#run ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/chef/knife/oci_server_show.rb', line 26 def run validate_required_params(%i[instance_id], config) vnic_array = [] server = check_can_access_instance(config[:instance_id]) error_and_exit 'Unable to retrieve instance' unless server.data vnics = compute_client.(compartment_id, instance_id: config[:instance_id]) vnics.data && vnics.data.each do |vnic| next unless vnic.lifecycle_state == 'ATTACHED' begin vnic_info = network_client.get_vnic(vnic.vnic_id, {}) rescue OCI::Errors::ServiceError => service_error raise unless service_error.service_code == 'NotAuthorizedOrNotFound' else add_vnic_details(vnic_info.data) if vnic_info.data.is_primary == true vnic_array.unshift(vnic_info.data) # make primary interface first in the array else vnic_array.push(vnic_info.data) end end end add_server_details(server.data, vnic_array[0] ? vnic_array[0].vcn_id : nil) display_server_info(config, server.data, vnic_array) end |