mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add attributes to image model by extracting them from metadata.
This commit is contained in:
parent
2c37b04860
commit
485419ec6c
1 changed files with 26 additions and 2 deletions
|
@ -14,12 +14,16 @@ module Fog
|
||||||
attribute :updated_at, :aliases => 'updated'
|
attribute :updated_at, :aliases => 'updated'
|
||||||
attribute :progress
|
attribute :progress
|
||||||
attribute :status
|
attribute :status
|
||||||
attribute :minDisk, :aliases => 'min_disk'
|
|
||||||
attribute :minRam, :aliases => 'min_ram'
|
|
||||||
attribute :server
|
attribute :server
|
||||||
attribute :metadata
|
attribute :metadata
|
||||||
attribute :links
|
attribute :links
|
||||||
|
|
||||||
|
# these values are extracted from metadata
|
||||||
|
attr_reader :min_disk
|
||||||
|
attr_reader :min_ram
|
||||||
|
attr_reader :image_type
|
||||||
|
attr_reader :architecture
|
||||||
|
|
||||||
def initialize(attributes)
|
def initialize(attributes)
|
||||||
@connection = attributes[:connection]
|
@connection = attributes[:connection]
|
||||||
super
|
super
|
||||||
|
@ -40,6 +44,26 @@ module Fog
|
||||||
metadata.load(metas)
|
metadata.load(metas)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def min_disk
|
||||||
|
m = metadata.get("min_disk")
|
||||||
|
m.value unless m.nil?
|
||||||
|
end
|
||||||
|
|
||||||
|
def min_ram
|
||||||
|
m = metadata.get("min_ram")
|
||||||
|
m.value unless m.nil?
|
||||||
|
end
|
||||||
|
|
||||||
|
def image_type
|
||||||
|
m = metadata.get("image_type")
|
||||||
|
m.value unless m.nil?
|
||||||
|
end
|
||||||
|
|
||||||
|
def architecture
|
||||||
|
m = metadata.get("architecture")
|
||||||
|
m.value unless m.nil?
|
||||||
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
requires :id
|
requires :id
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue