fog-vsphere 3.4.0 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1090356cd911b5f4d34de083d7ebd0c26fc10d976155a4896767dbc8c4593001
4
- data.tar.gz: c52e89e4fb8fbb66654d8555abf1c3d962fa1baf915b8bd5ab45f85a6ae6b789
3
+ metadata.gz: 18ada3fe97234aa0bf59aaab14ea04ba2ceaa40cb62abc6189026b6214d85759
4
+ data.tar.gz: 7894e6c462e8501eb2c9a16170300d75516ba8e4431a64be14d5cc6140271fbe
5
5
  SHA512:
6
- metadata.gz: 5031553aa6291340875c681f9ec771668bc1465e5b09fca9681713a0bab8feda8c5f08e95c11f99f0ffc7a82c18e76e8f1fba6b7dce923641885ccea0dbc1746
7
- data.tar.gz: c1207ec44317315c925f77efe93b8c5469677fb0807cf3163654052eb63ea5941320672a20cf4a36f8fd92a91a747153846d9f474cd7c16bad335be4679809bb
6
+ metadata.gz: 8db1f07c4c800261506a22d0be60cc2c777a2da9e6001cee6a39a22218719af8eb4f105071383732c40f20201818645954a388420f7291bd0d3fecee0adc1a91
7
+ data.tar.gz: ba9313ddc1af94248d965ae9cda4734766cf36c494f33f5f84fc40581be22532ff96700539f63dce3583d955a60e86b75e367795bd3c0ca29291fa921717d1db
@@ -21,7 +21,3 @@ script: bundle exec rake travis:ci
21
21
  notifications:
22
22
  email:
23
23
  - chrobert@redhat.com
24
- addons:
25
- code_climate:
26
- repo_token: 44bcd04b60228fc94f2be3a5e0346441b5ea156e94e89a17fc24c5d3de483721
27
-
@@ -1,3 +1,9 @@
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
+
1
7
  ## v3.4.0
2
8
  * list_resource_pools returns incorrect resource pool name (#256)
3
9
  * Add ability to create update and delete Resource Pools (#253)
@@ -168,7 +168,8 @@ module Fog
168
168
  memoryHotAddEnabled: 'config.memoryHotAddEnabled',
169
169
  firmware: 'config.firmware',
170
170
  boot_order: 'config.bootOptions.bootOrder',
171
- annotation: 'config.annotation'
171
+ annotation: 'config.annotation',
172
+ extra_config: 'config.extraConfig'
172
173
  }.freeze
173
174
 
174
175
  def convert_vm_view_to_attr_hash(vms)
@@ -250,6 +251,8 @@ module Fog
250
251
  nil
251
252
  end
252
253
  }
254
+
255
+ attrs['extra_config'] = parse_extra_config(attrs['extra_config'])
253
256
  end
254
257
  # This inline rescue catches any standard error. While a VM is
255
258
  # cloning, a call to the macs method will throw and NoMethodError
@@ -308,6 +311,12 @@ module Fog
308
311
  end.compact.uniq
309
312
  end
310
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
+
311
320
  # returns vmware managed obj id string
312
321
  def managed_obj_id(obj)
313
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
@@ -6,17 +6,19 @@ module Fog
6
6
  cluster = get_raw_cluster(attributes[:cluster], attributes[:datacenter])
7
7
 
8
8
  root_resource_pool = if attributes[:root_resource_pool_name]
9
- cluster.resourcePool.find attributes[:root_resource_pool_name]
9
+ cluster.resourcePool.find attributes[:root_resource_pool_name].gsub('/', '%2f')
10
10
  else
11
11
  cluster.resourcePool
12
12
  end
13
13
 
14
- root_resource_pool.CreateResourcePool(
14
+ raise ArgumentError, 'Root resource pool could not be found' if root_resource_pool.nil?
15
+
16
+ resource_pool = root_resource_pool.CreateResourcePool(
15
17
  name: attributes[:name],
16
18
  spec: get_resource_pool_spec(attributes)
17
19
  )
18
20
 
19
- get_resource_pool(attributes[:name], attributes[:cluster], attributes[:datacenter])
21
+ resource_pool_attributes(resource_pool, attributes[:cluster], attributes[:datacenter])
20
22
  end
21
23
 
22
24
  private
@@ -10,7 +10,7 @@ module Fog
10
10
  config: get_resource_pool_spec(attributes)
11
11
  )
12
12
 
13
- get_resource_pool(attributes[:name], attributes[:cluster], attributes[:datacenter])
13
+ resource_pool_attributes(raw_resource_pool, attributes[:cluster], attributes[:datacenter])
14
14
  end
15
15
 
16
16
  private
@@ -21,7 +21,10 @@ 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', '/')
27
30
  if options.key?('datastore') && !options['datastore'].nil? && !get_raw_datastore(options['datastore'], options['datacenter'])
@@ -50,6 +53,9 @@ module Fog
50
53
  # want to clone FROM. Relative to Datacenter (Example:
51
54
  # "FolderNameHere/VMNameHere")
52
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.
53
59
  # * 'dest_folder'<~String> - Destination Folder of where 'name' will
54
60
  # be placed on your cluster. Relative Path to Datacenter E.G.
55
61
  # "FolderPlaceHere/anotherSub Folder/onemore"
@@ -104,14 +110,11 @@ module Fog
104
110
  # Option handling
105
111
  options = vm_clone_check_options(options)
106
112
 
107
- # Added for people still using options['path']
108
- template_path = options['path'] || options['template_path']
109
-
110
113
  # Options['template_path']<~String>
111
114
  # Added for people still using options['path']
112
115
  template_path = options['path'] || options['template_path']
113
116
  # Now find the template itself using the efficient find method
114
- vm_mob_ref = get_vm_ref(template_path, options['datacenter'])
117
+ vm_mob_ref = get_vm_ref(template_path, options['template_datacenter'] || options['datacenter'])
115
118
 
116
119
  # Options['dest_folder']<~String>
117
120
  # Grab the destination folder object if it exists else use cloned mach
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Vsphere
3
- VERSION = '3.4.0'.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.4.0
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-07-22 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
@@ -338,7 +338,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
338
338
  - !ruby/object:Gem::Version
339
339
  version: '0'
340
340
  requirements: []
341
- rubygems_version: 3.1.2
341
+ rubygems_version: 3.1.4
342
342
  signing_key:
343
343
  specification_version: 4
344
344
  summary: Module for the 'fog' gem to support VMware vSphere.