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

Add name, accessIPv4 and accessIPv6 as properties. Change create_server signature to include the now required name param. Breaking change due to OS API.

This commit is contained in:
Rupak Ganguly 2011-11-03 14:37:06 -04:00
parent 9a64b3f1d4
commit 60b11858c1

View file

@ -6,9 +6,9 @@ module Fog
# Create a new server
#
# ==== Parameters
# * name<~String> - Name of server
# * flavor_id<~Integer> - Id of flavor for server
# * image_id<~Integer> - Id of image for server
# * name<~String> - Name of server
# * options<~Hash>:
# * 'metadata'<~Hash> - Up to 5 key value pairs containing 255 bytes of info
# * 'name'<~String> - Name of server, defaults to "slice#{id}"
@ -16,6 +16,8 @@ module Fog
# * file<~Hash>:
# * 'contents'<~String> - Contents of file (10kb total of contents)
# * 'path'<~String> - Path to file (255 bytes total of path strings)
# * 'accessIPv4'<~String> - IPv4 IP address
# * 'accessIPv6'<~String> - IPv6 IP address
#
# ==== Returns
# * response<~Excon::Response>:
@ -30,21 +32,25 @@ module Fog
# * 'id'<~Integer> - Id of server
# * 'imageId'<~Integer> - Id of image used to boot server
# * 'metadata'<~Hash> - metadata
# * 'name<~String> - Name of server
# * 'name'<~String> - Name of server
# * 'progress'<~Integer> - Progress through current status
# * 'status'<~String> - Current server status
def create_server(flavor_id, image_id, options = {})
def create_server(name, flavor_id, image_id, options = {})
data = {
'server' => {
'flavorRef' => flavor_id,
'imageRef' => image_id
'imageRef' => image_id,
'name' => name
}
}
if options['metadata']
data['server']['metadata'] = options['metadata']
end
if options['name']
data['server']['name'] = options['name']
if options['accessIPv4']
data['server']['accessIPv4'] = options['accessIPv4']
end
if options['accessIPv6']
data['server']['accessIPv6'] = options['accessIPv6']
end
if options['personality']
data['server']['personality'] = []
@ -67,18 +73,21 @@ module Fog
class Mock
def create_server(flavor_id, image_id, options = {})
def create_server(name, flavor_id, image_id, options = {})
response = Excon::Response.new
response.status = 202
data = {
'addresses' => { 'private' => ['0.0.0.0'], 'public' => ['0.0.0.0'] },
'flavorId' => flavor_id,
'id' => Fog::Mock.random_numbers(6).to_i,
'imageId' => image_id,
'flavor' => {"id"=>"1", "links"=>[{"href"=>"http://nova1:8774/admin/flavors/1", "rel"=>"bookmark"}]},
'id' => Fog::Mock.random_numbers(6).to_s,
'image' => {"id"=>"3", "links"=>[{"href"=>"http://nova1:8774/admin/images/3", "rel"=>"bookmark"}]},
'links' => [{"href"=>"http://nova1:8774/v1.1/admin/servers/5", "rel"=>"self"}, {"href"=>"http://nova1:8774/admin/servers/5", "rel"=>"bookmark"}],
'hostId' => "123456789ABCDEF01234567890ABCDEF",
'metadata' => options['metadata'] || {},
'name' => options['name'] || "server_#{rand(999)}",
'name' => name || "server_#{rand(999)}",
'accessIPv4' => options['accessIPv4'] || "",
'accessIPv6' => options['accessIPv6'] || "",
'progress' => 0,
'status' => 'BUILD'
}