clc-chef-metal-vsphere 0.3.1 → 0.3.2

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
  SHA1:
3
- metadata.gz: 626716097bd3a3074cab890277c2bbfc9726b451
4
- data.tar.gz: 405e2fe7989615c898dec0e0a4448fe5b82722a5
3
+ metadata.gz: 30ca8337aad8fb990cd2be047ae531f283da2a5a
4
+ data.tar.gz: e9d7037e74152546784045c3821bd96dd342008f
5
5
  SHA512:
6
- metadata.gz: e92adb82d2585a7541efaef326d9fb08c3652e78393653ce55c3bad915a0768c7366bc2468962d1b180084c82a33a769c0426acd8ed83eb6fc7ec18811b90ee7
7
- data.tar.gz: f502e75e457ebca62d585e971bf3dd69afa1f2c360c2969c9f72e7e7b3c17d85c80b45d993a652ffe9956f8e2968c4abaa99859b6fe2bdf1e4dce81e6dc2fd94
6
+ metadata.gz: dc1fdc88af6f42f22d995b43e6bec397f9b1119fb01c054329b07c18101c1c1f09972a9e6ef14b51aad39da431bb50624de1063e8ecc3e1b591cdd70751ab7f1
7
+ data.tar.gz: 22327524c3ca5b889de9c4bfca907a9479445b384c67d5981a27989a599268223b84eeab3c220dabc1b5ad0326883f232f77611cc375a82dcd23b5e8ab1bf522
@@ -1,3 +1,3 @@
1
1
  module ChefMetalVsphere
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  end
@@ -94,9 +94,14 @@ module ChefMetalVsphere
94
94
 
95
95
  def do_vm_clone(dc_name, vm_template, vm_name, options)
96
96
  datacenter = dc(dc_name)
97
- pool = options[:resource_pool] ? find_pool(datacenter, options[:resource_pool]) : vm_template.resourcePool
98
- rspec = RbVmomi::VIM.VirtualMachineRelocateSpec(pool: pool)
99
- raise ':resource_pool must be specified when cloning from a VM Template' if pool.nil?
97
+ if options.has_key?(:host)
98
+ host = find_host(datacenter, options[:host])
99
+ rspec = RbVmomi::VIM.VirtualMachineRelocateSpec(host: host)
100
+ else
101
+ pool = options[:resource_pool] ? find_pool(datacenter, options[:resource_pool]) : vm_template.resourcePool
102
+ rspec = RbVmomi::VIM.VirtualMachineRelocateSpec(pool: pool)
103
+ raise 'either :host or :resource_pool must be specified when cloning from a VM Template' if pool.nil?
104
+ end
100
105
 
101
106
  unless options[:datastore].to_s.empty?
102
107
  rspec.datastore = find_datastore(datacenter, options[:datastore])
@@ -216,6 +221,29 @@ module ChefMetalVsphere
216
221
  baseEntity.find { |f| f.info.name == datastore_name } or raise "no such datastore #{datastore_name}"
217
222
  end
218
223
 
224
+ def find_host(dc, host_name)
225
+ baseEntity = dc.hostFolder
226
+ entityArray = host_name.split('/')
227
+ entityArray.each do |entityArrItem|
228
+ if entityArrItem != ''
229
+ if baseEntity.is_a? RbVmomi::VIM::Folder
230
+ baseEntity = baseEntity.childEntity.find { |f| f.name == entityArrItem } or nil
231
+ elsif baseEntity.is_a? RbVmomi::VIM::ClusterComputeResource or baseEntity.is_a? RbVmomi::VIM::ComputeResource
232
+ baseEntity = baseEntity.host.find { |f| f.name == entityArrItem } or nil
233
+ elsif baseEntity.is_a? RbVmomi::VIM::HostSystem
234
+ baseEntity = baseEntity.host.find { |f| f.name == entityArrItem } or nil
235
+ else
236
+ baseEntity = nil
237
+ end
238
+ end
239
+ end
240
+
241
+ raise "vSphere Host not found [#{host_name}]" if baseEntity.nil?
242
+
243
+ baseEntity = baseEntity.host if not baseEntity.is_a?(RbVmomi::VIM::HostSystem) and baseEntity.respond_to?(:host)
244
+ baseEntity
245
+ end
246
+
219
247
  def find_pool(dc, pool_name)
220
248
  baseEntity = dc.hostFolder
221
249
  entityArray = pool_name.split('/')
@@ -1,7 +1,7 @@
1
1
  {
2
2
  :driver_options => {
3
- :host => '172.21.10.10',
4
- :user => 'vmapi',
3
+ :host => '172.22.10.11',
4
+ :user => 'qa4t3nvc01\\vmapi',
5
5
  :password => 'Pass@word1',
6
6
  :insecure => true
7
7
  },
@@ -9,14 +9,14 @@
9
9
  :start_timeout => 600,
10
10
  :create_timeout => 600,
11
11
  :bootstrap_options => {
12
- :datacenter => 'QA1',
12
+ :datacenter => 'QA3HPC',
13
13
  :template_name => 'UBUNTU-12-64-TEMPLATE',
14
14
  :vm_folder => 'DLAB',
15
- :datastore => 'QA1-2-SFIRE-01',
15
+ :datastore => 'QA3-VMTEMPLATES-HPC-A01',
16
16
  :num_cpus => 2,
17
- :network_name => 'vlan_20_172.21.20',
17
+ :network_name => 'vlan_388_172.22.188',
18
18
  :memory_mb => 4096,
19
- :resource_pool => 'CLSTR02/DLAB',
19
+ :host => 'QA3HPCCL01/qa4t3nesx02.t3n.dom',
20
20
  :additional_disk_size_gb => 50,
21
21
  :ssh => {
22
22
  :user => 'root',
@@ -27,9 +27,9 @@
27
27
  :convergence_options => {},
28
28
  :customization_spec => {
29
29
  :ipsettings => {
30
- :ip => "172.21.20.197",
30
+ :ip => "172.22.188.197",
31
31
  :subnetMask => '255.255.255.0',
32
- :gateway => ["172.21.20.1"],
32
+ :gateway => ["172.22.188.1"],
33
33
  :dnsServerList => ["172.17.1.26","172.17.1.27"]
34
34
  },
35
35
  :domain => 'local'
@@ -80,10 +80,19 @@ describe "vsphere_driver" do
80
80
  expect(@vm.datastore[0].name).to eq(@metal_config[:machine_options][:bootstrap_options][:datastore])
81
81
  end
82
82
  it "is in the correct resource pool" do
83
- expect(@vm.resourcePool.name).to eq(@metal_config[:machine_options][:bootstrap_options][:resource_pool].split('/')[1])
83
+ if @metal_config[:machine_options][:bootstrap_options].has_key?(:resource_pool)
84
+ expect(@vm.resourcePool.name).to eq(@metal_config[:machine_options][:bootstrap_options][:resource_pool].split('/')[1])
85
+ end
86
+ end
87
+ it "is in the correct host" do
88
+ if @metal_config[:machine_options][:bootstrap_options].has_key?(:host)
89
+ expect(@vm.runtime.host.name).to eq(@metal_config[:machine_options][:bootstrap_options][:host].split('/')[1])
90
+ end
84
91
  end
85
92
  it "is in the correct cluster" do
86
- expect(@vm.resourcePool.owner.name).to eq(@metal_config[:machine_options][:bootstrap_options][:resource_pool].split('/')[0])
93
+ if @metal_config[:machine_options][:bootstrap_options].has_key?(:resource_pool)
94
+ expect(@vm.resourcePool.owner.name).to eq(@metal_config[:machine_options][:bootstrap_options][:resource_pool].split('/')[0])
95
+ end
87
96
  end
88
97
  it "is in the correct datacenter" do
89
98
  expect(@connection.serviceInstance.find_datacenter(@metal_config[:machine_options][:bootstrap_options][:datacenter]).find_vm("#{@vm.parent.name}/#{@vm_name}")).not_to eq(nil)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clc-chef-metal-vsphere
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - CenturyLink Cloud