Class: Fog::Compute::RackspaceV2::Image
- Defined in:
- lib/fog/rackspace/models/compute_v2/image.rb
Constant Summary collapse
- UNKNOWN =
'UNKNOWN'
- ACTIVE =
'ACTIVE'
- SAVING =
'SAVING'
- ERROR =
'ERROR'
- DELETED =
'DELETED'
Instance Attribute Summary
Attributes inherited from Model
Instance Method Summary collapse
- #destroy ⇒ Object
-
#initialize(attributes = {}) ⇒ Image
constructor
A new instance of Image.
- #metadata ⇒ Object
- #metadata=(hash = {}) ⇒ Object
- #ready?(ready_state = ACTIVE, error_states = [ERROR]) ⇒ Boolean
Methods inherited from Model
#inspect, #reload, #symbolize_keys, #to_json, #wait_for
Methods included from Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
Methods included from Fog::Core::DeprecatedConnectionAccessors
#connection, #connection=, #prepare_service_value
Methods included from Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one
Constructor Details
#initialize(attributes = {}) ⇒ Image
Returns a new instance of Image.
29 30 31 32 |
# File 'lib/fog/rackspace/models/compute_v2/image.rb', line 29 def initialize(attributes={}) @connection = attributes[:connection] super end |
Instance Method Details
#destroy ⇒ Object
58 59 60 61 |
# File 'lib/fog/rackspace/models/compute_v2/image.rb', line 58 def destroy requires :identity service.delete_image(identity) end |
#metadata ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/fog/rackspace/models/compute_v2/image.rb', line 34 def raise "Please save image before accessing metadata" unless identity @metadata ||= begin Fog::Compute::RackspaceV2::Metadata.new({ :connection => connection, :parent => self }) end end |
#metadata=(hash = {}) ⇒ Object
44 45 46 47 |
# File 'lib/fog/rackspace/models/compute_v2/image.rb', line 44 def (hash={}) raise "Please save image before accessing metadata" unless identity .from_hash(hash) end |
#ready?(ready_state = ACTIVE, error_states = [ERROR]) ⇒ Boolean
49 50 51 52 53 54 55 |
# File 'lib/fog/rackspace/models/compute_v2/image.rb', line 49 def ready?(ready_state = ACTIVE, error_states=[ERROR]) if error_states error_states = Array(error_states) raise "Image should have transitioned to '#{ready_state}' not '#{state}'" if error_states.include?(state) end state == ready_state end |