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 2013/01/02 15:11:13 UTC

[PATCH core 1/4] VSphere: Make API_PROVIDER format consistent with other drivers (DTACLOUD-399)

From: Michal Fojtik <mf...@redhat.com>


Signed-off-by: Michal fojtik <mf...@redhat.com>
---
 server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
index 11d2759..4f9df5f 100644
--- a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
+++ b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
@@ -409,7 +409,14 @@ module Deltacloud::Drivers::Vsphere
     end
 
     def host_endpoint
-      endpoint = api_provider
+      endpoint = "#{api_provider}"
+      # We need to have the 'hostname' form in API_PROVIDER, but to be
+      # compatible with other drivers, we allow 'https://vsphere/api' format.
+      # The 'http' and '/.*' parts are however stripped.
+      if endpoint =~ /^http/
+        endpoint.gsub!(/^http(s?):\/\//, '')
+        endpoint.gsub!(/\/.*$/, '')
+      end
       endpoint || Deltacloud::Drivers::driver_config[:vsphere][:entrypoints]['default']['default']
     end
 
-- 
1.8.0.2


[PATCH core 3/4] VSphere: Make the 'name' parameter optional

Posted by mf...@redhat.com.
From: Michal Fojtik <mf...@redhat.com>

In case 'name' is not sent, use the default "inst#{Time.now.to_i}"
name.

Signed-off-by: Michal fojtik <mf...@redhat.com>
---
 server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
index 5bc7088..2ddd43a 100644
--- a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
+++ b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
@@ -290,7 +290,7 @@ module Deltacloud::Drivers::Vsphere
           :config => RbVmomi::VIM.VirtualMachineConfigSpec(machine_config)
         )
         instance_profile = InstanceProfile::new('default', :hwp_memory => opts[:hwp_memory], :hwp_cpu => opts[:hwp_cpu])
-        task = vm[:instance].CloneVM_Task(:folder => vm[:instance].parent, :name => opts[:name], :spec => spec)
+        task = vm[:instance].CloneVM_Task(:folder => vm[:instance].parent, :name => opts[:name] || "inst#{Time.now.to_i}", :spec => spec)
         new_instance = Instance::new(
           :id => opts[:name],
           :name => opts[:name],
-- 
1.8.0.2


[PATCH core 4/4] Vsphere: Fixed typo in create_instance method (DTACLOUD-401)

Posted by mf...@redhat.com.
From: Michal Fojtik <mf...@redhat.com>

In case the driver method is called from CIMI, the opts[:image_id]
is empty. Lets use the 'image_id' here anyway.

Signed-off-by: Michal fojtik <mf...@redhat.com>
---
 server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
index 2ddd43a..272f471 100644
--- a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
+++ b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
@@ -214,7 +214,7 @@ module Deltacloud::Drivers::Vsphere
         if opts[:hwp_cpu]
           raise "Invalid CPU value. Must be in integer format" unless valid_cpu_value?(opts[:hwp_cpu])
         end
-        vm = find_vm(credentials, opts[:image_id])
+        vm = find_vm(credentials, image_id)
         raise "ERROR: Could not find the image in given datacenter" unless vm[:instance]
         # New instance need valid resource pool and datastore to be placed.
         # For this reason, realm_id **needs** to be set.
-- 
1.8.0.2


[PATCH core 2/4] Vsphere: Return 400 in case that required parameter is missing

Posted by mf...@redhat.com.
From: Michal Fojtik <mf...@redhat.com>

I discover this by creating an instance without name. The error
was reported as 500 (Backend error), but it should be 400 (Bad request).

Signed-off-by: Michal fojtik <mf...@redhat.com>
---
 server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
index 4f9df5f..5bc7088 100644
--- a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
+++ b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
@@ -380,6 +380,10 @@ module Deltacloud::Drivers::Vsphere
         status 504
       end
 
+      on /missing required parameter name/ do
+        status 400
+      end
+
       on /Invalid/ do
         status 400
       end
-- 
1.8.0.2