deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [2/3] git commit: VSphere: Report MAC addresses together with ipv4 addresses (DTACLOUD-376)
Date Wed, 21 Nov 2012 13:25:25 GMT
VSphere: Report MAC addresses together with ipv4 addresses (DTACLOUD-376)

* 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.


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/e4d189d4
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/e4d189d4
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/e4d189d4

Branch: refs/heads/master
Commit: e4d189d4f593100489d0353cef98a7bc9e86247b
Parents: d8c9a44
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Wed Nov 21 12:09:13 2012 +0100
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Wed Nov 21 14:24:59 2012 +0100

----------------------------------------------------------------------
 .../deltacloud/drivers/vsphere/vsphere_driver.rb   |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/e4d189d4/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
----------------------------------------------------------------------
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,


Mime
View raw message