Class: Chef::Knife::BmcsCompartmentList
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::BmcsCompartmentList
- Includes:
- BmcsCommonOptions, BmcsHelper
- Defined in:
- lib/chef/knife/bmcs_compartment_list.rb
Overview
List BMCS compartments
Instance Method Summary collapse
Methods included from BmcsCommonOptions
Methods included from BmcsHelper
#bmcs_config, #check_can_access_instance, #compartment_id, #compute_client, #confirm, #display_list, #display_server_info, #error_and_exit, #identity_client, #network_client, #show_value, #validate_required_params, #warn_if_page_is_truncated
Instance Method Details
#run ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/chef/knife/bmcs_compartment_list.rb', line 24 def run = {} [:limit] = config[:limit] if config[:limit] response = identity_client.list_compartments(bmcs_config.tenancy, ) # Check whether there is a next page to decide whether to show an 'output is truncated' warning. # TODO: expected to be addressed server-side in a future release at which point this special # handling can be removed. show_truncated_warning = false if response && response.headers.include?('opc-next-page') response_page2 = identity_client.list_compartments(bmcs_config.tenancy, .merge(page: response.headers['opc-next-page'])) show_truncated_warning = response_page2 && response_page2.data && !response_page2.data.empty? end display_list(response, ['Display Name', 'ID'], warn_on_truncated: show_truncated_warning) do |item| [item.name, item.id] end end |