fog-vsphere 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/CONTRIBUTORS.md +1 -0
- data/lib/fog/vsphere/compute.rb +24 -0
- data/lib/fog/vsphere/requests/compute/get_datastore.rb +4 -6
- data/lib/fog/vsphere/requests/compute/get_network.rb +2 -9
- data/lib/fog/vsphere/requests/compute/get_storage_pod.rb +2 -8
- data/lib/fog/vsphere/requests/compute/list_hosts.rb +1 -1
- data/lib/fog/vsphere/requests/compute/list_storage_pods.rb +4 -8
- data/lib/fog/vsphere/requests/compute/list_templates.rb +2 -6
- data/lib/fog/vsphere/requests/compute/list_virtual_machines.rb +6 -12
- data/lib/fog/vsphere/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4991c02472ff132b2a1edef665c3dee7ee98ecec1a98bbad65947e574a9d6957
|
4
|
+
data.tar.gz: e484ae1b367e65fd7d799d1f50673a6584221da5e52ad610cd525e1d32e7de42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0aed9e163c96fadd05853581565a520e841b4df4ff2509b5c8952ee9421f65ebd35d03cd4f94366708d866e97c9b068221818cc02c1e9848fec2041217122d23
|
7
|
+
data.tar.gz: d22e96a6ccaa8bdfd0a1c6ae564ba50317e08b6ab718ce78e1ace8c0422a05ea56fc9590e2ecc341b86ef6d5808b6289874f4b3312542f00c126187c108c3a4f
|
data/CHANGELOG.md
CHANGED
data/CONTRIBUTORS.md
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
* Ben Talbot - btalbot <ben_t48@hotmail.com>
|
5
5
|
* Carl Caum <carl@carlcaum.com>
|
6
6
|
* Carlos Sanchez <csanchez@maestrodev.com>
|
7
|
+
* Chris Roberts <chrobert@redhat.com>
|
7
8
|
* Chris Thompson <chris.thompson@govdelivery.com>
|
8
9
|
* Chris Thompson <teaforthecat@gmail.com>
|
9
10
|
* Christopher Oliver <coliver@datapipe.com>
|
data/lib/fog/vsphere/compute.rb
CHANGED
@@ -648,6 +648,30 @@ module Fog
|
|
648
648
|
raise Fog::Vsphere::Errors::SecurityError, "The remote system presented a public key with hash #{pubkey_hash} but we're expecting a hash of #{expected_pubkey_hash || '<unset>'}. If you are sure the remote system is authentic set vsphere_expected_pubkey_hash: <the hash printed in this message> in ~/.fog"
|
649
649
|
end
|
650
650
|
end
|
651
|
+
|
652
|
+
def list_container_view(datacenter_obj_or_name, type, container_object = nil)
|
653
|
+
dc = if datacenter_obj_or_name.kind_of?(String)
|
654
|
+
find_raw_datacenter(datacenter_obj_or_name)
|
655
|
+
else
|
656
|
+
datacenter_obj_or_name
|
657
|
+
end
|
658
|
+
|
659
|
+
container = if container_object
|
660
|
+
dc.public_send(container_object)
|
661
|
+
else
|
662
|
+
dc
|
663
|
+
end
|
664
|
+
|
665
|
+
container_view = connection.serviceContent.viewManager.CreateContainerView(
|
666
|
+
:container => dc,
|
667
|
+
:type => [type],
|
668
|
+
:recursive => true
|
669
|
+
)
|
670
|
+
|
671
|
+
result = container_view.view
|
672
|
+
container_view.DestroyView
|
673
|
+
result
|
674
|
+
end
|
651
675
|
end
|
652
676
|
end
|
653
677
|
end
|
@@ -11,13 +11,11 @@ module Fog
|
|
11
11
|
protected
|
12
12
|
|
13
13
|
def get_raw_datastore(name, datacenter_name)
|
14
|
-
|
14
|
+
get_raw_datastores(datacenter_name).detect { |ds| ds.name == name }
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
:type => ["Datastore"],
|
19
|
-
:recursive => true
|
20
|
-
}).view.select{|ds| ds.name == name}.first
|
17
|
+
def get_raw_datastores(datacenter_name)
|
18
|
+
list_container_view(datacenter_name, 'Datastore', :datastoreFolder)
|
21
19
|
end
|
22
20
|
end
|
23
21
|
|
@@ -12,8 +12,7 @@ module Fog
|
|
12
12
|
|
13
13
|
def get_raw_network(name, datacenter_name, distributedswitch=nil)
|
14
14
|
finder = choose_finder(name, distributedswitch)
|
15
|
-
|
16
|
-
networks.find { |n| finder.call(n) }
|
15
|
+
get_all_raw_networks(datacenter_name).find { |n| finder.call(n) }
|
17
16
|
end
|
18
17
|
end
|
19
18
|
|
@@ -22,13 +21,7 @@ module Fog
|
|
22
21
|
protected
|
23
22
|
|
24
23
|
def get_all_raw_networks(datacenter_name)
|
25
|
-
|
26
|
-
connection.serviceContent.viewManager.
|
27
|
-
CreateContainerView({
|
28
|
-
:container => dc.networkFolder,
|
29
|
-
:type => ["Network"],
|
30
|
-
:recursive => true
|
31
|
-
}).view
|
24
|
+
list_container_view(datacenter_name, 'Network', :networkFolder)
|
32
25
|
end
|
33
26
|
|
34
27
|
def choose_finder(name, distributedswitch)
|
@@ -11,19 +11,13 @@ module Fog
|
|
11
11
|
protected
|
12
12
|
|
13
13
|
def get_raw_storage_pod(name, datacenter_name)
|
14
|
-
|
15
|
-
|
16
|
-
connection.serviceContent.viewManager.CreateContainerView({
|
17
|
-
:container => dc,
|
18
|
-
:type => ["StoragePod"],
|
19
|
-
:recursive => true
|
20
|
-
}).view.select{|pod| pod.name == name}.first
|
14
|
+
raw_storage_pods(datacenter_name).detect { |pod| pod.name == name}
|
21
15
|
end
|
22
16
|
end
|
23
17
|
|
24
18
|
class Mock
|
25
19
|
def get_storage_pod(name, datacenter_name)
|
26
|
-
list_storage_pods({datacenter: datacenter_name}).
|
20
|
+
list_storage_pods({datacenter: datacenter_name}).detect { |h| h[:name] == name }
|
27
21
|
end
|
28
22
|
end
|
29
23
|
end
|
@@ -27,7 +27,7 @@ module Fog
|
|
27
27
|
product_version: host.summary.config.product.version,
|
28
28
|
hostname: (host.config.network.dnsConfig.hostName rescue nil),
|
29
29
|
domainname: (host.config.network.dnsConfig.domainName rescue nil),
|
30
|
-
vm_ids: Proc.new { host[:vm].map {|vm| vm.config.instanceUuid } }
|
30
|
+
vm_ids: Proc.new { host[:vm].map {|vm| vm.config.instanceUuid rescue nil} }
|
31
31
|
}
|
32
32
|
end
|
33
33
|
end
|
@@ -10,18 +10,14 @@ module Fog
|
|
10
10
|
end
|
11
11
|
|
12
12
|
private
|
13
|
-
def raw_storage_pods(datacenter_name)
|
14
|
-
dc = find_raw_datacenter(datacenter_name)
|
15
13
|
|
16
|
-
|
17
|
-
|
18
|
-
:type => ["StoragePod"],
|
19
|
-
:recursive => true
|
20
|
-
}).view
|
14
|
+
def raw_storage_pods(datacenter_name)
|
15
|
+
list_container_view(datacenter_name, 'StoragePod')
|
21
16
|
end
|
17
|
+
|
22
18
|
protected
|
23
19
|
|
24
|
-
def storage_pod_attributes
|
20
|
+
def storage_pod_attributes(storage_pod, datacenter)
|
25
21
|
{
|
26
22
|
:id => managed_obj_id(storage_pod),
|
27
23
|
:name => storage_pod.name,
|
@@ -27,14 +27,10 @@ module Fog
|
|
27
27
|
datacenters = find_datacenters(options[:datacenter])
|
28
28
|
|
29
29
|
vms = datacenters.map do |dc|
|
30
|
-
|
31
|
-
:container => dc.vmFolder,
|
32
|
-
:type => ["VirtualMachine"],
|
33
|
-
:recursive => true
|
34
|
-
}).view
|
30
|
+
list_container_view(dc, 'VirtualMachine', :vmFolder)
|
35
31
|
end.flatten
|
36
32
|
# remove all virtual machines that are not templates
|
37
|
-
vms.delete_if { |v| v.config.nil?
|
33
|
+
vms.delete_if { |v| v.config.nil? || !v.config.template }
|
38
34
|
|
39
35
|
vms.map(&method(:convert_vm_mob_ref_to_attr_hash))
|
40
36
|
end
|
@@ -23,15 +23,15 @@ module Fog
|
|
23
23
|
def list_all_virtual_machines_in_folder(path, datacenter_name, recursive)
|
24
24
|
vms = raw_list_all_virtual_machines_in_folder(path, datacenter_name, recursive).to_a
|
25
25
|
# remove all template based virtual machines
|
26
|
-
vms.delete_if { |v| v.config.nil?
|
26
|
+
vms.delete_if { |v| v.config.nil? || v.config.template }
|
27
27
|
vms.map(&method(:convert_vm_mob_ref_to_attr_hash))
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
def raw_list_all_virtual_machines_in_folder(path, datacenter_name, recursive)
|
31
31
|
folder = get_raw_vmfolder(path, datacenter_name)
|
32
32
|
folder_enumerator(folder, recursive)
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
# An enumerator for a folder. Enumerates all the VMs in the folder, recursively if
|
36
36
|
# passed recursive=true
|
37
37
|
def folder_enumerator(raw_folder, recursive)
|
@@ -46,7 +46,7 @@ module Fog
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
def list_all_virtual_machines(options = { })
|
51
51
|
raw_vms = raw_list_all_virtual_machines(options[:datacenter])
|
52
52
|
vms = convert_vm_view_to_attr_hash(raw_vms)
|
@@ -62,17 +62,11 @@ module Fog
|
|
62
62
|
## much faster to interact for some functions.
|
63
63
|
datacenters = find_datacenters(datacenter_name)
|
64
64
|
datacenters.map do |dc|
|
65
|
-
|
66
|
-
:container => dc.vmFolder,
|
67
|
-
:type => ["VirtualMachine"],
|
68
|
-
:recursive => true
|
69
|
-
}).view
|
65
|
+
list_container_view(dc, 'VirtualMachine', :vmFolder)
|
70
66
|
end.flatten
|
71
67
|
end
|
72
68
|
def get_folder_path(folder, root = nil)
|
73
|
-
if (
|
74
|
-
return
|
75
|
-
end
|
69
|
+
return if (!folder.methods.include?('parent')) || (folder == root)
|
76
70
|
"#{get_folder_path(folder.parent)}/#{folder.name}"
|
77
71
|
end
|
78
72
|
end
|
data/lib/fog/vsphere/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-vsphere
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- J.R. Garcia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-core
|