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.
@@ -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
- module KnifeVCloud
22
- class VcVappConfigNetwork < Chef::Knife
23
- include KnifeVCloud::Common
21
+ class Chef
22
+ class Knife
23
+ class VcVappConfigNetwork < Chef::Knife
24
+ include Knife::VcCommon
24
25
 
25
- deps do
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
- option :fence_mode,
63
- :short => "-F FENCE_MODE",
64
- :long => "--fence-mode FENCE_MODE",
65
- :description => "Set Fence Mode (e.g., Isolated, Bridged)",
66
- :proc => Proc.new { |key| Chef::Config[:knife][:fence_mode] = key }
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
- option :retain_network,
69
- :short => "-R RETAIN_NETWORK",
70
- :long => "--retain-network RETAIN_NETWORK",
71
- :description => "Toggle Retain Network across deployments (e.g., true, false)",
72
- :proc => Proc.new { |key| Chef::Config[:knife][:retain_network] = key }
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
- def run
75
- $stdout.sync = true
40
+ def run
41
+ $stdout.sync = true
76
42
 
77
- vapp_id = @name_args.shift
78
- network_name = @name_args.shift
43
+ vapp_id = @name_args.shift
44
+ network_name = @name_args.shift
79
45
 
80
- connection.login
46
+ connection.login
81
47
 
82
- config = {
83
- :fence_mode => locate_config_value(:fence_mode),
84
- :retain_net => locate_config_value(:retain_net)
85
- }
48
+ config = {
49
+ :fence_mode => locate_config_value(:fence_mode),
50
+ :retain_net => locate_config_value(:retain_net)
51
+ }
86
52
 
87
- task_id, response = connection.set_vapp_network_config vapp_id, network_name, config
53
+ task_id, response = connection.set_vapp_network_config vapp_id, network_name, config
88
54
 
89
- print "vApp network configuration..."
90
- wait_task(connection, task_id)
55
+ print "vApp network configuration..."
56
+ wait_task(connection, task_id)
91
57
 
92
- connection.logout
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
- module KnifeVCloud
22
- class VcVappCreate < Chef::Knife
23
- include KnifeVCloud::Common
21
+ class Chef
22
+ class Knife
23
+ class VcVappCreate < Chef::Knife
24
+ include Knife::VcCommon
24
25
 
25
- deps do
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
- def run
63
- $stdout.sync = true
28
+ def run
29
+ $stdout.sync = true
64
30
 
65
- vdc_id = @name_args.shift
66
- name = @name_args.shift
67
- description = @name_args.shift
68
- templateId = @name_args.shift
31
+ vdc_id = @name_args.shift
32
+ name = @name_args.shift
33
+ description = @name_args.shift
34
+ templateId = @name_args.shift
69
35
 
70
- connection.login
36
+ connection.login
71
37
 
72
- vapp_id, task_id = connection.create_vapp_from_template vdc_id, name, description, templateId
38
+ vapp_id, task_id = connection.create_vapp_from_template vdc_id, name, description, templateId
73
39
 
74
- print "vApp creation..."
75
- wait_task(connection, task_id)
76
- puts "vApp created with ID: #{ui.color(vapp_id, :cyan)}"
40
+ print "vApp creation..."
41
+ wait_task(connection, task_id)
42
+ puts "vApp created with ID: #{ui.color(vapp_id, :cyan)}"
77
43
 
78
- connection.logout
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
- module KnifeVCloud
22
- class VcVappDelete < Chef::Knife
23
- include KnifeVCloud::Common
21
+ class Chef
22
+ class Knife
23
+ class VcVappDelete < Chef::Knife
24
+ include Knife::VcCommon
24
25
 
25
- deps do
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
- def run
63
- $stdout.sync = true
28
+ def run
29
+ $stdout.sync = true
64
30
 
65
- vapp_id = @name_args.first
31
+ vapp_id = @name_args.first
66
32
 
67
- if ui.confirm("Do you really want to #{ui.color('DELETE', :red)} vApp #{vapp_id}?")
68
- connection.login
69
- task_id = connection.delete_vapp vapp_id
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
- print "vApp deletion..."
72
- wait_task(connection, task_id)
37
+ print "vApp deletion..."
38
+ wait_task(connection, task_id)
73
39
 
74
- connection.logout
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
- module KnifeVCloud
22
- class VcVappShow < Chef::Knife
23
- include KnifeVCloud::Common
24
-
25
- deps do
26
- require 'vcloud-rest/connection'
27
- require 'chef/api_client'
28
- end
29
-
30
- banner "knife vc vapp show [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 }
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
- module KnifeVCloud
22
- class VcVappStart < Chef::Knife
23
- include KnifeVCloud::Common
21
+ class Chef
22
+ class Knife
23
+ class VcVappStart < Chef::Knife
24
+ include Knife::VcCommon
24
25
 
25
- deps do
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
- def run
63
- $stdout.sync = true
28
+ def run
29
+ $stdout.sync = true
64
30
 
65
- vapp_id = @name_args.first
31
+ vapp_id = @name_args.first
66
32
 
67
- connection.login
33
+ connection.login
68
34
 
69
- task_id = connection.poweron_vapp vapp_id
35
+ task_id = connection.poweron_vapp vapp_id
70
36
 
71
- print "vApp startup..."
72
- wait_task(connection, task_id)
37
+ print "vApp startup..."
38
+ wait_task(connection, task_id)
73
39
 
74
- connection.logout
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
- module KnifeVCloud
22
- class VcVappStop < Chef::Knife
23
- include KnifeVCloud::Common
21
+ class Chef
22
+ class Knife
23
+ class VcVappStop < Chef::Knife
24
+ include Knife::VcCommon
24
25
 
25
- deps do
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
- def run
63
- $stdout.sync = true
28
+ def run
29
+ $stdout.sync = true
64
30
 
65
- vapp_id = @name_args.first
31
+ vapp_id = @name_args.first
66
32
 
67
- connection.login
33
+ connection.login
68
34
 
69
- task_id = connection.poweroff_vapp vapp_id
35
+ task_id = connection.poweroff_vapp vapp_id
70
36
 
71
- print "vApp shutdown..."
72
- wait_task(connection, task_id)
37
+ print "vApp shutdown..."
38
+ wait_task(connection, task_id)
73
39
 
74
- connection.logout
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
- module KnifeVCloud
22
- class VcVdcShow < Chef::Knife
23
- include KnifeVCloud::Common
21
+ class Chef
22
+ class Knife
23
+ class VcVdcShow < Chef::Knife
24
+ include Knife::VcCommon
24
25
 
25
- deps do
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
- 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 }
28
+ def run
29
+ $stdout.sync = true
49
30
 
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 }
31
+ vdc_id = @name_args.first
55
32
 
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 }
33
+ connection.login
61
34
 
62
- def run
63
- $stdout.sync = true
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
- vdc_id = @name_args.first
42
+ description, vapps, networks = connection.show_vdc vdc_id
66
43
 
67
- connection.login
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
- header = [
70
- ui.color('Name', :bold),
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