summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@gmail.com>2012-08-09 11:51:05 -0700
committerVishvananda Ishaya <vishvananda@gmail.com>2012-08-09 12:28:05 -0700
commit38561c758dd0699fa31d17222bd06c06f4a28168 (patch)
tree0f52dacf5e3559670bef86eed2608ff9972e76ac /nova/api
parent8b51c7dcaaf03f0b2b287420dad5c61e05cf31b6 (diff)
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
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/contrib/multiple_create.py27
-rw-r--r--nova/api/openstack/compute/servers.py11
2 files changed, 34 insertions, 4 deletions
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'.