deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dko...@apache.org
Subject [4/8] git commit: CIMI: made id optional in client UI helper method so it can be used for collection operations such as import
Date Mon, 15 Jul 2013 07:00:14 GMT
CIMI: made id optional in client UI helper method
so it can be used for collection operations such as import


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

Branch: refs/heads/master
Commit: 452093b757b350a88dc8678b63b3c4ea7064d7c3
Parents: a8ed21e
Author: Dies Koper <diesk@fast.au.fujitsu.com>
Authored: Mon Jul 15 10:25:50 2013 +1000
Committer: Dies Koper <diesk@fast.au.fujitsu.com>
Committed: Mon Jul 15 11:07:21 2013 +1000

----------------------------------------------------------------------
 clients/cimi/lib/client.rb           | 7 +++++--
 clients/cimi/lib/entities/machine.rb | 6 +++---
 2 files changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/452093b7/clients/cimi/lib/client.rb
----------------------------------------------------------------------
diff --git a/clients/cimi/lib/client.rb b/clients/cimi/lib/client.rb
index e0ba51b..7a9ba60 100644
--- a/clients/cimi/lib/client.rb
+++ b/clients/cimi/lib/client.rb
@@ -57,8 +57,11 @@ module CIMI
         client["%s/%s" % [entity_type, id]].delete(auth_header(credentials))
       end
 
-      def entity_action(entity_type, action, id, body, credentials)
-        client["%s/%s/%s" % [entity_type, id, action.to_s]].post(body, auth_header(credentials).merge(:content_type
=> 'application/xml'))
+      def entity_action(entity_type, action, body, credentials, id=nil)
+        entity_href = get_entity_collection_href(entity_type, credentials)
+        raise RestClient::ResourceNotFound if not entity_href
+        url = id ? '%s/%s/%s' % [entity_href, id, action.to_s] : '%s/%s' % [entity_href,
action.to_s]
+        RestClient::Resource.new(url).post(body, auth_header(credentials).merge(:content_type
=> 'application/xml'))
       end
 
       def provider_header(credentials)

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/452093b7/clients/cimi/lib/entities/machine.rb
----------------------------------------------------------------------
diff --git a/clients/cimi/lib/entities/machine.rb b/clients/cimi/lib/entities/machine.rb
index f193ebd..d124f5f 100644
--- a/clients/cimi/lib/entities/machine.rb
+++ b/clients/cimi/lib/entities/machine.rb
@@ -69,7 +69,7 @@ class CIMI::Frontend::Machine < CIMI::Frontend::Entity
         xml.action "http://schemas.dmtf.org/cimi/1/action/stop"
       }
     end.to_xml
-    entity_action 'machines', 'stop', params[:id], action_xml, credentials
+    entity_action 'machines', 'stop', action_xml, credentials, params[:id]
     flash[:success] = "Machine successfully stopped."
     redirect '/cimi/machines/%s' % params[:id]
   end
@@ -80,7 +80,7 @@ class CIMI::Frontend::Machine < CIMI::Frontend::Entity
         xml.action "http://schemas.dmtf.org/cimi/1/action/start"
       }
     end.to_xml
-    entity_action 'machines', 'start', params[:id], action_xml, credentials
+    entity_action 'machines', 'start', action_xml, credentials, params[:id]
     flash[:success] = "Machine successfully started."
     redirect '/cimi/machines/%s' % params[:id]
   end
@@ -91,7 +91,7 @@ class CIMI::Frontend::Machine < CIMI::Frontend::Entity
         xml.action "http://schemas.dmtf.org/cimi/1/action/restart"
       }
     end.to_xml
-    entity_action 'machines', 'restart', params[:id], action_xml, credentials
+    entity_action 'machines', 'restart', action_xml, credentials, action_xml
     flash[:success] = "Machine successfully restarted."
     redirect '/cimi/machines/%s' % params[:id]
   end


Mime
View raw message