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

Allow DHCP assignment by default.

This commit is contained in:
Sean Handley 2012-07-15 18:04:33 +02:00
parent 212ea7b3ed
commit d34abe2a33
2 changed files with 11 additions and 3 deletions

View file

@ -21,6 +21,8 @@ module Fog
attribute :status attribute :status
attribute :user attribute :user
attribute :started attribute :started
attribute :nic_0_model, :aliases => 'nic:0:model'
attribute :nic_0_dhcp, :aliases => 'nic:0:dhcp'
def save def save
attributes = {} attributes = {}
@ -30,7 +32,7 @@ module Fog
else else
requires :name requires :name
requires :cpu requires :cpu
attributes = connection.create_server(allowed_attributes).body attributes = connection.create_server(self.defaults.merge(allowed_attributes)).body
end end
merge_attributes(attributes) merge_attributes(attributes)
@ -47,6 +49,10 @@ module Fog
allowed = [:name, :cpu, :mem, :persistent, :vnc_password] allowed = [:name, :cpu, :mem, :persistent, :vnc_password]
attributes.select {|k,v| allowed.include? k} attributes.select {|k,v| allowed.include? k}
end end
def self.defaults
{ 'nic:0:model' => 'e1000', 'nic:0:dhcp' => 'auto' }
end
end end
end end
end end

View file

@ -9,7 +9,9 @@ Shindo.tests('Fog::Compute[:serverlove] | server requests', ['serverlove']) do
'cpu' => Integer, 'cpu' => Integer,
'mem' => Integer, 'mem' => Integer,
'persistent' => Fog::Nullable::String, 'persistent' => Fog::Nullable::String,
'vnc:password' => Fog::Nullable::String 'vnc:password' => Fog::Nullable::String,
'nic:0:dhcp' => String,
'nic:0:model' => String
} }
tests('success') do tests('success') do
@ -17,7 +19,7 @@ Shindo.tests('Fog::Compute[:serverlove] | server requests', ['serverlove']) do
attributes = { 'name' => 'Test', 'cpu' => '1000', 'mem' => '1000', 'persistent' => 'true' } attributes = { 'name' => 'Test', 'cpu' => '1000', 'mem' => '1000', 'persistent' => 'true' }
tests("#create_server").formats(@server_format) do tests("#create_server").formats(@server_format) do
@server = Fog::Compute[:serverlove].create_server(attributes).body @server = Fog::Compute[:serverlove].create_server(Fog::Compute::Serverlove::Server.defaults.merge(attributes)).body
end end
tests("#list_servers").succeeds do tests("#list_servers").succeeds do