Module: Chef::Knife::ClodoBase

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(includer) ⇒ Object

I don’t know what this means, so just copy it from Rackspace



8
9
10
11
12
13
14
15
16
17
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
# File 'lib/chef/knife/clodo_base.rb', line 8

def self.included(includer)
  includer.class_eval do

    deps do
      require 'fog'
      require 'net/ssh/multi'
      require 'readline'
      require 'chef/json_compat'
    end

    option :clodo_api_key,
    :short => "-K KEY",
    :long => "--clodo-api-key KEY",
    :description => "Your clodo.ru API key"

    option :clodo_username,
    :short => "-A USERNAME",
    :long => "--clodo-username USERNAME",
    :description => "Your clodo.ru API username"

    option :clodo_api_auth_url,
    :long => "--clodo-api-auth-url URL",
    :description => "Your clodo.ru API auth url"
  end

  def connection
    @connection ||= Fog::Compute::Clodo.new({
                                              :clodo_api_key  => locate_config_value(:clodo_api_key),
                                              :clodo_username => locate_config_value(:clodo_username),
                                              :clodo_auth_url => locate_config_value(:clodo_api_auth_url) || 'api.clodo.ru'})
  end

  def locate_config_value(key)
    key = key.to_sym
    config[key] || Chef::Config[:knife][key]
  end
end

Instance Method Details

#connectionObject



33
34
35
36
37
38
# File 'lib/chef/knife/clodo_base.rb', line 33

def connection
  @connection ||= Fog::Compute::Clodo.new({
                                            :clodo_api_key  => locate_config_value(:clodo_api_key),
                                            :clodo_username => locate_config_value(:clodo_username),
                                            :clodo_auth_url => locate_config_value(:clodo_api_auth_url) || 'api.clodo.ru'})
end

#locate_config_value(key) ⇒ Object



40
41
42
43
# File 'lib/chef/knife/clodo_base.rb', line 40

def locate_config_value(key)
  key = key.to_sym
  config[key] || Chef::Config[:knife][key]
end