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,82 +16,49 @@
|
|
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 VcVmConfigGuest < 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 vm config guest [VAPP_ID] [COMPUTER_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 vm config guest [VAPP_ID] [COMPUTER_NAME] (options)"
|
61
27
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
28
|
+
option :guest_enabled,
|
29
|
+
:short => "-E ENABLED",
|
30
|
+
:long => "--enable-guest true|false",
|
31
|
+
:description => "Toggle Guest Customization"
|
66
32
|
|
67
|
-
|
68
|
-
|
69
|
-
|
33
|
+
option :admin_passwd_enabled,
|
34
|
+
:long => "--admin-passwd-enabled true|false",
|
35
|
+
:description => "Toggle Admin Password"
|
70
36
|
|
71
|
-
|
72
|
-
|
73
|
-
|
37
|
+
option :admin_passwd,
|
38
|
+
:long => "--admin-passwd ADMIN_PASSWD",
|
39
|
+
:description => "Set Admin Password"
|
74
40
|
|
75
|
-
|
76
|
-
|
41
|
+
def run
|
42
|
+
$stdout.sync = true
|
77
43
|
|
78
|
-
|
79
|
-
|
44
|
+
vm_id = @name_args.shift
|
45
|
+
computer_name = @name_args.shift
|
80
46
|
|
81
|
-
|
47
|
+
connection.login
|
82
48
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
49
|
+
config = {
|
50
|
+
:enabled => locate_config_value(:guest_enabled),
|
51
|
+
:admin_passwd_enabled => locate_config_value(:admin_passwd_enabled),
|
52
|
+
:admin_passwd => locate_config_value(:admin_passwd)
|
53
|
+
}
|
88
54
|
|
89
|
-
|
55
|
+
task_id, response = connection.set_vm_guest_customization vm_id, computer_name, config
|
90
56
|
|
91
|
-
|
92
|
-
|
57
|
+
print "VM network configuration..."
|
58
|
+
wait_task(connection, task_id)
|
93
59
|
|
94
|
-
|
60
|
+
connection.logout
|
61
|
+
end
|
95
62
|
end
|
96
63
|
end
|
97
64
|
end
|
@@ -16,83 +16,50 @@
|
|
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 VcVmConfigNetwork < 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 vm 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 vm config network [VAPP_ID] [NETWORK_NAME] (options)"
|
61
27
|
|
62
|
-
|
63
|
-
|
64
|
-
|
28
|
+
option :vm_net_primary_index,
|
29
|
+
:long => "--net-primary NETWORK_PRIMARY_IDX",
|
30
|
+
:description => "Index of the primary network interface"
|
65
31
|
|
66
|
-
|
67
|
-
|
68
|
-
|
32
|
+
option :vm_net_index,
|
33
|
+
:long => "--net-index NETWORK_IDX",
|
34
|
+
:description => "Index of the current network interface"
|
69
35
|
|
70
|
-
|
71
|
-
|
72
|
-
|
36
|
+
option :vm_net_ip,
|
37
|
+
:long => "--net-ip NETWORK_IP",
|
38
|
+
:description => "IP of the current network interface"
|
73
39
|
|
74
|
-
|
75
|
-
|
76
|
-
|
40
|
+
option :vm_net_is_connected,
|
41
|
+
:long => "--net-is-connected true|false",
|
42
|
+
:description => "Toggle IsConnected flag of the current network interface"
|
77
43
|
|
78
|
-
|
79
|
-
|
80
|
-
|
44
|
+
option :vm_ip_allocation_mode,
|
45
|
+
:long => "--ip-allocation-mode ALLOCATION_MODE",
|
46
|
+
:description => "Set IP allocation mode of the current network interface (e.g., POOL)"
|
81
47
|
|
82
|
-
|
83
|
-
|
48
|
+
def run
|
49
|
+
$stdout.sync = true
|
84
50
|
|
85
|
-
|
86
|
-
|
51
|
+
vm_id = @name_args.shift
|
52
|
+
network_name = @name_args.shift
|
87
53
|
|
88
|
-
|
54
|
+
connection.login
|
89
55
|
|
90
|
-
|
56
|
+
task_id, response = connection.set_vm_network_config vm_id, network_name, {:ip_allocation_mode => 'POOL'}
|
91
57
|
|
92
|
-
|
93
|
-
|
58
|
+
print "VM network configuration..."
|
59
|
+
wait_task(connection, task_id)
|
94
60
|
|
95
|
-
|
61
|
+
connection.logout
|
62
|
+
end
|
96
63
|
end
|
97
64
|
end
|
98
|
-
end
|
65
|
+
end
|
@@ -16,82 +16,49 @@
|
|
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 VcVmShow < 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 vm show [VM_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 }
|
26
|
+
banner "knife vc vm show [VM_ID] (options)"
|
55
27
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
:description => "vCloud API version (1.5 and 5.1 supported)",
|
60
|
-
:proc => Proc.new { |key| Chef::Config[:knife][:vcloud_api_version] = key }
|
28
|
+
def pretty_symbol(key)
|
29
|
+
key.to_s.gsub('_', ' ').capitalize
|
30
|
+
end
|
61
31
|
|
62
|
-
|
63
|
-
|
64
|
-
end
|
32
|
+
def run
|
33
|
+
$stdout.sync = true
|
65
34
|
|
66
|
-
|
67
|
-
$stdout.sync = true
|
35
|
+
vm_id = @name_args.first
|
68
36
|
|
69
|
-
|
37
|
+
list = []
|
70
38
|
|
71
|
-
|
39
|
+
connection.login
|
40
|
+
os_desc, networks, guest_customizations = connection.show_vm vm_id
|
41
|
+
connection.logout
|
72
42
|
|
73
|
-
|
74
|
-
os_desc, networks, guest_customizations = connection.show_vm vm_id
|
75
|
-
connection.logout
|
43
|
+
out_msg("OS Name", os_desc)
|
76
44
|
|
77
|
-
|
45
|
+
networks.each do |network, values|
|
46
|
+
list << ui.color('Network', :bold)
|
47
|
+
list << (network || '')
|
48
|
+
values.each do |k, v|
|
49
|
+
list << (pretty_symbol(k) || '')
|
50
|
+
list << (v || '')
|
51
|
+
end
|
52
|
+
end
|
78
53
|
|
79
|
-
|
80
|
-
list
|
81
|
-
|
82
|
-
values.each do |k, v|
|
54
|
+
list << ['', '', ui.color('Guest Customizations', :bold), '']
|
55
|
+
list.flatten!
|
56
|
+
guest_customizations.each do |k, v|
|
83
57
|
list << (pretty_symbol(k) || '')
|
84
58
|
list << (v || '')
|
85
59
|
end
|
60
|
+
puts ui.list(list, :columns_across, 2)
|
86
61
|
end
|
87
|
-
|
88
|
-
list << ['', '', ui.color('Guest Customizations', :bold), '']
|
89
|
-
list.flatten!
|
90
|
-
guest_customizations.each do |k, v|
|
91
|
-
list << (pretty_symbol(k) || '')
|
92
|
-
list << (v || '')
|
93
|
-
end
|
94
|
-
puts ui.list(list, :columns_across, 2)
|
95
62
|
end
|
96
63
|
end
|
97
64
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-vcloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef
|
@@ -69,9 +69,9 @@ files:
|
|
69
69
|
- CHANGELOG.md
|
70
70
|
- README.md
|
71
71
|
- LICENSE
|
72
|
-
- lib/chef/knife/common.rb
|
73
72
|
- lib/chef/knife/vc_catalog_item_show.rb
|
74
73
|
- lib/chef/knife/vc_catalog_show.rb
|
74
|
+
- lib/chef/knife/vc_common.rb
|
75
75
|
- lib/chef/knife/vc_login.rb
|
76
76
|
- lib/chef/knife/vc_org_list.rb
|
77
77
|
- lib/chef/knife/vc_org_show.rb
|
data/lib/chef/knife/common.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Stefano Tortarolo (<stefano.tortarolo@gmail.com>)
|
3
|
-
# Copyright:: Copyright (c) 2012
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
module KnifeVCloud
|
20
|
-
# Module for operations common among commands
|
21
|
-
module Common
|
22
|
-
def connection
|
23
|
-
unless @connection
|
24
|
-
@connection = VCloudClient::Connection.new(
|
25
|
-
locate_config_value(:vcloud_url),
|
26
|
-
locate_config_value(:vcloud_user),
|
27
|
-
locate_config_value(:vcloud_password),
|
28
|
-
locate_config_value(:vcloud_org),
|
29
|
-
locate_config_value(:vcloud_api_version)
|
30
|
-
)
|
31
|
-
end
|
32
|
-
@connection
|
33
|
-
end
|
34
|
-
|
35
|
-
def out_msg(label, value)
|
36
|
-
if value && !value.empty?
|
37
|
-
puts "#{ui.color(label, :cyan)}: #{value}"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def locate_config_value(key)
|
42
|
-
key = key.to_sym
|
43
|
-
Chef::Config[:knife][key] || config[key]
|
44
|
-
end
|
45
|
-
|
46
|
-
def wait_task(connection, task_id)
|
47
|
-
status, errormsg, start_time, end_time = connection.wait_task_completion task_id
|
48
|
-
puts "Done!"
|
49
|
-
out_msg("Summary", "Status: #{ui.color(status, :cyan)} - started at #{start_time} and ended at #{end_time}")
|
50
|
-
|
51
|
-
if errormsg
|
52
|
-
puts ui.color("ATTENTION: #{errormsg}", :red)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|