1
0
Fork 0
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:
Rupak Ganguly 2012-06-25 16:10:19 -04:00
parent 2c37b04860
commit 485419ec6c

View file

@ -14,12 +14,16 @@ module Fog
attribute :updated_at, :aliases => 'updated'
attribute :progress
attribute :status
attribute :minDisk, :aliases => 'min_disk'
attribute :minRam, :aliases => 'min_ram'
attribute :server
attribute :metadata
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)
@connection = attributes[:connection]
super
@ -40,6 +44,26 @@ module Fog
metadata.load(metas)
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
requires :id