From: Michal Fojtik <[email protected]> * This patch also fix the case when instance was not created using Deltacloud and the template_id was not saved in extraConfig. In that case Deltacloud will not advertise link to original template.
Signed-off-by: Michal fojtik <[email protected]> --- server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb index 98b3468..11d2759 100644 --- a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +++ b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb @@ -162,6 +162,7 @@ module Deltacloud::Drivers::Vsphere # instance. template_id = vm.config[:extraConfig].select { |k| k.key == 'template_id' } template_id = template_id.first.value unless template_id.empty? + properties = { :memory => config[:memorySizeMB], :cpus => config[:numCpu], @@ -177,17 +178,15 @@ module Deltacloud::Drivers::Vsphere # We're getting IP address from 'vmware guest tools'. # If guest tools are not installed, we return list of MAC addresses # assigned to this instance. - public_addresses = [] - if vm.guest[:net].empty? - public_addresses = vm.macs.values.collect { |mac_address| InstanceAddress.new(mac_address, :type => :mac) } - else - public_addresses = [InstanceAddress.new(vm.guest[:net].first[:ipAddress].first)] + public_addresses = vm.macs.values.collect { |mac_address| InstanceAddress.new(mac_address, :type => :mac) } + if !vm.guest[:net].empty? and ip_address = vm.guest[:net].first[:ipAddress].first + public_addresses += [InstanceAddress.new(ip_address)] end Instance.new( :id => properties[:name], :name => properties[:name], :owner_id => credentials.user, - :image_id => template_id, + :image_id => template_id.empty? ? nil : template_id, :description => properties[:full_name], :realm_id => realm_id, :state => instance_state, -- 1.8.0
