From 38561c758dd0699fa31d17222bd06c06f4a28168 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 9 Aug 2012 11:51:05 -0700 Subject: Key min_count, max_count, ret_res_id off of ext. Implements part of blueprint disable-server-extensions Adds a new extension descriptor callsed os-multiple-create. Modifies the min_count, max_count, and return_reservation_id parameters to server create to only be allowed if the extension is enabled. Change-Id: Iaca009588d6c824e0852a060787d2a4cb9614278 --- .../openstack/compute/contrib/multiple_create.py | 27 ++++++++++++++++++++++ nova/api/openstack/compute/servers.py | 11 +++++---- 2 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 nova/api/openstack/compute/contrib/multiple_create.py (limited to 'nova/api') diff --git a/nova/api/openstack/compute/contrib/multiple_create.py b/nova/api/openstack/compute/contrib/multiple_create.py new file mode 100644 index 000000000..9b3ca8a57 --- /dev/null +++ b/nova/api/openstack/compute/contrib/multiple_create.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 Multiple_create(extensions.ExtensionDescriptor): + """Allow multiple create in the Create Server v1.1 API""" + + name = "MultipleCreate" + alias = "os-multiple-create" + namespace = ("http://docs.openstack.org/compute/ext/" + "multiplecreate/api/v1.1") + updated = "2012-08-07T00:00:00+00:00" diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index de8f32d53..25a7e55e8 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -655,10 +655,13 @@ class Controller(wsgi.Controller): if self.ext_mgr.is_loaded('os-volumes'): block_device_mapping = server_dict.get('block_device_mapping') - ret_resv_id = server_dict.get('return_reservation_id', False) - - min_count = server_dict.get('min_count') - max_count = server_dict.get('max_count') + ret_resv_id = False + min_count = None + max_count = None + if self.ext_mgr.is_loaded('os-multiple-create'): + ret_resv_id = server_dict.get('return_reservation_id', False) + min_count = server_dict.get('min_count') + max_count = server_dict.get('max_count') # min_count and max_count are optional. If they exist, they come # in as strings. We want to default 'min_count' to 1, and default # 'max_count' to be 'min_count'. -- cgit