knife-vcloud 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +7 -0
- data/README.md +1 -1
- data/lib/chef/knife/vc_catalog_item_show.rb +24 -57
- data/lib/chef/knife/vc_catalog_show.rb +24 -57
- data/lib/chef/knife/vc_common.rb +103 -0
- data/lib/chef/knife/vc_login.rb +13 -46
- data/lib/chef/knife/vc_org_list.rb +20 -53
- data/lib/chef/knife/vc_org_show.rb +58 -91
- data/lib/chef/knife/vc_vapp_config_network.rb +30 -63
- data/lib/chef/knife/vc_vapp_create.rb +19 -52
- data/lib/chef/knife/vc_vapp_delete.rb +16 -49
- data/lib/chef/knife/vc_vapp_show.rb +38 -71
- data/lib/chef/knife/vc_vapp_start.rb +15 -48
- data/lib/chef/knife/vc_vapp_stop.rb +16 -49
- data/lib/chef/knife/vc_vdc_show.rb +30 -63
- data/lib/chef/knife/vc_vm_config_guest.rb +31 -64
- data/lib/chef/knife/vc_vm_config_network.rb +32 -65
- data/lib/chef/knife/vc_vm_show.rb +29 -62
- metadata +3 -3
- data/lib/chef/knife/common.rb +0 -56
@@ -16,80 +16,47 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require 'chef/knife'
|
19
|
+
require 'chef/knife/vc_common'
|
20
20
|
|
21
|
-
|
22
|
-
class
|
23
|
-
|
21
|
+
class Chef
|
22
|
+
class Knife
|
23
|
+
class VcVappConfigNetwork < Chef::Knife
|
24
|
+
include Knife::VcCommon
|
24
25
|
|
25
|
-
|
26
|
-
require 'vcloud-rest/connection'
|
27
|
-
require 'chef/api_client'
|
28
|
-
end
|
29
|
-
|
30
|
-
banner "knife vc vapp config network [VAPP_ID] [NETWORK_NAME] (options)"
|
31
|
-
|
32
|
-
option :vcloud_url,
|
33
|
-
:short => "-H URL",
|
34
|
-
:long => "--vcloud-url URL",
|
35
|
-
:description => "The vCloud endpoint URL",
|
36
|
-
:proc => Proc.new { |url| Chef::Config[:knife][:vcloud_url] = url }
|
37
|
-
|
38
|
-
option :vcloud_user,
|
39
|
-
:short => "-U USER",
|
40
|
-
:long => "--vcloud-user USER",
|
41
|
-
:description => "Your vCloud User",
|
42
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_user] = key }
|
43
|
-
|
44
|
-
option :vcloud_password,
|
45
|
-
:short => "-P SECRET",
|
46
|
-
:long => "--vcloud-password SECRET",
|
47
|
-
:description => "Your vCloud secret key",
|
48
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_password] = key }
|
49
|
-
|
50
|
-
option :vcloud_org,
|
51
|
-
:short => "-O ORGANIZATION",
|
52
|
-
:long => "--vcloud-organization ORGANIZATION",
|
53
|
-
:description => "Your vCloud Organization",
|
54
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_org] = key }
|
55
|
-
|
56
|
-
option :vcloud_api_version,
|
57
|
-
:short => "-A API_VERSION",
|
58
|
-
:long => "--vcloud-api-version API_VERSION",
|
59
|
-
:description => "vCloud API version (1.5 and 5.1 supported)",
|
60
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_api_version] = key }
|
26
|
+
banner "knife vc vapp config network [VAPP_ID] [NETWORK_NAME] (options)"
|
61
27
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
28
|
+
option :fence_mode,
|
29
|
+
:short => "-F FENCE_MODE",
|
30
|
+
:long => "--fence-mode FENCE_MODE",
|
31
|
+
:description => "Set Fence Mode (e.g., Isolated, Bridged)",
|
32
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:fence_mode] = key }
|
67
33
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
34
|
+
option :retain_network,
|
35
|
+
:short => "-R RETAIN_NETWORK",
|
36
|
+
:long => "--retain-network RETAIN_NETWORK",
|
37
|
+
:description => "Toggle Retain Network across deployments (e.g., true, false)",
|
38
|
+
:proc => Proc.new { |key| Chef::Config[:knife][:retain_network] = key }
|
73
39
|
|
74
|
-
|
75
|
-
|
40
|
+
def run
|
41
|
+
$stdout.sync = true
|
76
42
|
|
77
|
-
|
78
|
-
|
43
|
+
vapp_id = @name_args.shift
|
44
|
+
network_name = @name_args.shift
|
79
45
|
|
80
|
-
|
46
|
+
connection.login
|
81
47
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
48
|
+
config = {
|
49
|
+
:fence_mode => locate_config_value(:fence_mode),
|
50
|
+
:retain_net => locate_config_value(:retain_net)
|
51
|
+
}
|
86
52
|
|
87
|
-
|
53
|
+
task_id, response = connection.set_vapp_network_config vapp_id, network_name, config
|
88
54
|
|
89
|
-
|
90
|
-
|
55
|
+
print "vApp network configuration..."
|
56
|
+
wait_task(connection, task_id)
|
91
57
|
|
92
|
-
|
58
|
+
connection.logout
|
59
|
+
end
|
93
60
|
end
|
94
61
|
end
|
95
62
|
end
|
@@ -16,66 +16,33 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require 'chef/knife'
|
19
|
+
require 'chef/knife/vc_common'
|
20
20
|
|
21
|
-
|
22
|
-
class
|
23
|
-
|
21
|
+
class Chef
|
22
|
+
class Knife
|
23
|
+
class VcVappCreate < Chef::Knife
|
24
|
+
include Knife::VcCommon
|
24
25
|
|
25
|
-
|
26
|
-
require 'vcloud-rest/connection'
|
27
|
-
require 'chef/api_client'
|
28
|
-
end
|
29
|
-
|
30
|
-
banner "knife vc vapp create [VDC_ID] [NAME] [DESCRIPTION] [TEMPLATE_ID] (options)"
|
31
|
-
|
32
|
-
option :vcloud_url,
|
33
|
-
:short => "-H URL",
|
34
|
-
:long => "--vcloud-url URL",
|
35
|
-
:description => "The vCloud endpoint URL",
|
36
|
-
:proc => Proc.new { |url| Chef::Config[:knife][:vcloud_url] = url }
|
37
|
-
|
38
|
-
option :vcloud_user,
|
39
|
-
:short => "-U USER",
|
40
|
-
:long => "--vcloud-user USER",
|
41
|
-
:description => "Your vCloud User",
|
42
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_user] = key }
|
43
|
-
|
44
|
-
option :vcloud_password,
|
45
|
-
:short => "-P SECRET",
|
46
|
-
:long => "--vcloud-password SECRET",
|
47
|
-
:description => "Your vCloud secret key",
|
48
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_password] = key }
|
49
|
-
|
50
|
-
option :vcloud_org,
|
51
|
-
:short => "-O ORGANIZATION",
|
52
|
-
:long => "--vcloud-organization ORGANIZATION",
|
53
|
-
:description => "Your vCloud Organization",
|
54
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_org] = key }
|
55
|
-
|
56
|
-
option :vcloud_api_version,
|
57
|
-
:short => "-A API_VERSION",
|
58
|
-
:long => "--vcloud-api-version API_VERSION",
|
59
|
-
:description => "vCloud API version (1.5 and 5.1 supported)",
|
60
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_api_version] = key }
|
26
|
+
banner "knife vc vapp create [VDC_ID] [NAME] [DESCRIPTION] [TEMPLATE_ID] (options)"
|
61
27
|
|
62
|
-
|
63
|
-
|
28
|
+
def run
|
29
|
+
$stdout.sync = true
|
64
30
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
31
|
+
vdc_id = @name_args.shift
|
32
|
+
name = @name_args.shift
|
33
|
+
description = @name_args.shift
|
34
|
+
templateId = @name_args.shift
|
69
35
|
|
70
|
-
|
36
|
+
connection.login
|
71
37
|
|
72
|
-
|
38
|
+
vapp_id, task_id = connection.create_vapp_from_template vdc_id, name, description, templateId
|
73
39
|
|
74
|
-
|
75
|
-
|
76
|
-
|
40
|
+
print "vApp creation..."
|
41
|
+
wait_task(connection, task_id)
|
42
|
+
puts "vApp created with ID: #{ui.color(vapp_id, :cyan)}"
|
77
43
|
|
78
|
-
|
44
|
+
connection.logout
|
45
|
+
end
|
79
46
|
end
|
80
47
|
end
|
81
48
|
end
|
@@ -16,62 +16,29 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require 'chef/knife'
|
19
|
+
require 'chef/knife/vc_common'
|
20
20
|
|
21
|
-
|
22
|
-
class
|
23
|
-
|
21
|
+
class Chef
|
22
|
+
class Knife
|
23
|
+
class VcVappDelete < Chef::Knife
|
24
|
+
include Knife::VcCommon
|
24
25
|
|
25
|
-
|
26
|
-
require 'vcloud-rest/connection'
|
27
|
-
require 'chef/api_client'
|
28
|
-
end
|
29
|
-
|
30
|
-
banner "knife vc vapp delete [VAPP_ID] (options)"
|
31
|
-
|
32
|
-
option :vcloud_url,
|
33
|
-
:short => "-H URL",
|
34
|
-
:long => "--vcloud-url URL",
|
35
|
-
:description => "The vCloud endpoint URL",
|
36
|
-
:proc => Proc.new { |url| Chef::Config[:knife][:vcloud_url] = url }
|
37
|
-
|
38
|
-
option :vcloud_user,
|
39
|
-
:short => "-U USER",
|
40
|
-
:long => "--vcloud-user USER",
|
41
|
-
:description => "Your vCloud User",
|
42
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_user] = key }
|
43
|
-
|
44
|
-
option :vcloud_password,
|
45
|
-
:short => "-P SECRET",
|
46
|
-
:long => "--vcloud-password SECRET",
|
47
|
-
:description => "Your vCloud secret key",
|
48
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_password] = key }
|
49
|
-
|
50
|
-
option :vcloud_org,
|
51
|
-
:short => "-O ORGANIZATION",
|
52
|
-
:long => "--vcloud-organization ORGANIZATION",
|
53
|
-
:description => "Your vCloud Organization",
|
54
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_org] = key }
|
55
|
-
|
56
|
-
option :vcloud_api_version,
|
57
|
-
:short => "-A API_VERSION",
|
58
|
-
:long => "--vcloud-api-version API_VERSION",
|
59
|
-
:description => "vCloud API version (1.5 and 5.1 supported)",
|
60
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_api_version] = key }
|
26
|
+
banner "knife vc vapp delete [VAPP_ID] (options)"
|
61
27
|
|
62
|
-
|
63
|
-
|
28
|
+
def run
|
29
|
+
$stdout.sync = true
|
64
30
|
|
65
|
-
|
31
|
+
vapp_id = @name_args.first
|
66
32
|
|
67
|
-
|
68
|
-
|
69
|
-
|
33
|
+
if ui.confirm("Do you really want to #{ui.color('DELETE', :red)} vApp #{vapp_id}?")
|
34
|
+
connection.login
|
35
|
+
task_id = connection.delete_vapp vapp_id
|
70
36
|
|
71
|
-
|
72
|
-
|
37
|
+
print "vApp deletion..."
|
38
|
+
wait_task(connection, task_id)
|
73
39
|
|
74
|
-
|
40
|
+
connection.logout
|
41
|
+
end
|
75
42
|
end
|
76
43
|
end
|
77
44
|
end
|
@@ -16,77 +16,44 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require 'chef/knife'
|
20
|
-
|
21
|
-
|
22
|
-
class
|
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
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
option :vcloud_api_version,
|
57
|
-
:short => "-A API_VERSION",
|
58
|
-
:long => "--vcloud-api-version API_VERSION",
|
59
|
-
:description => "vCloud API version (1.5 and 5.1 supported)",
|
60
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_api_version] = key }
|
61
|
-
|
62
|
-
def run
|
63
|
-
$stdout.sync = true
|
64
|
-
|
65
|
-
vapp_id = @name_args.first
|
66
|
-
|
67
|
-
list = [
|
68
|
-
ui.color('Name', :bold),
|
69
|
-
ui.color('Status', :bold),
|
70
|
-
ui.color('IPs', :bold),
|
71
|
-
ui.color('ID', :bold)
|
72
|
-
]
|
73
|
-
|
74
|
-
connection.login
|
75
|
-
name, description, status, ip, vms_hash = connection.show_vapp vapp_id
|
76
|
-
connection.logout
|
77
|
-
|
78
|
-
out_msg("Name", name)
|
79
|
-
out_msg("Description", description)
|
80
|
-
out_msg("Status", status)
|
81
|
-
out_msg("IP", ip)
|
82
|
-
|
83
|
-
vms_hash.each do |k, v|
|
84
|
-
list << (k || '')
|
85
|
-
list << (v[:status] || '')
|
86
|
-
list << (v[:addresses].join(', ') || '<no ip>')
|
87
|
-
list << (v[:id] || '')
|
19
|
+
require 'chef/knife/vc_common'
|
20
|
+
|
21
|
+
class Chef
|
22
|
+
class Knife
|
23
|
+
class VcVappShow < Chef::Knife
|
24
|
+
include Knife::VcCommon
|
25
|
+
|
26
|
+
banner "knife vc vapp show [VAPP_ID] (options)"
|
27
|
+
|
28
|
+
def run
|
29
|
+
$stdout.sync = true
|
30
|
+
|
31
|
+
vapp_id = @name_args.first
|
32
|
+
|
33
|
+
list = [
|
34
|
+
ui.color('Name', :bold),
|
35
|
+
ui.color('Status', :bold),
|
36
|
+
ui.color('IPs', :bold),
|
37
|
+
ui.color('ID', :bold)
|
38
|
+
]
|
39
|
+
|
40
|
+
connection.login
|
41
|
+
name, description, status, ip, vms_hash = connection.show_vapp vapp_id
|
42
|
+
connection.logout
|
43
|
+
|
44
|
+
out_msg("Name", name)
|
45
|
+
out_msg("Description", description)
|
46
|
+
out_msg("Status", status)
|
47
|
+
out_msg("IP", ip)
|
48
|
+
|
49
|
+
vms_hash.each do |k, v|
|
50
|
+
list << (k || '')
|
51
|
+
list << (v[:status] || '')
|
52
|
+
list << (v[:addresses].join(', ') || '<no ip>')
|
53
|
+
list << (v[:id] || '')
|
54
|
+
end
|
55
|
+
puts ui.list(list, :columns_across, 4)
|
88
56
|
end
|
89
|
-
puts ui.list(list, :columns_across, 4)
|
90
57
|
end
|
91
58
|
end
|
92
|
-
end
|
59
|
+
end
|
@@ -16,62 +16,29 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require 'chef/knife'
|
19
|
+
require 'chef/knife/vc_common'
|
20
20
|
|
21
|
-
|
22
|
-
class
|
23
|
-
|
21
|
+
class Chef
|
22
|
+
class Knife
|
23
|
+
class VcVappStart < Chef::Knife
|
24
|
+
include Knife::VcCommon
|
24
25
|
|
25
|
-
|
26
|
-
require 'vcloud-rest/connection'
|
27
|
-
require 'chef/api_client'
|
28
|
-
end
|
29
|
-
|
30
|
-
banner "knife vc vapp start [VAPP_ID] (options)"
|
31
|
-
|
32
|
-
option :vcloud_url,
|
33
|
-
:short => "-H URL",
|
34
|
-
:long => "--vcloud-url URL",
|
35
|
-
:description => "The vCloud endpoint URL",
|
36
|
-
:proc => Proc.new { |url| Chef::Config[:knife][:vcloud_url] = url }
|
37
|
-
|
38
|
-
option :vcloud_user,
|
39
|
-
:short => "-U USER",
|
40
|
-
:long => "--vcloud-user USER",
|
41
|
-
:description => "Your vCloud User",
|
42
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_user] = key }
|
43
|
-
|
44
|
-
option :vcloud_password,
|
45
|
-
:short => "-P SECRET",
|
46
|
-
:long => "--vcloud-password SECRET",
|
47
|
-
:description => "Your vCloud secret key",
|
48
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_password] = key }
|
49
|
-
|
50
|
-
option :vcloud_org,
|
51
|
-
:short => "-O ORGANIZATION",
|
52
|
-
:long => "--vcloud-organization ORGANIZATION",
|
53
|
-
:description => "Your vCloud Organization",
|
54
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_org] = key }
|
55
|
-
|
56
|
-
option :vcloud_api_version,
|
57
|
-
:short => "-A API_VERSION",
|
58
|
-
:long => "--vcloud-api-version API_VERSION",
|
59
|
-
:description => "vCloud API version (1.5 and 5.1 supported)",
|
60
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_api_version] = key }
|
26
|
+
banner "knife vc vapp start [VAPP_ID] (options)"
|
61
27
|
|
62
|
-
|
63
|
-
|
28
|
+
def run
|
29
|
+
$stdout.sync = true
|
64
30
|
|
65
|
-
|
31
|
+
vapp_id = @name_args.first
|
66
32
|
|
67
|
-
|
33
|
+
connection.login
|
68
34
|
|
69
|
-
|
35
|
+
task_id = connection.poweron_vapp vapp_id
|
70
36
|
|
71
|
-
|
72
|
-
|
37
|
+
print "vApp startup..."
|
38
|
+
wait_task(connection, task_id)
|
73
39
|
|
74
|
-
|
40
|
+
connection.logout
|
41
|
+
end
|
75
42
|
end
|
76
43
|
end
|
77
44
|
end
|
@@ -16,62 +16,29 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require 'chef/knife'
|
19
|
+
require 'chef/knife/vc_common'
|
20
20
|
|
21
|
-
|
22
|
-
class
|
23
|
-
|
21
|
+
class Chef
|
22
|
+
class Knife
|
23
|
+
class VcVappStop < Chef::Knife
|
24
|
+
include Knife::VcCommon
|
24
25
|
|
25
|
-
|
26
|
-
require 'vcloud-rest/connection'
|
27
|
-
require 'chef/api_client'
|
28
|
-
end
|
29
|
-
|
30
|
-
banner "knife vc vapp stop [VAPP_ID] (options)"
|
31
|
-
|
32
|
-
option :vcloud_url,
|
33
|
-
:short => "-H URL",
|
34
|
-
:long => "--vcloud-url URL",
|
35
|
-
:description => "The vCloud endpoint URL",
|
36
|
-
:proc => Proc.new { |url| Chef::Config[:knife][:vcloud_url] = url }
|
37
|
-
|
38
|
-
option :vcloud_user,
|
39
|
-
:short => "-U USER",
|
40
|
-
:long => "--vcloud-user USER",
|
41
|
-
:description => "Your vCloud User",
|
42
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_user] = key }
|
43
|
-
|
44
|
-
option :vcloud_password,
|
45
|
-
:short => "-P SECRET",
|
46
|
-
:long => "--vcloud-password SECRET",
|
47
|
-
:description => "Your vCloud secret key",
|
48
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_password] = key }
|
49
|
-
|
50
|
-
option :vcloud_org,
|
51
|
-
:short => "-O ORGANIZATION",
|
52
|
-
:long => "--vcloud-organization ORGANIZATION",
|
53
|
-
:description => "Your vCloud Organization",
|
54
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_org] = key }
|
55
|
-
|
56
|
-
option :vcloud_api_version,
|
57
|
-
:short => "-A API_VERSION",
|
58
|
-
:long => "--vcloud-api-version API_VERSION",
|
59
|
-
:description => "vCloud API version (1.5 and 5.1 supported)",
|
60
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_api_version] = key }
|
26
|
+
banner "knife vc vapp stop [VAPP_ID] (options)"
|
61
27
|
|
62
|
-
|
63
|
-
|
28
|
+
def run
|
29
|
+
$stdout.sync = true
|
64
30
|
|
65
|
-
|
31
|
+
vapp_id = @name_args.first
|
66
32
|
|
67
|
-
|
33
|
+
connection.login
|
68
34
|
|
69
|
-
|
35
|
+
task_id = connection.poweroff_vapp vapp_id
|
70
36
|
|
71
|
-
|
72
|
-
|
37
|
+
print "vApp shutdown..."
|
38
|
+
wait_task(connection, task_id)
|
73
39
|
|
74
|
-
|
40
|
+
connection.logout
|
41
|
+
end
|
75
42
|
end
|
76
43
|
end
|
77
|
-
end
|
44
|
+
end
|
@@ -16,79 +16,46 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require 'chef/knife'
|
19
|
+
require 'chef/knife/vc_common'
|
20
20
|
|
21
|
-
|
22
|
-
class
|
23
|
-
|
21
|
+
class Chef
|
22
|
+
class Knife
|
23
|
+
class VcVdcShow < Chef::Knife
|
24
|
+
include Knife::VcCommon
|
24
25
|
|
25
|
-
|
26
|
-
require 'vcloud-rest/connection'
|
27
|
-
require 'chef/api_client'
|
28
|
-
end
|
29
|
-
|
30
|
-
banner "knife vc vdc show [VDC_ID] (options)"
|
31
|
-
|
32
|
-
option :vcloud_url,
|
33
|
-
:short => "-H URL",
|
34
|
-
:long => "--vcloud-url URL",
|
35
|
-
:description => "The vCloud endpoint URL",
|
36
|
-
:proc => Proc.new { |url| Chef::Config[:knife][:vcloud_url] = url }
|
37
|
-
|
38
|
-
option :vcloud_user,
|
39
|
-
:short => "-U USER",
|
40
|
-
:long => "--vcloud-user USER",
|
41
|
-
:description => "Your vCloud User",
|
42
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_user] = key }
|
26
|
+
banner "knife vc vdc show [VDC_ID] (options)"
|
43
27
|
|
44
|
-
|
45
|
-
|
46
|
-
:long => "--vcloud-password SECRET",
|
47
|
-
:description => "Your vCloud secret key",
|
48
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_password] = key }
|
28
|
+
def run
|
29
|
+
$stdout.sync = true
|
49
30
|
|
50
|
-
|
51
|
-
:short => "-O ORGANIZATION",
|
52
|
-
:long => "--vcloud-organization ORGANIZATION",
|
53
|
-
:description => "Your vCloud Organization",
|
54
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_org] = key }
|
31
|
+
vdc_id = @name_args.first
|
55
32
|
|
56
|
-
|
57
|
-
:short => "-A API_VERSION",
|
58
|
-
:long => "--vcloud-api-version API_VERSION",
|
59
|
-
:description => "vCloud API version (1.5 and 5.1 supported)",
|
60
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_api_version] = key }
|
33
|
+
connection.login
|
61
34
|
|
62
|
-
|
63
|
-
|
35
|
+
header = [
|
36
|
+
ui.color('Name', :bold),
|
37
|
+
ui.color('ID', :bold),
|
38
|
+
ui.color('Status', :bold),
|
39
|
+
ui.color('IP', :bold),
|
40
|
+
]
|
64
41
|
|
65
|
-
|
42
|
+
description, vapps, networks = connection.show_vdc vdc_id
|
66
43
|
|
67
|
-
|
44
|
+
puts "#{ui.color('Description:', :cyan)} #{description}"
|
45
|
+
list = ["#{ui.color('vAPPS', :cyan)}", '', '', '']
|
46
|
+
list << header
|
47
|
+
list.flatten!
|
48
|
+
vapps.each do |k, v|
|
49
|
+
name, description, status, ip, vms_hash = connection.show_vapp v
|
50
|
+
list << ("#{k} (#{vms_hash.count} VMs)" || '')
|
51
|
+
list << (v || '')
|
52
|
+
list << (status || '')
|
53
|
+
list << (ip || '')
|
54
|
+
end
|
68
55
|
|
69
|
-
|
70
|
-
|
71
|
-
ui.color('ID', :bold),
|
72
|
-
ui.color('Status', :bold),
|
73
|
-
ui.color('IP', :bold),
|
74
|
-
]
|
75
|
-
|
76
|
-
description, vapps, networks = connection.show_vdc vdc_id
|
77
|
-
|
78
|
-
puts "#{ui.color('Description:', :cyan)} #{description}"
|
79
|
-
list = ["#{ui.color('vAPPS', :cyan)}", '', '', '']
|
80
|
-
list << header
|
81
|
-
list.flatten!
|
82
|
-
vapps.each do |k, v|
|
83
|
-
name, description, status, ip, vms_hash = connection.show_vapp v
|
84
|
-
list << ("#{k} (#{vms_hash.count} VMs)" || '')
|
85
|
-
list << (v || '')
|
86
|
-
list << (status || '')
|
87
|
-
list << (ip || '')
|
56
|
+
puts ui.list(list, :columns_across, 4)
|
57
|
+
connection.logout
|
88
58
|
end
|
89
|
-
|
90
|
-
puts ui.list(list, :columns_across, 4)
|
91
|
-
connection.logout
|
92
59
|
end
|
93
60
|
end
|
94
61
|
end
|