fog-vsphere 3.7.2 → 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/requests/compute/destroy_iso.rb +65 -0
- data/lib/fog/vsphere/requests/compute/upload_iso.rb +35 -12
- data/lib/fog/vsphere/version.rb +1 -1
- 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
- metadata +34 -1
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
|
@@ -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
|
|
@@ -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
|
@@ -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
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
|
|
@@ -37,6 +37,34 @@ dependencies:
|
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
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'
|
|
40
68
|
- !ruby/object:Gem::Dependency
|
|
41
69
|
name: bundler
|
|
42
70
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -275,6 +303,7 @@ files:
|
|
|
275
303
|
- lib/fog/vsphere/requests/compute/create_vm.rb
|
|
276
304
|
- lib/fog/vsphere/requests/compute/current_time.rb
|
|
277
305
|
- lib/fog/vsphere/requests/compute/destroy_group.rb
|
|
306
|
+
- lib/fog/vsphere/requests/compute/destroy_iso.rb
|
|
278
307
|
- lib/fog/vsphere/requests/compute/destroy_resource_pool.rb
|
|
279
308
|
- lib/fog/vsphere/requests/compute/destroy_rule.rb
|
|
280
309
|
- lib/fog/vsphere/requests/compute/folder_destroy.rb
|
|
@@ -381,6 +410,7 @@ files:
|
|
|
381
410
|
- tests/models/compute/tickets_tests.rb
|
|
382
411
|
- tests/requests/compute/create_folder_tests.rb
|
|
383
412
|
- tests/requests/compute/current_time_tests.rb
|
|
413
|
+
- tests/requests/compute/destroy_iso_tests.rb
|
|
384
414
|
- tests/requests/compute/folder_destroy_tests.rb
|
|
385
415
|
- tests/requests/compute/get_cluster_tests.rb
|
|
386
416
|
- tests/requests/compute/get_compute_resource_tests.rb
|
|
@@ -407,6 +437,7 @@ files:
|
|
|
407
437
|
- tests/requests/compute/revert_to_snapshot_tests.rb
|
|
408
438
|
- tests/requests/compute/set_vm_customvalue_tests.rb
|
|
409
439
|
- tests/requests/compute/update_vm_tests.rb
|
|
440
|
+
- tests/requests/compute/upload_iso_tests.rb
|
|
410
441
|
- tests/requests/compute/vm_clone_tests.rb
|
|
411
442
|
- tests/requests/compute/vm_config_vnc_tests.rb
|
|
412
443
|
- tests/requests/compute/vm_destroy_tests.rb
|
|
@@ -472,6 +503,7 @@ test_files:
|
|
|
472
503
|
- tests/models/compute/tickets_tests.rb
|
|
473
504
|
- tests/requests/compute/create_folder_tests.rb
|
|
474
505
|
- tests/requests/compute/current_time_tests.rb
|
|
506
|
+
- tests/requests/compute/destroy_iso_tests.rb
|
|
475
507
|
- tests/requests/compute/folder_destroy_tests.rb
|
|
476
508
|
- tests/requests/compute/get_cluster_tests.rb
|
|
477
509
|
- tests/requests/compute/get_compute_resource_tests.rb
|
|
@@ -498,6 +530,7 @@ test_files:
|
|
|
498
530
|
- tests/requests/compute/revert_to_snapshot_tests.rb
|
|
499
531
|
- tests/requests/compute/set_vm_customvalue_tests.rb
|
|
500
532
|
- tests/requests/compute/update_vm_tests.rb
|
|
533
|
+
- tests/requests/compute/upload_iso_tests.rb
|
|
501
534
|
- tests/requests/compute/vm_clone_tests.rb
|
|
502
535
|
- tests/requests/compute/vm_config_vnc_tests.rb
|
|
503
536
|
- tests/requests/compute/vm_destroy_tests.rb
|