Module: Chef::Knife::SoftlayerBase
- Included in:
- SoftlayerDatacenterList, SoftlayerDatacenterShow, SoftlayerFlavorList, SoftlayerGlobalIpList, SoftlayerImageList, SoftlayerKeyPairCreate, SoftlayerKeyPairList, SoftlayerServerCreate, SoftlayerServerDestroy, SoftlayerVlanCreate, SoftlayerVlanList, SoftlayerVlanShow
- Defined in:
- lib/chef/knife/softlayer_base.rb
Constant Summary collapse
Class Method Summary collapse
-
.included(includer) ⇒ Object
:nodoc:.
Instance Method Summary collapse
- #compute ⇒ Object
-
#connection(service = :compute) ⇒ SoftLayer::Service
Returns a connection to a SoftLayer API Service Endpoint.
-
#locate_config_value(key) ⇒ String
Locates a config value.
-
#msg_pair(label, value, color = :cyan) ⇒ String
A CLI output formatting wrapper.
- #network ⇒ Object
Class Method Details
.included(includer) ⇒ Object
:nodoc:
18 19 20 21 22 23 24 25 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 51 52 |
# File 'lib/chef/knife/softlayer_base.rb', line 18 def self.included(includer) includer.class_eval do deps do require 'fog/softlayer' require 'net/ssh' require 'net/ssh/multi' require 'chef/monkey_patches/net-ssh-multi' require 'readline' require 'chef/exceptions' require 'chef/search/query' require 'chef/mixin/command' require 'chef/mixin/shell_out' require 'mixlib/shellout' require 'chef/json_compat' end option :softlayer_credential_file, :long => "--softlayer-credential-file FILE", :description => "File containing SoftLayer credentials as used by `softlayer_api` Ruby gem.", :proc => Proc.new { |key| Chef::Config[:knife][:softlayer_credential_file] = key } option :softlayer_username, :short => "-U USERNAME", :long => "--softlayer-username KEY", :description => "Your SoftLayer Username", :proc => Proc.new { |key| Chef::Config[:knife][:softlayer_access_key_id] = key } option :softlayer_api_key, :short => "-K SECRET", :long => "--softlayer-api-key SECRET", :description => "Your SoftLayer API Key", :proc => Proc.new { |key| Chef::Config[:knife][:softlayer_secret_access_key] = key } end end |
Instance Method Details
#compute ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/chef/knife/softlayer_base.rb', line 62 def compute @compute_connection ||= Fog::Compute.new( :provider => :softlayer, :softlayer_username => Chef::Config[:knife][:softlayer_username], :softlayer_api_key => Chef::Config[:knife][:softlayer_api_key], :softlayer_default_datacenter => Chef::Config[:knife][:softlayer_default_datacenter], :softlayer_default_domain => Chef::Config[:knife][:softlayer_default_domain], ) end |
#connection(service = :compute) ⇒ SoftLayer::Service
Returns a connection to a SoftLayer API Service Endpoint.
58 59 60 |
# File 'lib/chef/knife/softlayer_base.rb', line 58 def connection(service=:compute) self.send(service) end |
#locate_config_value(key) ⇒ String
Locates a config value.
84 85 86 87 |
# File 'lib/chef/knife/softlayer_base.rb', line 84 def locate_config_value(key) key = key.to_sym config[key] || Chef::Config[:knife][key] end |
#msg_pair(label, value, color = :cyan) ⇒ String
A CLI output formatting wrapper.
95 96 97 98 99 |
# File 'lib/chef/knife/softlayer_base.rb', line 95 def msg_pair(label, value, color=:cyan) if value && !value.to_s.empty? puts "#{ui.color(label, color)}: #{value}" end end |
#network ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/chef/knife/softlayer_base.rb', line 72 def network @network_connection ||= Fog::Network.new( :provider => :softlayer, :softlayer_username => Chef::Config[:knife][:softlayer_username], :softlayer_api_key => Chef::Config[:knife][:softlayer_api_key], ) end |