vcloud-rest 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/README.md +1 -1
- data/lib/vcloud-rest/connection.rb +32 -0
- data/lib/vcloud-rest/vcloud/ovf.rb +4 -2
- data/lib/vcloud-rest/vcloud/vapp.rb +23 -23
- data/lib/vcloud-rest/vcloud/vm.rb +28 -34
- data/lib/vcloud-rest/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5423c402bd67bd07893da3ed80210af1ae63b0c
|
4
|
+
data.tar.gz: 389acab1aaec5d6cbf9733dc02d5143f8fcdaabf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66eaeeec2baa31c8903f80ef68fd9315b260bcf72ea4180f014c118fa8cdaf1cff64f21f91af8aecb7b234534ac0f4bdc9a4726fa27feedd2e9f6e066bf76c47
|
7
|
+
data.tar.gz: a45669ed115205cd51fda43166b99d64892834f9128c04a78e2bba7ca0fcfb31b08a902d10f12eb2f08b75f3d5d272ca2fef65e766b9f340d30bc26926911925
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,26 @@
|
|
1
1
|
Changes
|
2
2
|
==
|
3
|
+
2014-02-06 (1.2.0)
|
4
|
+
|
5
|
+
FEATURES:
|
6
|
+
|
7
|
+
* vm
|
8
|
+
* actions to control vm snapshots just as vApp snapshots
|
9
|
+
* create_vm_snapshot
|
10
|
+
* revert_vm_snapshot
|
11
|
+
* network add/edit handle PrimaryNetworkConnectionIndex
|
12
|
+
|
13
|
+
DEPRECATIONS:
|
14
|
+
|
15
|
+
* `create_snapshot` is deprecated in favour of create_vapp_snapshot
|
16
|
+
* `revert_snapshot` is deprecated in favour of revert_vapp_snapshot
|
17
|
+
* remove `set_vm_network_config` deprecated in 1.1.0
|
18
|
+
|
19
|
+
FIXES:
|
20
|
+
|
21
|
+
* OVF: fix upload link retrieval (issue #23)
|
22
|
+
* Remove network placeholder when adding a network to a VM
|
23
|
+
|
3
24
|
2013-12-31 (1.1.1)
|
4
25
|
--
|
5
26
|
|
data/README.md
CHANGED
@@ -17,7 +17,7 @@ This plugin is distributed as a Ruby Gem. To install it, run:
|
|
17
17
|
|
18
18
|
Depending on your system's configuration, you may need to run this command with root privileges.
|
19
19
|
|
20
|
-
vcloud-rest is tested against ruby 2.0.0, 1.9.x and 1.8.7+.
|
20
|
+
vcloud-rest is tested against ruby 2.1.0, 2.0.0, 1.9.x and 1.8.7+.
|
21
21
|
|
22
22
|
FEATURES
|
23
23
|
--
|
@@ -235,5 +235,37 @@ module VCloudClient
|
|
235
235
|
task_id = headers[:location].gsub(/.*\/task\//, "")
|
236
236
|
task_id
|
237
237
|
end
|
238
|
+
|
239
|
+
##
|
240
|
+
# Create a new vapp/vm snapshot (overwrites any existing)
|
241
|
+
def create_snapshot_action(id, description="New Snapshot", type=:vapp)
|
242
|
+
params = {
|
243
|
+
"method" => :post,
|
244
|
+
"command" => "/vApp/#{type}-#{id}/action/createSnapshot"
|
245
|
+
}
|
246
|
+
builder = Nokogiri::XML::Builder.new do |xml|
|
247
|
+
xml.CreateSnapshotParams(
|
248
|
+
"xmlns" => "http://www.vmware.com/vcloud/v1.5") {
|
249
|
+
xml.Description description
|
250
|
+
}
|
251
|
+
end
|
252
|
+
response, headers = send_request(params, builder.to_xml, "application/vnd.vmware.vcloud.createSnapshotParams+xml")
|
253
|
+
task_id = headers[:location].gsub(/.*\/task\//, "")
|
254
|
+
task_id
|
255
|
+
end
|
256
|
+
|
257
|
+
##
|
258
|
+
# Revert to an existing snapshot (vapp/vm)
|
259
|
+
def revert_snapshot_action(id, type=:vapp)
|
260
|
+
params = {
|
261
|
+
"method" => :post,
|
262
|
+
"command" => "/vApp/#{type}-#{id}/action/revertToCurrentSnapshot"
|
263
|
+
}
|
264
|
+
response, headers = send_request(params)
|
265
|
+
task_id = headers[:location].gsub(/.*\/task\//, "")
|
266
|
+
task_id
|
267
|
+
end
|
268
|
+
|
269
|
+
|
238
270
|
end # class
|
239
271
|
end
|
@@ -41,7 +41,9 @@ module VCloudClient
|
|
41
41
|
|
42
42
|
# Get vAppTemplate Link from location
|
43
43
|
vAppTemplate = headers[:location].gsub(/.*\/vAppTemplate\/vappTemplate\-/, "")
|
44
|
-
|
44
|
+
uploadHref = response.css("Files Link [rel='upload:default']").first[:href]
|
45
|
+
descriptorUpload = uploadHref.gsub(/.*\/transfer\//, "")
|
46
|
+
|
45
47
|
transferGUID = descriptorUpload.gsub("/descriptor.ovf", "")
|
46
48
|
|
47
49
|
ovfFileBasename = File.basename(ovfFile, ".ovf")
|
@@ -89,7 +91,7 @@ module VCloudClient
|
|
89
91
|
}
|
90
92
|
response, headers = send_request(params)
|
91
93
|
response.css("Files File [bytesTransferred='0'] Link [rel='upload:default']").each do |file|
|
92
|
-
fileName = file[:href].gsub(
|
94
|
+
fileName = file[:href].gsub(/.*\/transfer\/#{transferGUID}\//, "")
|
93
95
|
uploadFile = "#{ovfDir}/#{fileName}"
|
94
96
|
uploadURL = "/transfer/#{transferGUID}/#{fileName}"
|
95
97
|
upload_file(uploadURL, uploadFile, vAppTemplate, uploadOptions)
|
@@ -310,34 +310,34 @@ module VCloudClient
|
|
310
310
|
{ :vapp_id => vapp_id, :task_id => task_id }
|
311
311
|
end
|
312
312
|
|
313
|
+
|
314
|
+
|
313
315
|
##
|
314
|
-
# Create a new snapshot (overwrites any existing)
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
}
|
320
|
-
builder = Nokogiri::XML::Builder.new do |xml|
|
321
|
-
xml.CreateSnapshotParams(
|
322
|
-
"xmlns" => "http://www.vmware.com/vcloud/v1.5") {
|
323
|
-
xml.Description description
|
324
|
-
}
|
325
|
-
end
|
326
|
-
response, headers = send_request(params, builder.to_xml, "application/vnd.vmware.vcloud.createSnapshotParams+xml")
|
327
|
-
task_id = headers[:location].gsub(/.*\/task\//, "")
|
328
|
-
task_id
|
316
|
+
# Create a new vm snapshot (overwrites any existing)
|
317
|
+
# DEPRECATED - use create_vapp_snapshot instead.
|
318
|
+
def create_snapshot(vmId, description="New Snapshot")
|
319
|
+
@logger.warn 'DEPRECATION WARNING: use [create,revert]_vapp_snapshot instead.'
|
320
|
+
create_snapshot_action(vmId, description, :vapp)
|
329
321
|
end
|
330
322
|
|
331
323
|
##
|
332
324
|
# Revert to an existing snapshot
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
325
|
+
# DEPRECATED - use revert_vapp_snapshot instead.
|
326
|
+
def revert_snapshot(vmId)
|
327
|
+
@logger.warn 'DEPRECATION WARNING: use [create,revert]_vapp_snapshot instead.'
|
328
|
+
revert_snapshot_action(vmId, :vapp)
|
329
|
+
end
|
330
|
+
|
331
|
+
##
|
332
|
+
# Create a new vm snapshot (overwrites any existing)
|
333
|
+
def create_vapp_snapshot(vmId, description="New Snapshot")
|
334
|
+
create_snapshot_action(vmId, description, :vapp)
|
335
|
+
end
|
336
|
+
|
337
|
+
##
|
338
|
+
# Revert to an existing snapshot
|
339
|
+
def revert_vapp_snapshot(vmId)
|
340
|
+
revert_snapshot_action(vmId, :vapp)
|
341
341
|
end
|
342
342
|
|
343
343
|
##
|
@@ -129,6 +129,11 @@ module VCloudClient
|
|
129
129
|
|
130
130
|
netconfig_response, headers = send_request(params)
|
131
131
|
|
132
|
+
if config[:primary_index]
|
133
|
+
node = netconfig_response.css('PrimaryNetworkConnectionIndex').first
|
134
|
+
node.content = config[:primary_index]
|
135
|
+
end
|
136
|
+
|
132
137
|
picked_network = netconfig_response.css("NetworkConnection").select do |net|
|
133
138
|
net.attribute('network').text == network[:name]
|
134
139
|
end.first
|
@@ -181,8 +186,18 @@ module VCloudClient
|
|
181
186
|
# For some reasons these elements must be removed
|
182
187
|
netconfig_response.css("Link").each {|n| n.remove}
|
183
188
|
|
189
|
+
# Delete placeholder network
|
190
|
+
netconfig_response.css('NetworkConnection').find{|n| n.attribute('network').text == 'none'}.remove
|
191
|
+
|
184
192
|
networks_count = netconfig_response.css('NetworkConnection').count
|
185
193
|
|
194
|
+
primary_index_node = netconfig_response.css('PrimaryNetworkConnectionIndex').first
|
195
|
+
unless primary_index_node
|
196
|
+
primary_index_node = Nokogiri::XML::Node.new "PrimaryNetworkConnectionIndex", parent_section
|
197
|
+
parent_section.add_child(primary_index_node)
|
198
|
+
end
|
199
|
+
primary_index_node.content = config[:primary_index] || 0
|
200
|
+
|
186
201
|
new_network = Nokogiri::XML::Node.new "NetworkConnection", parent_section
|
187
202
|
new_network["network"] = network[:name]
|
188
203
|
new_network["needsCustomization"] = true
|
@@ -247,40 +262,6 @@ module VCloudClient
|
|
247
262
|
task_id
|
248
263
|
end
|
249
264
|
|
250
|
-
##
|
251
|
-
# Set VM Network Config
|
252
|
-
#
|
253
|
-
# DEPRECATED: use set_vm_network
|
254
|
-
def set_vm_network_config(vmid, network_name, config={})
|
255
|
-
@logger.warn 'DEPRECATION WARNING: use [add,delete,edit]_vm_network instead.'
|
256
|
-
|
257
|
-
builder = Nokogiri::XML::Builder.new do |xml|
|
258
|
-
xml.NetworkConnectionSection(
|
259
|
-
"xmlns" => "http://www.vmware.com/vcloud/v1.5",
|
260
|
-
"xmlns:ovf" => "http://schemas.dmtf.org/ovf/envelope/1") {
|
261
|
-
xml['ovf'].Info "VM Network configuration"
|
262
|
-
xml.PrimaryNetworkConnectionIndex(config[:primary_index] || 0)
|
263
|
-
xml.NetworkConnection("network" => network_name, "needsCustomization" => true) {
|
264
|
-
xml.NetworkConnectionIndex(config[:network_index] || 0)
|
265
|
-
xml.IpAddress config[:ip] if config[:ip]
|
266
|
-
xml.IsConnected(config[:is_connected] || true)
|
267
|
-
xml.IpAddressAllocationMode config[:ip_allocation_mode] if config[:ip_allocation_mode]
|
268
|
-
}
|
269
|
-
}
|
270
|
-
end
|
271
|
-
|
272
|
-
params = {
|
273
|
-
'method' => :put,
|
274
|
-
'command' => "/vApp/vm-#{vmid}/networkConnectionSection"
|
275
|
-
}
|
276
|
-
|
277
|
-
response, headers = send_request(params, builder.to_xml, "application/vnd.vmware.vcloud.networkConnectionSection+xml")
|
278
|
-
|
279
|
-
task_id = headers[:location].gsub(/.*\/task\//, "")
|
280
|
-
task_id
|
281
|
-
end
|
282
|
-
|
283
|
-
|
284
265
|
##
|
285
266
|
# Set VM Guest Customization Config
|
286
267
|
def set_vm_guest_customization(vmid, computer_name, config={})
|
@@ -462,6 +443,19 @@ module VCloudClient
|
|
462
443
|
power_action(vmId, 'powerOn', :vm)
|
463
444
|
end
|
464
445
|
|
446
|
+
##
|
447
|
+
# Create a new vm snapshot (overwrites any existing)
|
448
|
+
def create_vm_snapshot(vmId, description="New Snapshot")
|
449
|
+
create_snapshot_action(vmId, description, :vm)
|
450
|
+
end
|
451
|
+
|
452
|
+
##
|
453
|
+
# Revert to an existing snapshot
|
454
|
+
def revert_vm_snapshot(vmId)
|
455
|
+
revert_snapshot_action(vmId, :vm)
|
456
|
+
end
|
457
|
+
|
458
|
+
|
465
459
|
private
|
466
460
|
def add_disk(source_xml, disk_info)
|
467
461
|
disks_count = source_xml.css("Item").css("rasd|HostResource").count
|
data/lib/vcloud-rest/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vcloud-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefano Tortarolo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.4.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.
|
68
|
+
version: 1.4.0
|
69
69
|
description: Ruby bindings to create, list and manage vCloud servers
|
70
70
|
email:
|
71
71
|
- stefano.tortarolo@gmail.com
|