fog-vsphere 3.7.1 → 3.7.3
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/fog-vsphere.gemspec +3 -0
- data/lib/fog/vsphere/compute.rb +1 -0
- data/lib/fog/vsphere/models/compute/server.rb +2 -2
- data/lib/fog/vsphere/requests/compute/create_vm.rb +4 -4
- data/lib/fog/vsphere/requests/compute/destroy_iso.rb +65 -0
- data/lib/fog/vsphere/requests/compute/get_virtual_machine.rb +4 -0
- data/lib/fog/vsphere/requests/compute/upload_iso.rb +35 -12
- data/lib/fog/vsphere/version.rb +1 -1
- data/tests/helper.rb +2 -3
- data/tests/requests/compute/destroy_iso_tests.rb +16 -0
- data/tests/requests/compute/update_vm_tests.rb +0 -2
- data/tests/requests/compute/upload_iso_tests.rb +16 -0
- data/tests/test_helper.rb +1 -0
- metadata +36 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 007c81c87f05ab21ba0a6adb8a8bb48a43a6ed64642a463af8d65a12211fae44
|
|
4
|
+
data.tar.gz: 40124e384e184ffbacd47fd37f1e564f5cdb6a3be87611df65493866f5a55885
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ef28241d40f0026f973f0a8660dc9d9a905201fe78c1bc45f8978b86aa1a631580dbb1f257b068f49c5409fdf34849b61d5c3f5512201f0a0494c6a0bbd66b79
|
|
7
|
+
data.tar.gz: fd3a32c0ad6d6ee14fa7b592d9b872eaeefa022fe5134e6312a5c5cc159f6f21884eec70e35a2aa9b343e806a487c74baf61504238a7095d81dab1d777f34bce
|
data/fog-vsphere.gemspec
CHANGED
|
@@ -25,6 +25,9 @@ Gem::Specification.new do |spec|
|
|
|
25
25
|
spec.add_runtime_dependency 'fog-core'
|
|
26
26
|
spec.add_runtime_dependency 'rbvmomi2', '~> 3.0'
|
|
27
27
|
|
|
28
|
+
spec.add_dependency "base64"
|
|
29
|
+
spec.add_dependency "ostruct"
|
|
30
|
+
|
|
28
31
|
spec.add_development_dependency 'bundler'
|
|
29
32
|
spec.add_development_dependency 'pry', '~> 0.10'
|
|
30
33
|
spec.add_development_dependency 'rake', '>= 12.3.3'
|
data/lib/fog/vsphere/compute.rb
CHANGED
|
@@ -290,11 +290,11 @@ module Fog
|
|
|
290
290
|
end
|
|
291
291
|
|
|
292
292
|
def scsi_controllers
|
|
293
|
-
attributes[:scsi_controllers] ||= service.list_vm_scsi_controllers(id)
|
|
293
|
+
attributes[:scsi_controllers] ||= id.nil? ? [] : service.list_vm_scsi_controllers(id)
|
|
294
294
|
end
|
|
295
295
|
|
|
296
296
|
def nvme_controllers
|
|
297
|
-
attributes[:nvme_controllers] ||= service.list_vm_nvme_controllers(id)
|
|
297
|
+
attributes[:nvme_controllers] ||= id.nil? ? [] : service.list_vm_nvme_controllers(id)
|
|
298
298
|
end
|
|
299
299
|
|
|
300
300
|
def scsi_controller
|
|
@@ -136,7 +136,7 @@ module Fog
|
|
|
136
136
|
def device_change(attributes)
|
|
137
137
|
devices = []
|
|
138
138
|
if (nics = attributes[:interfaces])
|
|
139
|
-
devices << nics.map { |nic| create_interface(nic,
|
|
139
|
+
devices << nics.each_with_index.map { |nic, index| create_interface(nic, index, :add, attributes) }
|
|
140
140
|
end
|
|
141
141
|
|
|
142
142
|
if (scsi_controllers = attributes[:scsi_controllers] || attributes['scsi_controller'])
|
|
@@ -152,7 +152,7 @@ module Fog
|
|
|
152
152
|
end
|
|
153
153
|
|
|
154
154
|
if (cdroms = attributes[:cdroms])
|
|
155
|
-
devices << cdroms.map { |cdrom| create_cdrom(cdrom,
|
|
155
|
+
devices << cdroms.each_with_index.map { |cdrom, index| create_cdrom(cdrom, index) }
|
|
156
156
|
end
|
|
157
157
|
|
|
158
158
|
devices << create_virtual_tpm if attributes[:virtual_tpm]
|
|
@@ -189,9 +189,9 @@ module Fog
|
|
|
189
189
|
if nics = attributes[:interfaces]
|
|
190
190
|
# key is based on 4000 + the interface index
|
|
191
191
|
# we allow booting from all network interfaces, the first interface has the highest priority
|
|
192
|
-
nics.
|
|
192
|
+
nics.each_with_index do |_nic, index|
|
|
193
193
|
boot_order << RbVmomi::VIM::VirtualMachineBootOptionsBootableEthernetDevice.new(
|
|
194
|
-
deviceKey: 4000 +
|
|
194
|
+
deviceKey: 4000 + index
|
|
195
195
|
)
|
|
196
196
|
end
|
|
197
197
|
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
module Fog
|
|
2
|
+
module Vsphere
|
|
3
|
+
class Compute
|
|
4
|
+
class Real
|
|
5
|
+
def destroy_iso(options = {})
|
|
6
|
+
# Keep using the same validation helper for required keys, etc.
|
|
7
|
+
options = destroy_iso_check_options(options)
|
|
8
|
+
|
|
9
|
+
datastore = get_raw_datastore(options['datastore'], options['datacenter'])
|
|
10
|
+
datacenter = get_raw_datacenter(options['datacenter'])
|
|
11
|
+
|
|
12
|
+
filename = options['filename'] || File.basename(options['local_path'])
|
|
13
|
+
remote_rel = File.join(options['upload_directory'].to_s, filename).sub(%r{\A/+}, '')
|
|
14
|
+
remote_ds = "[#{options['datastore']}] #{remote_rel}"
|
|
15
|
+
|
|
16
|
+
task = connection.serviceContent.fileManager.DeleteDatastoreFile_Task(
|
|
17
|
+
name: remote_ds,
|
|
18
|
+
datacenter: datacenter
|
|
19
|
+
)
|
|
20
|
+
task.wait_for_completion
|
|
21
|
+
|
|
22
|
+
# Return true if it is gone
|
|
23
|
+
!datastore.exists?(remote_rel)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def destroy_iso_check_options(options)
|
|
29
|
+
default_options = {
|
|
30
|
+
'upload_directory' => 'isos'
|
|
31
|
+
}
|
|
32
|
+
options = default_options.merge(options)
|
|
33
|
+
required_options = %w[datacenter datastore local_path]
|
|
34
|
+
required_options.each do |param|
|
|
35
|
+
raise ArgumentError, "#{required_options.join(', ')} are required" unless options.key? param
|
|
36
|
+
end
|
|
37
|
+
raise Fog::Vsphere::Compute::NotFound, "Datacenter #{options['datacenter']} doesn't exist!" unless get_datacenter(options['datacenter'])
|
|
38
|
+
raise Fog::Vsphere::Compute::NotFound, "Datastore #{options['datastore']} doesn't exist!" unless get_raw_datastore(options['datastore'], options['datacenter'])
|
|
39
|
+
options
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
class Mock
|
|
44
|
+
def destroy_iso(options = {})
|
|
45
|
+
destroy_iso_check_options(options)
|
|
46
|
+
true
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
def destroy_iso_check_options(options)
|
|
52
|
+
default_options = {
|
|
53
|
+
'upload_directory' => 'isos'
|
|
54
|
+
}
|
|
55
|
+
options = default_options.merge(options)
|
|
56
|
+
required_options = %w[datacenter datastore local_path]
|
|
57
|
+
required_options.each do |param|
|
|
58
|
+
raise ArgumentError, "#{required_options.join(', ')} are required" unless options.key? param
|
|
59
|
+
end
|
|
60
|
+
options
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -3,6 +3,8 @@ module Fog
|
|
|
3
3
|
class Compute
|
|
4
4
|
class Real
|
|
5
5
|
def get_virtual_machine(id, datacenter_name = nil, folder = nil, recursive = false)
|
|
6
|
+
raise(Fog::Vsphere::Compute::NotFound, "The id of the virtual machine can't be nil") if id.nil?
|
|
7
|
+
|
|
6
8
|
# The larger the VM list the longer it will take if not searching based on UUID.
|
|
7
9
|
convert_vm_mob_ref_to_attr_hash(get_vm_ref(id, datacenter_name, folder, recursive))
|
|
8
10
|
end
|
|
@@ -10,6 +12,8 @@ module Fog
|
|
|
10
12
|
protected
|
|
11
13
|
|
|
12
14
|
def get_vm_ref(id, dc = nil, folder = nil, recursive = false)
|
|
15
|
+
raise(Fog::Vsphere::Compute::NotFound, "The id of the virtual machine can't be nil") if id.nil?
|
|
16
|
+
|
|
13
17
|
raw_datacenter = find_raw_datacenter(dc) if dc
|
|
14
18
|
vm = case is_uuid?(id)
|
|
15
19
|
# UUID based
|
|
@@ -2,6 +2,22 @@ module Fog
|
|
|
2
2
|
module Vsphere
|
|
3
3
|
class Compute
|
|
4
4
|
class Real
|
|
5
|
+
def upload_iso(options = {})
|
|
6
|
+
options = upload_iso_check_options(options)
|
|
7
|
+
datastore = get_raw_datastore(options['datastore'], options['datacenter'])
|
|
8
|
+
datacenter = get_raw_datacenter(options['datacenter'])
|
|
9
|
+
filename = options['filename'] || File.basename(options['local_path'])
|
|
10
|
+
unless datastore.exists?(options['upload_directory'])
|
|
11
|
+
connection.serviceContent.fileManager.MakeDirectory name: "[#{options['datastore']}] #{options['upload_directory']}",
|
|
12
|
+
datacenter: datacenter,
|
|
13
|
+
createParentDirectories: false
|
|
14
|
+
end
|
|
15
|
+
datastore.upload options['upload_directory'] + '/' + filename, options['local_path']
|
|
16
|
+
datastore.exists? options['upload_directory'] + '/' + filename
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
5
21
|
def upload_iso_check_options(options)
|
|
6
22
|
default_options = {
|
|
7
23
|
'upload_directory' => 'isos'
|
|
@@ -11,23 +27,30 @@ module Fog
|
|
|
11
27
|
required_options.each do |param|
|
|
12
28
|
raise ArgumentError, "#{required_options.join(', ')} are required" unless options.key? param
|
|
13
29
|
end
|
|
14
|
-
raise Fog::Vsphere::Compute::NotFound, "Datacenter #{options['datacenter']}
|
|
15
|
-
raise Fog::Vsphere::Compute::NotFound, "Datastore #{options['datastore']}
|
|
30
|
+
raise Fog::Vsphere::Compute::NotFound, "Datacenter #{options['datacenter']} doesn't exist!" unless get_datacenter(options['datacenter'])
|
|
31
|
+
raise Fog::Vsphere::Compute::NotFound, "Datastore #{options['datastore']} doesn't exist!" unless get_raw_datastore(options['datastore'], options['datacenter'])
|
|
16
32
|
options
|
|
17
33
|
end
|
|
34
|
+
end
|
|
18
35
|
|
|
36
|
+
class Mock
|
|
19
37
|
def upload_iso(options = {})
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
38
|
+
upload_iso_check_options(options)
|
|
39
|
+
true
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
def upload_iso_check_options(options)
|
|
45
|
+
default_options = {
|
|
46
|
+
'upload_directory' => 'isos'
|
|
47
|
+
}
|
|
48
|
+
options = default_options.merge(options)
|
|
49
|
+
required_options = %w[datacenter datastore local_path]
|
|
50
|
+
required_options.each do |param|
|
|
51
|
+
raise ArgumentError, "#{required_options.join(', ')} are required" unless options.key? param
|
|
28
52
|
end
|
|
29
|
-
|
|
30
|
-
datastore.exists? options['upload_directory'] + '/' + filename
|
|
53
|
+
options
|
|
31
54
|
end
|
|
32
55
|
end
|
|
33
56
|
end
|
data/lib/fog/vsphere/version.rb
CHANGED
data/tests/helper.rb
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Shindo.tests('Fog::Compute[:vsphere] | destroy_iso request', ['vsphere']) do
|
|
2
|
+
compute = Fog::Compute[:vsphere]
|
|
3
|
+
|
|
4
|
+
tests('The response should') do
|
|
5
|
+
response = compute.destroy_iso(
|
|
6
|
+
'datacenter' => 'dc1',
|
|
7
|
+
'datastore' => 'datastore-1',
|
|
8
|
+
'local_path' => '/tmp/test.iso'
|
|
9
|
+
)
|
|
10
|
+
test('be true') { response == true }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
tests('The expected options') do
|
|
14
|
+
raises(ArgumentError, 'raises ArgumentError when required options are missing') { compute.destroy_iso }
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Shindo.tests('Fog::Compute[:vsphere] | upload_iso request', ['vsphere']) do
|
|
2
|
+
compute = Fog::Compute[:vsphere]
|
|
3
|
+
|
|
4
|
+
tests('The response should') do
|
|
5
|
+
response = compute.upload_iso(
|
|
6
|
+
'datacenter' => 'dc1',
|
|
7
|
+
'datastore' => 'datastore-1',
|
|
8
|
+
'local_path' => '/tmp/test.iso'
|
|
9
|
+
)
|
|
10
|
+
test('be true') { response == true }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
tests('The expected options') do
|
|
14
|
+
raises(ArgumentError, 'raises ArgumentError when required options are missing') { compute.upload_iso }
|
|
15
|
+
end
|
|
16
|
+
end
|
data/tests/test_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fog-vsphere
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.7.
|
|
4
|
+
version: 3.7.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- J.R. Garcia
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: fog-core
|
|
@@ -38,6 +37,34 @@ dependencies:
|
|
|
38
37
|
- - "~>"
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
39
|
version: '3.0'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: base64
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: ostruct
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0'
|
|
61
|
+
type: :runtime
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '0'
|
|
41
68
|
- !ruby/object:Gem::Dependency
|
|
42
69
|
name: bundler
|
|
43
70
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -276,6 +303,7 @@ files:
|
|
|
276
303
|
- lib/fog/vsphere/requests/compute/create_vm.rb
|
|
277
304
|
- lib/fog/vsphere/requests/compute/current_time.rb
|
|
278
305
|
- lib/fog/vsphere/requests/compute/destroy_group.rb
|
|
306
|
+
- lib/fog/vsphere/requests/compute/destroy_iso.rb
|
|
279
307
|
- lib/fog/vsphere/requests/compute/destroy_resource_pool.rb
|
|
280
308
|
- lib/fog/vsphere/requests/compute/destroy_rule.rb
|
|
281
309
|
- lib/fog/vsphere/requests/compute/folder_destroy.rb
|
|
@@ -382,6 +410,7 @@ files:
|
|
|
382
410
|
- tests/models/compute/tickets_tests.rb
|
|
383
411
|
- tests/requests/compute/create_folder_tests.rb
|
|
384
412
|
- tests/requests/compute/current_time_tests.rb
|
|
413
|
+
- tests/requests/compute/destroy_iso_tests.rb
|
|
385
414
|
- tests/requests/compute/folder_destroy_tests.rb
|
|
386
415
|
- tests/requests/compute/get_cluster_tests.rb
|
|
387
416
|
- tests/requests/compute/get_compute_resource_tests.rb
|
|
@@ -408,6 +437,7 @@ files:
|
|
|
408
437
|
- tests/requests/compute/revert_to_snapshot_tests.rb
|
|
409
438
|
- tests/requests/compute/set_vm_customvalue_tests.rb
|
|
410
439
|
- tests/requests/compute/update_vm_tests.rb
|
|
440
|
+
- tests/requests/compute/upload_iso_tests.rb
|
|
411
441
|
- tests/requests/compute/vm_clone_tests.rb
|
|
412
442
|
- tests/requests/compute/vm_config_vnc_tests.rb
|
|
413
443
|
- tests/requests/compute/vm_destroy_tests.rb
|
|
@@ -426,7 +456,6 @@ homepage: https://github.com/fog/fog-vsphere
|
|
|
426
456
|
licenses:
|
|
427
457
|
- MIT
|
|
428
458
|
metadata: {}
|
|
429
|
-
post_install_message:
|
|
430
459
|
rdoc_options: []
|
|
431
460
|
require_paths:
|
|
432
461
|
- lib
|
|
@@ -441,8 +470,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
441
470
|
- !ruby/object:Gem::Version
|
|
442
471
|
version: '0'
|
|
443
472
|
requirements: []
|
|
444
|
-
rubygems_version: 3.
|
|
445
|
-
signing_key:
|
|
473
|
+
rubygems_version: 3.8.0.dev
|
|
446
474
|
specification_version: 4
|
|
447
475
|
summary: Module for the 'fog' gem to support VMware vSphere.
|
|
448
476
|
test_files:
|
|
@@ -475,6 +503,7 @@ test_files:
|
|
|
475
503
|
- tests/models/compute/tickets_tests.rb
|
|
476
504
|
- tests/requests/compute/create_folder_tests.rb
|
|
477
505
|
- tests/requests/compute/current_time_tests.rb
|
|
506
|
+
- tests/requests/compute/destroy_iso_tests.rb
|
|
478
507
|
- tests/requests/compute/folder_destroy_tests.rb
|
|
479
508
|
- tests/requests/compute/get_cluster_tests.rb
|
|
480
509
|
- tests/requests/compute/get_compute_resource_tests.rb
|
|
@@ -501,6 +530,7 @@ test_files:
|
|
|
501
530
|
- tests/requests/compute/revert_to_snapshot_tests.rb
|
|
502
531
|
- tests/requests/compute/set_vm_customvalue_tests.rb
|
|
503
532
|
- tests/requests/compute/update_vm_tests.rb
|
|
533
|
+
- tests/requests/compute/upload_iso_tests.rb
|
|
504
534
|
- tests/requests/compute/vm_clone_tests.rb
|
|
505
535
|
- tests/requests/compute/vm_config_vnc_tests.rb
|
|
506
536
|
- tests/requests/compute/vm_destroy_tests.rb
|