incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject svn commit: r1089029 - in /incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm: rhevm_client.rb rhevm_driver.rb
Date Tue, 05 Apr 2011 13:20:32 GMT
Author: mfojtik
Date: Tue Apr  5 13:20:31 2011
New Revision: 1089029

URL: http://svn.apache.org/viewvc?rev=1089029&view=rev
Log:
Fixed XML for create_instance in RHEV-M driver

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

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb?rev=1089029&r1=1089028&r2=1089029&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/rhevm/rhevm_client.rb Tue Apr
 5 13:20:31 2011
@@ -91,7 +91,7 @@ module RHEVM
     end
 
     def create_vm(opts="")
-      Nokogiri::XML(post("#{@base_uri}/vms", opts))
+      (Nokogiri::XML(post("#{@base_uri}/vms", opts))/'vm').first
     end
 
     def delete_vm(id)
@@ -114,7 +114,6 @@ module RHEVM
       if ENV['RACK_ENV'] == 'test'
         response = mock_request(:get, uri, {}, headers)
       else
-        puts "[RHEV-M] #{uri}"
         begin
           response = RestClient.get(uri, headers).to_s
         rescue Exception => e
@@ -155,7 +154,6 @@ module RHEVM
     def read_fake_url(filename)
       fixture_file = "../tests/rhevm/support/fixtures/#{filename}"
       if File.exists?(fixture_file)
-        puts "Using fixture: #{fixture_file}"
         return JSON::parse(File.read(fixture_file))
       else
         raise FixtureNotFound.new
@@ -183,7 +181,6 @@ module RHEVM
         }
         fixtures_dir = "../tests/rhevm/support/fixtures/"
         FileUtils.mkdir_p(fixtures_dir)
-        puts "Saving fixture #{fixture_filename}"
         File.open(File::join(fixtures_dir, fixture_filename), 'w') do |f|
           f.puts [request_uri, http_method, response].to_json
         end and retry
@@ -257,8 +254,6 @@ module RHEVM
       self
     end
 
-    private
-
     def get_nics(client, xml)
       nics = []
       doc = Nokogiri::XML(client.get(client.host + (xml/'link[@rel="nics"]').first[:href]))
@@ -343,3 +338,5 @@ class String
   end
 
 end
+
+require "lib/deltacloud/drivers/rhevm/rhevm_ip_helper"

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=1089029&r1=1089028&r2=1089029&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 Tue Apr
 5 13:20:31 2011
@@ -178,13 +178,19 @@ class RHEVMDriver < Deltacloud::BaseDriv
     client = new_client(credentials)
     safely do
       # TODO: Add setting CPU topology here
-      vm_name = opts[:name] ? "<name>#{opts[:name]}</name>" : ""
+      # FIXME: Condor is using GlobalJobId here as a name, which is malformed
+      #        and contains >50 characters
+      #
+      # FIXME: Memory calculation is wrong in Conductor, they are sending
+      #        value/1024. Original line is here.
+      vm_name = opts[:name] ? "<name>#{opts[:name].split("#").last}</name>" :
"<name>#{Time.now.to_i}</name>"
       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>"
 : "<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_type = opts[:hwp_id] ? "<type>#{opts[:hwp_id].upcase}</type>" : "<type>DESKTOP</type>"
+      #vm_memory = opts[:hwp_memory] ? "<memory>#{opts[:hwp_memory].to_i*1024*1024}</memory>"
 : ''
+      vm_memory = opts[:hwp_memory] ? "<memory>#{opts[:hwp_memory].to_i*1024}</memory>"
 : '' # Conductor workaround
+      vm_cpus = opts[:hwp_cpu] ? "<cpu><topology cores='#{opts[:hwp_cpu]}' sockets='1'/></cpu>"
 : ''
+      xml = "<vm>"+
         vm_name +
         vm_template +
         vm_cluster +
@@ -192,7 +198,8 @@ class RHEVMDriver < Deltacloud::BaseDriv
         vm_memory +
         vm_cpus +
         "</vm>"
-      convert_instance(client, ::RHEVM::Vm::new(client, client.create_vm(post_body).xpath('vm')))
+      # TODO: Add storage here (it isn't supported by RHEV-M API so far)
+      convert_instance(client, ::RHEVM::Vm::new(client, client.create_vm(xml)))
     end
   end
 
@@ -210,9 +217,9 @@ class RHEVMDriver < Deltacloud::BaseDriv
 
   def new_client(credentials)
     url = (Thread.current[:provider] || ENV['API_PROVIDER'] || provider_uri)
-    safely do
+    #safely do
       ::RHEVM::Client.new(credentials.user, credentials.password, url)
-    end
+    #end
   end
 
   def convert_instance(client, inst)
@@ -311,7 +318,7 @@ class RHEVMDriver < Deltacloud::BaseDriv
   def catched_exceptions_list
     {
       :auth => RestClient::Unauthorized,
-      :error => RestClient::InternalServerError,
+      :error => RestClient::InternalServerError
       :glob => [ /(RestClient|RHEVM)::(\w+)/ ]
     }
   end



Mime
View raw message