Class: Chef::Knife::GandiDatacenterList
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::GandiDatacenterList
- Defined in:
- lib/chef/knife/gandi_datacenter_list.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
39 40 41 |
# File 'lib/chef/knife/gandi_datacenter_list.rb', line 39 def api_key @api_key end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
39 40 41 |
# File 'lib/chef/knife/gandi_datacenter_list.rb', line 39 def connection @connection end |
Instance Method Details
#run ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/chef/knife/gandi_datacenter_list.rb', line 41 def run # Unsual to extend here but enables 'plugin_helper' to be require'd lazily extend KnifeGandi::PluginHelper $stdout.sync = true # Necessary changes to xmlrpc's defaults, prevent warnings from showing up in prompt suppress_warnings do XMLRPC::Config.const_set(:ENABLE_NIL_PARSER, true) end @connection = XMLRPC::Client.new2(KnifeGandi::API_ENDPOINT_URL) @api_key = Chef::Config[:knife][:gandi_api_key] || config[:gandi_api_key] server_list = [ ui.color('ID', :bold), ui.color('Name', :bold), ui.color('Country', :bold) ] connection.call('datacenter.list', api_key).each do |server| server_list << server['id'].to_s server_list << server['name'] server_list << server['country'] end puts ui.list(server_list, :columns_across, 3) end |