fog-vsphere 3.2.2 → 3.5.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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -5
  3. data/CHANGELOG.md +27 -0
  4. data/CONTRIBUTORS.md +2 -1
  5. data/fog-vsphere.gemspec +2 -2
  6. data/lib/fog/vsphere/compute.rb +13 -1
  7. data/lib/fog/vsphere/models/compute/clusters.rb +0 -2
  8. data/lib/fog/vsphere/models/compute/customfields.rb +0 -2
  9. data/lib/fog/vsphere/models/compute/customvalues.rb +0 -2
  10. data/lib/fog/vsphere/models/compute/datacenters.rb +0 -2
  11. data/lib/fog/vsphere/models/compute/datastores.rb +0 -2
  12. data/lib/fog/vsphere/models/compute/folders.rb +0 -2
  13. data/lib/fog/vsphere/models/compute/interfaces.rb +0 -2
  14. data/lib/fog/vsphere/models/compute/interfacetypes.rb +0 -2
  15. data/lib/fog/vsphere/models/compute/network.rb +1 -0
  16. data/lib/fog/vsphere/models/compute/networks.rb +0 -2
  17. data/lib/fog/vsphere/models/compute/resource_pools.rb +0 -2
  18. data/lib/fog/vsphere/models/compute/rules.rb +0 -2
  19. data/lib/fog/vsphere/models/compute/server.rb +3 -1
  20. data/lib/fog/vsphere/models/compute/servers.rb +0 -2
  21. data/lib/fog/vsphere/models/compute/servertypes.rb +0 -2
  22. data/lib/fog/vsphere/models/compute/templates.rb +0 -2
  23. data/lib/fog/vsphere/models/compute/tickets.rb +0 -2
  24. data/lib/fog/vsphere/models/compute/volumes.rb +0 -2
  25. data/lib/fog/vsphere/requests/compute/create_resource_pool.rb +51 -0
  26. data/lib/fog/vsphere/requests/compute/create_vm.rb +4 -2
  27. data/lib/fog/vsphere/requests/compute/destroy_resource_pool.rb +15 -0
  28. data/lib/fog/vsphere/requests/compute/list_networks.rb +5 -0
  29. data/lib/fog/vsphere/requests/compute/list_resource_pools.rb +2 -2
  30. data/lib/fog/vsphere/requests/compute/list_vm_interfaces.rb +8 -4
  31. data/lib/fog/vsphere/requests/compute/list_vm_volumes.rb +5 -0
  32. data/lib/fog/vsphere/requests/compute/update_resource_pool.rb +31 -0
  33. data/lib/fog/vsphere/requests/compute/vm_clone.rb +13 -6
  34. data/lib/fog/vsphere/version.rb +1 -1
  35. metadata +14 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78c397e17b42379d4faf61cf8a3febdf774389e2df303f3b0711199341d63e12
4
- data.tar.gz: 252c2e0e3edd5064b0bad1d658a37964c2a11c208ffdb27d9e6a4beadf6bd1be
3
+ metadata.gz: 18ada3fe97234aa0bf59aaab14ea04ba2ceaa40cb62abc6189026b6214d85759
4
+ data.tar.gz: 7894e6c462e8501eb2c9a16170300d75516ba8e4431a64be14d5cc6140271fbe
5
5
  SHA512:
6
- metadata.gz: fc10dca7dd3e262a16ebf4c5e6df5f6863d0864579de95211ec5dbe291c91b970ba3ca9e00a92d1bc070daa5f1fc9facac542e03fc71ba0662f3a0acc3b96649
7
- data.tar.gz: 23bcdf44c1e119499a3c5b9da42c1d95fef56a60dbef878d70a79246319ba7b5e4f94cc63cfe6a2e67fbf154d356c1c7de945eaa9f22c716f53567df88c57564
6
+ metadata.gz: 8db1f07c4c800261506a22d0be60cc2c777a2da9e6001cee6a39a22218719af8eb4f105071383732c40f20201818645954a388420f7291bd0d3fecee0adc1a91
7
+ data.tar.gz: ba9313ddc1af94248d965ae9cda4734766cf36c494f33f5f84fc40581be22532ff96700539f63dce3583d955a60e86b75e367795bd3c0ca29291fa921717d1db
@@ -1,6 +1,5 @@
1
1
  language: ruby
2
2
  sudo: false
3
- before_install: gem install bundler -v 1.17.3
4
3
  matrix:
5
4
  allow_failures:
6
5
  - rvm: jruby-head
@@ -22,7 +21,3 @@ script: bundle exec rake travis:ci
22
21
  notifications:
23
22
  email:
24
23
  - chrobert@redhat.com
25
- addons:
26
- code_climate:
27
- repo_token: 44bcd04b60228fc94f2be3a5e0346441b5ea156e94e89a17fc24c5d3de483721
28
-
@@ -1,3 +1,30 @@
1
+ ## v3.5.0
2
+ * Clone vm from different datacenter (#263)
3
+ * Fix autoload issues (#267)
4
+ * Add extra_config attribute to server (#268)
5
+ * Expose `_ref` from Compute::Network (#265)
6
+
7
+ ## v3.4.0
8
+ * list_resource_pools returns incorrect resource pool name (#256)
9
+ * Add ability to create update and delete Resource Pools (#253)
10
+ * Check datastore for existence prior vm_clone
11
+
12
+ ## v3.3.1
13
+ Fixes eager zero flag (#251, #252)
14
+
15
+ ## v3.3.0
16
+ * Add support for nsx-t (#248)
17
+
18
+ ## v3.2.5
19
+ * Check cluster existance properly (#239)
20
+
21
+ ## ~~v3.2.3~~
22
+ * Check cluster existance (#239)
23
+
24
+ ## v3.2.2
25
+ * Load simple clusters (#237)
26
+ * ISO upload: correctly check if upload directory exists
27
+
1
28
  ## v3.2.1
2
29
 
3
30
  * Fix VM creation on storagePod (#234)
@@ -56,9 +56,10 @@
56
56
  * Paul Thornthwaite <paul@brightbox.co.uk>
57
57
  * Paul Thornthwaite <tokengeek@gmail.com>
58
58
  * Paulo Henrique Lopes Ribeiro <plribeiro3000@gmail.com>
59
- * Rohan Arora <roarora@redhat.com>
60
59
  * Rich Daley <rdaley@williamhill.co.uk>
61
60
  * Rich Lane <rlane@club.cc.cmu.edu>
61
+ * Rohan Arora <roarora@redhat.com>
62
+ * Roman Lazoryshchak <lazoryshchak@gmail.com>
62
63
  * Samuel Keeley <samuel@dropbox.com>
63
64
  * Sergio Cambra <sergio@programatica.es>
64
65
  * Shlomi Zadok <shlomi@ben-hanna.com>
@@ -24,9 +24,9 @@ Gem::Specification.new do |spec|
24
24
  spec.add_runtime_dependency 'fog-core'
25
25
  spec.add_runtime_dependency 'rbvmomi', '>= 1.9', '< 3'
26
26
 
27
- spec.add_development_dependency 'bundler', '~> 1.10'
27
+ spec.add_development_dependency 'bundler'
28
28
  spec.add_development_dependency 'pry', '~> 0.10'
29
- spec.add_development_dependency 'rake', '~> 10.0'
29
+ spec.add_development_dependency 'rake', '>= 12.3.3'
30
30
  spec.add_development_dependency 'minitest', '~> 5.8'
31
31
  spec.add_development_dependency 'rubocop', '~> 0.50.0'
32
32
  spec.add_development_dependency 'mocha', '~> 1.8'
@@ -71,6 +71,9 @@ module Fog
71
71
  request :get_cluster
72
72
  request :list_resource_pools
73
73
  request :get_resource_pool
74
+ request :create_resource_pool
75
+ request :update_resource_pool
76
+ request :destroy_resource_pool
74
77
  request :list_networks
75
78
  request :get_network
76
79
  request :list_datastores
@@ -165,7 +168,8 @@ module Fog
165
168
  memoryHotAddEnabled: 'config.memoryHotAddEnabled',
166
169
  firmware: 'config.firmware',
167
170
  boot_order: 'config.bootOptions.bootOrder',
168
- annotation: 'config.annotation'
171
+ annotation: 'config.annotation',
172
+ extra_config: 'config.extraConfig'
169
173
  }.freeze
170
174
 
171
175
  def convert_vm_view_to_attr_hash(vms)
@@ -247,6 +251,8 @@ module Fog
247
251
  nil
248
252
  end
249
253
  }
254
+
255
+ attrs['extra_config'] = parse_extra_config(attrs['extra_config'])
250
256
  end
251
257
  # This inline rescue catches any standard error. While a VM is
252
258
  # cloning, a call to the macs method will throw and NoMethodError
@@ -305,6 +311,12 @@ module Fog
305
311
  end.compact.uniq
306
312
  end
307
313
 
314
+ # Flattens Array of RbVmomi::VIM::OptionValue to simple hash
315
+ def parse_extra_config(vm_extra_config)
316
+ return unless vm_extra_config.is_a?(Array)
317
+ vm_extra_config.map { |entry| [entry[:key], entry[:value]] }.to_h
318
+ end
319
+
308
320
  # returns vmware managed obj id string
309
321
  def managed_obj_id(obj)
310
322
  obj.to_s.match(/\("([^"]+)"\)/)[1]
@@ -2,8 +2,6 @@ module Fog
2
2
  module Vsphere
3
3
  class Compute
4
4
  class Clusters < Fog::Collection
5
- autoload :Cluster, File.expand_path('../cluster', __FILE__)
6
-
7
5
  model Fog::Vsphere::Compute::Cluster
8
6
  attr_accessor :datacenter
9
7
 
@@ -2,8 +2,6 @@ module Fog
2
2
  module Vsphere
3
3
  class Compute
4
4
  class Customfields < Fog::Collection
5
- autoload :Customfield, File.expand_path('../customfield', __FILE__)
6
-
7
5
  model Fog::Vsphere::Compute::Customfield
8
6
 
9
7
  attr_accessor :vm
@@ -2,8 +2,6 @@ module Fog
2
2
  module Vsphere
3
3
  class Compute
4
4
  class Customvalues < Fog::Collection
5
- autoload :Customvalue, File.expand_path('../customvalue', __FILE__)
6
-
7
5
  model Fog::Vsphere::Compute::Customvalue
8
6
 
9
7
  attr_accessor :vm
@@ -2,8 +2,6 @@ module Fog
2
2
  module Vsphere
3
3
  class Compute
4
4
  class Datacenters < Fog::Collection
5
- autoload :Datacenter, File.expand_path('../datacenter', __FILE__)
6
-
7
5
  model Fog::Vsphere::Compute::Datacenter
8
6
 
9
7
  def all(filters = {})
@@ -2,8 +2,6 @@ module Fog
2
2
  module Vsphere
3
3
  class Compute
4
4
  class Datastores < Fog::Collection
5
- autoload :Datastore, File.expand_path('../datastore', __FILE__)
6
-
7
5
  model Fog::Vsphere::Compute::Datastore
8
6
  attr_accessor :datacenter, :cluster
9
7
 
@@ -2,8 +2,6 @@ module Fog
2
2
  module Vsphere
3
3
  class Compute
4
4
  class Folders < Fog::Collection
5
- autoload :Folder, File.expand_path('../folder', __FILE__)
6
-
7
5
  model Fog::Vsphere::Compute::Folder
8
6
  attr_accessor :datacenter, :type, :path
9
7
 
@@ -2,8 +2,6 @@ module Fog
2
2
  module Vsphere
3
3
  class Compute
4
4
  class Interfaces < Fog::Collection
5
- autoload :Interface, File.expand_path('../interface', __FILE__)
6
-
7
5
  model Fog::Vsphere::Compute::Interface
8
6
 
9
7
  attribute :server_id
@@ -2,8 +2,6 @@ module Fog
2
2
  module Vsphere
3
3
  class Compute
4
4
  class Interfacetypes < Fog::Collection
5
- autoload :Interfacetype, File.expand_path('../interfacetype', __FILE__)
6
-
7
5
  model Fog::Vsphere::Compute::Interfacetype
8
6
  attr_accessor :datacenter
9
7
  attr_accessor :servertype
@@ -9,6 +9,7 @@ module Fog
9
9
  attribute :accessible # reachable by at least one hypervisor
10
10
  attribute :virtualswitch
11
11
  attribute :vlanid
12
+ attribute :_ref
12
13
 
13
14
  def to_s
14
15
  name
@@ -2,8 +2,6 @@ module Fog
2
2
  module Vsphere
3
3
  class Compute
4
4
  class Networks < Fog::Collection
5
- autoload :Network, File.expand_path('../network', __FILE__)
6
-
7
5
  model Fog::Vsphere::Compute::Network
8
6
  attr_accessor :datacenter, :cluster
9
7
 
@@ -2,8 +2,6 @@ module Fog
2
2
  module Vsphere
3
3
  class Compute
4
4
  class ResourcePools < Fog::Collection
5
- autoload :ResourcePool, File.expand_path('../resource_pool', __FILE__)
6
-
7
5
  model Fog::Vsphere::Compute::ResourcePool
8
6
  attr_accessor :datacenter, :cluster
9
7
 
@@ -2,8 +2,6 @@ module Fog
2
2
  module Vsphere
3
3
  class Compute
4
4
  class Rules < Fog::Collection
5
- autoload :Rule, File.expand_path('../rule', __FILE__)
6
-
7
5
  model Fog::Vsphere::Compute::Rule
8
6
  attribute :datacenter
9
7
  attribute :cluster
@@ -52,6 +52,7 @@ module Fog
52
52
  attribute :firmware
53
53
  attribute :boot_order
54
54
  attribute :annotation
55
+ attribute :extra_config
55
56
 
56
57
  def initialize(attributes = {})
57
58
  super defaults.merge(attributes)
@@ -157,7 +158,8 @@ module Fog
157
158
 
158
159
  # Give our path to the request
159
160
  req_options['template_path'] = "#{relative_path}/#{name}"
160
- req_options['datacenter'] = datacenter.to_s
161
+ req_options['template_datacenter'] = datacenter.to_s
162
+ req_options['datacenter'] ||= datacenter.to_s
161
163
 
162
164
  # Perform the actual clone
163
165
  clone_results = service.vm_clone(req_options)
@@ -2,8 +2,6 @@ module Fog
2
2
  module Vsphere
3
3
  class Compute
4
4
  class Servers < Fog::Collection
5
- autoload :Server, File.expand_path('../server', __FILE__)
6
-
7
5
  model Fog::Vsphere::Compute::Server
8
6
  attr_accessor :datacenter
9
7
  attr_accessor :network
@@ -2,8 +2,6 @@ module Fog
2
2
  module Vsphere
3
3
  class Compute
4
4
  class Servertypes < Fog::Collection
5
- autoload :Servertype, File.expand_path('../servertype', __FILE__)
6
-
7
5
  model Fog::Vsphere::Compute::Servertype
8
6
  attr_accessor :datacenter, :id, :fullname
9
7
 
@@ -2,8 +2,6 @@ module Fog
2
2
  module Vsphere
3
3
  class Compute
4
4
  class Templates < Fog::Collection
5
- autoload :Template, File.expand_path('../template', __FILE__)
6
-
7
5
  model Fog::Vsphere::Compute::Template
8
6
 
9
7
  def all(filters = {})
@@ -2,8 +2,6 @@ module Fog
2
2
  module Vsphere
3
3
  class Compute
4
4
  class Tickets < Fog::Collection
5
- autoload :Ticket, File.expand_path('../ticket', __FILE__)
6
-
7
5
  model Fog::Vsphere::Compute::Ticket
8
6
 
9
7
  attr_accessor :server
@@ -2,8 +2,6 @@ module Fog
2
2
  module Vsphere
3
3
  class Compute
4
4
  class Volumes < Fog::Collection
5
- autoload :Volume, File.expand_path('../volume', __FILE__)
6
-
7
5
  attribute :server_id
8
6
 
9
7
  model Fog::Vsphere::Compute::Volume
@@ -0,0 +1,51 @@
1
+ module Fog
2
+ module Vsphere
3
+ class Compute
4
+ class Real
5
+ def create_resource_pool(attributes = {})
6
+ cluster = get_raw_cluster(attributes[:cluster], attributes[:datacenter])
7
+
8
+ root_resource_pool = if attributes[:root_resource_pool_name]
9
+ cluster.resourcePool.find attributes[:root_resource_pool_name].gsub('/', '%2f')
10
+ else
11
+ cluster.resourcePool
12
+ end
13
+
14
+ raise ArgumentError, 'Root resource pool could not be found' if root_resource_pool.nil?
15
+
16
+ resource_pool = root_resource_pool.CreateResourcePool(
17
+ name: attributes[:name],
18
+ spec: get_resource_pool_spec(attributes)
19
+ )
20
+
21
+ resource_pool_attributes(resource_pool, attributes[:cluster], attributes[:datacenter])
22
+ end
23
+
24
+ private
25
+
26
+ def get_resource_pool_spec(attributes = {})
27
+ RbVmomi::VIM.ResourceConfigSpec(
28
+ cpuAllocation: get_resource_pool_allocation_spec(attributes.fetch(:cpu, {})),
29
+ memoryAllocation: get_resource_pool_allocation_spec(attributes.fetch(:memory, {}))
30
+ )
31
+ end
32
+
33
+ def get_resource_pool_allocation_spec(attributes = {})
34
+ RbVmomi::VIM.ResourceAllocationInfo(
35
+ reservation: attributes.fetch(:reservation, 0),
36
+ limit: attributes.fetch(:limit, -1),
37
+ expandableReservation: attributes.fetch(:expandable_reservation, false),
38
+ shares: RbVmomi::VIM.SharesInfo(
39
+ level: RbVmomi::VIM.SharesLevel(attributes.fetch(:shares_level, 'normal')),
40
+ shares: attributes.fetch(:shares, 0)
41
+ )
42
+ )
43
+ end
44
+ end
45
+
46
+ class Mock
47
+ def create_resource_pool(attributes = {}); end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -4,6 +4,8 @@ module Fog
4
4
  class Real
5
5
  def create_vm(attributes = {})
6
6
  # build up vm configuration
7
+ cluster = get_raw_cluster(attributes[:cluster], attributes[:datacenter])
8
+ raise Fog::Vsphere::Compute::NotFound, "Cluster #{attributes[:cluster]} Doesn't Exist in the DC!" unless cluster
7
9
 
8
10
  vm_cfg = {
9
11
  name: attributes[:name],
@@ -24,7 +26,7 @@ module Fog
24
26
  resource_pool = if attributes[:resource_pool] && attributes[:resource_pool] != 'Resources'
25
27
  get_raw_resource_pool(attributes[:resource_pool], attributes[:cluster], attributes[:datacenter])
26
28
  else
27
- get_raw_cluster(attributes[:cluster], attributes[:datacenter]).resourcePool
29
+ cluster.resourcePool
28
30
  end
29
31
  vmFolder = get_raw_vmfolder(attributes[:path], attributes[:datacenter])
30
32
  host = if attributes.key?(:host)
@@ -298,7 +300,7 @@ module Fog
298
300
  file_operation = options[:file_operation] || (:create if operation == :add)
299
301
  payload[:fileOperation] = file_operation if file_operation
300
302
 
301
- if operation == :add && disk.thin == 'false' && disk.eager_zero == 'true'
303
+ if operation == :add && !disk.thin && disk.eager_zero
302
304
  payload[:device][:backing][:eagerlyScrub] = disk.eager_zero
303
305
  end
304
306
 
@@ -0,0 +1,15 @@
1
+ module Fog
2
+ module Vsphere
3
+ class Compute
4
+ class Real
5
+ def destroy_resource_pool(attributes = {})
6
+ get_raw_resource_pool_by_ref(attributes).Destroy_Task().wait_for_completion
7
+ end
8
+ end
9
+
10
+ class Mock
11
+ def destroy_resource_pool(attributes = {}); end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -29,6 +29,11 @@ module Fog
29
29
  vlanid: raw_network_vlan(network['config.defaultPortConfig']),
30
30
  virtualswitch: dvswitches[network['config.distributedVirtualSwitch']._ref]
31
31
  )
32
+ elsif network.obj.is_a?(RbVmomi::VIM::OpaqueNetwork)
33
+ map_attrs_to_hash(network, network_dvportgroup_attribute_mapping).merge(
34
+ id: network.obj._ref,
35
+ opaqueNetworkId: network.obj.summary.opaqueNetworkId
36
+ )
32
37
  else
33
38
  map_attrs_to_hash(network, network_attribute_mapping).merge(
34
39
  id: network.obj._ref
@@ -36,8 +36,8 @@ module Fog
36
36
  end
37
37
 
38
38
  def resource_pool_attributes(resource_pool, cluster, datacenter)
39
- name = folder_path(resource_pool).gsub(/^.*Resources(\/|)/, '')
40
- name = 'Resources' if name.empty?
39
+ folder_path(resource_pool) =~ /(?<=Resources\/)(.+)/
40
+ name = Regexp.last_match(1) || 'Resources'
41
41
  {
42
42
  id: managed_obj_id(resource_pool),
43
43
  name: name,
@@ -29,12 +29,12 @@ module Fog
29
29
  # unitNumber: 7,
30
30
  #
31
31
  def list_vm_interfaces(vm_id, datacenter = nil)
32
- get_raw_interfaces(vm_id, datacenter).map { |nic| raw_to_hash nic }
32
+ get_raw_interfaces(vm_id, datacenter).map { |nic| raw_to_hash(nic, datacenter) }
33
33
  end
34
34
 
35
35
  def get_vm_interface(vm_id, options = {})
36
36
  raw = get_raw_interface(vm_id, options)
37
- raw_to_hash(raw) if raw
37
+ raw_to_hash(raw, options[:datacenter]) if raw
38
38
  end
39
39
 
40
40
  def get_raw_interfaces(vm_id, datacenter = nil)
@@ -61,12 +61,16 @@ module Fog
61
61
 
62
62
  private
63
63
 
64
- # rubocop:disable Style/ConditionalAssignment
65
- def raw_to_hash(nic)
64
+ def raw_to_hash(nic, datacenter)
66
65
  if nic.backing.respond_to?(:network)
67
66
  network = nic.backing.network.name
68
67
  elsif nic.backing.respond_to?(:port)
69
68
  network = nic.backing.port.portgroupKey
69
+ elsif nic.backing.respond_to?(:opaqueNetworkId)
70
+ opaquenetworks = list_networks(:datacenter => datacenter).select { |net| net.key?(:opaqueNetworkId) }
71
+ network = opaquenetworks.find do |opaquenetwork|
72
+ nic.backing.opaqueNetworkId == opaquenetwork[:opaqueNetworkId]
73
+ end[:id]
70
74
  else
71
75
  network = nil
72
76
  end
@@ -37,6 +37,11 @@ module Fog
37
37
  rescue
38
38
  (nil)
39
39
  end),
40
+ eager_zero: (begin
41
+ vol.backing.eagerlyScrub
42
+ rescue
43
+ (nil)
44
+ end),
40
45
  mode: vol.backing.diskMode,
41
46
  filename: vol.backing.fileName,
42
47
  datastore: (begin
@@ -0,0 +1,31 @@
1
+ module Fog
2
+ module Vsphere
3
+ class Compute
4
+ class Real
5
+ def update_resource_pool(attributes = {})
6
+ raw_resource_pool = get_raw_resource_pool_by_ref(attributes)
7
+
8
+ raw_resource_pool.UpdateConfig(
9
+ name: attributes[:name],
10
+ config: get_resource_pool_spec(attributes)
11
+ )
12
+
13
+ resource_pool_attributes(raw_resource_pool, attributes[:cluster], attributes[:datacenter])
14
+ end
15
+
16
+ private
17
+
18
+ def get_raw_resource_pool_by_ref(attributes = {})
19
+ dc = find_raw_datacenter(attributes[:datacenter])
20
+ cluster = dc.find_compute_resource(attributes[:cluster])
21
+
22
+ list_raw_resource_pools(cluster).detect { |rp| rp._ref == attributes[:ref] }
23
+ end
24
+ end
25
+
26
+ class Mock
27
+ def update_resource_pool(attributes = {}); end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -21,9 +21,15 @@ module Fog
21
21
  end
22
22
  raise ArgumentError, 'cluster option is required' unless options['resource_pool'][0]
23
23
  raise Fog::Vsphere::Compute::NotFound, "Datacenter #{options['datacenter']} Doesn't Exist!" unless get_datacenter(options['datacenter'])
24
- raise Fog::Vsphere::Compute::NotFound, "Template #{options['template_path']} Doesn't Exist!" unless get_virtual_machine(options['template_path'], options['datacenter'])
24
+ if options['template_datacenter'] && !get_datacenter(options['template_datacenter'])
25
+ raise Fog::Vsphere::Compute::NotFound, "Datacenter #{options['template_datacenter']} Doesn't Exist!"
26
+ end
27
+ raise Fog::Vsphere::Compute::NotFound, "Template #{options['template_path']} Doesn't Exist!" unless get_virtual_machine(options['template_path'], options['template_datacenter'] || options['datacenter'])
25
28
  raise Fog::Vsphere::Compute::NotFound, "Cluster #{options['resource_pool'][0]} Doesn't Exist in the DC!" unless get_raw_cluster(options["resource_pool"][0], options['datacenter'])
26
29
  raise ArgumentError, 'path option is required' unless options.fetch('dest_folder', '/')
30
+ if options.key?('datastore') && !options['datastore'].nil? && !get_raw_datastore(options['datastore'], options['datacenter'])
31
+ raise Fog::Vsphere::Compute::NotFound, "Datastore #{options['datastore']} Doesn't Exist!"
32
+ end
27
33
  if options.key?('storage_pod') && !options['storage_pod'].nil? && !get_raw_storage_pod(options['storage_pod'], options['datacenter'])
28
34
  raise Fog::Vsphere::Compute::NotFound, "Storage Pod #{options['storage_pod']} Doesn't Exist!"
29
35
  end
@@ -47,6 +53,9 @@ module Fog
47
53
  # want to clone FROM. Relative to Datacenter (Example:
48
54
  # "FolderNameHere/VMNameHere")
49
55
  # * 'name'<~String> - *REQUIRED* The VMName of the Destination
56
+ # * 'template_datacenter'<~String> - Datacenter name where template
57
+ # is. Make sure this datacenter exists, should if you're using
58
+ # the clone function in server.rb model.
50
59
  # * 'dest_folder'<~String> - Destination Folder of where 'name' will
51
60
  # be placed on your cluster. Relative Path to Datacenter E.G.
52
61
  # "FolderPlaceHere/anotherSub Folder/onemore"
@@ -101,14 +110,11 @@ module Fog
101
110
  # Option handling
102
111
  options = vm_clone_check_options(options)
103
112
 
104
- # Added for people still using options['path']
105
- template_path = options['path'] || options['template_path']
106
-
107
113
  # Options['template_path']<~String>
108
114
  # Added for people still using options['path']
109
115
  template_path = options['path'] || options['template_path']
110
116
  # Now find the template itself using the efficient find method
111
- vm_mob_ref = get_vm_ref(template_path, options['datacenter'])
117
+ vm_mob_ref = get_vm_ref(template_path, options['template_datacenter'] || options['datacenter'])
112
118
 
113
119
  # Options['dest_folder']<~String>
114
120
  # Grab the destination folder object if it exists else use cloned mach
@@ -800,7 +806,7 @@ module Fog
800
806
  device: template_nic
801
807
  }
802
808
  else
803
- interface = Fog::Vsphere::Compute::Interface.new(raw_to_hash(template_nic))
809
+ interface = Fog::Vsphere::Compute::Interface.new(raw_to_hash(template_nic, datacenter))
804
810
  specs << create_interface(interface, interface.key, :remove, datacenter: datacenter)
805
811
  end
806
812
  end
@@ -838,6 +844,7 @@ module Fog
838
844
  end
839
845
  template_volume.backing.diskMode = new_volume.mode
840
846
  template_volume.backing.thinProvisioned = new_volume.thin
847
+ template_volume.backing.eagerlyScrub = !new_volume.thin && new_volume.eager_zero
841
848
  specs << { operation: :edit, device: template_volume }
842
849
  else
843
850
  specs << { operation: :remove,
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Vsphere
3
- VERSION = '3.2.2'.freeze
3
+ VERSION = '3.5.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: 3.2.2
4
+ version: 3.5.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: 2020-01-24 00:00:00.000000000 Z
11
+ date: 2020-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core
@@ -48,16 +48,16 @@ dependencies:
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: '1.10'
53
+ version: '0'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "~>"
58
+ - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: '1.10'
60
+ version: '0'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: pry
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -76,16 +76,16 @@ dependencies:
76
76
  name: rake
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - "~>"
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
- version: '10.0'
81
+ version: 12.3.3
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - "~>"
86
+ - - ">="
87
87
  - !ruby/object:Gem::Version
88
- version: '10.0'
88
+ version: 12.3.3
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: minitest
91
91
  requirement: !ruby/object:Gem::Requirement
@@ -240,10 +240,12 @@ files:
240
240
  - lib/fog/vsphere/requests/compute/cloudinit_to_customspec.rb
241
241
  - lib/fog/vsphere/requests/compute/create_folder.rb
242
242
  - lib/fog/vsphere/requests/compute/create_group.rb
243
+ - lib/fog/vsphere/requests/compute/create_resource_pool.rb
243
244
  - lib/fog/vsphere/requests/compute/create_rule.rb
244
245
  - lib/fog/vsphere/requests/compute/create_vm.rb
245
246
  - lib/fog/vsphere/requests/compute/current_time.rb
246
247
  - lib/fog/vsphere/requests/compute/destroy_group.rb
248
+ - lib/fog/vsphere/requests/compute/destroy_resource_pool.rb
247
249
  - lib/fog/vsphere/requests/compute/destroy_rule.rb
248
250
  - lib/fog/vsphere/requests/compute/folder_destroy.rb
249
251
  - lib/fog/vsphere/requests/compute/get_cluster.rb
@@ -293,6 +295,7 @@ files:
293
295
  - lib/fog/vsphere/requests/compute/modify_vm_volume.rb
294
296
  - lib/fog/vsphere/requests/compute/revert_to_snapshot.rb
295
297
  - lib/fog/vsphere/requests/compute/set_vm_customvalue.rb
298
+ - lib/fog/vsphere/requests/compute/update_resource_pool.rb
296
299
  - lib/fog/vsphere/requests/compute/update_vm.rb
297
300
  - lib/fog/vsphere/requests/compute/upload_iso.rb
298
301
  - lib/fog/vsphere/requests/compute/vm_acquire_ticket.rb
@@ -335,7 +338,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
335
338
  - !ruby/object:Gem::Version
336
339
  version: '0'
337
340
  requirements: []
338
- rubygems_version: 3.0.6
341
+ rubygems_version: 3.1.4
339
342
  signing_key:
340
343
  specification_version: 4
341
344
  summary: Module for the 'fog' gem to support VMware vSphere.