vagrant-vcloud 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -76
- data/lib/vagrant-vcloud/action.rb +36 -15
- data/lib/vagrant-vcloud/action/build_vapp.rb +3 -5
- data/lib/vagrant-vcloud/action/forward_ports.rb +31 -19
- data/lib/vagrant-vcloud/action/handle_nat_port_collisions.rb +3 -11
- data/lib/vagrant-vcloud/action/inventory_check.rb +25 -10
- data/lib/vagrant-vcloud/action/message_not_created.rb +1 -1
- data/lib/vagrant-vcloud/action/power_on.rb +14 -0
- data/lib/vagrant-vcloud/action/read_ssh_info.rb +41 -17
- data/lib/vagrant-vcloud/action/unmap_port_forwardings.rb +18 -17
- data/lib/vagrant-vcloud/cap/forwarded_ports.rb +1 -6
- data/lib/vagrant-vcloud/cap/public_address.rb +0 -2
- data/lib/vagrant-vcloud/cap/rdp_info.rb +18 -0
- data/lib/vagrant-vcloud/cap/winrm_info.rb +18 -0
- data/lib/vagrant-vcloud/command.rb +19 -4
- data/lib/vagrant-vcloud/config.rb +9 -0
- data/lib/vagrant-vcloud/driver/base.rb +4 -1
- data/lib/vagrant-vcloud/driver/version_5_1.rb +68 -0
- data/lib/vagrant-vcloud/plugin.rb +10 -0
- data/lib/vagrant-vcloud/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c67fed2281158e2886200db7ede9d6897960497
|
4
|
+
data.tar.gz: 5755cae7234f427fbc190ceb4b56a41d49450b38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 086de3a0a7d11d6a093363599de2d2d44ed41aa6e74331ffffadb9b7f96f8c91f784090f0ed07b299afb7d44e9c1fd64ca4eabaf597a1b79a7552748619f7fbd
|
7
|
+
data.tar.gz: e784aeae136758ca9f591f7403fa89155f05a66b08e01872d0dbe68c58c09f8b2a8e21eec25c346c0b956a16e36aec11d27b8832627eb080acdfe8606ea51e3d
|
data/README.md
CHANGED
@@ -1,64 +1,15 @@
|
|
1
1
|
[Vagrant](http://www.vagrantup.com) provider for VMware vCloud Director®
|
2
2
|
=============
|
3
3
|
|
4
|
-
[Version 0.
|
4
|
+
[Version 0.4.0](../../releases/tag/v0.4.0) has been released!
|
5
5
|
-------------
|
6
6
|
|
7
7
|
Please note that this software is still Alpha/Beta quality and is not recommended for production usage.
|
8
8
|
|
9
|
-
|
9
|
+
We have a wide array of boxes available at [Vagrant Cloud](https://vagrantcloud.com/gosddc) you can use them directly or you can roll your own as you please, make sure to install VMware tools in it.
|
10
10
|
|
11
11
|
If you're unsure about what are the correct network settings for your Vagrantfile make sure to check out the [Network Deployment Options](https://github.com/frapposelli/vagrant-vcloud/wiki/Network-Deployment-Options) wiki page.
|
12
12
|
|
13
|
-
Features of Version 0.3.3 are:
|
14
|
-
|
15
|
-
- Critical Bug Fix for ```network_bridge``` users [[#67](../../issues/67)]
|
16
|
-
|
17
|
-
Features of Version 0.3.2 are:
|
18
|
-
|
19
|
-
- Added support for ```vagrant share``` command [[#31](../../issues/31)] *experimental*
|
20
|
-
- Restructured the ```vagrant vcloud-status``` command to ```vagrant vcloud``` namespace for future-proofing [[#53](../../issues/53)]
|
21
|
-
- Added ```vagrant vcloud --redeploy-edge-gw``` to redeploy Edge Gateway [[#54](../../issues/54)]
|
22
|
-
- Fixed Issues [[#45](https://github.com/frapposelli/vagrant-vcloud/issues/45), [#46](https://github.com/frapposelli/vagrant-vcloud/issues/46), [#47](https://github.com/frapposelli/vagrant-vcloud/issues/47), [#48](https://github.com/frapposelli/vagrant-vcloud/issues/48), [#51](https://github.com/frapposelli/vagrant-vcloud/issues/51), [#52](https://github.com/frapposelli/vagrant-vcloud/issues/52), [#56](https://github.com/frapposelli/vagrant-vcloud/issues/56), [#57](https://github.com/frapposelli/vagrant-vcloud/issues/57), [#61](https://github.com/frapposelli/vagrant-vcloud/issues/61)]
|
23
|
-
|
24
|
-
|
25
|
-
Features of Version 0.3.1 are:
|
26
|
-
|
27
|
-
- Small hotfix to include "preRunning" condition when using vCloud Director 5.5 [[#44](https://github.com/frapposelli/vagrant-vcloud/issues/44)]. - [Andrew Poland](https://github.com/apoland)
|
28
|
-
|
29
|
-
Features of Version 0.3.0 are:
|
30
|
-
|
31
|
-
A substantial release, major kudos to [Stefan Scherer](https://github.com/StefanScherer) who submitted some substantious PRs!
|
32
|
-
|
33
|
-
- Added support for port mapping at the Organization Edge Gateway.
|
34
|
-
- Added a new configuration options ```vapp_prefix``` to change vApp prefix (defaults to Vagrant).
|
35
|
-
- Improved vcloud-status command.
|
36
|
-
- Fixed cygdrive path for rsync on Windows.
|
37
|
-
- Fixed Issue [[#33](../../issues/33)] - Error removing/creating NAT rules on second vagrant up.
|
38
|
-
- Fixed Issue [[#43](../../issues/43)] - Destroy fails if VMs are halted.
|
39
|
-
|
40
|
-
Features of Version 0.2.2 are:
|
41
|
-
|
42
|
-
- Fixed Issue [[#32](../../issues/32)] - Port Forwarding rules are deleted when Halting a VM.
|
43
|
-
|
44
|
-
Features of Version 0.2.1 are:
|
45
|
-
|
46
|
-
- Critical Bugfixes
|
47
|
-
|
48
|
-
Features of Version 0.2.0 are:
|
49
|
-
|
50
|
-
- It's now possible to connect to an existing VDC network without creating a vShield Edge using ```network_bridge = true``` in the Vagrantfile [[#23](../../issues/23)]. *experimental*
|
51
|
-
- Added a ```upload_chunksize``` parameter to specify the chunk dimension during box uploads [[#21](../../issues/21)].
|
52
|
-
- Added support for [vCloud® Hybrid Service™](http://www.vmware.com/products/vcloud-hybrid-service) API version 5.7.
|
53
|
-
- Added a new command to vagrant called ```vcloud-status``` that shows the current status of the vCloud instance relative to the Vagrant deployment. *experimental*
|
54
|
-
- General code cleanup, code should be more readable and there's a rubocop file for our code conventions.
|
55
|
-
- Passwords are now hidden when running in DEBUG mode.
|
56
|
-
- Initial support for Vagrant 1.5 (currently not supporting the new "share" features).
|
57
|
-
- Lowered Nokogiri requirement to 1.5.5 (you may need to remove a later version if installed).
|
58
|
-
- Fixed the Edge Gateway NAT rules creation / deletion.
|
59
|
-
- Added debug capabilities down to XML traffic exchanged during the REST calls.
|
60
|
-
|
61
|
-
|
62
13
|
Check the full releases changelog [here](../../releases)
|
63
14
|
|
64
15
|
Install
|
@@ -78,36 +29,33 @@ Configuration
|
|
78
29
|
Here's a sample Multi-VM Vagrantfile, please note that ```vcloud.vdc_edge_gateway``` and ```vcloud.vdc_edge_gateway_ip``` are required only when you cannot access ```vcloud.vdc_network_name``` directly and there's an Organization Edge between your workstation and the vCloud Network.
|
79
30
|
|
80
31
|
```ruby
|
81
|
-
precise32_vm_box_url = "http://vagrant.tsugliani.fr/precise32.box"
|
82
|
-
|
83
32
|
nodes = [
|
84
|
-
{ :
|
85
|
-
{ :
|
86
|
-
{ :
|
87
|
-
{ :
|
88
|
-
{ :hostname => "app-vm", :box => "precise32", :box_url => precise32_vm_box_url },
|
33
|
+
{ hostname: 'web-vm', box: 'gosddc/precise32' },
|
34
|
+
{ hostname: 'ssh-vm', box: 'gosddc/precise32' },
|
35
|
+
{ hostname: 'sql-vm', box: 'gosddc/precise32' },
|
36
|
+
{ hostname: 'app-vm', box: 'gosddc/precise32' }
|
89
37
|
]
|
90
38
|
|
91
|
-
Vagrant.configure(
|
39
|
+
Vagrant.configure('2') do |config|
|
92
40
|
|
93
41
|
# vCloud Director provider settings
|
94
42
|
config.vm.provider :vcloud do |vcloud|
|
95
|
-
vcloud.vapp_prefix =
|
96
|
-
|
97
|
-
vcloud.hostname =
|
98
|
-
vcloud.username =
|
99
|
-
vcloud.password =
|
100
|
-
|
101
|
-
vcloud.org_name =
|
102
|
-
vcloud.vdc_name =
|
103
|
-
|
104
|
-
vcloud.catalog_name =
|
105
|
-
vcloud.ip_subnet =
|
106
|
-
|
107
|
-
vcloud.vdc_network_name =
|
108
|
-
|
109
|
-
vcloud.vdc_edge_gateway =
|
110
|
-
vcloud.vdc_edge_gateway_ip =
|
43
|
+
vcloud.vapp_prefix = 'multibox-sample'
|
44
|
+
|
45
|
+
vcloud.hostname = 'https://my.cloudprovider.com'
|
46
|
+
vcloud.username = 'MyUserName'
|
47
|
+
vcloud.password = 'MySup3rS3cr3tPassw0rd!'
|
48
|
+
|
49
|
+
vcloud.org_name = 'OrganizationName'
|
50
|
+
vcloud.vdc_name = 'vDC_Name'
|
51
|
+
|
52
|
+
vcloud.catalog_name = 'Vagrant'
|
53
|
+
vcloud.ip_subnet = '172.16.32.125/255.255.255.240'
|
54
|
+
|
55
|
+
vcloud.vdc_network_name = 'MyNetwork'
|
56
|
+
|
57
|
+
vcloud.vdc_edge_gateway = 'MyOrgEdgeGateway'
|
58
|
+
vcloud.vdc_edge_gateway_ip = '10.10.10.10'
|
111
59
|
end
|
112
60
|
|
113
61
|
nodes.each do |node|
|
@@ -115,7 +63,10 @@ Vagrant.configure("2") do |config|
|
|
115
63
|
node_config.vm.box = node[:box]
|
116
64
|
node_config.vm.hostname = node[:hostname]
|
117
65
|
node_config.vm.box_url = node[:box_url]
|
118
|
-
node_config.vm.network :forwarded_port,
|
66
|
+
node_config.vm.network :forwarded_port,
|
67
|
+
guest: 80,
|
68
|
+
host: 8080,
|
69
|
+
auto_correct: true
|
119
70
|
# node_config.vm.provision :puppet do |puppet|
|
120
71
|
# puppet.manifests_path = 'puppet/manifests'
|
121
72
|
# puppet.manifest_file = 'site.pp'
|
@@ -96,21 +96,28 @@ module VagrantPlugins
|
|
96
96
|
if env[:result]
|
97
97
|
b2.use ConfigValidate
|
98
98
|
b2.use ConnectVCloud
|
99
|
-
b2.use Call,
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
99
|
+
b2.use Call, IsCreated do |env2, b3|
|
100
|
+
unless env2[:result]
|
101
|
+
b3.use MessageNotCreated
|
102
|
+
next
|
103
|
+
end
|
104
|
+
|
105
|
+
b3.use Call, IsRunning do |env3, b4|
|
106
|
+
# If the VM is running, must power off
|
107
|
+
b4.use action_halt if env3[:result]
|
108
|
+
end
|
109
|
+
b3.use Call, IsLastVM do |env3, b4|
|
110
|
+
if env3[:result]
|
111
|
+
# Check if the network is bridged
|
112
|
+
b4.use Call, IsBridged do |env4, b5|
|
113
|
+
# if it's not, delete port forwardings.
|
114
|
+
b5.use UnmapPortForwardings unless env4[:bridged_network]
|
115
|
+
end
|
116
|
+
b4.use PowerOffVApp
|
117
|
+
b4.use DestroyVApp
|
118
|
+
else
|
119
|
+
b4.use DestroyVM
|
109
120
|
end
|
110
|
-
b3.use PowerOffVApp
|
111
|
-
b3.use DestroyVApp
|
112
|
-
else
|
113
|
-
b3.use DestroyVM
|
114
121
|
end
|
115
122
|
end
|
116
123
|
else
|
@@ -140,7 +147,21 @@ module VagrantPlugins
|
|
140
147
|
def self.action_read_ssh_info
|
141
148
|
Vagrant::Action::Builder.new.tap do |b|
|
142
149
|
b.use ConnectVCloud
|
143
|
-
b.use ReadSSHInfo
|
150
|
+
b.use ReadSSHInfo, 22
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def self.action_read_winrm_info
|
155
|
+
Vagrant::Action::Builder.new.tap do |b|
|
156
|
+
b.use ConnectVCloud
|
157
|
+
b.use ReadSSHInfo, 5985
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
def self.action_read_rdp_info
|
162
|
+
Vagrant::Action::Builder.new.tap do |b|
|
163
|
+
b.use ConnectVCloud
|
164
|
+
b.use ReadSSHInfo, 3389
|
144
165
|
end
|
145
166
|
end
|
146
167
|
|
@@ -112,9 +112,7 @@ module VagrantPlugins
|
|
112
112
|
env[:ui].info('Building vApp...')
|
113
113
|
|
114
114
|
vapp_prefix = cfg.vapp_prefix
|
115
|
-
if vapp_prefix.nil?
|
116
|
-
vapp_prefix = "Vagrant"
|
117
|
-
end
|
115
|
+
vapp_prefix = 'Vagrant' if vapp_prefix.nil?
|
118
116
|
|
119
117
|
compose = cnx.compose_vapp_from_vm(
|
120
118
|
cfg.vdc_id,
|
@@ -124,7 +122,7 @@ module VagrantPlugins
|
|
124
122
|
"#{Socket.gethostname.downcase} using vagrant-vcloud on " +
|
125
123
|
"#{Time.now.strftime("%B %d, %Y")}",
|
126
124
|
{
|
127
|
-
vm_name => cfg.catalog_item[:vms_hash]
|
125
|
+
vm_name => cfg.catalog_item[:vms_hash].first.last[:id]
|
128
126
|
},
|
129
127
|
network_options
|
130
128
|
)
|
@@ -180,7 +178,7 @@ module VagrantPlugins
|
|
180
178
|
recompose = cnx.recompose_vapp_from_vm(
|
181
179
|
env[:machine].get_vapp_id,
|
182
180
|
{
|
183
|
-
vm_name => cfg.catalog_item[:vms_hash]
|
181
|
+
vm_name => cfg.catalog_item[:vms_hash].first.last[:id]
|
184
182
|
},
|
185
183
|
network_options
|
186
184
|
)
|
@@ -59,8 +59,6 @@ module VagrantPlugins
|
|
59
59
|
:nat_protocol => fp.protocol.upcase,
|
60
60
|
:vapp_scoped_local_id => vm_info[:vapp_scoped_local_id]
|
61
61
|
}
|
62
|
-
|
63
|
-
edge_ports << fp.host_port
|
64
62
|
end
|
65
63
|
|
66
64
|
if !ports.empty?
|
@@ -91,27 +89,41 @@ module VagrantPlugins
|
|
91
89
|
cfg.vdc_edge_gateway && \
|
92
90
|
cfg.network_bridge.nil?
|
93
91
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
92
|
+
vapp_edge_ip = cnx.get_vapp_edge_public_ip(vapp_id)
|
93
|
+
@logger.debug('Getting edge gateway port forwarding rules...')
|
94
|
+
edge_gateway_rules = cnx.get_edge_gateway_rules(cfg.vdc_edge_gateway,
|
95
|
+
cfg.vdc_id)
|
96
|
+
vapp_edge_dnat_rules = edge_gateway_rules.select {|r| (r[:rule_type] == 'DNAT' &&
|
97
|
+
r[:translated_ip] == vapp_edge_ip)}
|
98
|
+
vapp_edge_ports_in_use = vapp_edge_dnat_rules.map{|r| r[:original_port].to_i}.to_set
|
99
|
+
|
100
|
+
ports.each do |port|
|
101
|
+
if port[:vapp_scoped_local_id] == vm_info[:vapp_scoped_local_id] &&
|
102
|
+
!vapp_edge_ports_in_use.include?(port[:nat_external_port])
|
103
|
+
@env[:ui].info(
|
104
|
+
"Creating NAT rules on [#{cfg.vdc_edge_gateway}] " +
|
105
|
+
"for IP [#{vapp_edge_ip}] port #{port[:nat_external_port]}."
|
106
|
+
)
|
107
|
+
|
108
|
+
edge_ports << port[:nat_external_port]
|
109
|
+
end
|
100
110
|
end
|
101
111
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
112
|
+
if !edge_ports.empty?
|
113
|
+
# Add the vShield Edge Gateway rules
|
114
|
+
add_ports = cnx.add_edge_gateway_rules(
|
115
|
+
cfg.vdc_edge_gateway,
|
116
|
+
cfg.vdc_id,
|
117
|
+
cfg.vdc_edge_gateway_ip,
|
118
|
+
vapp_id,
|
119
|
+
edge_ports
|
120
|
+
)
|
110
121
|
|
111
|
-
|
122
|
+
wait = cnx.wait_task_completion(add_ports)
|
112
123
|
|
113
|
-
|
114
|
-
|
124
|
+
if !wait[:errormsg].nil?
|
125
|
+
raise Errors::ComposeVAppError, :message => wait[:errormsg]
|
126
|
+
end
|
115
127
|
end
|
116
128
|
|
117
129
|
end
|
@@ -47,10 +47,12 @@ module VagrantPlugins
|
|
47
47
|
vm = cnx.get_vapp(vapp_id)
|
48
48
|
vm_info = vm[:vms_hash][vm_name.to_sym]
|
49
49
|
|
50
|
+
vapp_edge_ip = cnx.get_vapp_edge_public_ip(vapp_id)
|
51
|
+
|
50
52
|
@logger.debug('Getting edge gateway port forwarding rules...')
|
51
53
|
edge_gateway_rules = cnx.get_edge_gateway_rules(cfg.vdc_edge_gateway,
|
52
54
|
cfg.vdc_id)
|
53
|
-
edge_dnat_rules = edge_gateway_rules.select {|r| (r[:rule_type] == 'DNAT')}
|
55
|
+
edge_dnat_rules = edge_gateway_rules.select {|r| (r[:rule_type] == 'DNAT' && r[:translated_ip] != vapp_edge_ip)}
|
54
56
|
edge_ports_in_use = edge_dnat_rules.map{|r| r[:original_port].to_i}.to_set
|
55
57
|
|
56
58
|
@logger.debug('Getting port forwarding rules...')
|
@@ -65,16 +67,6 @@ module VagrantPlugins
|
|
65
67
|
guest_port = options[:guest]
|
66
68
|
host_port = options[:host]
|
67
69
|
|
68
|
-
# Find if there already is a DNAT rule to this vApp
|
69
|
-
if r = edge_dnat_rules.find { |rule| (rule[:translated_ip] == vm_info[:ip] &&
|
70
|
-
rule[:translated_port] == guest_port.to_s) }
|
71
|
-
|
72
|
-
@logger.info(
|
73
|
-
"Found existing edge gateway port forwarding rule #r[:original_port] to #{guest_port}"
|
74
|
-
)
|
75
|
-
options[:already_exists_on_edge] = true
|
76
|
-
end
|
77
|
-
|
78
70
|
# Find if there already is a NAT rule to guest_port of this VM
|
79
71
|
if r = vapp_nat_rules.find { |rule| (rule[:vapp_scoped_local_id] == vm_info[:vapp_scoped_local_id] &&
|
80
72
|
rule[:nat_internal_port] == guest_port.to_s) }
|
@@ -20,7 +20,14 @@ module VagrantPlugins
|
|
20
20
|
cnx = cfg.vcloud_cnx.driver
|
21
21
|
|
22
22
|
box_dir = env[:machine].box.directory.to_s
|
23
|
-
|
23
|
+
|
24
|
+
if env[:machine].box.name.to_s.include? '/'
|
25
|
+
box_file = env[:machine].box.name.rpartition('/').last.to_s
|
26
|
+
box_name = env[:machine].box.name.to_s
|
27
|
+
else
|
28
|
+
box_file = env[:machine].box.name.to_s
|
29
|
+
box_name = box_file
|
30
|
+
end
|
24
31
|
|
25
32
|
box_ovf = "#{box_dir}/#{box_file}.ovf"
|
26
33
|
|
@@ -29,7 +36,7 @@ module VagrantPlugins
|
|
29
36
|
@logger.debug("OVF File: #{box_ovf}")
|
30
37
|
upload_ovf = cnx.upload_ovf(
|
31
38
|
cfg.vdc_id,
|
32
|
-
|
39
|
+
box_name,
|
33
40
|
'Vagrant Box',
|
34
41
|
box_ovf,
|
35
42
|
cfg.catalog_id,
|
@@ -40,7 +47,7 @@ module VagrantPlugins
|
|
40
47
|
)
|
41
48
|
|
42
49
|
env[:ui].info(
|
43
|
-
"Adding [#{
|
50
|
+
"Adding [#{box_name}] to " +
|
44
51
|
"Catalog [#{cfg.catalog_name}]"
|
45
52
|
)
|
46
53
|
add_ovf_to_catalog = cnx.wait_task_completion(upload_ovf)
|
@@ -53,7 +60,7 @@ module VagrantPlugins
|
|
53
60
|
# Retrieve catalog_item ID
|
54
61
|
cfg.catalog_item = cnx.get_catalog_item_by_name(
|
55
62
|
cfg.catalog_id,
|
56
|
-
|
63
|
+
box_name
|
57
64
|
)
|
58
65
|
end
|
59
66
|
|
@@ -82,6 +89,14 @@ module VagrantPlugins
|
|
82
89
|
cfg = env[:machine].provider_config
|
83
90
|
cnx = cfg.vcloud_cnx.driver
|
84
91
|
|
92
|
+
if env[:machine].box.name.to_s.include? '/'
|
93
|
+
box_file = env[:machine].box.name.rpartition('/').last.to_s
|
94
|
+
box_name = env[:machine].box.name.to_s
|
95
|
+
else
|
96
|
+
box_file = env[:machine].box.name.to_s
|
97
|
+
box_name = box_file
|
98
|
+
end
|
99
|
+
|
85
100
|
cfg.org = cnx.get_organization_by_name(cfg.org_name)
|
86
101
|
cfg.org_id = cnx.get_organization_id_by_name(cfg.org_name)
|
87
102
|
|
@@ -113,11 +128,11 @@ module VagrantPlugins
|
|
113
128
|
|
114
129
|
@logger.debug(
|
115
130
|
"Getting catalog item with cfg.catalog_id: [#{cfg.catalog_id}] " +
|
116
|
-
"and machine name [#{
|
131
|
+
"and machine name [#{box_name}]"
|
117
132
|
)
|
118
133
|
cfg.catalog_item = cnx.get_catalog_item_by_name(
|
119
134
|
cfg.catalog_id,
|
120
|
-
|
135
|
+
box_name
|
121
136
|
)
|
122
137
|
|
123
138
|
@logger.debug("Catalog item is now #{cfg.catalog_item}")
|
@@ -148,18 +163,18 @@ module VagrantPlugins
|
|
148
163
|
|
149
164
|
if !cfg.catalog_item
|
150
165
|
env[:ui].warn(
|
151
|
-
"Catalog item [#{
|
166
|
+
"Catalog item [#{box_name}] " +
|
152
167
|
"in Catalog [#{cfg.catalog_name}] does not exist!"
|
153
168
|
)
|
154
169
|
|
155
170
|
user_input = env[:ui].ask(
|
156
|
-
"Would you like to upload the [#{
|
171
|
+
"Would you like to upload the [#{box_name}] " +
|
157
172
|
"box to [#{cfg.catalog_name}] Catalog?\n" +
|
158
173
|
'Choice (yes/no): '
|
159
174
|
)
|
160
175
|
|
161
176
|
if user_input.downcase == 'yes' || user_input.downcase == 'y'
|
162
|
-
env[:ui].info("Uploading [#{
|
177
|
+
env[:ui].info("Uploading [#{box_name}]...")
|
163
178
|
vcloud_upload_box(env)
|
164
179
|
else
|
165
180
|
env[:ui].error('Catalog item not available, exiting...')
|
@@ -171,7 +186,7 @@ module VagrantPlugins
|
|
171
186
|
|
172
187
|
else
|
173
188
|
@logger.info(
|
174
|
-
"Using catalog item [#{
|
189
|
+
"Using catalog item [#{box_name}] " +
|
175
190
|
"in Catalog [#{cfg.catalog_name}]..."
|
176
191
|
)
|
177
192
|
end
|
@@ -13,8 +13,22 @@ module VagrantPlugins
|
|
13
13
|
cfg = env[:machine].provider_config
|
14
14
|
cnx = cfg.vcloud_cnx.driver
|
15
15
|
|
16
|
+
env[:ui].info('Setting VM hardware...')
|
17
|
+
|
18
|
+
set_vm_hardware = cnx.set_vm_hardware(env[:machine].id, cfg)
|
19
|
+
if set_vm_hardware
|
20
|
+
cnx.wait_task_completion(set_vm_hardware)
|
21
|
+
end
|
22
|
+
|
16
23
|
env[:ui].info('Powering on VM...')
|
17
24
|
|
25
|
+
if ! cfg.nested_hypervisor.nil?
|
26
|
+
set_vm_nested_hypervisor = cnx.set_vm_nested_hypervisor(env[:machine].id, cfg.nested_hypervisor)
|
27
|
+
if set_vm_nested_hypervisor
|
28
|
+
cnx.wait_task_completion(set_vm_nested_hypervisor)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
18
32
|
poweron_vm = cnx.poweron_vm(env[:machine].id)
|
19
33
|
cnx.wait_task_completion(poweron_vm)
|
20
34
|
|
@@ -2,8 +2,9 @@ module VagrantPlugins
|
|
2
2
|
module VCloud
|
3
3
|
module Action
|
4
4
|
class ReadSSHInfo
|
5
|
-
def initialize(app, env)
|
5
|
+
def initialize(app, env, port = 22)
|
6
6
|
@app = app
|
7
|
+
@port = port
|
7
8
|
@logger = Log4r::Logger.new('vagrant_vcloud::action::read_ssh_info')
|
8
9
|
end
|
9
10
|
|
@@ -15,21 +16,21 @@ module VagrantPlugins
|
|
15
16
|
|
16
17
|
# Small method to check the tcp connection to an ip:port works.
|
17
18
|
# Return false if anything fails, and true if it succeeded.
|
18
|
-
def
|
19
|
+
def check_for_port(ip, port, port_name)
|
19
20
|
begin
|
20
21
|
Timeout::timeout(1) do
|
21
22
|
begin
|
22
23
|
s = TCPSocket.new(ip, port)
|
23
24
|
s.close
|
24
|
-
@logger.debug("
|
25
|
+
@logger.debug("#{port_name} Connection successful !")
|
25
26
|
return true
|
26
|
-
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
|
27
|
-
@logger.debug("
|
27
|
+
rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::EHOSTDOWN
|
28
|
+
@logger.debug("#{port_name} Connection Refused/Host Unreachable...")
|
28
29
|
return false
|
29
30
|
end
|
30
31
|
end
|
31
32
|
rescue Timeout::Error
|
32
|
-
@logger.debug("
|
33
|
+
@logger.debug("#{port_name} Connection Timeout...")
|
33
34
|
end
|
34
35
|
|
35
36
|
return false
|
@@ -68,14 +69,14 @@ module VagrantPlugins
|
|
68
69
|
)
|
69
70
|
|
70
71
|
@external_ip = vm_info[:networks]['Vagrant-vApp-Net'][:ip]
|
71
|
-
@external_port =
|
72
|
+
@external_port = "#{@port}"
|
72
73
|
else
|
73
74
|
|
74
75
|
@logger.debug('Getting port forwarding rules...')
|
75
76
|
rules = cnx.get_vapp_port_forwarding_rules(vapp_id)
|
76
77
|
|
77
78
|
rules.each do |rule|
|
78
|
-
if rule[:vapp_scoped_local_id] == myhash[:vapp_scoped_local_id] && rule[:nat_internal_port] ==
|
79
|
+
if rule[:vapp_scoped_local_id] == myhash[:vapp_scoped_local_id] && rule[:nat_internal_port] == "#{@port}"
|
79
80
|
@external_ip = rule[:nat_external_ip]
|
80
81
|
@external_port = rule[:nat_external_port]
|
81
82
|
break
|
@@ -87,12 +88,33 @@ module VagrantPlugins
|
|
87
88
|
@logger.debug(
|
88
89
|
"We're running vagrant behind an Organization vDC Edge"
|
89
90
|
)
|
90
|
-
|
91
|
+
|
92
|
+
#
|
93
|
+
# Add config.ssh.host support
|
94
|
+
# http://docs.vagrantup.com/v2/vagrantfile/ssh_settings.html
|
95
|
+
#
|
96
|
+
if env[:machine].config.ssh.host
|
97
|
+
@logger.debug(
|
98
|
+
'SSH Host setting configured too: ' \
|
99
|
+
"#{env[:machine].config.ssh.host}"
|
100
|
+
)
|
101
|
+
@external_ip = env[:machine].config.ssh.host
|
102
|
+
else
|
103
|
+
@logger.debug(
|
104
|
+
"Using Edge Gateway IP: #{cfg.vdc_edge_gateway_ip}"
|
105
|
+
)
|
106
|
+
@external_ip = cfg.vdc_edge_gateway_ip
|
107
|
+
end
|
91
108
|
end
|
92
109
|
end
|
93
110
|
|
111
|
+
port_name = "SSH"
|
112
|
+
if @port == 5985
|
113
|
+
port_name = "WinRM"
|
114
|
+
end
|
115
|
+
|
94
116
|
@logger.debug(
|
95
|
-
"
|
117
|
+
"#{port_name} INFO: IP #{@external_ip} and Port #{@external_port}"
|
96
118
|
)
|
97
119
|
|
98
120
|
# tsugliani: Temporary Fix for Issue #56
|
@@ -104,17 +126,19 @@ module VagrantPlugins
|
|
104
126
|
# and something like:
|
105
127
|
#
|
106
128
|
# retryable(:on => Vagrant::Errors::SSHSomething, :tries => 10, :sleep => 5) do
|
107
|
-
#
|
129
|
+
# check_for_port(ip, port, "SSH", :error_class => Vagrant::Errors::SSHSomething)
|
108
130
|
# end
|
109
131
|
#
|
110
132
|
sleep_counter = 5
|
111
133
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
134
|
+
if @port == 22 || @port == 5985
|
135
|
+
while check_for_port(@external_ip, @external_port, port_name) == false
|
136
|
+
env[:ui].info(
|
137
|
+
"Waiting for #{port_name} Access on #{@external_ip}:#{@external_port} ... "
|
138
|
+
)
|
139
|
+
sleep sleep_counter
|
140
|
+
sleep_counter += 1
|
141
|
+
end
|
118
142
|
end
|
119
143
|
|
120
144
|
# If we are here, then SSH is ready, continue
|
@@ -39,30 +39,31 @@ module VagrantPlugins
|
|
39
39
|
@logger.debug('Getting vApp information...')
|
40
40
|
vm = cnx.get_vapp(vapp_id)
|
41
41
|
myhash = vm[:vms_hash][vm_name.to_sym]
|
42
|
-
|
43
42
|
@logger.debug('Getting port forwarding rules...')
|
44
43
|
rules = cnx.get_vapp_port_forwarding_rules(vapp_id)
|
45
44
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
unless myhash.nil?
|
46
|
+
# FIXME: not familiar with this syntax (tsugliani)
|
47
|
+
new_rule_set = rules.select {
|
48
|
+
|h| !myhash[:vapp_scoped_local_id].include? h[:vapp_scoped_local_id]
|
49
|
+
}
|
50
50
|
|
51
|
-
|
51
|
+
@logger.debug("OUR NEW RULE SET, PURGED: #{new_rule_set}")
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
53
|
+
remove_ports = cnx.set_vapp_port_forwarding_rules(
|
54
|
+
vapp_id,
|
55
|
+
'Vagrant-vApp-Net',
|
56
|
+
:fence_mode => 'natRouted',
|
57
|
+
:parent_network => cfg.vdc_network_id,
|
58
|
+
:nat_policy_type => 'allowTraffic',
|
59
|
+
:nat_rules => new_rule_set
|
60
|
+
)
|
61
61
|
|
62
|
-
|
62
|
+
wait = cnx.wait_task_completion(remove_ports)
|
63
63
|
|
64
|
-
|
65
|
-
|
64
|
+
unless wait[:errormsg].nil?
|
65
|
+
fail Errors::ComposeVAppError, :message => wait[:errormsg]
|
66
|
+
end
|
66
67
|
end
|
67
68
|
|
68
69
|
@app.call(env)
|
@@ -2,7 +2,6 @@ module VagrantPlugins
|
|
2
2
|
module VCloud
|
3
3
|
module Cap
|
4
4
|
module ForwardedPorts
|
5
|
-
|
6
5
|
# Reads the forwarded ports that currently exist on the machine
|
7
6
|
# itself. This raises an exception if the machine isn't running.
|
8
7
|
#
|
@@ -20,9 +19,7 @@ module VagrantPlugins
|
|
20
19
|
vm = cnx.get_vapp(vapp_id)
|
21
20
|
myhash = vm[:vms_hash][vm_name.to_sym]
|
22
21
|
|
23
|
-
if vm.nil?
|
24
|
-
return
|
25
|
-
end
|
22
|
+
return if vm.nil?
|
26
23
|
|
27
24
|
if cfg.network_bridge.nil?
|
28
25
|
rules = cnx.get_vapp_port_forwarding_rules(vapp_id)
|
@@ -35,9 +32,7 @@ module VagrantPlugins
|
|
35
32
|
end
|
36
33
|
result
|
37
34
|
end
|
38
|
-
|
39
35
|
end
|
40
36
|
end
|
41
37
|
end
|
42
38
|
end
|
43
|
-
|
@@ -2,9 +2,7 @@ module VagrantPlugins
|
|
2
2
|
module VCloud
|
3
3
|
module Cap
|
4
4
|
module PublicAddress
|
5
|
-
|
6
5
|
def self.public_address(machine)
|
7
|
-
|
8
6
|
# Initial try for vagrant share feature.
|
9
7
|
# It seems ssh_info[:port] is given automatically.
|
10
8
|
# I think this feature was built planning that the port forwarding
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module VCloud
|
3
|
+
module Cap
|
4
|
+
module RDP
|
5
|
+
|
6
|
+
# Reads the RDP forwarded port that currently exists on the machine
|
7
|
+
# itself. This raises an exception if the machine isn't running.
|
8
|
+
# @return [Hash<Integer, Integer>] Host => Guest port mappings.
|
9
|
+
def self.rdp_info(machine)
|
10
|
+
env = machine.action('read_rdp_info')
|
11
|
+
env[:machine_ssh_info]
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module VCloud
|
3
|
+
module Cap
|
4
|
+
module WinRM
|
5
|
+
|
6
|
+
# Reads the WinRM forwarded port that currently exists on the machine
|
7
|
+
# itself. This raises an exception if the machine isn't running.
|
8
|
+
# @return [Hash<Integer, Integer>] Host => Guest port mappings.
|
9
|
+
def self.winrm_info(machine)
|
10
|
+
env = machine.action('read_winrm_info')
|
11
|
+
env[:machine_ssh_info]
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -44,7 +44,7 @@ module VagrantPlugins
|
|
44
44
|
puts table
|
45
45
|
end
|
46
46
|
|
47
|
-
def command_vcloud_network(cfg, vapp_id)
|
47
|
+
def command_vcloud_network(cfg, vapp_id, ssh_host)
|
48
48
|
# FIXME: this needs to be fixed to accomodate the bridged scenario
|
49
49
|
# potentially showing only the assigned IPs in the VMs
|
50
50
|
|
@@ -97,10 +97,23 @@ module VagrantPlugins
|
|
97
97
|
# If rules don't match, you will not see them !
|
98
98
|
if edge_gateway_rule
|
99
99
|
# DNAT rule from edge to vapp to vm
|
100
|
+
connect_host = nil
|
101
|
+
|
102
|
+
# Add support for config.ssh.host
|
103
|
+
if ssh_host
|
104
|
+
connect_host = "#{ssh_host}:" +
|
105
|
+
"#{vapp_edge_rule[:nat_external_port]}" +
|
106
|
+
' -> ' +
|
107
|
+
"#{cfg.vdc_edge_gateway_ip}:" +
|
108
|
+
"#{vapp_edge_rule[:nat_external_port]}"
|
109
|
+
else
|
110
|
+
connect_host = "#{cfg.vdc_edge_gateway_ip}:" +
|
111
|
+
"#{vapp_edge_rule[:nat_external_port]}"
|
112
|
+
end
|
113
|
+
|
100
114
|
network_table << [
|
101
115
|
"#{vm[0]}",
|
102
|
-
"#{
|
103
|
-
"#{vapp_edge_rule[:nat_external_port]}" +
|
116
|
+
"#{connect_host}" +
|
104
117
|
" -> #{vapp_edge_ip}:" +
|
105
118
|
"#{vapp_edge_rule[:nat_external_port]}" +
|
106
119
|
" -> #{vm[1][:addresses][0]}:" +
|
@@ -223,6 +236,7 @@ module VagrantPlugins
|
|
223
236
|
|
224
237
|
puts 'Initializing vCloud Director provider...'
|
225
238
|
# initialize some variables
|
239
|
+
ssh_host = nil
|
226
240
|
vapp_id = nil
|
227
241
|
cfg = nil
|
228
242
|
|
@@ -246,6 +260,7 @@ module VagrantPlugins
|
|
246
260
|
# populate cfg & vApp Id for later use.
|
247
261
|
cfg = machine.provider_config
|
248
262
|
vapp_id = machine.get_vapp_id
|
263
|
+
ssh_host = machine.config.ssh.host
|
249
264
|
break
|
250
265
|
end
|
251
266
|
|
@@ -255,7 +270,7 @@ module VagrantPlugins
|
|
255
270
|
when :status
|
256
271
|
command_vcloud_status(cfg, vapp_id)
|
257
272
|
when :network
|
258
|
-
command_vcloud_network(cfg, vapp_id)
|
273
|
+
command_vcloud_network(cfg, vapp_id, ssh_host)
|
259
274
|
when :redeploy_edge_gw
|
260
275
|
command_vcloud_redeploy_edge_gw(cfg)
|
261
276
|
end
|
@@ -133,6 +133,15 @@ module VagrantPlugins
|
|
133
133
|
# vApp Id (String)
|
134
134
|
attr_accessor :vAppId
|
135
135
|
|
136
|
+
# VM memory size in MB (Integer)
|
137
|
+
attr_accessor :memory
|
138
|
+
|
139
|
+
# VM number of cpus (Integer)
|
140
|
+
attr_accessor :cpus
|
141
|
+
|
142
|
+
# NestedHypervisor (Bool)
|
143
|
+
attr_accessor :nested_hypervisor
|
144
|
+
|
136
145
|
def validate(machine)
|
137
146
|
errors = _detected_errors
|
138
147
|
|
@@ -246,6 +246,9 @@ module VagrantPlugins
|
|
246
246
|
catalog_id, upload_options = {})
|
247
247
|
end
|
248
248
|
|
249
|
+
def set_vm_hardware(vm_id, cfg)
|
250
|
+
end
|
251
|
+
|
249
252
|
##
|
250
253
|
# Fetch information for a given task
|
251
254
|
def get_task(task_id)
|
@@ -492,4 +495,4 @@ module VagrantPlugins
|
|
492
495
|
end # class
|
493
496
|
end
|
494
497
|
end
|
495
|
-
end
|
498
|
+
end
|
@@ -1838,6 +1838,74 @@ module VagrantPlugins
|
|
1838
1838
|
task_id
|
1839
1839
|
end
|
1840
1840
|
|
1841
|
+
# Enable VM Nested Hardware-Assisted Virtualization
|
1842
|
+
def set_vm_nested_hypervisor(vm_id, enable)
|
1843
|
+
action = enable ? "enable" : "disable"
|
1844
|
+
params = {
|
1845
|
+
'method' => :post,
|
1846
|
+
'command' => "/vApp/vm-#{vm_id}/action/#{action}NestedHypervisor"
|
1847
|
+
}
|
1848
|
+
|
1849
|
+
_response, headers = send_request(params)
|
1850
|
+
task_id = headers['Location'].gsub("#{@api_url}/task/", '')
|
1851
|
+
task_id
|
1852
|
+
end
|
1853
|
+
|
1854
|
+
##
|
1855
|
+
# Set memory and number of cpus in virtualHardwareSection of a given vm
|
1856
|
+
# returns task_id or nil if there is no task to wait for
|
1857
|
+
def set_vm_hardware(vm_id, cfg)
|
1858
|
+
params = {
|
1859
|
+
'method' => :get,
|
1860
|
+
'command' => "/vApp/vm-#{vm_id}/virtualHardwareSection"
|
1861
|
+
}
|
1862
|
+
|
1863
|
+
changed = false
|
1864
|
+
response, _headers = send_request(params)
|
1865
|
+
|
1866
|
+
response.css('ovf|Item').each do |item|
|
1867
|
+
type = item.css('rasd|ResourceType').first
|
1868
|
+
if type.content == '3'
|
1869
|
+
# cpus
|
1870
|
+
if cfg.cpus
|
1871
|
+
if item.at_css('rasd|VirtualQuantity').content != cfg.cpus.to_s
|
1872
|
+
item.at_css('rasd|VirtualQuantity').content = cfg.cpus
|
1873
|
+
item.at_css('rasd|ElementName').content = "#{cfg.cpus} virtual CPU(s)"
|
1874
|
+
changed = true
|
1875
|
+
end
|
1876
|
+
end
|
1877
|
+
elsif type.content == '4'
|
1878
|
+
# memory
|
1879
|
+
if cfg.memory
|
1880
|
+
if item.at_css('rasd|VirtualQuantity').content != cfg.memory.to_s
|
1881
|
+
item.at_css('rasd|VirtualQuantity').content = cfg.memory
|
1882
|
+
item.at_css('rasd|ElementName').content = "#{cfg.memory} MB of memory"
|
1883
|
+
changed = true
|
1884
|
+
end
|
1885
|
+
end
|
1886
|
+
end
|
1887
|
+
end
|
1888
|
+
|
1889
|
+
if changed
|
1890
|
+
params = {
|
1891
|
+
'method' => :put,
|
1892
|
+
'command' => "/vApp/vm-#{vm_id}/virtualHardwareSection"
|
1893
|
+
}
|
1894
|
+
|
1895
|
+
_response, headers = send_request(
|
1896
|
+
params,
|
1897
|
+
response.to_xml,
|
1898
|
+
'application/vnd.vmware.vcloud.virtualhardwaresection+xml'
|
1899
|
+
)
|
1900
|
+
|
1901
|
+
task_id = headers['Location'].gsub("#{@api_url}/task/", '')
|
1902
|
+
task_id
|
1903
|
+
else
|
1904
|
+
return nil
|
1905
|
+
end
|
1906
|
+
end
|
1907
|
+
|
1908
|
+
|
1841
1909
|
##
|
1842
1910
|
# Fetch details about a given VM
|
1843
1911
|
def get_vm(vm_id)
|
@@ -41,6 +41,16 @@ module VagrantPlugins
|
|
41
41
|
Cap::ForwardedPorts
|
42
42
|
end
|
43
43
|
|
44
|
+
provider_capability(:vcloud, :winrm_info) do
|
45
|
+
require_relative "cap/winrm_info"
|
46
|
+
Cap::WinRM
|
47
|
+
end
|
48
|
+
|
49
|
+
provider_capability(:vcloud, :rdp_info) do
|
50
|
+
require_relative "cap/rdp_info"
|
51
|
+
Cap::RDP
|
52
|
+
end
|
53
|
+
|
44
54
|
# Added a vagrant vcloud-status command to enhance troubleshooting and
|
45
55
|
# visibility.
|
46
56
|
command('vcloud') do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-vcloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabio Rapposelli
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-06-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: i18n
|
@@ -228,6 +228,8 @@ files:
|
|
228
228
|
- lib/vagrant-vcloud/action/unmap_port_forwardings.rb
|
229
229
|
- lib/vagrant-vcloud/cap/forwarded_ports.rb
|
230
230
|
- lib/vagrant-vcloud/cap/public_address.rb
|
231
|
+
- lib/vagrant-vcloud/cap/rdp_info.rb
|
232
|
+
- lib/vagrant-vcloud/cap/winrm_info.rb
|
231
233
|
- lib/vagrant-vcloud/command.rb
|
232
234
|
- lib/vagrant-vcloud/config.rb
|
233
235
|
- lib/vagrant-vcloud/driver/base.rb
|