Module: Chef::Knife::ProfitbricksBase

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(includer) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/chef/knife/profitbricks_base.rb', line 6

def self.included(includer)
  includer.class_eval do
    deps do
      require 'profitbricks'
    end

    option :profitbricks_username,
      short: '-u USERNAME',
      long: '--username USERNAME',
      description: 'Your ProfitBricks username',
      proc: proc { |username| Chef::Config[:knife][:profitbricks_username] = username }

    option :profitbricks_password,
      short: '-p PASSWORD',
      long: '--password PASSWORD',
      description: 'Your ProfitBricks password',
      proc: proc { |password| Chef::Config[:knife][:profitbricks_password] = password }

    option :profitbricks_url,
      short: '-U URL',
      long: '--url URL',
      description: 'The ProfitBricks API URL',
      proc: proc { |url| Chef::Config[:knife][:profitbricks_url] = url }
  end
end

Instance Method Details

#connectionObject



32
33
34
35
36
37
38
39
40
# File 'lib/chef/knife/profitbricks_base.rb', line 32

def connection
  ProfitBricks.configure do |config|
    config.username = Chef::Config[:knife][:profitbricks_username]
    config.password = Chef::Config[:knife][:profitbricks_password]
    config.url = Chef::Config[:knife][:profitbricks_url]
    config.debug = Chef::Config[:knife][:profitbricks_debug] || false
    config.global_classes = false
  end
end

#msg_pair(label, value, color = :cyan) ⇒ Object



42
43
44
45
46
# File 'lib/chef/knife/profitbricks_base.rb', line 42

def msg_pair(label, value, color = :cyan)
  if value && !value.to_s.empty?
    puts "#{ui.color(label, color)}: #{value}"
  end
end