fog-vsphere 3.2.1 → 3.4.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: cfa29ecec11049b1398d65cb6c1542b14658a3afad14a9f005f19d5a21b2820a
4
- data.tar.gz: 7f356b9fcc49454d530ce22fd244450f0aac04cf2f6ddc1e0072a4c02a684248
3
+ metadata.gz: 1090356cd911b5f4d34de083d7ebd0c26fc10d976155a4896767dbc8c4593001
4
+ data.tar.gz: c52e89e4fb8fbb66654d8555abf1c3d962fa1baf915b8bd5ab45f85a6ae6b789
5
5
  SHA512:
6
- metadata.gz: 6a3dd52da5a8a6a9a2b8cb43ff4dae629efe0e89c6fef8878f6d30278f13901507b4c8c7c03e172dbf597aff7b27335c39ab994dcf3e253dede5ba03e9dbcf48
7
- data.tar.gz: e7543eb6086cb7806e5a574e4c889e7576f325749fd98f65564aa55b7451baea68e37ecd05f7f673b8cc584cd5a6a42aff3e051e79da4d906f30f14398234803
6
+ metadata.gz: 5031553aa6291340875c681f9ec771668bc1465e5b09fca9681713a0bab8feda8c5f08e95c11f99f0ffc7a82c18e76e8f1fba6b7dce923641885ccea0dbc1746
7
+ data.tar.gz: c1207ec44317315c925f77efe93b8c5469677fb0807cf3163654052eb63ea5941320672a20cf4a36f8fd92a91a747153846d9f474cd7c16bad335be4679809bb
@@ -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
@@ -1,3 +1,24 @@
1
+ ## v3.4.0
2
+ * list_resource_pools returns incorrect resource pool name (#256)
3
+ * Add ability to create update and delete Resource Pools (#253)
4
+ * Check datastore for existence prior vm_clone
5
+
6
+ ## v3.3.1
7
+ Fixes eager zero flag (#251, #252)
8
+
9
+ ## v3.3.0
10
+ * Add support for nsx-t (#248)
11
+
12
+ ## v3.2.5
13
+ * Check cluster existance properly (#239)
14
+
15
+ ## ~~v3.2.3~~
16
+ * Check cluster existance (#239)
17
+
18
+ ## v3.2.2
19
+ * Load simple clusters (#237)
20
+ * ISO upload: correctly check if upload directory exists
21
+
1
22
  ## v3.2.1
2
23
 
3
24
  * 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
@@ -276,7 +279,7 @@ module Fog
276
279
  when :datacenter
277
280
  RbVmomi::VIM::Datacenter
278
281
  when :cluster
279
- RbVmomi::VIM::ClusterComputeResource
282
+ RbVmomi::VIM::ComputeResource
280
283
  when :host
281
284
  RbVmomi::VIM::HostSystem
282
285
  else
@@ -0,0 +1,49 @@
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]
10
+ else
11
+ cluster.resourcePool
12
+ end
13
+
14
+ root_resource_pool.CreateResourcePool(
15
+ name: attributes[:name],
16
+ spec: get_resource_pool_spec(attributes)
17
+ )
18
+
19
+ get_resource_pool(attributes[:name], attributes[:cluster], attributes[:datacenter])
20
+ end
21
+
22
+ private
23
+
24
+ def get_resource_pool_spec(attributes = {})
25
+ RbVmomi::VIM.ResourceConfigSpec(
26
+ cpuAllocation: get_resource_pool_allocation_spec(attributes.fetch(:cpu, {})),
27
+ memoryAllocation: get_resource_pool_allocation_spec(attributes.fetch(:memory, {}))
28
+ )
29
+ end
30
+
31
+ def get_resource_pool_allocation_spec(attributes = {})
32
+ RbVmomi::VIM.ResourceAllocationInfo(
33
+ reservation: attributes.fetch(:reservation, 0),
34
+ limit: attributes.fetch(:limit, -1),
35
+ expandableReservation: attributes.fetch(:expandable_reservation, false),
36
+ shares: RbVmomi::VIM.SharesInfo(
37
+ level: RbVmomi::VIM.SharesLevel(attributes.fetch(:shares_level, 'normal')),
38
+ shares: attributes.fetch(:shares, 0)
39
+ )
40
+ )
41
+ end
42
+ end
43
+
44
+ class Mock
45
+ def create_resource_pool(attributes = {}); end
46
+ end
47
+ end
48
+ end
49
+ 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
+ get_resource_pool(attributes[:name], 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,7 +21,7 @@ module Fog
21
21
  datastore = get_raw_datastore(options['datastore'], options['datacenter'])
22
22
  datacenter = get_raw_datacenter(options['datacenter'])
23
23
  filename = options['filename'] || File.basename(options['local_path'])
24
- unless datastore.exists? options['upload_directory'] + '/'
24
+ unless datastore.exists?(options['upload_directory'])
25
25
  connection.serviceContent.fileManager.MakeDirectory name: "[#{options['datastore']}] #{options['upload_directory']}",
26
26
  datacenter: datacenter,
27
27
  createParentDirectories: false
@@ -24,6 +24,9 @@ module Fog
24
24
  raise Fog::Vsphere::Compute::NotFound, "Template #{options['template_path']} Doesn't Exist!" unless get_virtual_machine(options['template_path'], options['datacenter'])
25
25
  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
26
  raise ArgumentError, 'path option is required' unless options.fetch('dest_folder', '/')
27
+ if options.key?('datastore') && !options['datastore'].nil? && !get_raw_datastore(options['datastore'], options['datacenter'])
28
+ raise Fog::Vsphere::Compute::NotFound, "Datastore #{options['datastore']} Doesn't Exist!"
29
+ end
27
30
  if options.key?('storage_pod') && !options['storage_pod'].nil? && !get_raw_storage_pod(options['storage_pod'], options['datacenter'])
28
31
  raise Fog::Vsphere::Compute::NotFound, "Storage Pod #{options['storage_pod']} Doesn't Exist!"
29
32
  end
@@ -800,7 +803,7 @@ module Fog
800
803
  device: template_nic
801
804
  }
802
805
  else
803
- interface = Fog::Vsphere::Compute::Interface.new(raw_to_hash(template_nic))
806
+ interface = Fog::Vsphere::Compute::Interface.new(raw_to_hash(template_nic, datacenter))
804
807
  specs << create_interface(interface, interface.key, :remove, datacenter: datacenter)
805
808
  end
806
809
  end
@@ -838,6 +841,7 @@ module Fog
838
841
  end
839
842
  template_volume.backing.diskMode = new_volume.mode
840
843
  template_volume.backing.thinProvisioned = new_volume.thin
844
+ template_volume.backing.eagerlyScrub = !new_volume.thin && new_volume.eager_zero
841
845
  specs << { operation: :edit, device: template_volume }
842
846
  else
843
847
  specs << { operation: :remove,
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Vsphere
3
- VERSION = '3.2.1'.freeze
3
+ VERSION = '3.4.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.1
4
+ version: 3.4.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: 2019-08-29 00:00:00.000000000 Z
11
+ date: 2020-07-22 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,8 +338,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
335
338
  - !ruby/object:Gem::Version
336
339
  version: '0'
337
340
  requirements: []
338
- rubyforge_project:
339
- rubygems_version: 2.7.6.2
341
+ rubygems_version: 3.1.2
340
342
  signing_key:
341
343
  specification_version: 4
342
344
  summary: Module for the 'fog' gem to support VMware vSphere.