incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject svn commit: r1084629 - /incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
Date Wed, 23 Mar 2011 16:24:16 GMT
Author: mfojtik
Date: Wed Mar 23 16:24:16 2011
New Revision: 1084629

URL: http://svn.apache.org/viewvc?rev=1084629&view=rev
Log:
Added missing valid_credentials? method to RHEV-M driver

Modified:
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb?rev=1084629&r1=1084628&r2=1084629&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb Wed Mar
23 16:24:16 2011
@@ -182,12 +182,9 @@ class RHEVMDriver < Deltacloud::BaseDriv
       vm_template = "<template id='#{image_id}'/>"
       vm_cluster = opts[:realm_id] ? "<cluster id='#{opts[:realm_id]}'/>" : "<cluster
id='0'/>"
       vm_type = opts[:hwp_id] ? "<type>#{opts[:hwp_id]}</type>" : "<type>DESKTOP</type>"
-      vm_memory = opts[:hwp_memory] ? "<memory>#{opts[:hwp_memory].to_i*1024*1024}</memory>"
 : ''
-      vm_cpus = opts[:hwp_cpu] ? "<cpu><topology cores='#{opts[:hwp_cpu]}' sockets='1'/></cpu>"
 : ''
-      puts vm_cpus.inspect
-      # TODO: Add storage here (it isn't supported by RHEV-M API so far)
-      convert_instance(client, ::RHEVM::Vm::new(client, client.create_vm(
-        "<vm>"+
+      vm_memory = opts[:hwp_memory] ? "<memory>#{opts[:hwp_memory].to_i*1024*1024}</memory>"
 : "<memory>#{512*1024*1024}</memory>"
+      vm_cpus = opts[:hwp_cpu] ? "<cpu><topology cores='#{opts[:hwp_cpu]}' sockets='1'/></cpu>"
 : "<cpu><topology cores='1' sockets='1'/></cpu>"
+      post_body = "<vm>"+
         vm_name +
         vm_template +
         vm_cluster +
@@ -195,10 +192,20 @@ class RHEVMDriver < Deltacloud::BaseDriv
         vm_memory +
         vm_cpus +
         "</vm>"
-      ).xpath('vm')))
+      convert_instance(client, ::RHEVM::Vm::new(client, client.create_vm(post_body).xpath('vm')))
     end
   end
 
+  def valid_credentials?(credentials)
+    retval = true
+    begin
+      realms(credentials)
+    rescue Deltacloud::BackendError
+     retval = false
+    end
+    retval
+  end
+
   private
 
   def new_client(credentials)



Mime
View raw message