fog-vsphere 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50674c6fa7d5ee252ada84a587b3321aa1eea6fcfdc39b6a7d4024f6aca1ff2b
4
- data.tar.gz: 8ff973afd99e08033368d76e7907d5944c5cecaa5c221dcb6d967616ea30e5af
3
+ metadata.gz: 2802cab39cda0d34fbf317a0ef39e79b53a7ce20fd736e2f41ac86e0d95f494b
4
+ data.tar.gz: d173548894fdfed4a4c517e1e6b30b513420b2bf59be77ce1147350ba695a15f
5
5
  SHA512:
6
- metadata.gz: a463bfaf886fadb3e0944aefdc7b5a93e2345d7183ccd0862a52ff735be9251e29d323d9baab700f86c9815452d66e8052149f577177d4bd6b253871480e746c
7
- data.tar.gz: bb5a1ec93db10d8f59424cf0deb625a3add86471a5eecec6b81be885d738003617fd54386c5dd423c876b2afaae7f30fdb48fe11e7096fad8f47c2f2dc265aa8
6
+ metadata.gz: 62ec056eb0f333a9a80eb1d4ec523cb2e5f8893d8b0cdd9f5243210a920b2acfeeaa74dd5fe00770b5eb77bd5a255167dde730b8f89b257e1d8891133803e1e6
7
+ data.tar.gz: 4ac64f5bca359eb6e6290d137e1975644929f4eee39e0ad5f48d6c7fb2f58d8f6a235d557efe5bb26f1e0bfc98f88321a199b78bbf6b195aa92c3459e7b9bfd9
@@ -1,3 +1,8 @@
1
+ ## v2.3.0
2
+ * set volume unit_number when cloning a vm (#151)
3
+ * add unclustered esxi hosts back to cluster selection (#149)
4
+ * reduce the time required to list networks (#145)
5
+
1
6
  ## v2.2.0
2
7
  * vm interface updating needs a datacenter as option (#140)
3
8
  * improve vm saving to use a single api call and support network changes (#142)
@@ -8,9 +8,7 @@ module Fog
8
8
  list_datacenters.map { |dc| list_clusters(datacenter: dc[:name]) }.flatten
9
9
  else
10
10
  raw_clusters(datacenter_name).map do |cluster|
11
- if cluster.instance_of? RbVmomi::VIM::ClusterComputeResource
12
- cluster_attributes(cluster, datacenter_name)
13
- end
11
+ cluster_attributes(cluster, datacenter_name)
14
12
  end.compact
15
13
  end
16
14
  end
@@ -7,42 +7,83 @@ module Fog
7
7
  cluster_name = filters.fetch(:cluster, nil)
8
8
  # default to show all networks
9
9
  only_active = filters[:accessible] || false
10
- raw_networks(datacenter_name, cluster_name).map do |network|
11
- next if only_active && !network.summary.accessible
12
- network_attributes(network, datacenter_name)
13
- end.compact
14
- end
15
10
 
16
- def raw_networks(datacenter_name, cluster = nil)
17
- if cluster.nil?
18
- find_raw_datacenter(datacenter_name).network
19
- else
20
- get_raw_cluster(cluster, datacenter_name).network
11
+ dc = find_raw_datacenter(datacenter_name)
12
+
13
+ results = property_collector_results(network_filter_spec(dc))
14
+
15
+ dvswitches = results.select { |result| result.obj.is_a?(RbVmomi::VIM::DistributedVirtualSwitch) }.each_with_object({}) do |dvswitch, obj|
16
+ obj[dvswitch.obj._ref] = dvswitch['summary.name']
21
17
  end
18
+
19
+ if cluster_name
20
+ cluster = get_raw_cluster(cluster_name, datacenter_name)
21
+ cluster_networks = cluster.network.map(&:_ref)
22
+ end
23
+
24
+ results.select { |result| result.obj.is_a?(RbVmomi::VIM::DistributedVirtualPortgroup) || result.obj.is_a?(RbVmomi::VIM::Network) }.map do |network|
25
+ next if cluster_name && !cluster_networks.include?(network.obj._ref)
26
+ next if only_active && !network['summary.accessible']
27
+ if network.obj.is_a?(RbVmomi::VIM::DistributedVirtualPortgroup)
28
+ map_attrs_to_hash(network, network_dvportgroup_attribute_mapping).merge(
29
+ vlanid: raw_network_vlan(network['config.defaultPortConfig']),
30
+ virtualswitch: dvswitches[network['config.distributedVirtualSwitch']._ref]
31
+ )
32
+ else
33
+ map_attrs_to_hash(network, network_attribute_mapping).merge(
34
+ id: managed_obj_id(network.obj)
35
+ )
36
+ end.merge(
37
+ datacenter: datacenter_name,
38
+ _ref: network.obj._ref
39
+ )
40
+ end.compact
22
41
  end
23
42
 
24
43
  protected
25
44
 
26
- def network_attributes(network, datacenter)
27
- if network.is_a?(RbVmomi::VIM::DistributedVirtualPortgroup)
28
- id = network.key
29
- virtualswitch = network.config.distributedVirtualSwitch.name
30
- vlanid = raw_network_vlan(network.config.defaultPortConfig)
31
- else
32
- id = managed_obj_id(network)
33
- virtualswitch = nil
34
- vlanid = nil
35
- end
45
+ def network_attribute_mapping
36
46
  {
37
- id: id,
38
- name: network.name,
39
- accessible: network.summary.accessible,
40
- datacenter: datacenter,
41
- virtualswitch: virtualswitch,
42
- vlanid: vlanid
47
+ name: 'name',
48
+ accessible: 'summary.accessible'
43
49
  }
44
50
  end
45
51
 
52
+ def network_dvportgroup_attribute_mapping
53
+ network_attribute_mapping.merge(
54
+ id: 'config.key'
55
+ )
56
+ end
57
+
58
+ def folder_traversal_spec
59
+ RbVmomi::VIM.TraversalSpec(
60
+ name: 'FolderTraversalSpec',
61
+ type: 'Folder',
62
+ path: 'childEntity',
63
+ skip: false,
64
+ selectSet: [
65
+ RbVmomi::VIM.SelectionSpec(name: 'FolderTraversalSpec')
66
+ ]
67
+ )
68
+ end
69
+
70
+ def network_filter_spec(obj)
71
+ RbVmomi::VIM.PropertyFilterSpec(
72
+ objectSet: [
73
+ obj: obj.networkFolder,
74
+ skip: true,
75
+ selectSet: [
76
+ folder_traversal_spec
77
+ ]
78
+ ],
79
+ propSet: [
80
+ { type: 'DistributedVirtualSwitch', pathSet: ['summary.name'] },
81
+ { type: 'Network', pathSet: network_attribute_mapping.values },
82
+ { type: 'DistributedVirtualPortgroup', pathSet: network_dvportgroup_attribute_mapping.values + ['config.defaultPortConfig', 'config.distributedVirtualSwitch'] }
83
+ ]
84
+ )
85
+ end
86
+
46
87
  private
47
88
 
48
89
  def raw_network_vlan(network)
@@ -59,6 +100,7 @@ module Fog
59
100
  end
60
101
  end
61
102
  end
103
+
62
104
  class Mock
63
105
  def list_networks(filters)
64
106
  datacenter_name = filters[:datacenter]
@@ -28,6 +28,7 @@ module Fog
28
28
  end
29
29
  end
30
30
 
31
+ # rubocop:disable ClassLength
31
32
  class Real
32
33
  include Shared
33
34
 
@@ -803,6 +804,7 @@ module Fog
803
804
  device: template_volume }
804
805
  end
805
806
  end
807
+ new_volumes.map { |volume| volume.unit_number = volumes.index(volume) < 7 ? volumes.index(volume) : volumes.index(volume) + 1 }
806
808
  specs.concat(new_volumes.map { |volume| create_disk(volume) })
807
809
  specs
808
810
  end
@@ -821,6 +823,7 @@ module Fog
821
823
  end
822
824
  end
823
825
 
826
+ # rubocop:enable ClassLength
824
827
  class Mock
825
828
  include Shared
826
829
  def vm_clone(options = {})
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Vsphere
3
- VERSION = '2.2.0'.freeze
3
+ VERSION = '2.3.0'.freeze
4
4
  end
5
5
  end
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.2.0
4
+ version: 2.3.0
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-05-18 00:00:00.000000000 Z
11
+ date: 2018-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core