1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/openstack/models/compute/flavor.rb
Alfonso Juan Dillera 1db7605986 [openstack|compute] Add flavor CRUD
- Added requests.
- Added definitions to model.
- Added tests but having a problem with some items being of float type.
- Must revisit test.
2012-04-30 10:35:00 +08:00

40 lines
964 B
Ruby

require 'fog/core/model'
module Fog
module Compute
class OpenStack
class Flavor < Fog::Model
identity :id
attribute :name
attribute :ram
attribute :disk
attribute :vcpus
attribute :links
attribute :swap
attribute :rxtx_factor
attribute :ephemeral, :aliases => 'OS-FLV-EXT-DATA:ephemeral'
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
def destroy
requires :id
connection.delete_flavor(self.id)
true
end
end
end
end
end