Hey,

This patch supports the User-Level API in oVirt.
Note that I wrote some issues below. I opened tickets on them, and I think most 
were fixed, so just have a look at the patch when you can.

Thank you, and happy new year everyone!
Oved

----- Forwarded Message -----
From: "Oved Ourfalli" <[email protected]>
To: "[email protected]" <[email protected]>, "Michal Fojtik" 
<[email protected]>
Sent: Monday, December 10, 2012 10:55:09 AM
Subject: Patch to support User-Level API

Hey,

I've attached a patch that uses the API_PROVIDER to configure whether we work 
in Admin or User-level API.
Marios - I know you didn't like that approach so much, but as Michal mentioned 
in the meeting we had, it will allow setting it also using the HTTP header 
X-Deltacloud-Provider.

Also, in order for it to work we need a new rbovirt version (and also add a 
dependency on it to this patch).

Is that okay with you?
Michal - if so, can you release rbovirt with the latest changes?

I tested EC2 and CIMI (using examples from my blog :-) ) and only some basic 
deltacloud API tests (as I'm less familiar with it).

I saw the following issues:
1. CIMI - create VM is broken to user-level API - need to getCluster by ID and 
we don't support that.
The result is failing to create VM without specifying target cluster. There is 
no way to tell CIMI which cluster you want your VM on... it works well on EC2.

Bug: https://bugzilla.redhat.com/show_bug.cgi?id=876460
Patch by Ravi: http://gerrit.ovirt.org/#/c/9248/5
Maybe we should consider fixing this bug also on z-stream?

2. Delete VM in CIMI failed (but it also failed for admin, and doesn't seem 
related to the ovirt driver).

Trace:

ERROR -- 500: [NoMethodError] undefined method `destroy' for nil:NilClass

/autohome/oourfali/git/deltacloud/server/pkg/deltacloud-core-1.0.5/lib/db.rb:51:in
 `delete_attributes_for'
/autohome/oourfali/git/deltacloud/server/pkg/deltacloud-core-1.0.5/lib/cimi/models/machine.rb:114:in
 `delete!'
/autohome/oourfali/git/deltacloud/server/pkg/deltacloud-core-1.0.5/lib/cimi/collections/machines.rb:66:in
 `block (3 levels) in <class:Machines>'
/autohome/oourfali/.gem/ruby/1.9.1/gems/sinatra-rabbit-1.1.3/lib/sinatra/rabbit/base.rb:396:in
 `instance_eval'
/autohome/oourfali/.gem/ruby/1.9.1/gems/sinatra-rabbit-1.1.3/lib/sinatra/rabbit/base.rb:396:in
 `block in control'
/usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:1265:in `call'
/usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:1265:in `block in 
compile!'
/usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in `[]'
/usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in `block (3 
levels) in route!'
/usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:851:in `route_eval'
/usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in `block (2 
levels) in route!'
/usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:872:in `block in 
process_route'
/usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:870:in `catch'
/usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:870:in 
`process_route'
/usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:834:in `block in 
route!'
/usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:833:in `each'
/usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:833:in `route!'
/usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:936:in `dispatch!'
/usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:769:in `block in 
call!'
/usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:in `block in 
invoke'
/usr/local/share/gems/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:in `catch'

127.0.0.1 - - [09/Dec/2012 15:09:08] "DELETE 
/cimi/machines/ec7fbdba-83d7-4835-b304-0fc1aa90b71a HTTP/1.1" 500 1459 0.0278

Are you aware of this issue?

Thank you,
Oved
From 88a8743373fd4155eb71eaf83594ab570d6dd2e6 Mon Sep 17 00:00:00 2001
From: Oved Ourfali <[email protected]>
Date: Mon, 10 Dec 2012 10:44:57 +0200
Subject: [PATCH] ovirt driver: support user-level API

This patch contains the necessary changes to support the oVirt engine
user-level API.

The current way of configuring that is to use the API_PROVIDER
environment variable:
1. API_PROVIDER="http://server:port/api;;USER"; - User API (no DC-id)
2. API_PROVIDER="http://server:port/api"; - no DC-id, Admin API
3. API_PROVIDER="http://server:port/api;dc-id;USER"; - User API (dc-id is
ignored by rbovirt)
4. API_PROVIDER="http://server:port/api;dc-id"; - Admin API working in a specific
DC scope
---
 server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
index 37e6622..a765a7b 100644
--- a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
+++ b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
@@ -208,8 +208,13 @@ class RhevmDriver < Deltacloud::BaseDriver
   def new_client(credentials)
     safely do
       raise 'No API provider set for this request.' unless api_provider
-      url, datacenter = api_provider.split(';')
-      OVIRT::Client.new(credentials.user, credentials.password, url, datacenter)
+      url, datacenter, filtered = api_provider.split(';')
+      if filtered.nil?
+        OVIRT::Client.new(credentials.user, credentials.password, url, datacenter)
+      else
+        filtered_api = filtered.upcase == 'USER'
+        OVIRT::Client.new(credentials.user, credentials.password, url, datacenter, nil, filtered_api)
+      end
     end
   end
 
-- 
1.7.11.2

Reply via email to