You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2011/07/07 17:19:07 UTC
[PATCH core 1/2] VSphere: Added support for referencing template machine using 'extraConfig' property
From: Michal Fojtik <mf...@redhat.com>
Signed-off-by: Michal fojtik <mf...@redhat.com>
---
.../deltacloud/drivers/vsphere/vsphere_driver.rb | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
index 2d3d279..daf34f1 100644
--- a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
+++ b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
@@ -151,13 +151,16 @@ module Deltacloud::Drivers::VSphere
config = vm.summary.config
next unless config
next unless vm.summary.storage
+ 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],
:storage => vm.summary.storage[:unshared],
:name => config[:name],
- :full_name => config[:guestFullName]
+ :full_name => config[:guestFullName],
}
+ puts properties.inspect
instance_state = convert_state(:instance, vm.summary.runtime[:powerState])
instance_profile = InstanceProfile::new(match_hwp_id(:memory => properties[:memory].to_s, :cpus => properties[:cpus].to_s),
:hwp_cpu => properties[:cpus],
@@ -168,6 +171,7 @@ module Deltacloud::Drivers::VSphere
:id => properties[:name],
:name => properties[:name],
:owner_id => credentials.user,
+ :image_id => template_id,
:description => properties[:full_name],
:realm_id => realm_id,
:state => instance_state,
@@ -206,7 +210,10 @@ module Deltacloud::Drivers::VSphere
:template => false,
:config => RbVmomi::VIM.VirtualMachineConfigSpec(
:memoryMB => instance_profile.memory.value,
- :numCPUs => instance_profile.cpu.value
+ :numCPUs => instance_profile.cpu.value,
+ :extraConfig => [
+ { :key => 'template_id', :value => image_id }
+ ]
)
)
#
--
1.7.4.1