From 7b664a93379af7e4183792d25a41155dc1406aef Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Tue, 11 Oct 2011 17:08:34 -0400 Subject: [PATCH] [OpenStack|compute] add zone awareness Nova has a `ZoneScheduler` that can run instances on a particular set of hardware. This attribute hasn't been documented in the api spec, but is effective at setting the availability_zone and letting ZoneScheduler work. --- lib/fog/openstack/models/compute/server.rb | 4 +++- lib/fog/openstack/requests/compute/create_server.rb | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/fog/openstack/models/compute/server.rb b/lib/fog/openstack/models/compute/server.rb index 9f2b0a9c3..b3e6b3307 100644 --- a/lib/fog/openstack/models/compute/server.rb +++ b/lib/fog/openstack/models/compute/server.rb @@ -20,6 +20,7 @@ module Fog attribute :progress attribute :accessIPv4 attribute :accessIPv6 + attribute :availability_zone attribute :state, :aliases => 'status' attr_reader :password @@ -152,7 +153,8 @@ module Fog 'metadata' => meta_hash, 'personality' => personality, 'accessIPv4' => accessIPv4, - 'accessIPv6' => accessIPv6 + 'accessIPv6' => accessIPv6, + 'availability_zone' => availability_zone } options = options.reject {|key, value| value.nil?} data = connection.create_server(name, image_ref, flavor_ref, options) diff --git a/lib/fog/openstack/requests/compute/create_server.rb b/lib/fog/openstack/requests/compute/create_server.rb index 957407b0e..b5bc88276 100644 --- a/lib/fog/openstack/requests/compute/create_server.rb +++ b/lib/fog/openstack/requests/compute/create_server.rb @@ -30,6 +30,9 @@ module Fog } end end + if options['availability_zone'] + data['server']['availability_zone'] = options['availability_zone'] + end request( :body => MultiJson.encode(data), :expects => [200, 202],