opennebula 6.2.1 → 6.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cloud/CloudClient.rb +1 -1
- data/lib/host.rb +3 -2
- data/lib/opennebula/flow/service_pool.rb +6 -2
- data/lib/opennebula/flow/service_template.rb +6 -0
- data/lib/opennebula/host.rb +12 -4
- data/lib/opennebula/marketplaceapp_ext.rb +140 -32
- data/lib/opennebula/oneflow_client.rb +12 -1
- data/lib/opennebula.rb +1 -1
- data/lib/scripts_common.rb +5 -0
- data/lib/vcenter_importer.rb +9 -0
- data/lib/vi_helper.rb +11 -1
- data/lib/virtual_machine.rb +15 -8
- data/lib/vm_template.rb +46 -2
- data/lib/vmm_importer.rb +10 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9492453d246b5d413a5902766bda7526160e953c1e6072d242509ebff8df73bc
|
4
|
+
data.tar.gz: eb349b7f7f2a87b29cbbae06ec35db4131db8baf96e5cbf4cf9875f3815e2db3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 546bd3075e73b2e73be4abe53dad5af5d27956dbb896182fd828a2794b510b5df71ea615915b82abbba506ff824f31091fb54afee8d8e67b3b50092714a15ffb
|
7
|
+
data.tar.gz: 6476073b7b334c8e746350760a0de9082770f45df57ee3c9db318b72ee9f1c72c86f8626d892e313c4d92387920e367a063878ac24237b017b66fecb7dc3d7fb
|
data/lib/cloud/CloudClient.rb
CHANGED
data/lib/host.rb
CHANGED
@@ -712,7 +712,7 @@ module VCenterDriver
|
|
712
712
|
|
713
713
|
# Only take care of VMs, not templates
|
714
714
|
if !hashed_properties['config.template']
|
715
|
-
vms[r.obj._ref] = hashed_properties
|
715
|
+
vms[r.obj._ref + '_' + vc_uuid] = hashed_properties
|
716
716
|
vm_objects << r.obj
|
717
717
|
end
|
718
718
|
end
|
@@ -802,7 +802,8 @@ module VCenterDriver
|
|
802
802
|
found_vm =
|
803
803
|
host_vms
|
804
804
|
.select do |vm|
|
805
|
-
vm['DEPLOY_ID']
|
805
|
+
vm['DEPLOY_ID'] == vm_ref ||
|
806
|
+
vm['DEPLOY_ID'] == VIHelper.get_deploy_id(vm_ref)
|
806
807
|
end.first
|
807
808
|
id = found_vm['ID'] if found_vm
|
808
809
|
|
@@ -55,8 +55,12 @@ module OpenNebula
|
|
55
55
|
@one_pool = nil
|
56
56
|
|
57
57
|
if @client
|
58
|
-
|
59
|
-
|
58
|
+
rc = @client.call('user.info', -1)
|
59
|
+
|
60
|
+
unless OpenNebula.is_error?(rc)
|
61
|
+
info = Nokogiri::XML(rc)
|
62
|
+
@user_id = Integer(info.xpath('/USER/ID').text)
|
63
|
+
end
|
60
64
|
end
|
61
65
|
|
62
66
|
super('DOCUMENT_POOL', 'DOCUMENT', @client)
|
@@ -315,6 +315,12 @@ module OpenNebula
|
|
315
315
|
end
|
316
316
|
else
|
317
317
|
IMMUTABLE_ATTRS.each do |attr|
|
318
|
+
# Allows updating the template without
|
319
|
+
# specifying the immutable attributes
|
320
|
+
if template[attr].nil?
|
321
|
+
template[attr] = @body[attr]
|
322
|
+
end
|
323
|
+
|
318
324
|
next if template[attr] == @body[attr]
|
319
325
|
|
320
326
|
return [false, "service_template/#{attr}"]
|
data/lib/opennebula/host.rb
CHANGED
@@ -14,7 +14,6 @@
|
|
14
14
|
# limitations under the License. #
|
15
15
|
#--------------------------------------------------------------------------- #
|
16
16
|
|
17
|
-
|
18
17
|
require 'opennebula/pool_element'
|
19
18
|
require 'base64'
|
20
19
|
require 'yaml'
|
@@ -217,10 +216,12 @@ module OpenNebula
|
|
217
216
|
# Imports a wild VM from the host and puts it in running state
|
218
217
|
#
|
219
218
|
# @param name [String] Name of the VM to import
|
219
|
+
# @param ipv4 [Array] Array with IP4s to set
|
220
|
+
# @param ipv6 [Array] Array with IP6s to set
|
220
221
|
#
|
221
222
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
222
223
|
# otherwise
|
223
|
-
def import_wild(name)
|
224
|
+
def import_wild(name, ipv4 = nil, ipv6 = nil)
|
224
225
|
vms = importable_wilds.select {|vm| vm['VM_NAME'] == name }
|
225
226
|
|
226
227
|
if vms.length == 0
|
@@ -247,8 +248,15 @@ module OpenNebula
|
|
247
248
|
vi_client = VCenterDriver::VIClient.new_from_host(self["ID"])
|
248
249
|
importer = VCenterDriver::VmmImporter.new(@client, vi_client)
|
249
250
|
|
250
|
-
return importer.import(
|
251
|
-
|
251
|
+
return importer.import(
|
252
|
+
{ :wild => wild,
|
253
|
+
:template => template,
|
254
|
+
:one_item => vm,
|
255
|
+
:host => self['ID'],
|
256
|
+
:ipv4 => ipv4,
|
257
|
+
:ipv6 => ipv6
|
258
|
+
}
|
259
|
+
)
|
252
260
|
else
|
253
261
|
rc = vm.allocate(template)
|
254
262
|
|
@@ -185,9 +185,22 @@ module OpenNebula::MarketPlaceAppExt
|
|
185
185
|
#---------------------------------------------------------------
|
186
186
|
# Created an associated VMTemplate if needed
|
187
187
|
#---------------------------------------------------------------
|
188
|
-
if
|
189
|
-
options[:
|
190
|
-
options
|
188
|
+
if is_vcenter &&
|
189
|
+
(!options[:template] || options[:template] == -1)
|
190
|
+
tmpl = create_vcenter_template(ds, options, image)
|
191
|
+
|
192
|
+
if OpenNebula.is_error?(tmpl)
|
193
|
+
rc_info[:vmtemplate] = [tmpl]
|
194
|
+
else
|
195
|
+
rc_info[:vmtemplate] = [tmpl.id]
|
196
|
+
end
|
197
|
+
|
198
|
+
return rc_info
|
199
|
+
end
|
200
|
+
|
201
|
+
if self['TEMPLATE/VMTEMPLATE64'].nil? ||
|
202
|
+
options[:notemplate] ||
|
203
|
+
options[:template] == -1
|
191
204
|
return rc_info
|
192
205
|
end
|
193
206
|
|
@@ -286,33 +299,128 @@ module OpenNebula::MarketPlaceAppExt
|
|
286
299
|
rc
|
287
300
|
end
|
288
301
|
|
289
|
-
|
290
|
-
|
291
|
-
|
302
|
+
# Create a VM template in vCenter in order to use it when
|
303
|
+
# deploying an app from the marketplace
|
304
|
+
#
|
305
|
+
# @param ds [OpenNebula::Datastore] Datastore information
|
306
|
+
# @param options [Hash] Export options
|
307
|
+
# @param image [OpenNebula::Image] Image information
|
308
|
+
def create_vcenter_template(ds, options, image = nil)
|
309
|
+
ret = {}
|
310
|
+
keys = %w[VCENTER_TEMPLATE_REF
|
311
|
+
VCENTER_CCR_REF
|
312
|
+
VCENTER_INSTANCE_ID]
|
313
|
+
|
314
|
+
if ds['//VCENTER_TEMPLATE_REF']
|
315
|
+
keys.each do |key|
|
316
|
+
ret[key] = ds["//#{key}"]
|
317
|
+
end
|
318
|
+
else
|
319
|
+
require 'vcenter_driver'
|
292
320
|
|
293
|
-
|
294
|
-
|
321
|
+
# Get vi client for current datastore
|
322
|
+
vi_client = VCenterDriver::VIClient.new_from_datastore(
|
323
|
+
ds.id
|
324
|
+
)
|
295
325
|
|
296
|
-
|
297
|
-
|
298
|
-
|
326
|
+
# Get datastore object
|
327
|
+
ds_ref = ds['//VCENTER_DS_REF']
|
328
|
+
datastore = VCenterDriver::Datastore.new_from_ref(
|
329
|
+
ds_ref,
|
330
|
+
vi_client
|
331
|
+
)
|
299
332
|
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
333
|
+
# Get resource pool
|
334
|
+
host_ref = datastore['host'].first.key.parent._ref
|
335
|
+
vi_client.ccr_ref = host_ref
|
336
|
+
|
337
|
+
host = VCenterDriver::ClusterComputeResource.new_from_ref(
|
338
|
+
host_ref,
|
339
|
+
vi_client
|
340
|
+
)
|
341
|
+
|
342
|
+
rp = host.resource_pools.first
|
343
|
+
|
344
|
+
# Get vCentrer instance ID
|
345
|
+
uuid = vi_client.vim.serviceContent.about.instanceUuid
|
346
|
+
|
347
|
+
# Create VM folder it not exists
|
348
|
+
dc = datastore.obtain_dc.item
|
349
|
+
vm_folder = dc.find_folder('one_default_template')
|
350
|
+
|
351
|
+
if vm_folder.nil?
|
352
|
+
dc.vmFolder.CreateFolder(
|
353
|
+
:name => 'one_default_template'
|
354
|
+
)
|
355
|
+
vm_folder = dc.find_folder('one_default_template')
|
356
|
+
end
|
357
|
+
|
358
|
+
# Define default VM config
|
359
|
+
vm_cfg = { :name => "one_app_template-#{ds.id}",
|
360
|
+
:guestId => 'otherGuest',
|
361
|
+
:numCPUs => 1,
|
362
|
+
:memoryMB => 128,
|
363
|
+
:files => {
|
364
|
+
:vmPathName => "[#{datastore.item.name}]"
|
365
|
+
} }
|
366
|
+
|
367
|
+
# Create the VM
|
368
|
+
vm = vm_folder.CreateVM_Task(
|
369
|
+
:config => vm_cfg,
|
370
|
+
:pool => rp
|
371
|
+
).wait_for_completion
|
372
|
+
|
373
|
+
# Create the VM template
|
374
|
+
vm.MarkAsTemplate
|
375
|
+
|
376
|
+
ret['VCENTER_TEMPLATE_REF'] = vm._ref
|
377
|
+
ret['VCENTER_CCR_REF'] = host_ref
|
378
|
+
ret['VCENTER_INSTANCE_ID'] = uuid
|
379
|
+
|
380
|
+
ret.each do |key, value|
|
381
|
+
ds.update("#{key}=\"#{value}\"", true)
|
308
382
|
end
|
383
|
+
end
|
384
|
+
|
385
|
+
tmpl = <<-EOT
|
386
|
+
NAME = "#{options[:vmtemplate_name] || options[:name]}"
|
387
|
+
CPU = "1"
|
388
|
+
VCPU = "1"
|
389
|
+
MEMORY = "128"
|
390
|
+
HYPERVISOR = "vcenter"
|
391
|
+
EOT
|
392
|
+
|
393
|
+
tmpl << "DISK = [ IMAGE_ID = \"#{image.id}\" ]" if image
|
394
|
+
|
395
|
+
ret.each do |key, value|
|
396
|
+
tmpl << "#{key}=\"#{value}\"\n"
|
397
|
+
end
|
398
|
+
|
399
|
+
vmtpl = Template.new(Template.build_xml, @client)
|
400
|
+
|
401
|
+
rc = vmtpl.allocate(tmpl)
|
402
|
+
|
403
|
+
if OpenNebula.is_error?(rc)
|
404
|
+
rc
|
309
405
|
else
|
310
|
-
|
311
|
-
' Please use the --template file to define' \
|
312
|
-
' a VM Template ID if needed.'
|
406
|
+
Template.new_with_id(vmtpl.id, @client)
|
313
407
|
end
|
314
408
|
end
|
315
409
|
|
410
|
+
def update_options_with_template(options)
|
411
|
+
path = "#{VAR_LOCATION}/remotes/etc/vmm/vcenter/vcenterrc"
|
412
|
+
|
413
|
+
return options unless File.file?(path)
|
414
|
+
|
415
|
+
config = YAML.load_file(path)
|
416
|
+
|
417
|
+
return options unless config.key?(:default_template)
|
418
|
+
|
419
|
+
options[:template] = config[:default_template]
|
420
|
+
|
421
|
+
options
|
422
|
+
end
|
423
|
+
|
316
424
|
# Creates a VM template based on the APPTEMPLATE64 attribute
|
317
425
|
# @param [Hash] options
|
318
426
|
# :export_name [String] name of the vm template
|
@@ -334,19 +442,19 @@ module OpenNebula::MarketPlaceAppExt
|
|
334
442
|
options = update_options_with_template(options)
|
335
443
|
end
|
336
444
|
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
445
|
+
if !options[:template] || options[:template] == -1
|
446
|
+
vmtpl = create_vcenter_template(ds, options)
|
447
|
+
else
|
448
|
+
template_id = options[:template]
|
449
|
+
template = Template.new_with_id(template_id, @client)
|
342
450
|
|
343
|
-
|
451
|
+
vmtpl_id = template.clone(
|
452
|
+
options[:vmtemplate_name] || options[:name]
|
453
|
+
)
|
344
454
|
|
345
|
-
|
346
|
-
|
347
|
-
)
|
455
|
+
vmtpl = Template.new_with_id(vmtpl_id, @client)
|
456
|
+
end
|
348
457
|
|
349
|
-
vmtpl = Template.new_with_id(vmtpl_id, @client)
|
350
458
|
rc = vmtpl.info
|
351
459
|
else
|
352
460
|
# ----------------------------------------------------------
|
@@ -319,10 +319,21 @@ module Service
|
|
319
319
|
|
320
320
|
class Client
|
321
321
|
def initialize(opts={})
|
322
|
+
endpoint = '/.one/oneflow_endpoint'
|
322
323
|
@username = opts[:username] || ENV['ONEFLOW_USER']
|
323
324
|
@password = opts[:password] || ENV['ONEFLOW_PASSWORD']
|
324
325
|
|
325
|
-
|
326
|
+
if opts[:url]
|
327
|
+
url = opts[:url]
|
328
|
+
elsif ENV['ONEFLOW_URL']
|
329
|
+
url = ENV['ONEFLOW_URL']
|
330
|
+
elsif ENV['HOME'] && File.exists?(ENV['HOME'] + endpoint)
|
331
|
+
url = File.read(ENV['HOME'] + endpoint).strip
|
332
|
+
elsif File.exists?('/var/lib/one/.one/oneflow_endpoint')
|
333
|
+
url = File.read('/var/lib/one/.one/oneflow_endpoint').strip
|
334
|
+
else
|
335
|
+
url = 'http://localhost:2474'
|
336
|
+
end
|
326
337
|
|
327
338
|
if @username.nil? && @password.nil?
|
328
339
|
if ENV["ONE_AUTH"] and !ENV["ONE_AUTH"].empty? and File.file?(ENV["ONE_AUTH"])
|
data/lib/opennebula.rb
CHANGED
data/lib/scripts_common.rb
CHANGED
@@ -28,6 +28,11 @@ module OpenNebula
|
|
28
28
|
log_function("INFO", message)
|
29
29
|
end
|
30
30
|
|
31
|
+
# Logs an info message
|
32
|
+
def self.log_warning(message)
|
33
|
+
log_function('WARNING', message)
|
34
|
+
end
|
35
|
+
|
31
36
|
# Logs an error message
|
32
37
|
def self.log_error(message)
|
33
38
|
log_function("ERROR", message)
|
data/lib/vcenter_importer.rb
CHANGED
@@ -279,6 +279,15 @@ module VCenterDriver
|
|
279
279
|
rs = dc_folder.get_unimported_hosts(hpool,
|
280
280
|
vcenter_instance_name)
|
281
281
|
|
282
|
+
# Select just cluster with this reference
|
283
|
+
if options[:cluster_ref]
|
284
|
+
rs.each do |_, clusters|
|
285
|
+
clusters.select! do |c|
|
286
|
+
c[:cluster_ref] == options[:cluster_ref]
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
282
291
|
STDOUT.print "done!\n\n"
|
283
292
|
|
284
293
|
rs.each do |dc, clusters|
|
data/lib/vi_helper.rb
CHANGED
@@ -118,6 +118,16 @@ module VCenterDriver
|
|
118
118
|
return_if_error(rc, item, exit_if_fail)
|
119
119
|
end
|
120
120
|
|
121
|
+
# Since https://github.com/OpenNebula/one/issues/5689
|
122
|
+
# there two deploy_ids allowed:
|
123
|
+
# * moref, eg: vm-567
|
124
|
+
# * moref +"_" + vcenter uuid, eg:
|
125
|
+
# 2499952a-6c85-480e-b7df-4cbd2137eb69_vm-456
|
126
|
+
# This function will always return the moref
|
127
|
+
def self.get_deploy_id(deploy_id)
|
128
|
+
deploy_id.split('_')[0]
|
129
|
+
end
|
130
|
+
|
121
131
|
def self.find_by_name(the_class, name, pool = nil, raise_if_fail = true)
|
122
132
|
pool = one_pool(the_class, raise_if_fail) if pool.nil?
|
123
133
|
element = pool.find {|e| e['NAME'] == name.to_s }
|
@@ -251,7 +261,7 @@ module VCenterDriver
|
|
251
261
|
# Let's try to find the VM object only by its name
|
252
262
|
# Let's build the VM name
|
253
263
|
vm_prefix = host['TEMPLATE/VM_PREFIX']
|
254
|
-
vm_prefix = VM_PREFIX_DEFAULT if vm_prefix.nil?
|
264
|
+
vm_prefix = VM_PREFIX_DEFAULT if vm_prefix.nil?
|
255
265
|
vm_prefix.gsub!('$i', one_vm['ID'])
|
256
266
|
vm_name = vm_prefix + one_vm['NAME']
|
257
267
|
|
data/lib/virtual_machine.rb
CHANGED
@@ -103,6 +103,7 @@ end
|
|
103
103
|
|
104
104
|
def initialize(vi_client, ref, one_id)
|
105
105
|
if ref
|
106
|
+
ref = VCenterDriver::VIHelper.get_deploy_id(ref)
|
106
107
|
@item = RbVmomi::VIM::VirtualMachine.new(vi_client.vim, ref)
|
107
108
|
check_item(@item, RbVmomi::VIM::VirtualMachine)
|
108
109
|
end
|
@@ -470,7 +471,7 @@ end
|
|
470
471
|
# @return String vcenter name
|
471
472
|
def vc_name
|
472
473
|
vm_prefix = host['TEMPLATE/VM_PREFIX']
|
473
|
-
vm_prefix = VM_PREFIX_DEFAULT if vm_prefix.nil?
|
474
|
+
vm_prefix = VM_PREFIX_DEFAULT if vm_prefix.nil?
|
474
475
|
|
475
476
|
if !one_item['USER_TEMPLATE/VM_PREFIX'].nil?
|
476
477
|
vm_prefix = one_item['USER_TEMPLATE/VM_PREFIX']
|
@@ -1713,8 +1714,13 @@ end
|
|
1713
1714
|
def sync(deploy = {})
|
1714
1715
|
extraconfig = []
|
1715
1716
|
device_change = []
|
1717
|
+
sync_opt = nil
|
1716
1718
|
|
1717
|
-
|
1719
|
+
# Disk are only synced with :all option when VM is first created
|
1720
|
+
# NOTE: Detach actions are implemented through TM (not sync)
|
1721
|
+
sync_opt = :all if deploy[:new] == true
|
1722
|
+
|
1723
|
+
disks = sync_disks(sync_opt, false)
|
1718
1724
|
resize_unmanaged_disks
|
1719
1725
|
|
1720
1726
|
if deploy[:boot] && !deploy[:boot].empty?
|
@@ -2306,6 +2312,7 @@ end
|
|
2306
2312
|
detach_disk_array = []
|
2307
2313
|
extra_config = []
|
2308
2314
|
keys = disk_keys.invert
|
2315
|
+
|
2309
2316
|
ipool = VCenterDriver::VIHelper.one_pool(OpenNebula::ImagePool)
|
2310
2317
|
disks_each(:detached?) do |d|
|
2311
2318
|
key = d.key.to_s
|
@@ -2381,8 +2388,7 @@ end
|
|
2381
2388
|
# @param option [symbol] if :all is provided the
|
2382
2389
|
# method will try to sync
|
2383
2390
|
# all the disks (detached and not existing ones)
|
2384
|
-
#
|
2385
|
-
# the disks that are not existing
|
2391
|
+
# otherwise it will only sync the disks that are not existing
|
2386
2392
|
#
|
2387
2393
|
# @param execute [boolean] indicates if the reconfigure operation
|
2388
2394
|
# is going to
|
@@ -2432,8 +2438,8 @@ end
|
|
2432
2438
|
# https://github.com/OpenNebula/one/issues/5409
|
2433
2439
|
if snapshots? || one_snapshots?
|
2434
2440
|
error_msg = 'Existing sytem snapshots, cannot change disks. '
|
2435
|
-
error_msg << 'Please remove all snapshots and try again
|
2436
|
-
raise
|
2441
|
+
error_msg << 'Please remove all snapshots and try again'
|
2442
|
+
raise error_msg
|
2437
2443
|
end
|
2438
2444
|
|
2439
2445
|
spec_hash = {}
|
@@ -2619,7 +2625,7 @@ end
|
|
2619
2625
|
|
2620
2626
|
if snapshots? || one_snapshots?
|
2621
2627
|
error_message = 'Existing sytem snapshots, cannot change disks'
|
2622
|
-
error_message << '. Please remove all snapshots and try again
|
2628
|
+
error_message << '. Please remove all snapshots and try again'
|
2623
2629
|
raise error_message
|
2624
2630
|
end
|
2625
2631
|
|
@@ -3070,7 +3076,7 @@ end
|
|
3070
3076
|
@item.ReconfigVM_Task(:spec => vm_config_spec).wait_for_completion
|
3071
3077
|
|
3072
3078
|
devices.each do |device|
|
3073
|
-
next unless
|
3079
|
+
next unless first_condition &&
|
3074
3080
|
device.key == scsi_key
|
3075
3081
|
|
3076
3082
|
controller = device.deviceInfo.label
|
@@ -3430,6 +3436,7 @@ end
|
|
3430
3436
|
config[:esx_migration_list] = 'Selected_by_DRS'
|
3431
3437
|
end
|
3432
3438
|
|
3439
|
+
vc_vm.reference_all_disks
|
3433
3440
|
vc_vm.migrate(config)
|
3434
3441
|
|
3435
3442
|
vm.replace({ 'VCENTER_CCR_REF' => ccr_ref })
|
data/lib/vm_template.rb
CHANGED
@@ -623,6 +623,23 @@ module VCenterDriver
|
|
623
623
|
|
624
624
|
network.info
|
625
625
|
|
626
|
+
if nic[:ipv4] || nic[:ipv6]
|
627
|
+
ar_array = network.to_hash['VNET']['AR_POOL']['AR']
|
628
|
+
ar_array = [ar_array] if ar_array.is_a?(Hash)
|
629
|
+
|
630
|
+
ipv4, _ipv6, _arid = find_ip_in_ar(
|
631
|
+
IPAddr.new(nic[:ipv4]),
|
632
|
+
ar_array
|
633
|
+
) if ar_array && nic[:ipv4]
|
634
|
+
|
635
|
+
_ipv4, ipv6, _arid = find_ip_in_ar(
|
636
|
+
IPAddr.new(nic[:ipv6]),
|
637
|
+
ar_array
|
638
|
+
) if ar_array && nic[:ipv6]
|
639
|
+
|
640
|
+
return [ipv4, ipv6]
|
641
|
+
end
|
642
|
+
|
626
643
|
# Iterate over Retrieve vCenter VM NICs
|
627
644
|
unless vm_object.item.guest.net.empty?
|
628
645
|
vm_object.item.guest.net.each do |net|
|
@@ -755,9 +772,10 @@ module VCenterDriver
|
|
755
772
|
nic_tmp = "NIC=[\n"
|
756
773
|
nic_tmp << "NETWORK_ID=\"#{one_vn.id}\",\n"
|
757
774
|
nic_tmp << "NAME =\"VC_NIC#{nic_index}\",\n"
|
775
|
+
nic_tmp << "IP = \"#{nic[:ipv4]}\",\n" if nic[:ipv4]
|
758
776
|
|
759
777
|
if vm?
|
760
|
-
if nic[:mac]
|
778
|
+
if nic[:mac] && !nic[:ipv4]
|
761
779
|
nic_tmp << "MAC=\"#{nic[:mac]}\",\n"
|
762
780
|
end
|
763
781
|
if nic[:ipv4_additionals]
|
@@ -813,6 +831,7 @@ module VCenterDriver
|
|
813
831
|
ar_tmp = create_ar(nic)
|
814
832
|
network_found.add_ar(ar_tmp)
|
815
833
|
end
|
834
|
+
|
816
835
|
ipv4, ipv6 = find_ips_in_network(network_found, vm_object,
|
817
836
|
nic, true)
|
818
837
|
network_found.info
|
@@ -824,8 +843,10 @@ module VCenterDriver
|
|
824
843
|
if nic[:mac] && ipv4.empty? && ipv6.empty?
|
825
844
|
nic_tmp << "MAC=\"#{nic[:mac]}\",\n"
|
826
845
|
end
|
846
|
+
|
827
847
|
nic_tmp << "IP=\"#{ipv4}\"," unless ipv4.empty?
|
828
848
|
nic_tmp << "IP6=\"#{ipv6}\"," unless ipv6.empty?
|
849
|
+
|
829
850
|
if nic[:ipv4_additionals]
|
830
851
|
nic_tmp <<
|
831
852
|
'VCENTER_ADDITIONALS_IP4'\
|
@@ -1053,7 +1074,13 @@ module VCenterDriver
|
|
1053
1074
|
ar_tmp << "]\n"
|
1054
1075
|
|
1055
1076
|
if vm?
|
1056
|
-
ar_tmp << create_ar(nic,
|
1077
|
+
ar_tmp << create_ar(nic, false, nic[:ipv4]) if nic[:ipv4]
|
1078
|
+
|
1079
|
+
if nic[:ipv6]
|
1080
|
+
ar_tmp << create_ar(nic, false, nil, nic[:ipv6])
|
1081
|
+
end
|
1082
|
+
|
1083
|
+
ar_tmp << create_ar(nic, true) if !nic[:ipv4] && !nic[:ipv6]
|
1057
1084
|
end
|
1058
1085
|
|
1059
1086
|
one_vnet[:one] << ar_tmp
|
@@ -1108,6 +1135,23 @@ module VCenterDriver
|
|
1108
1135
|
nic_index = 0
|
1109
1136
|
|
1110
1137
|
vc_nics.each do |nic|
|
1138
|
+
[:ipv4, :ipv6].each do |type|
|
1139
|
+
if nic[type]
|
1140
|
+
opts[type].shift if opts[type]
|
1141
|
+
next
|
1142
|
+
end
|
1143
|
+
|
1144
|
+
begin
|
1145
|
+
ip = opts[type].shift if opts[type]
|
1146
|
+
|
1147
|
+
# Check if it is a valid IP
|
1148
|
+
IPAddr.new(ip)
|
1149
|
+
|
1150
|
+
nic[type] = ip
|
1151
|
+
rescue StandardError
|
1152
|
+
end
|
1153
|
+
end
|
1154
|
+
|
1111
1155
|
# Check if the network already exists
|
1112
1156
|
network_found =
|
1113
1157
|
VCenterDriver::VIHelper
|
data/lib/vmm_importer.rb
CHANGED
@@ -46,7 +46,8 @@ module VCenterDriver
|
|
46
46
|
vm_ref = selected['DEPLOY_ID'] || selected[:wild]['DEPLOY_ID']
|
47
47
|
vm = selected[:one_item] || build
|
48
48
|
template = selected[:template] || import_tmplt
|
49
|
-
|
49
|
+
template = "DEPLOY_ID = #{vm_ref}\n" + template
|
50
|
+
host_id = selected[:host] || @list.keys[0]
|
50
51
|
|
51
52
|
vc_uuid = @vi_client.vim.serviceContent.about.instanceUuid
|
52
53
|
vc_name = @vi_client.vim.host
|
@@ -72,13 +73,15 @@ module VCenterDriver
|
|
72
73
|
template << template_disks
|
73
74
|
|
74
75
|
opts = {
|
75
|
-
:vi_client
|
76
|
-
:vc_uuid
|
77
|
-
:npool
|
78
|
-
:hpool
|
79
|
-
:vcenter
|
76
|
+
:vi_client => @vi_client,
|
77
|
+
:vc_uuid => vc_uuid,
|
78
|
+
:npool => npool,
|
79
|
+
:hpool => hpool,
|
80
|
+
:vcenter => vc_name,
|
80
81
|
:template_moref => vm_ref,
|
81
|
-
:vm_object
|
82
|
+
:vm_object => vc_vm,
|
83
|
+
:ipv4 => selected[:ipv4],
|
84
|
+
:ipv6 => selected[:ipv6]
|
82
85
|
}
|
83
86
|
|
84
87
|
# Create images or get nics information for template
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opennebula
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.2.
|
4
|
+
version: 6.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OpenNebula
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|