Permalink
Browse files

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).
  • Loading branch information...
1 parent c4d1769 commit bae7186994ebff42c049df05afe9f6e7df9bd64b @dprince dprince committed Nov 27, 2012
@@ -14,6 +14,8 @@ class Flavor < Fog::Model
attribute :swap
attribute :rxtx_factor
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)
@connection = attributes[:connection]
@@ -23,8 +25,10 @@ def initialize(attributes)
def save
requires :name, :ram, :vcpus, :disk
attributes[:ephemeral] = self.ephemeral || 0
+ attributes[:is_public] = self.is_public || false
+ attributes[:disabled] = self.disabled || false
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'])
self
end
@@ -29,6 +29,7 @@ def create_flavor(attributes)
'id' => attributes[:flavor_id],
'swap' => attributes[:swap],
'OS-FLV-EXT-DATA:ephemeral' => attributes[:ephemeral],
+ 'os-flavor-access:is_public' => attributes[:is_public],
'rxtx_factor' => attributes[:rxtx_factor]
}
}
@@ -67,8 +68,10 @@ def create_flavor(attributes)
"rel" => "bookmark"
}
],
- "rxtx_factor" => attributes[:rxtx_factor] || 1,
+ "rxtx_factor" => attributes[:rxtx_factor] || 1.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],
"id" => "11",
"swap" => attributes[:swap] || ""
@@ -6,9 +6,11 @@
'disk' => Integer,
'ram' => Integer,
'links' => Array,
- 'swap' => String,
+ 'swap' => Fog::Nullable::String,
'rxtx_factor' => Fog::Nullable::Float,
'OS-FLV-EXT-DATA:ephemeral' => Integer,
+ 'os-flavor-access:is_public' => Fog::Nullable::Boolean,
+ 'OS-FLV-DISABLED:disabled' => Fog::Nullable::Boolean,
'vcpus' => Integer
}
@@ -27,7 +29,7 @@
end
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
end

0 comments on commit bae7186

Please sign in to comment.