diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-09-18 21:42:29 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-09-18 21:42:29 +0000 |
| commit | 1625eec4187d9e82ca6c39c3df2d6fa7059f3aa6 (patch) | |
| tree | d153ea2e6e3bb3af9e1cbd7f00fd99ea09109448 /nova | |
| parent | cc84de5968623b289137ef53bd218ad4f54a0bc5 (diff) | |
| parent | 71c9677d803a722f5c9eb5b2d0719f1e713d1b7b (diff) | |
Merge "Add deserialization for multiple create and az"
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/api/openstack/compute/servers.py | 7 | ||||
| -rw-r--r-- | nova/tests/api/openstack/compute/test_servers.py | 32 |
2 files changed, 38 insertions, 1 deletions
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index c949ad661..5cb7369c0 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -159,11 +159,16 @@ class CommonDeserializer(wsgi.MetadataXMLDeserializer): server_node = self.find_first_child_named(node, 'server') attributes = ["name", "imageRef", "flavorRef", "adminPass", - "accessIPv4", "accessIPv6", "key_name"] + "accessIPv4", "accessIPv6", "key_name", + "availability_zone", "min_count", "max_count"] for attr in attributes: if server_node.getAttribute(attr): server[attr] = server_node.getAttribute(attr) + res_id = server_node.getAttribute('return_reservation_id') + if res_id: + server['return_reservation_id'] = utils.bool_from_str(res_id) + scheduler_hints = self._extract_scheduler_hints(server_node) if scheduler_hints: server['os:scheduler_hints'] = scheduler_hints diff --git a/nova/tests/api/openstack/compute/test_servers.py b/nova/tests/api/openstack/compute/test_servers.py index aa8f6132b..0aa628d96 100644 --- a/nova/tests/api/openstack/compute/test_servers.py +++ b/nova/tests/api/openstack/compute/test_servers.py @@ -3256,6 +3256,38 @@ class TestServerCreateRequestXMLDeserializer(test.TestCase): }} self.assertEquals(request['body'], expected) + def test_request_with_availability_zone(self): + serial_request = """ + <server xmlns="http://docs.openstack.org/compute/api/v2" + name="new-server-test" imageRef="1" flavorRef="1" + availability_zone="some_zone:some_host"> + </server>""" + request = self.deserializer.deserialize(serial_request) + expected = {"server": { + "name": "new-server-test", + "imageRef": "1", + "flavorRef": "1", + "availability_zone": "some_zone:some_host", + }} + self.assertEquals(request['body'], expected) + + def test_request_with_multiple_create_args(self): + serial_request = """ + <server xmlns="http://docs.openstack.org/compute/api/v2" + name="new-server-test" imageRef="1" flavorRef="1" + min_count="1" max_count="3" return_reservation_id="True"> + </server>""" + request = self.deserializer.deserialize(serial_request) + expected = {"server": { + "name": "new-server-test", + "imageRef": "1", + "flavorRef": "1", + "min_count": "1", + "max_count": "3", + "return_reservation_id": True, + }} + self.assertEquals(request['body'], expected) + class TestAddressesXMLSerialization(test.TestCase): |
