deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [2/6] git commit: Client: Added #actions and #create_image for Instance
Date Thu, 04 Apr 2013 06:54:32 GMT
Client: Added #actions and #create_image for Instance


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

Branch: refs/heads/master
Commit: 3b6bf56201cefb30e4650a8b0b9ee23e94721e21
Parents: 42fad4f
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Wed Apr 3 16:15:33 2013 +0200
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Thu Apr 4 08:54:12 2013 +0200

----------------------------------------------------------------------
 client/lib/deltacloud/client/models/instance.rb |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3b6bf562/client/lib/deltacloud/client/models/instance.rb
----------------------------------------------------------------------
diff --git a/client/lib/deltacloud/client/models/instance.rb b/client/lib/deltacloud/client/models/instance.rb
index 01e1882..77d3498 100644
--- a/client/lib/deltacloud/client/models/instance.rb
+++ b/client/lib/deltacloud/client/models/instance.rb
@@ -26,6 +26,7 @@ module Deltacloud::Client
     attr_reader :owner_id
     attr_reader :image_id
     attr_reader :hardware_profile_id
+    attr_reader :actions
 
     attr_accessor :state
     attr_accessor :public_addresses
@@ -74,6 +75,15 @@ module Deltacloud::Client
       super
     end
 
+    def can_create_image?
+      actions.include? :create_image
+    end
+
+    def create_image(create_opts={})
+      return false unless can_create_image?
+      super(_id, create_opts)
+    end
+
     # Helper for is_STATE?
     #
     # is_running?
@@ -100,7 +110,8 @@ module Deltacloud::Client
           ),
           :private_addresses => InstanceAddress.convert(
             xml_body.xpath('private_addresses/address')
-          )
+          ),
+          :actions => xml_body.xpath('actions/link').map { |a| a['rel'].to_sym }
         }
       end
 


Mime
View raw message