From 8b51c7dcaaf03f0b2b287420dad5c61e05cf31b6 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 9 Aug 2012 11:24:54 -0700 Subject: Key availability_zone in create server off of ext. Implements part of blueprint disable-server-extensions Adds a new extension descriptor for availability_zone and makes sure that availability_zone is only accepted in the create server request if the extension is enabled. Change-Id: I326b26c4741ffa6a8b594be26d0cd22d032a6162 --- .../openstack/compute/contrib/availability_zone.py | 27 ++++++++++++++++++++++ nova/api/openstack/compute/servers.py | 4 +++- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 nova/api/openstack/compute/contrib/availability_zone.py (limited to 'nova/api') diff --git a/nova/api/openstack/compute/contrib/availability_zone.py b/nova/api/openstack/compute/contrib/availability_zone.py new file mode 100644 index 000000000..524f454ea --- /dev/null +++ b/nova/api/openstack/compute/contrib/availability_zone.py @@ -0,0 +1,27 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2012 OpenStack LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License + +from nova.api.openstack import extensions + + +class Availability_zone(extensions.ExtensionDescriptor): + """Add availability_zone to the Create Server v1.1 API""" + + name = "AvailabilityZone" + alias = "os-availability-zone" + namespace = ("http://docs.openstack.org/compute/ext/" + "availabilityzone/api/v1.1") + updated = "2012-08-09T00:00:00+00:00" diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index b378d4139..de8f32d53 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -647,7 +647,9 @@ class Controller(wsgi.Controller): user_data = server_dict.get('user_data') self._validate_user_data(user_data) - availability_zone = server_dict.get('availability_zone') + availability_zone = None + if self.ext_mgr.is_loaded('os-availability-zone'): + availability_zone = server_dict.get('availability_zone') block_device_mapping = None if self.ext_mgr.is_loaded('os-volumes'): -- cgit