From 940e1cfd7dc8b382453e03215aeceefbc2afa173 Mon Sep 17 00:00:00 2001 From: "Mauro S. M. Rodrigues" Date: Thu, 13 Sep 2012 02:12:31 -0400 Subject: Add api samples to Scheduler hints extension Change-Id: Ic324d796dac0cfc7b36c47a181b55e09cb1503e2 --- .../scheduler-hints-post-req.json | 11 +++++++++++ .../scheduler-hints-post-req.xml | 10 ++++++++++ .../scheduler-hints-post-resp.json | 16 ++++++++++++++++ .../scheduler-hints-post-resp.xml | 6 ++++++ .../scheduler-hints-post-req.json.tpl | 11 +++++++++++ .../scheduler-hints-post-req.xml.tpl | 10 ++++++++++ .../scheduler-hints-post-resp.json.tpl | 16 ++++++++++++++++ .../scheduler-hints-post-resp.xml.tpl | 6 ++++++ nova/tests/integrated/test_api_samples.py | 22 ++++++++++++++++++++++ 9 files changed, 108 insertions(+) create mode 100644 doc/api_samples/os-scheduler-hints/scheduler-hints-post-req.json create mode 100644 doc/api_samples/os-scheduler-hints/scheduler-hints-post-req.xml create mode 100644 doc/api_samples/os-scheduler-hints/scheduler-hints-post-resp.json create mode 100644 doc/api_samples/os-scheduler-hints/scheduler-hints-post-resp.xml create mode 100644 nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-req.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-req.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-scheduler-hints/scheduler-hints-post-resp.xml.tpl 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 @@ + + + xen + eb999657-dd6b-464e-8713-95c532ac3b18 + + \ 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 @@ + + + + + + \ 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 @@ + + + xen + %(image_near)s + + 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 @@ + + + + + + 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' -- cgit