2011-09-26 02:41:54 -04:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class OpenStack
|
|
|
|
class Flavor < Fog::Model
|
|
|
|
identity :id
|
|
|
|
|
|
|
|
attribute :name
|
|
|
|
attribute :ram
|
2012-02-29 07:42:46 +08:00
|
|
|
attribute :disk
|
|
|
|
attribute :vcpus
|
2011-09-26 02:41:54 -04:00
|
|
|
attribute :links
|
2012-02-29 07:42:46 +08:00
|
|
|
attribute :swap
|
|
|
|
attribute :rxtx_factor
|
|
|
|
attribute :ephemeral, :aliases => 'OS-FLV-EXT-DATA:ephemeral'
|
2011-09-26 02:41:54 -04:00
|
|
|
|
2012-02-29 07:42:46 +08:00
|
|
|
def initialize(attributes)
|
|
|
|
@connection = attributes[:connection]
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
|
|
|
requires :name, :ram, :vcpus, :disk
|
|
|
|
attributes[:ephemeral] = self.ephemeral || 0
|
|
|
|
attributes[:swap] = self.swap || 0
|
|
|
|
attributes[:rxtx_factor] = self.rxtx_factor || 1
|
|
|
|
merge_attributes(connection.create_flavor(self.attributes).body['flavor'])
|
|
|
|
self
|
|
|
|
end
|
2011-09-26 02:41:54 -04:00
|
|
|
|
2012-02-29 07:42:46 +08:00
|
|
|
def destroy
|
|
|
|
requires :id
|
|
|
|
connection.delete_flavor(self.id)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
2011-09-26 02:41:54 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|