mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
7961ad6508
The 'connection' accessor in collections and models actually refered to a subclassed instance of Fog::Service which creates confusion in the code. References to 'connection' could have meant the service or the Fog::Connection held within that service. This deprecates the connection accessor and replaces it with `#service` as a read only value. When a collection or model is initalised then service should be passed. This commit also updates all the changes to @connection made by providers in model initialisers since these depending on the presence of the 'connection' key. The key is still accepted by outputs a warning.
58 lines
1.3 KiB
Ruby
58 lines
1.3 KiB
Ruby
require 'fog/core/model'
|
|
require 'fog/openstack/models/compute/metadata'
|
|
|
|
module Fog
|
|
module Compute
|
|
class OpenStack
|
|
|
|
class Image < Fog::Model
|
|
|
|
identity :id
|
|
|
|
attribute :name
|
|
attribute :created_at, :aliases => 'created'
|
|
attribute :updated_at, :aliases => 'updated'
|
|
attribute :progress
|
|
attribute :status
|
|
attribute :minDisk
|
|
attribute :minRam
|
|
attribute :server, :aliases => 'server'
|
|
attribute :metadata
|
|
attribute :links
|
|
|
|
def initialize(attributes)
|
|
# Old 'connection' is renamed as service and should be used instead
|
|
prepare_service_value(attributes)
|
|
super
|
|
end
|
|
|
|
def metadata
|
|
@metadata ||= begin
|
|
Fog::Compute::OpenStack::Metadata.new({
|
|
:connection => connection,
|
|
:parent => self
|
|
})
|
|
end
|
|
end
|
|
|
|
def metadata=(new_metadata={})
|
|
metas = []
|
|
new_metadata.each_pair {|k,v| metas << {"key" => k, "value" => v} }
|
|
metadata.load(metas)
|
|
end
|
|
|
|
def destroy
|
|
requires :id
|
|
connection.delete_image(id)
|
|
true
|
|
end
|
|
|
|
def ready?
|
|
status == 'ACTIVE'
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|