Class: Chef::Knife::VcConfigure

Inherits:
Chef::Knife show all
Includes:
VcCommon
Defined in:
lib/chef/knife/vc_configure.rb

Instance Method Summary collapse

Methods included from VcCommon

#connection, #deprecation_msg, #generate_key, #get_password, included, #locate_config_value, #locate_org_option, #notice_msg, #out_msg, #pretty_symbol, #sort_by_key, #store_config, #store_password, #wait_task

Instance Method Details

#runObject



35
36
37
38
39
40
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
68
# File 'lib/chef/knife/vc_configure.rb', line 35

def run
  $stdout.sync = true

  # Load or generate a keypair to encrypt info
  pemfile = locate_config_value(:vcloud_pem)
  if pemfile
    ui.msg("Loading existing pem")
    keyfile = "#{pemfile}"
  else
    ui.msg("PEM file not existing. Creating one.")
    generate_key()
    keyfile = locate_config_value(:vcloud_pem)
  end

  value = ui.ask("vCloud URL (%s): " % locate_config_value(:vcloud_url))
  unless value.empty?
    store_config(:vcloud_url, value)
  end

  value = ui.ask("vCloud username (%s): " % locate_config_value(:vcloud_user_login))
  unless value.empty?
    store_config(:vcloud_user_login, value)
  end

  value = ui.ask("vCloud API version (%s): " % (locate_config_value(:vcloud_api_version) || "5.1"))
  unless value.empty?
    store_config(:vcloud_api_version, value)
  end

  if !locate_config_value(:vcloud_password) ||
          locate_config_value(:change_password)
    store_password(keyfile)
  end
end