1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Sync with latest OpenStack flavors extensions.

Updates the OpenStack flavors model/request/and tests so
that they support the latest upstream flavor extensions in
Nova Folsom.

Also updated the Fog tests so they pass with both mocks and reals
(tested against OpenStack deployed on Fedora).
This commit is contained in:
Dan Prince 2012-11-27 13:16:19 -05:00
parent c4d176922c
commit bae7186994
3 changed files with 13 additions and 4 deletions

View file

@ -14,6 +14,8 @@ module Fog
attribute :swap attribute :swap
attribute :rxtx_factor attribute :rxtx_factor
attribute :ephemeral, :aliases => 'OS-FLV-EXT-DATA:ephemeral' attribute :ephemeral, :aliases => 'OS-FLV-EXT-DATA:ephemeral'
attribute :is_public, :aliases => 'os-flavor-access:is_public'
attribute :disabled, :aliases => 'OS-FLV-DISABLED:disabled'
def initialize(attributes) def initialize(attributes)
@connection = attributes[:connection] @connection = attributes[:connection]
@ -23,8 +25,10 @@ module Fog
def save def save
requires :name, :ram, :vcpus, :disk requires :name, :ram, :vcpus, :disk
attributes[:ephemeral] = self.ephemeral || 0 attributes[:ephemeral] = self.ephemeral || 0
attributes[:is_public] = self.is_public || false
attributes[:disabled] = self.disabled || false
attributes[:swap] = self.swap || 0 attributes[:swap] = self.swap || 0
attributes[:rxtx_factor] = self.rxtx_factor || 1 attributes[:rxtx_factor] = self.rxtx_factor || 1.0
merge_attributes(connection.create_flavor(self.attributes).body['flavor']) merge_attributes(connection.create_flavor(self.attributes).body['flavor'])
self self
end end

View file

@ -29,6 +29,7 @@ module Fog
'id' => attributes[:flavor_id], 'id' => attributes[:flavor_id],
'swap' => attributes[:swap], 'swap' => attributes[:swap],
'OS-FLV-EXT-DATA:ephemeral' => attributes[:ephemeral], 'OS-FLV-EXT-DATA:ephemeral' => attributes[:ephemeral],
'os-flavor-access:is_public' => attributes[:is_public],
'rxtx_factor' => attributes[:rxtx_factor] 'rxtx_factor' => attributes[:rxtx_factor]
} }
} }
@ -67,8 +68,10 @@ module Fog
"rel" => "bookmark" "rel" => "bookmark"
} }
], ],
"rxtx_factor" => attributes[:rxtx_factor] || 1, "rxtx_factor" => attributes[:rxtx_factor] || 1.0,
"OS-FLV-EXT-DATA:ephemeral" => attributes[:ephemeral] || 0, "OS-FLV-EXT-DATA:ephemeral" => attributes[:ephemeral] || 0,
"os-flavor-access:is_public" => attributes[:is_public] || false,
"OS-FLV-DISABLED:disabled" => attributes[:disabled] || false,
"ram" => attributes[:ram], "ram" => attributes[:ram],
"id" => "11", "id" => "11",
"swap" => attributes[:swap] || "" "swap" => attributes[:swap] || ""

View file

@ -6,9 +6,11 @@ Shindo.tests('Fog::Compute[:openstack] | flavor requests', ['openstack']) do
'disk' => Integer, 'disk' => Integer,
'ram' => Integer, 'ram' => Integer,
'links' => Array, 'links' => Array,
'swap' => String, 'swap' => Fog::Nullable::String,
'rxtx_factor' => Fog::Nullable::Float, 'rxtx_factor' => Fog::Nullable::Float,
'OS-FLV-EXT-DATA:ephemeral' => Integer, 'OS-FLV-EXT-DATA:ephemeral' => Integer,
'os-flavor-access:is_public' => Fog::Nullable::Boolean,
'OS-FLV-DISABLED:disabled' => Fog::Nullable::Boolean,
'vcpus' => Integer 'vcpus' => Integer
} }
@ -27,7 +29,7 @@ Shindo.tests('Fog::Compute[:openstack] | flavor requests', ['openstack']) do
end end
tests('#create_flavor(attributes)').formats({'flavor' => @flavor_format}) do tests('#create_flavor(attributes)').formats({'flavor' => @flavor_format}) do
attributes = {:flavor_id => '100', :name => 'shindo test flavor', :disk => 10, :ram => 10, :vcpus => 10, :swap => "0", :rxtx_factor => 1.0, :ephemeral => 0} attributes = {:flavor_id => '100', :name => 'shindo test flavor', :disk => 10, :ram => 10, :vcpus => 10, :swap => "0", :rxtx_factor => 2.4, :ephemeral => 0, :is_public => false}
Fog::Compute[:openstack].create_flavor(attributes).body Fog::Compute[:openstack].create_flavor(attributes).body
end end