Class: Fog::Compute::RackspaceV2::Image

Inherits:
Model
  • Object
show all
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 collapse

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

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.



66
67
68
69
# File 'lib/fog/rackspace/models/compute_v2/image.rb', line 66

def initialize(attributes={})
  @service = attributes[:service]
  super
end

Instance Attribute Details

#createdString (readonly)

Returns The time stamp for the creation date.

Returns:

  • (String)

    The time stamp for the creation date.



23
# File 'lib/fog/rackspace/models/compute_v2/image.rb', line 23

attribute :created

#disk_configString<AUTO, MANUAL>

The disk configuration value.

* AUTO -   The server is built with a single partition the size of the target flavor disk. The file system is automatically adjusted to fit the entire partition. 
           This keeps things simple and automated. AUTO is valid only for images and servers with a single partition that use the EXT3 file system. 
           This is the default setting for applicable Rackspace base images.

* MANUAL - The server is built using whatever partition scheme and file system is in the source image. If the target flavor disk is larger, 
           the remaining disk space is left unpartitioned. This enables images to have non-EXT3 file systems, multiple partitions, 
           and so on, and enables you to manage the disk configuration.

Returns:

  • (String<AUTO, MANUAL>)

    The disk configuration value.

See Also:



60
# File 'lib/fog/rackspace/models/compute_v2/image.rb', line 60

attribute :disk_config, :aliases => 'OS-DCF:diskConfig'

#idString (readonly)

Returns The server id.

Returns:



15
# File 'lib/fog/rackspace/models/compute_v2/image.rb', line 15

identity :id

Returns image links.

Returns:

  • (Array)

    image links.



64
# File 'lib/fog/rackspace/models/compute_v2/image.rb', line 64

attribute :links

#nameString (readonly)

Returns The image name.

Returns:

  • (String)

    The image name.



19
# File 'lib/fog/rackspace/models/compute_v2/image.rb', line 19

attribute :name

#progressFixnum (readonly)

Returns The build completion progress, as a percentage. Value is from 0 to 100.

Returns:

  • (Fixnum)

    The build completion progress, as a percentage. Value is from 0 to 100.



43
# File 'lib/fog/rackspace/models/compute_v2/image.rb', line 43

attribute :progress

#stateString (readonly)

Returns image status.

Returns:



31
# File 'lib/fog/rackspace/models/compute_v2/image.rb', line 31

attribute :state, :aliases => 'status'

#tenant_idString (readonly)

Returns The tenant Id.

Returns:



39
# File 'lib/fog/rackspace/models/compute_v2/image.rb', line 39

attribute :tenant_id

#updatedString (readonly)

Returns The time stamp for the last update.

Returns:

  • (String)

    The time stamp for the last update.



27
# File 'lib/fog/rackspace/models/compute_v2/image.rb', line 27

attribute :updated

#user_idString (readonly)

Returns The user Id.

Returns:



35
# File 'lib/fog/rackspace/models/compute_v2/image.rb', line 35

attribute :user_id

Instance Method Details

#destroyObject

Destroy image



103
104
105
106
# File 'lib/fog/rackspace/models/compute_v2/image.rb', line 103

def destroy
  requires :identity
  service.delete_image(identity)
end

#metadataFog::Compute::RackspaceV2::Metadata

Image metadata

Returns:



73
74
75
76
77
78
79
80
# File 'lib/fog/rackspace/models/compute_v2/image.rb', line 73

def 
  @metadata ||= begin
    Fog::Compute::RackspaceV2::Metadata.new({
      :service => service,
      :parent => self
    })
  end
end

#metadata=(hash = {}) ⇒ Object

Set server metadata

Parameters:

  • hash (Hash) (defaults to: {})

    contains key value pairs



84
85
86
# File 'lib/fog/rackspace/models/compute_v2/image.rb', line 84

def metadata=(hash={})
  .from_hash(hash)
end

#ready?(ready_state = ACTIVE, error_states = [ERROR]) ⇒ Boolean

Is image is in ready state

Parameters:

  • ready_state (String) (defaults to: ACTIVE)

    By default state is ACTIVE

  • error_states (Array, String) (defaults to: [ERROR])

    By default state is ERROR

Returns:

  • (Boolean)

    returns true if server is in a ready state

Raises:

  • (RuntimeException)

    if server state is an error state



93
94
95
96
97
98
99
# File 'lib/fog/rackspace/models/compute_v2/image.rb', line 93

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