deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject git commit: Updates for Opennebula driver - brings compatibility for ON 3.6 Many thanks to Daniel Molina dmolina@opennebula.org
Date Thu, 12 Jul 2012 09:18:21 GMT
Updated Branches:
  refs/heads/master 64ad28040 -> a213b54a1


Updates for Opennebula driver - brings compatibility for ON 3.6
Many thanks to Daniel Molina dmolina@opennebula.org


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

Branch: refs/heads/master
Commit: a213b54a1456fe9fcf98a42fde058f56161b6985
Parents: 64ad280
Author: marios <marios@redhat.com>
Authored: Wed Jul 11 16:47:05 2012 +0300
Committer: marios <marios@redhat.com>
Committed: Wed Jul 11 16:47:05 2012 +0300

----------------------------------------------------------------------
 .../deltacloud/drivers/opennebula/occi_client.rb   |   18 +++++++++----
 .../drivers/opennebula/opennebula_driver.rb        |   20 ++++----------
 2 files changed, 18 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a213b54a/server/lib/deltacloud/drivers/opennebula/occi_client.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/opennebula/occi_client.rb b/server/lib/deltacloud/drivers/opennebula/occi_client.rb
index 8688995..7d71962 100644
--- a/server/lib/deltacloud/drivers/opennebula/occi_client.rb
+++ b/server/lib/deltacloud/drivers/opennebula/occi_client.rb
@@ -83,8 +83,8 @@ module OCCIClient
     ######################################################################
     # Retieves the pool of Virtual Machines
     ######################################################################
-    def get_vms
-      get('/compute')
+    def get_vms(verbose=false)
+      get('/compute', verbose)
     end
 
     ######################################################################
@@ -196,8 +196,8 @@ module OCCIClient
     ######################################################################
     # Retieves the pool of Images owned by the user
     ######################################################################
-    def get_images
-      get('/storage')
+    def get_images(verbose=false)
+      get('/storage', verbose)
     end
 
 
@@ -275,10 +275,16 @@ module OCCIClient
 
     private
 
-    def get(path)
+    def get(path, verbose=false)
       url = URI.parse(@endpoint+path)
+
+      params = []
+      params << "verbose=true" if verbose
+      params << "#{url.query}" if url.query
+
       path = url.path
-      path << "?#{url.query}" if url.query
+      path << "?#{params.join('&')}"
+
       req = Net::HTTP::Get.new(path)
 
       do_request(url, req)

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a213b54a/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb b/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb
index b44482e..85b263a 100644
--- a/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb
+++ b/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb
@@ -84,13 +84,11 @@ class OpennebulaDriver < Deltacloud::BaseDriver
   def images(credentials, opts=nil)
     occi_client = new_client(credentials)
 
-    xml = treat_response(occi_client.get_images)
+    xml = treat_response(occi_client.get_images(true))
 
     # TBD Add extended info in the pool
     images = REXML::Document.new(xml).root.elements.map do |d|
-      im_id = d.attributes['href'].split("/").last
-      storage = treat_response(occi_client.get_image(im_id))
-      convert_image(storage, credentials)
+      convert_image(d, credentials)
     end
   end
 
@@ -156,13 +154,10 @@ class OpennebulaDriver < Deltacloud::BaseDriver
   def instances(credentials, opts=nil)
     occi_client = new_client(credentials)
 
-    xml = treat_response(occi_client.get_vms)
-
+    xml = treat_response(occi_client.get_vms(true))
     # TBD Add extended info in the pool
     instances = REXML::Document.new(xml).root.elements.map do |d|
-      vm_id = d.attributes['href'].split("/").last
-      computexml = treat_response(occi_client.get_vm(vm_id))
-      convert_instance(computexml, credentials)
+      convert_instance(d, credentials)
     end
 
     instances = filter_on( instances, :state, opts )
@@ -221,7 +216,7 @@ class OpennebulaDriver < Deltacloud::BaseDriver
 
 
   def convert_image(diskxml, credentials)
-    storage = REXML::Document.new(diskxml).root.elements
+    storage = REXML::Document.new(diskxml.to_s).root.elements
 
     # TBD Add Image STATE, OWNER
     Image.new( {
@@ -235,10 +230,8 @@ class OpennebulaDriver < Deltacloud::BaseDriver
     } )
   end
 
-
   def convert_instance(computexml, credentials)
-    compute = REXML::Document.new(computexml)
-    computehash = compute.root.elements
+    computehash = REXML::Document.new(computexml.to_s).root.elements
 
     network = []
     computehash.each('NIC/IP') {|ip| network<<InstanceAddress.new(ip.text, :type =>
:ipv4)}
@@ -247,7 +240,6 @@ class OpennebulaDriver < Deltacloud::BaseDriver
     if computehash['DISK/STORAGE']
       image_id = computehash['DISK/STORAGE'].attributes['href'].split("/").last
     end
-
     Instance.new( {
       :id=>computehash['ID'].text,
       :owner_id=>credentials.user,


Mime
View raw message