You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2013/04/03 16:20:04 UTC
[PATCH core 5/5] Client: Added #actions and #create_image for Instance
From: Michal Fojtik <mf...@redhat.com>
Signed-off-by: Michal fojtik <mf...@redhat.com>
---
client/lib/deltacloud/client/models/instance.rb | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
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
--
1.8.1.4