diff options
| author | Mauro S. M. Rodrigues <maurosr@linux.vnet.ibm.com> | 2012-09-13 02:12:31 -0400 |
|---|---|---|
| committer | Mauro S. M. Rodrigues <maurosr@linux.vnet.ibm.com> | 2012-09-15 20:32:27 -0400 |
| commit | 940e1cfd7dc8b382453e03215aeceefbc2afa173 (patch) | |
| tree | 24da48315d5d6f387f03eed46a4ee1952e840ad2 | |
| parent | 81e76480af6ad17943cd2385a045d24217b07a7b (diff) | |
| download | nova-940e1cfd7dc8b382453e03215aeceefbc2afa173.tar.gz nova-940e1cfd7dc8b382453e03215aeceefbc2afa173.tar.xz nova-940e1cfd7dc8b382453e03215aeceefbc2afa173.zip | |
Add api samples to Scheduler hints extension
Change-Id: Ic324d796dac0cfc7b36c47a181b55e09cb1503e2
9 files changed, 108 insertions, 0 deletions
diff --git a/doc/api_samples/os-scheduler-hints/scheduler-hints-post-req.json b/doc/api_samples/os-scheduler-hints/scheduler-hints-post-req.json new file mode 100644 index 000000000..3e437e63f --- /dev/null +++ b/doc/api_samples/os-scheduler-hints/scheduler-hints-post-req.json @@ -0,0 +1,11 @@ +{ + "server": { + "name": "new-server-test", + "imageRef": "70a599e0-31e7-49b7-b260-868f441e862b", + "flavorRef": "1" + }, + "os:scheduler_hints": { + "hypervisor": "xen", + "near": "2b7c42eb-7736-4a0f-afab-f23969a35ada" + } +}
\ No newline at end of file diff --git a/doc/api_samples/os-scheduler-hints/scheduler-hints-post-req.xml b/doc/api_samples/os-scheduler-hints/scheduler-hints-post-req.xml new file mode 100644 index 000000000..079289de0 --- /dev/null +++ b/doc/api_samples/os-scheduler-hints/scheduler-hints-post-req.xml @@ -0,0 +1,10 @@ +<server + name='new-server-test' + imageRef='70a599e0-31e7-49b7-b260-868f441e862b' + flavorRef='1' +> + <scheduler_hints> + <hypervisor>xen</hypervisor> + <near>eb999657-dd6b-464e-8713-95c532ac3b18</near> + </scheduler_hints> +</server>
\ No newline at end of file diff --git a/doc/api_samples/os-scheduler-hints/scheduler-hints-post-resp.json b/doc/api_samples/os-scheduler-hints/scheduler-hints-post-resp.json new file mode 100644 index 000000000..cc3a87316 --- /dev/null +++ b/doc/api_samples/os-scheduler-hints/scheduler-hints-post-resp.json @@ -0,0 +1,16 @@ +{ + "server": { + "adminPass": "yjzytFHb7XHc", + "id": "f8f4f3ce-f6e0-4e05-8f79-bf984fdfce45", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/servers/f8f4f3ce-f6e0-4e05-8f79-bf984fdfce45", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/servers/f8f4f3ce-f6e0-4e05-8f79-bf984fdfce45", + "rel": "bookmark" + } + ] + } +}
\ No newline at end of file diff --git a/doc/api_samples/os-scheduler-hints/scheduler-hints-post-resp.xml b/doc/api_samples/os-scheduler-hints/scheduler-hints-post-resp.xml new file mode 100644 index 000000000..59929d808 --- /dev/null +++ b/doc/api_samples/os-scheduler-hints/scheduler-hints-post-resp.xml @@ -0,0 +1,6 @@ +<?xml version='1.0' encoding='UTF-8'?> +<server xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" id="a14a9bf5-93b3-49e4-85f1-01d7cf2645b4" adminPass="Q6jfHPrnvB9X"> + <metadata/> + <atom:link href="http://openstack.example.com/v2/openstack/servers/a14a9bf5-93b3-49e4-85f1-01d7cf2645b4" rel="self"/> + <atom:link href="http://openstack.example.com/openstack/servers/a14a9bf5-93b3-49e4-85f1-01d7cf2645b4" rel="bookmark"/> +</server>
\ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-req.json.tpl b/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-req.json.tpl new file mode 100644 index 000000000..1a19960c2 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-req.json.tpl @@ -0,0 +1,11 @@ +{ + "server": { + "name": "new-server-test", + "imageRef": "%(image_id)s", + "flavorRef": "1" + }, + "os:scheduler_hints": { + "hypervisor": "xen", + "near": "%(image_near)s" + } +} diff --git a/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-req.xml.tpl b/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-req.xml.tpl new file mode 100644 index 000000000..66327c534 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-req.xml.tpl @@ -0,0 +1,10 @@ +<server + name='new-server-test' + imageRef='%(image_id)s' + flavorRef='1' +> + <scheduler_hints> + <hypervisor>xen</hypervisor> + <near>%(image_near)s</near> + </scheduler_hints> +</server> diff --git a/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-resp.json.tpl new file mode 100644 index 000000000..d5f030c87 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-resp.json.tpl @@ -0,0 +1,16 @@ +{ + "server": { + "adminPass": "%(password)s", + "id": "%(id)s", + "links": [ + { + "href": "%(host)s/v2/openstack/servers/%(uuid)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/servers/%(uuid)s", + "rel": "bookmark" + } + ] + } +} diff --git a/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-resp.xml.tpl new file mode 100644 index 000000000..5a11c73c3 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-resp.xml.tpl @@ -0,0 +1,6 @@ +<?xml version='1.0' encoding='UTF-8'?> +<server xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" id="%(id)s" adminPass="%(password)s"> + <metadata/> + <atom:link href="%(host)s/v2/openstack/servers/%(id)s" rel="self"/> + <atom:link href="%(host)s/openstack/servers/%(id)s" rel="bookmark"/> +</server> diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index ae40cc41c..a2ab51b61 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -15,6 +15,7 @@ import os import re +import uuid from lxml import etree @@ -596,3 +597,24 @@ class SecurityGroupsSampleJsonTest(ServersSampleBase): class SecurityGroupsSampleXmlTest(SecurityGroupsSampleJsonTest): ctype = 'xml' + + +class SchedulerHintsJsonTest(ApiSampleTestBase): + extension_name = ("nova.api.openstack.compute.contrib.scheduler_hints." + "Scheduler_hints") + + def test_scheduler_hints_post(self): + """Get api sample of scheduler hint post request""" + hints = {'image_id': fake.get_valid_image_id(), + 'image_near': str(uuid.uuid4()) + } + response = self._do_post('servers', 'scheduler-hints-post-req', + hints) + self.assertEqual(response.status, 202) + subs = self._get_regexes() + return self._verify_response('scheduler-hints-post-resp', subs, + response) + + +class SchedulerHintsXmlTest(SchedulerHintsJsonTest): + ctype = 'xml' |
