From 1241e3ec2a93b94d019ebaed8d5086d4622e6cc4 Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Wed, 27 Feb 2019 19:53:34 -0500 Subject: [PATCH] Stop using "nova" in API samples when creating a server The "availability_zone" parameter for server create in the API reference and the availabilty zone user docs both say that users should not use the default availability zone (nova) yet our server create API samples use "nova" which is...bad. This change fixes the API samples and related tests to use a fake "us-west" availability zone. For any samples that were requesting an AZ when creating a server, those are changed from requesting "nova" to requesting "us-west" and a new AvailabilityZoneFixture is added to stub out the code used to validate the requested AZ and what is shown in server detail responses. Some unused samples are removed from the os-availability-zone directory and the API reference and AZ user docs are updated for formatting and linking to other docs for reference. Change-Id: I3161157f15f05a3ffaaf1b48e7beb6b3e59c5513 Closes-Bug: #1817963 --- api-ref/source/os-availability-zone.inc | 2 + api-ref/source/parameters.yaml | 13 +++--- .../availability-zone-post-req.json | 17 -------- .../availability-zone-post-resp.json | 22 ---------- .../os-rescue/server-get-resp-rescue.json | 2 +- .../os-rescue/server-get-resp-unrescue.json | 2 +- .../v2.26/server-tags-show-details-resp.json | 2 +- .../v2.26/servers-tags-details-resp.json | 2 +- .../servers/server-create-req-v237.json | 2 +- .../servers/server-create-req-v257.json | 2 +- .../servers/server-create-req.json | 2 +- doc/api_samples/servers/server-get-resp.json | 2 +- .../servers/servers-details-resp.json | 2 +- .../servers/v2.16/server-get-resp.json | 2 +- .../servers/v2.16/servers-details-resp.json | 2 +- .../servers/v2.3/server-get-resp.json | 2 +- .../servers/v2.3/servers-details-resp.json | 2 +- .../servers/v2.47/server-create-req.json | 2 +- .../servers/v2.47/server-get-resp.json | 2 +- .../servers/v2.47/servers-details-resp.json | 2 +- .../servers/v2.52/server-create-req.json | 2 +- .../servers/v2.52/server-get-resp.json | 2 +- .../servers/v2.52/servers-details-resp.json | 2 +- .../servers/v2.57/server-create-req.json | 2 +- .../servers/v2.63/server-create-req.json | 2 +- .../servers/v2.63/server-get-resp.json | 2 +- .../servers/v2.63/servers-details-resp.json | 2 +- .../servers/v2.66/server-create-req.json | 2 +- .../servers-details-with-changes-before.json | 2 +- .../servers/v2.9/server-get-resp.json | 2 +- .../servers/v2.9/servers-details-resp.json | 2 +- doc/source/user/aggregates.rst | 2 +- nova/tests/fixtures.py | 41 +++++++++++++++++++ .../api_sample_tests/api_sample_base.py | 21 ++++++++++ .../availability-zone-post-req.json.tpl | 17 -------- .../availability-zone-post-resp.json.tpl | 22 ---------- .../os-rescue/server-get-resp-rescue.json.tpl | 2 +- .../server-get-resp-unrescue.json.tpl | 2 +- .../server-tags-show-details-resp.json.tpl | 2 +- .../v2.26/servers-tags-details-resp.json.tpl | 2 +- .../servers/server-create-req-v237.json.tpl | 2 +- .../servers/server-create-req-v257.json.tpl | 2 +- .../servers/server-create-req.json.tpl | 2 +- .../servers/server-get-resp.json.tpl | 2 +- .../servers/servers-details-resp.json.tpl | 2 +- .../servers/v2.16/server-get-resp.json.tpl | 2 +- .../v2.16/servers-details-resp.json.tpl | 2 +- .../servers/v2.3/server-get-resp.json.tpl | 2 +- .../v2.3/servers-details-resp.json.tpl | 2 +- .../servers/v2.47/server-create-req.json.tpl | 2 +- .../servers/v2.47/server-get-resp.json.tpl | 2 +- .../v2.47/servers-details-resp.json.tpl | 2 +- .../servers/v2.52/server-create-req.json.tpl | 2 +- .../servers/v2.52/server-get-resp.json.tpl | 2 +- .../v2.52/servers-details-resp.json.tpl | 2 +- .../servers/v2.57/server-create-req.json.tpl | 2 +- .../servers/v2.63/server-create-req.json.tpl | 2 +- .../servers/v2.63/server-get-resp.json.tpl | 2 +- .../v2.63/servers-details-resp.json.tpl | 2 +- .../servers/v2.66/server-create-req.json.tpl | 2 +- ...rvers-details-with-changes-before.json.tpl | 2 +- .../servers/v2.9/server-get-resp.json.tpl | 2 +- .../v2.9/servers-details-resp.json.tpl | 2 +- .../test_availability_zone.py | 5 +++ .../api_sample_tests/test_servers.py | 5 +++ 65 files changed, 137 insertions(+), 138 deletions(-) delete mode 100644 doc/api_samples/os-availability-zone/availability-zone-post-req.json delete mode 100644 doc/api_samples/os-availability-zone/availability-zone-post-resp.json delete mode 100644 nova/tests/functional/api_sample_tests/api_samples/os-availability-zone/availability-zone-post-req.json.tpl delete mode 100644 nova/tests/functional/api_sample_tests/api_samples/os-availability-zone/availability-zone-post-resp.json.tpl diff --git a/api-ref/source/os-availability-zone.inc b/api-ref/source/os-availability-zone.inc index 9869dc596c3..bcd9a3081ba 100644 --- a/api-ref/source/os-availability-zone.inc +++ b/api-ref/source/os-availability-zone.inc @@ -1,5 +1,7 @@ .. -*- rst -*- +.. _os-availability-zone: + =========================================== Availability zones (os-availability-zone) =========================================== diff --git a/api-ref/source/parameters.yaml b/api-ref/source/parameters.yaml index a5ee4f369d9..273d553b98c 100644 --- a/api-ref/source/parameters.yaml +++ b/api-ref/source/parameters.yaml @@ -4842,18 +4842,21 @@ os-availability-zone:availability_zone: want your instance to be built. Typically, an admin user will use availability zones to arrange OpenStack compute hosts into logical groups. + An availability zone provides a form of physical isolation and redundancy from other availability zones. For instance, if some racks in your data center are on a separate power source, you can put servers in those racks in their own availability zone. Availability zones can also help separate different classes of hardware. By segregating resources into availability zones, you can ensure that your application resources are spread across disparate machines to achieve high availability in - the event of hardware or other failure. + the event of hardware or other failure. See + `Availability Zones (AZs) `_ for more information. + You can list the available availability zones by calling the - os-availability-zone API, but you should avoid using the default - availability zone when booting the instance. In general, the - default availability zone is named ``nova``. This AZ is only shown - when listing the availability zones as an admin. + :ref:`os-availability-zone` API, but you should avoid using the `default + availability zone `_ + when creating the server. The default availability zone is named ``nova``. + This AZ is only shown when listing the availability zones as an admin. in: body required: false type: string diff --git a/doc/api_samples/os-availability-zone/availability-zone-post-req.json b/doc/api_samples/os-availability-zone/availability-zone-post-req.json deleted file mode 100644 index e19960f6be3..00000000000 --- a/doc/api_samples/os-availability-zone/availability-zone-post-req.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "server" : { - "name" : "new-server-test", - "imageRef" : "70a599e0-31e7-49b7-b260-868f441e862b", - "flavorRef" : "1", - "metadata" : { - "My Server Name" : "Apache1" - }, - "availability_zone": "nova", - "personality" : [ - { - "path" : "/etc/banner.txt", - "contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA==" - } - ] - } -} diff --git a/doc/api_samples/os-availability-zone/availability-zone-post-resp.json b/doc/api_samples/os-availability-zone/availability-zone-post-resp.json deleted file mode 100644 index a13b8b9a5b3..00000000000 --- a/doc/api_samples/os-availability-zone/availability-zone-post-resp.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "server": { - "adminPass": "k4pKvTfcA4gY", - "id": "3e45fa2a-5204-466f-a684-c2a8e1c82d7f", - "links": [ - { - "href": "http://openstack.example.com/v2/6f70656e737461636b20342065766572/servers/3e45fa2a-5204-466f-a684-c2a8e1c82d7f", - "rel": "self" - }, - { - "href": "http://openstack.example.com/6f70656e737461636b20342065766572/servers/3e45fa2a-5204-466f-a684-c2a8e1c82d7f", - "rel": "bookmark" - } - ], - "OS-DCF:diskConfig": "AUTO", - "security_groups": [ - { - "name": "default" - } - ] - } -} \ No newline at end of file diff --git a/doc/api_samples/os-rescue/server-get-resp-rescue.json b/doc/api_samples/os-rescue/server-get-resp-rescue.json index 8780bc668d3..707e5a89065 100644 --- a/doc/api_samples/os-rescue/server-get-resp-rescue.json +++ b/doc/api_samples/os-rescue/server-get-resp-rescue.json @@ -54,7 +54,7 @@ "user_id": "fake", "config_drive": "", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "b8b357f7100d4391828f2177c922ef93", "OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini", "OS-EXT-SRV-ATTR:instance_name": "instance-00000001", diff --git a/doc/api_samples/os-rescue/server-get-resp-unrescue.json b/doc/api_samples/os-rescue/server-get-resp-unrescue.json index a8c9f271aaf..b163bc064e0 100644 --- a/doc/api_samples/os-rescue/server-get-resp-unrescue.json +++ b/doc/api_samples/os-rescue/server-get-resp-unrescue.json @@ -55,7 +55,7 @@ "user_id": "fake", "config_drive": "", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "b8b357f7100d4391828f2177c922ef93", "OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini", "OS-EXT-SRV-ATTR:instance_name": "instance-00000001", diff --git a/doc/api_samples/os-server-tags/v2.26/server-tags-show-details-resp.json b/doc/api_samples/os-server-tags/v2.26/server-tags-show-details-resp.json index 1fdc541a73e..6ae101260ef 100644 --- a/doc/api_samples/os-server-tags/v2.26/server-tags-show-details-resp.json +++ b/doc/api_samples/os-server-tags/v2.26/server-tags-show-details-resp.json @@ -58,7 +58,7 @@ "description": null, "config_drive": "", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "b8b357f7100d4391828f2177c922ef93", "OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini", "OS-EXT-SRV-ATTR:instance_name": "instance-00000001", diff --git a/doc/api_samples/os-server-tags/v2.26/servers-tags-details-resp.json b/doc/api_samples/os-server-tags/v2.26/servers-tags-details-resp.json index c1ea45a29ce..6e39ae53ff0 100644 --- a/doc/api_samples/os-server-tags/v2.26/servers-tags-details-resp.json +++ b/doc/api_samples/os-server-tags/v2.26/servers-tags-details-resp.json @@ -59,7 +59,7 @@ "description": null, "config_drive": "", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "c3f14e9812ad496baf92ccfb3c61e15f", "OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini", "OS-EXT-SRV-ATTR:instance_name": "instance-00000001", diff --git a/doc/api_samples/servers/server-create-req-v237.json b/doc/api_samples/servers/server-create-req-v237.json index abffb363e43..8b5c272e782 100644 --- a/doc/api_samples/servers/server-create-req-v237.json +++ b/doc/api_samples/servers/server-create-req-v237.json @@ -5,7 +5,7 @@ "name" : "new-server-test", "imageRef" : "70a599e0-31e7-49b7-b260-868f441e862b", "flavorRef" : "1", - "availability_zone": "nova", + "availability_zone": "us-west", "OS-DCF:diskConfig": "AUTO", "metadata" : { "My Server Name" : "Apache1" diff --git a/doc/api_samples/servers/server-create-req-v257.json b/doc/api_samples/servers/server-create-req-v257.json index c6d8dec2424..7c5011e4fe1 100644 --- a/doc/api_samples/servers/server-create-req-v257.json +++ b/doc/api_samples/servers/server-create-req-v257.json @@ -5,7 +5,7 @@ "name" : "new-server-test", "imageRef" : "70a599e0-31e7-49b7-b260-868f441e862b", "flavorRef" : "http://openstack.example.com/flavors/1", - "availability_zone": "nova", + "availability_zone": "us-west", "OS-DCF:diskConfig": "AUTO", "metadata" : { "My Server Name" : "Apache1" diff --git a/doc/api_samples/servers/server-create-req.json b/doc/api_samples/servers/server-create-req.json index 4ac0157a85e..f51255b9065 100644 --- a/doc/api_samples/servers/server-create-req.json +++ b/doc/api_samples/servers/server-create-req.json @@ -5,7 +5,7 @@ "name" : "new-server-test", "imageRef" : "70a599e0-31e7-49b7-b260-868f441e862b", "flavorRef" : "1", - "availability_zone": "nova", + "availability_zone": "us-west", "OS-DCF:diskConfig": "AUTO", "metadata" : { "My Server Name" : "Apache1" diff --git a/doc/api_samples/servers/server-get-resp.json b/doc/api_samples/servers/server-get-resp.json index 6c1e246f7cb..667b3586b1d 100644 --- a/doc/api_samples/servers/server-get-resp.json +++ b/doc/api_samples/servers/server-get-resp.json @@ -50,7 +50,7 @@ "name": "new-server-test", "config_drive": "", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "b8b357f7100d4391828f2177c922ef93", "OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini", "OS-EXT-SRV-ATTR:instance_name": "instance-00000001", diff --git a/doc/api_samples/servers/servers-details-resp.json b/doc/api_samples/servers/servers-details-resp.json index 28a1e98efe1..1d4898cb6ac 100644 --- a/doc/api_samples/servers/servers-details-resp.json +++ b/doc/api_samples/servers/servers-details-resp.json @@ -51,7 +51,7 @@ "name": "new-server-test", "config_drive": "", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "c3f14e9812ad496baf92ccfb3c61e15f", "OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini", "OS-EXT-SRV-ATTR:instance_name": "instance-00000001", diff --git a/doc/api_samples/servers/v2.16/server-get-resp.json b/doc/api_samples/servers/v2.16/server-get-resp.json index 8737a0e80d3..36dfe8fb496 100644 --- a/doc/api_samples/servers/v2.16/server-get-resp.json +++ b/doc/api_samples/servers/v2.16/server-get-resp.json @@ -48,7 +48,7 @@ "name": "new-server-test", "config_drive": "", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "c5f474bf81474f9dbbc404d5b2e4e9b3", "OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini", "OS-EXT-SRV-ATTR:instance_name": "instance-00000001", diff --git a/doc/api_samples/servers/v2.16/servers-details-resp.json b/doc/api_samples/servers/v2.16/servers-details-resp.json index 9fc17f6137b..a6b1d4d5e16 100644 --- a/doc/api_samples/servers/v2.16/servers-details-resp.json +++ b/doc/api_samples/servers/v2.16/servers-details-resp.json @@ -49,7 +49,7 @@ "name": "new-server-test", "config_drive": "", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "bc8efe4fdb7148a4bb921a2b03d17de6", "OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini", "OS-EXT-SRV-ATTR:instance_name": "instance-00000001", diff --git a/doc/api_samples/servers/v2.3/server-get-resp.json b/doc/api_samples/servers/v2.3/server-get-resp.json index 22882a074a3..cfb9c9c57a5 100644 --- a/doc/api_samples/servers/v2.3/server-get-resp.json +++ b/doc/api_samples/servers/v2.3/server-get-resp.json @@ -50,7 +50,7 @@ "name": "new-server-test", "config_drive": "", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "b8b357f7100d4391828f2177c922ef93", "OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini", "OS-EXT-SRV-ATTR:instance_name": "instance-00000001", diff --git a/doc/api_samples/servers/v2.3/servers-details-resp.json b/doc/api_samples/servers/v2.3/servers-details-resp.json index 5e3876fd2c9..3f0ecab3165 100644 --- a/doc/api_samples/servers/v2.3/servers-details-resp.json +++ b/doc/api_samples/servers/v2.3/servers-details-resp.json @@ -51,7 +51,7 @@ "name": "new-server-test", "config_drive": "", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "c3f14e9812ad496baf92ccfb3c61e15f", "OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini", "OS-EXT-SRV-ATTR:instance_name": "instance-00000001", diff --git a/doc/api_samples/servers/v2.47/server-create-req.json b/doc/api_samples/servers/v2.47/server-create-req.json index 4068a9ed1ef..bd5dbca36f9 100644 --- a/doc/api_samples/servers/v2.47/server-create-req.json +++ b/doc/api_samples/servers/v2.47/server-create-req.json @@ -5,7 +5,7 @@ "name" : "new-server-test", "imageRef" : "70a599e0-31e7-49b7-b260-868f441e862b", "flavorRef" : "6", - "availability_zone": "nova", + "availability_zone": "us-west", "OS-DCF:diskConfig": "AUTO", "metadata" : { "My Server Name" : "Apache1" diff --git a/doc/api_samples/servers/v2.47/server-get-resp.json b/doc/api_samples/servers/v2.47/server-get-resp.json index 9983aec3eea..e7d39431cde 100644 --- a/doc/api_samples/servers/v2.47/server-get-resp.json +++ b/doc/api_samples/servers/v2.47/server-get-resp.json @@ -1,7 +1,7 @@ { "server": { "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "compute", "OS-EXT-SRV-ATTR:hostname": "new-server-test", "OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini", diff --git a/doc/api_samples/servers/v2.47/servers-details-resp.json b/doc/api_samples/servers/v2.47/servers-details-resp.json index a9aaea4cff4..626a0f7d72e 100644 --- a/doc/api_samples/servers/v2.47/servers-details-resp.json +++ b/doc/api_samples/servers/v2.47/servers-details-resp.json @@ -2,7 +2,7 @@ "servers": [ { "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "compute", "OS-EXT-SRV-ATTR:hostname": "new-server-test", "OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini", diff --git a/doc/api_samples/servers/v2.52/server-create-req.json b/doc/api_samples/servers/v2.52/server-create-req.json index 36d2b4cf5cc..b629e717473 100644 --- a/doc/api_samples/servers/v2.52/server-create-req.json +++ b/doc/api_samples/servers/v2.52/server-create-req.json @@ -5,7 +5,7 @@ "name" : "new-server-test", "imageRef" : "70a599e0-31e7-49b7-b260-868f441e862b", "flavorRef" : "http://openstack.example.com/flavors/1", - "availability_zone": "nova", + "availability_zone": "us-west", "OS-DCF:diskConfig": "AUTO", "metadata" : { "My Server Name" : "Apache1" diff --git a/doc/api_samples/servers/v2.52/server-get-resp.json b/doc/api_samples/servers/v2.52/server-get-resp.json index ff651f8547a..9eaff718fab 100644 --- a/doc/api_samples/servers/v2.52/server-get-resp.json +++ b/doc/api_samples/servers/v2.52/server-get-resp.json @@ -1,7 +1,7 @@ { "server": { "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "compute", "OS-EXT-SRV-ATTR:hostname": "new-server-test", "OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini", diff --git a/doc/api_samples/servers/v2.52/servers-details-resp.json b/doc/api_samples/servers/v2.52/servers-details-resp.json index 98285ddc098..6b7bd0220ad 100644 --- a/doc/api_samples/servers/v2.52/servers-details-resp.json +++ b/doc/api_samples/servers/v2.52/servers-details-resp.json @@ -2,7 +2,7 @@ "servers": [ { "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "compute", "OS-EXT-SRV-ATTR:hostname": "new-server-test", "OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini", diff --git a/doc/api_samples/servers/v2.57/server-create-req.json b/doc/api_samples/servers/v2.57/server-create-req.json index c6d8dec2424..7c5011e4fe1 100644 --- a/doc/api_samples/servers/v2.57/server-create-req.json +++ b/doc/api_samples/servers/v2.57/server-create-req.json @@ -5,7 +5,7 @@ "name" : "new-server-test", "imageRef" : "70a599e0-31e7-49b7-b260-868f441e862b", "flavorRef" : "http://openstack.example.com/flavors/1", - "availability_zone": "nova", + "availability_zone": "us-west", "OS-DCF:diskConfig": "AUTO", "metadata" : { "My Server Name" : "Apache1" diff --git a/doc/api_samples/servers/v2.63/server-create-req.json b/doc/api_samples/servers/v2.63/server-create-req.json index 5523ce8d349..7a576f02497 100644 --- a/doc/api_samples/servers/v2.63/server-create-req.json +++ b/doc/api_samples/servers/v2.63/server-create-req.json @@ -5,7 +5,7 @@ "name" : "new-server-test", "imageRef" : "70a599e0-31e7-49b7-b260-868f441e862b", "flavorRef" : "6", - "availability_zone": "nova", + "availability_zone": "%(availability_zone)s", "OS-DCF:diskConfig": "AUTO", "metadata" : { "My Server Name" : "Apache1" diff --git a/doc/api_samples/servers/v2.63/server-get-resp.json b/doc/api_samples/servers/v2.63/server-get-resp.json index 5645499fc77..c644f70a85c 100644 --- a/doc/api_samples/servers/v2.63/server-get-resp.json +++ b/doc/api_samples/servers/v2.63/server-get-resp.json @@ -1,7 +1,7 @@ { "server": { "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "compute", "OS-EXT-SRV-ATTR:hostname": "new-server-test", "OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini", diff --git a/doc/api_samples/servers/v2.63/servers-details-resp.json b/doc/api_samples/servers/v2.63/servers-details-resp.json index 620a7a22342..3810f0f19f4 100644 --- a/doc/api_samples/servers/v2.63/servers-details-resp.json +++ b/doc/api_samples/servers/v2.63/servers-details-resp.json @@ -2,7 +2,7 @@ "servers": [ { "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "compute", "OS-EXT-SRV-ATTR:hostname": "new-server-test", "OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini", diff --git a/doc/api_samples/servers/v2.66/server-create-req.json b/doc/api_samples/servers/v2.66/server-create-req.json index 5523ce8d349..59c9101f020 100644 --- a/doc/api_samples/servers/v2.66/server-create-req.json +++ b/doc/api_samples/servers/v2.66/server-create-req.json @@ -5,7 +5,7 @@ "name" : "new-server-test", "imageRef" : "70a599e0-31e7-49b7-b260-868f441e862b", "flavorRef" : "6", - "availability_zone": "nova", + "availability_zone": "us-west", "OS-DCF:diskConfig": "AUTO", "metadata" : { "My Server Name" : "Apache1" diff --git a/doc/api_samples/servers/v2.66/servers-details-with-changes-before.json b/doc/api_samples/servers/v2.66/servers-details-with-changes-before.json index 69d360dadbb..9d330522880 100644 --- a/doc/api_samples/servers/v2.66/servers-details-with-changes-before.json +++ b/doc/api_samples/servers/v2.66/servers-details-with-changes-before.json @@ -2,7 +2,7 @@ "servers": [ { "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "compute", "OS-EXT-SRV-ATTR:hostname": "new-server-test", "OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini", diff --git a/doc/api_samples/servers/v2.9/server-get-resp.json b/doc/api_samples/servers/v2.9/server-get-resp.json index c92ff85fd58..a4f32246e77 100644 --- a/doc/api_samples/servers/v2.9/server-get-resp.json +++ b/doc/api_samples/servers/v2.9/server-get-resp.json @@ -50,7 +50,7 @@ "name": "new-server-test", "config_drive": "", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "b8b357f7100d4391828f2177c922ef93", "OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini", "OS-EXT-SRV-ATTR:instance_name": "instance-00000001", diff --git a/doc/api_samples/servers/v2.9/servers-details-resp.json b/doc/api_samples/servers/v2.9/servers-details-resp.json index 0ca874f3332..610de3e0ccc 100644 --- a/doc/api_samples/servers/v2.9/servers-details-resp.json +++ b/doc/api_samples/servers/v2.9/servers-details-resp.json @@ -51,7 +51,7 @@ "name": "new-server-test", "config_drive": "", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "c3f14e9812ad496baf92ccfb3c61e15f", "OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini", "OS-EXT-SRV-ATTR:instance_name": "instance-00000001", diff --git a/doc/source/user/aggregates.rst b/doc/source/user/aggregates.rst index c76807d5df8..15d4831f658 100644 --- a/doc/source/user/aggregates.rst +++ b/doc/source/user/aggregates.rst @@ -50,7 +50,7 @@ between aggregates and availability zones: availability zone - by default a host is part of a default availability zone even if it doesn't belong to an aggregate (the configuration option is named - ``default_availability_zone``) + :oslo.config:option:`default_availability_zone`) .. warning:: That last rule can be very error-prone. Since the user can see the list of availability zones, they have no way to know whether the default diff --git a/nova/tests/fixtures.py b/nova/tests/fixtures.py index 86e9a3e10c0..0ee89734541 100644 --- a/nova/tests/fixtures.py +++ b/nova/tests/fixtures.py @@ -2117,3 +2117,44 @@ def stub_target_cell(ctxt, cell_mapping): 'nova.context.scatter_gather_cells', stub_scatter_gather_cells)) self.useFixture(fixtures.MonkeyPatch( 'nova.context.target_cell', stub_target_cell)) + + +class AvailabilityZoneFixture(fixtures.Fixture): + """Fixture to stub out the nova.availability_zones module + + The list of ``zones`` provided to the fixture are what get returned from + ``get_availability_zones``. + + ``get_instance_availability_zone`` will return the availability_zone + requested when creating a server otherwise the instance.availabilty_zone + or default_availability_zone is returned. + """ + def __init__(self, zones): + self.zones = zones + + def setUp(self): + super(AvailabilityZoneFixture, self).setUp() + + def fake_get_availability_zones( + ctxt, get_only_available=False, with_hosts=False): + # A 2-item tuple is returned if get_only_available=False. + if not get_only_available: + return self.zones, [] + return self.zones + self.useFixture(fixtures.MonkeyPatch( + 'nova.availability_zones.get_availability_zones', + fake_get_availability_zones)) + + def fake_get_instance_availability_zone(ctxt, instance): + # If the server was created with a specific AZ, return it. + reqspec = objects.RequestSpec.get_by_instance_uuid( + ctxt, instance.uuid) + requested_az = reqspec.availability_zone + if requested_az: + return requested_az + # Otherwise return the instance.availability_zone if set else + # the default AZ. + return instance.availability_zone or CONF.default_availability_zone + self.useFixture(fixtures.MonkeyPatch( + 'nova.availability_zones.get_instance_availability_zone', + fake_get_instance_availability_zone)) diff --git a/nova/tests/functional/api_sample_tests/api_sample_base.py b/nova/tests/functional/api_sample_tests/api_sample_base.py index cdedd7425f9..a5301d9577c 100644 --- a/nova/tests/functional/api_sample_tests/api_sample_base.py +++ b/nova/tests/functional/api_sample_tests/api_sample_base.py @@ -63,6 +63,9 @@ class ApiSampleTestBaseV21(testscenarios.WithScenarios, _additional_fixtures = [] sample_dir = None _use_project_id = True + # Availability zones for the API samples tests. Can be overridden by + # sub-classes. If set, the AvailabilityZoneFilter is not used. + availability_zones = ['us-west'] scenarios = [ # test v2 with the v2.1 compatibility stack @@ -128,5 +131,23 @@ def fake_noop(*args, **kwargs): self.stub_out('nova.privsep.linux_net.set_device_enabled', fake_noop) self.stub_out('nova.privsep.linux_net.set_device_macaddr', fake_noop) + if self.availability_zones: + self.useFixture( + fixtures.AvailabilityZoneFixture(self.availability_zones)) + def _setup_services(self): pass + + def _setup_scheduler_service(self): + """Overrides _IntegratedTestBase._setup_scheduler_service to filter + out the AvailabilityZoneFilter prior to starting the scheduler. + """ + if self.availability_zones: + # The test is using fake zones so disable the + # AvailabilityZoneFilter which is otherwise enabled by default. + enabled_filters = CONF.filter_scheduler.enabled_filters + if 'AvailabilityZoneFilter' in enabled_filters: + enabled_filters.remove('AvailabilityZoneFilter') + self.flags(enabled_filters=enabled_filters, + group='filter_scheduler') + return super(ApiSampleTestBaseV21, self)._setup_scheduler_service() diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-availability-zone/availability-zone-post-req.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-availability-zone/availability-zone-post-req.json.tpl deleted file mode 100644 index 788c8962779..00000000000 --- a/nova/tests/functional/api_sample_tests/api_samples/os-availability-zone/availability-zone-post-req.json.tpl +++ /dev/null @@ -1,17 +0,0 @@ -{ - "server" : { - "name" : "new-server-test", - "imageRef" : "%(image_id)s", - "flavorRef" : "1", - "metadata" : { - "My Server Name" : "Apache1" - }, - "availability_zone": "%(availability_zone)s", - "personality" : [ - { - "path" : "/etc/banner.txt", - "contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA==" - } - ] - } -} diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-availability-zone/availability-zone-post-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-availability-zone/availability-zone-post-resp.json.tpl deleted file mode 100644 index c971df42ab2..00000000000 --- a/nova/tests/functional/api_sample_tests/api_samples/os-availability-zone/availability-zone-post-resp.json.tpl +++ /dev/null @@ -1,22 +0,0 @@ -{ - "server": { - "adminPass": "%(password)s", - "id": "%(id)s", - "links": [ - { - "href": "%(versioned_compute_endpoint)s/servers/%(uuid)s", - "rel": "self" - }, - { - "href": "%(compute_endpoint)s/servers/%(uuid)s", - "rel": "bookmark" - } - ], - "OS-DCF:diskConfig": "AUTO", - "security_groups": [ - { - "name": "default" - } - ] - } -} diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-rescue/server-get-resp-rescue.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-rescue/server-get-resp-rescue.json.tpl index 8f1ae997c0f..4b6f0e1d3d4 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/os-rescue/server-get-resp-rescue.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/os-rescue/server-get-resp-rescue.json.tpl @@ -54,7 +54,7 @@ "key_name": null, "config_drive": "%(cdrive)s", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "%(compute_host)s", "OS-EXT-SRV-ATTR:hypervisor_hostname": "%(hypervisor_hostname)s", "OS-EXT-SRV-ATTR:instance_name": "%(instance_name)s", diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-rescue/server-get-resp-unrescue.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-rescue/server-get-resp-unrescue.json.tpl index 3240c49372a..5d1bfb32574 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/os-rescue/server-get-resp-unrescue.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/os-rescue/server-get-resp-unrescue.json.tpl @@ -55,7 +55,7 @@ "key_name": null, "config_drive": "%(cdrive)s", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "%(compute_host)s", "OS-EXT-SRV-ATTR:hypervisor_hostname": "%(hypervisor_hostname)s", "OS-EXT-SRV-ATTR:instance_name": "%(instance_name)s", diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/server-tags-show-details-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/server-tags-show-details-resp.json.tpl index eeccd56ebaa..4a1b8bd5ad2 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/server-tags-show-details-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/server-tags-show-details-resp.json.tpl @@ -58,7 +58,7 @@ "description": null, "config_drive": "", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "%(compute_host)s", "OS-EXT-SRV-ATTR:hypervisor_hostname": "%(hypervisor_hostname)s", "OS-EXT-SRV-ATTR:instance_name": "%(instance_name)s", diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/servers-tags-details-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/servers-tags-details-resp.json.tpl index 51deeb68a0f..665db740f6a 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/servers-tags-details-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/os-server-tags/v2.26/servers-tags-details-resp.json.tpl @@ -59,7 +59,7 @@ "description": null, "config_drive": "", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "%(compute_host)s", "OS-EXT-SRV-ATTR:hypervisor_hostname": "%(hypervisor_hostname)s", "OS-EXT-SRV-ATTR:instance_name": "%(instance_name)s", diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/server-create-req-v237.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/server-create-req-v237.json.tpl index 91d0fe8452d..6b41882d921 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/server-create-req-v237.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/server-create-req-v237.json.tpl @@ -5,7 +5,7 @@ "name" : "%(name)s", "imageRef" : "%(image_id)s", "flavorRef" : "1", - "availability_zone": "nova", + "availability_zone": "%(availability_zone)s", "OS-DCF:diskConfig": "AUTO", "metadata" : { "My Server Name" : "Apache1" diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/server-create-req-v257.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/server-create-req-v257.json.tpl index 14898309f1b..e73efe45331 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/server-create-req-v257.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/server-create-req-v257.json.tpl @@ -5,7 +5,7 @@ "name" : "%(name)s", "imageRef" : "%(image_id)s", "flavorRef" : "http://openstack.example.com/flavors/1", - "availability_zone": "nova", + "availability_zone": "%(availability_zone)s", "OS-DCF:diskConfig": "AUTO", "metadata" : { "My Server Name" : "Apache1" diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/server-create-req.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/server-create-req.json.tpl index 91ae7232ca3..1669d7668a3 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/server-create-req.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/server-create-req.json.tpl @@ -5,7 +5,7 @@ "name" : "new-server-test", "imageRef" : "%(image_id)s", "flavorRef" : "1", - "availability_zone": "nova", + "availability_zone": "%(availability_zone)s", "OS-DCF:diskConfig": "AUTO", "metadata" : { "My Server Name" : "Apache1" diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/server-get-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/server-get-resp.json.tpl index 38926326b3e..621c9be1134 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/server-get-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/server-get-resp.json.tpl @@ -50,7 +50,7 @@ "name": "new-server-test", "config_drive": "%(cdrive)s", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "%(compute_host)s", "OS-EXT-SRV-ATTR:hypervisor_hostname": "%(hypervisor_hostname)s", "OS-EXT-SRV-ATTR:instance_name": "%(instance_name)s", diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/servers-details-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/servers-details-resp.json.tpl index 97317e2dad3..3b5b1a1e25a 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/servers-details-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/servers-details-resp.json.tpl @@ -51,7 +51,7 @@ "name": "new-server-test", "config_drive": "%(cdrive)s", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "%(compute_host)s", "OS-EXT-SRV-ATTR:hypervisor_hostname": "%(hypervisor_hostname)s", "OS-EXT-SRV-ATTR:instance_name": "%(instance_name)s", diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.16/server-get-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.16/server-get-resp.json.tpl index bcbfd47e908..e3473a49794 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.16/server-get-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.16/server-get-resp.json.tpl @@ -2,7 +2,7 @@ "server": { "config_drive": "", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "%(compute_host)s", "OS-EXT-SRV-ATTR:hypervisor_hostname": "%(hypervisor_hostname)s", "OS-EXT-SRV-ATTR:instance_name": "%(instance_name)s", diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.16/servers-details-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.16/servers-details-resp.json.tpl index c438205fd42..640fc426509 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.16/servers-details-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.16/servers-details-resp.json.tpl @@ -51,7 +51,7 @@ "name": "new-server-test", "config_drive": "", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "%(compute_host)s", "OS-EXT-SRV-ATTR:hypervisor_hostname": "%(hypervisor_hostname)s", "OS-EXT-SRV-ATTR:instance_name": "%(instance_name)s", diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.3/server-get-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.3/server-get-resp.json.tpl index 9b45e3e8993..3639ab6c115 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.3/server-get-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.3/server-get-resp.json.tpl @@ -50,7 +50,7 @@ "name": "new-server-test", "config_drive": "", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "%(compute_host)s", "OS-EXT-SRV-ATTR:hypervisor_hostname": "%(hypervisor_hostname)s", "OS-EXT-SRV-ATTR:instance_name": "%(instance_name)s", diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.3/servers-details-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.3/servers-details-resp.json.tpl index edb6ac463b1..1dffa0a7806 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.3/servers-details-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.3/servers-details-resp.json.tpl @@ -51,7 +51,7 @@ "name": "new-server-test", "config_drive": "", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "%(compute_host)s", "OS-EXT-SRV-ATTR:hypervisor_hostname": "%(hypervisor_hostname)s", "OS-EXT-SRV-ATTR:instance_name": "%(instance_name)s", diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.47/server-create-req.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.47/server-create-req.json.tpl index c78f5815851..fea6ab37f63 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.47/server-create-req.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.47/server-create-req.json.tpl @@ -5,7 +5,7 @@ "name" : "%(name)s", "imageRef" : "%(image_id)s", "flavorRef" : "6", - "availability_zone": "nova", + "availability_zone": "%(availability_zone)s", "OS-DCF:diskConfig": "AUTO", "metadata" : { "My Server Name" : "Apache1" diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.47/server-get-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.47/server-get-resp.json.tpl index 57fbcb6e47c..809aa812342 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.47/server-get-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.47/server-get-resp.json.tpl @@ -57,7 +57,7 @@ "name": "new-server-test", "config_drive": "%(cdrive)s", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "%(compute_host)s", "OS-EXT-SRV-ATTR:hostname": "%(hostname)s", "OS-EXT-SRV-ATTR:hypervisor_hostname": "%(hypervisor_hostname)s", diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.47/servers-details-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.47/servers-details-resp.json.tpl index 4fe3770c0e6..53fe2c90bc9 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.47/servers-details-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.47/servers-details-resp.json.tpl @@ -58,7 +58,7 @@ "name": "new-server-test", "config_drive": "%(cdrive)s", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "%(compute_host)s", "OS-EXT-SRV-ATTR:hostname": "%(hostname)s", "OS-EXT-SRV-ATTR:hypervisor_hostname": "%(hypervisor_hostname)s", diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.52/server-create-req.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.52/server-create-req.json.tpl index 220973ec37d..e158ba5d129 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.52/server-create-req.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.52/server-create-req.json.tpl @@ -5,7 +5,7 @@ "name" : "new-server-test", "imageRef" : "%(image_id)s", "flavorRef" : "http://openstack.example.com/flavors/1", - "availability_zone": "nova", + "availability_zone": "%(availability_zone)s", "OS-DCF:diskConfig": "AUTO", "metadata" : { "My Server Name" : "Apache1" diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.52/server-get-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.52/server-get-resp.json.tpl index 67caad0f2dd..39f9038eabb 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.52/server-get-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.52/server-get-resp.json.tpl @@ -54,7 +54,7 @@ "name": "new-server-test", "config_drive": "%(cdrive)s", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "%(compute_host)s", "OS-EXT-SRV-ATTR:hostname": "%(hostname)s", "OS-EXT-SRV-ATTR:hypervisor_hostname": "%(hypervisor_hostname)s", diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.52/servers-details-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.52/servers-details-resp.json.tpl index 1135a590cbe..c73cf740b85 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.52/servers-details-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.52/servers-details-resp.json.tpl @@ -55,7 +55,7 @@ "name": "new-server-test", "config_drive": "%(cdrive)s", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "%(compute_host)s", "OS-EXT-SRV-ATTR:hostname": "%(hostname)s", "OS-EXT-SRV-ATTR:hypervisor_hostname": "%(hypervisor_hostname)s", diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.57/server-create-req.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.57/server-create-req.json.tpl index ff9a9c8b1c4..f89c2cd4b88 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.57/server-create-req.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.57/server-create-req.json.tpl @@ -5,7 +5,7 @@ "name" : "new-server-test", "imageRef" : "%(image_id)s", "flavorRef" : "http://openstack.example.com/flavors/1", - "availability_zone": "nova", + "availability_zone": "%(availability_zone)s", "OS-DCF:diskConfig": "AUTO", "metadata" : { "My Server Name" : "Apache1" diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.63/server-create-req.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.63/server-create-req.json.tpl index 7e2addb0fb5..fb4aabbf61f 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.63/server-create-req.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.63/server-create-req.json.tpl @@ -5,7 +5,7 @@ "name" : "%(name)s", "imageRef" : "%(image_id)s", "flavorRef" : "6", - "availability_zone": "nova", + "availability_zone": "us-west", "OS-DCF:diskConfig": "AUTO", "metadata" : { "My Server Name" : "Apache1" diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.63/server-get-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.63/server-get-resp.json.tpl index 88a533c0a4a..5dab6aa0e09 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.63/server-get-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.63/server-get-resp.json.tpl @@ -57,7 +57,7 @@ "name": "new-server-test", "config_drive": "%(cdrive)s", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "%(compute_host)s", "OS-EXT-SRV-ATTR:hostname": "%(hostname)s", "OS-EXT-SRV-ATTR:hypervisor_hostname": "%(hypervisor_hostname)s", diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.63/servers-details-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.63/servers-details-resp.json.tpl index f58a458ecb5..2a976163336 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.63/servers-details-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.63/servers-details-resp.json.tpl @@ -58,7 +58,7 @@ "name": "new-server-test", "config_drive": "%(cdrive)s", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "%(compute_host)s", "OS-EXT-SRV-ATTR:hostname": "%(hostname)s", "OS-EXT-SRV-ATTR:hypervisor_hostname": "%(hypervisor_hostname)s", diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.66/server-create-req.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.66/server-create-req.json.tpl index 7e2addb0fb5..dd887928cd1 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.66/server-create-req.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.66/server-create-req.json.tpl @@ -5,7 +5,7 @@ "name" : "%(name)s", "imageRef" : "%(image_id)s", "flavorRef" : "6", - "availability_zone": "nova", + "availability_zone": "%(availability_zone)s", "OS-DCF:diskConfig": "AUTO", "metadata" : { "My Server Name" : "Apache1" diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.66/servers-details-with-changes-before.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.66/servers-details-with-changes-before.json.tpl index a64e4c48b15..7cfb1ed2efc 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.66/servers-details-with-changes-before.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.66/servers-details-with-changes-before.json.tpl @@ -58,7 +58,7 @@ "name": "new-server-test", "config_drive": "%(cdrive)s", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "%(compute_host)s", "OS-EXT-SRV-ATTR:hostname": "%(hostname)s", "OS-EXT-SRV-ATTR:hypervisor_hostname": "%(hypervisor_hostname)s", diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.9/server-get-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.9/server-get-resp.json.tpl index 3bac1e253cc..635d3012a46 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.9/server-get-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.9/server-get-resp.json.tpl @@ -50,7 +50,7 @@ "name": "new-server-test", "config_drive": "", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "%(compute_host)s", "OS-EXT-SRV-ATTR:hypervisor_hostname": "%(hypervisor_hostname)s", "OS-EXT-SRV-ATTR:instance_name": "%(instance_name)s", diff --git a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.9/servers-details-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.9/servers-details-resp.json.tpl index 9ad567291fe..424968bbe0c 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/servers/v2.9/servers-details-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/servers/v2.9/servers-details-resp.json.tpl @@ -51,7 +51,7 @@ "name": "new-server-test", "config_drive": "", "OS-DCF:diskConfig": "AUTO", - "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-AZ:availability_zone": "us-west", "OS-EXT-SRV-ATTR:host": "%(compute_host)s", "OS-EXT-SRV-ATTR:hypervisor_hostname": "%(hypervisor_hostname)s", "OS-EXT-SRV-ATTR:instance_name": "%(instance_name)s", diff --git a/nova/tests/functional/api_sample_tests/test_availability_zone.py b/nova/tests/functional/api_sample_tests/test_availability_zone.py index 688ec4422d0..6e765bef838 100644 --- a/nova/tests/functional/api_sample_tests/test_availability_zone.py +++ b/nova/tests/functional/api_sample_tests/test_availability_zone.py @@ -19,6 +19,11 @@ class AvailabilityZoneJsonTest(test_servers.ServersSampleBase): ADMIN_API = True sample_dir = "os-availability-zone" + # Do not use the AvailabilityZoneFixture in the base class. + # TODO(mriedem): Make this more realistic by creating a "us-west" zone + # and putting the "compute" service host in it. + availability_zones = [] + def test_availability_zone_list(self): response = self._do_get('os-availability-zone') self._verify_response('availability-zone-list-resp', {}, response, 200) diff --git a/nova/tests/functional/api_sample_tests/test_servers.py b/nova/tests/functional/api_sample_tests/test_servers.py index 5532171a5ef..795c67a3601 100644 --- a/nova/tests/functional/api_sample_tests/test_servers.py +++ b/nova/tests/functional/api_sample_tests/test_servers.py @@ -74,6 +74,11 @@ def _post_server(self, use_common_server_api_samples=True, name=None, '-[0-9a-f]{4}-[0-9a-f]{12}', 'name': 'new-server-test' if name is None else name, } + # If the template is requesting an explicit availability zone and + # the test is setup to have AZs, use the first one in the list which + # should default to "us-west". + if self.availability_zones: + subs['availability_zone'] = self.availability_zones[0] if extra_subs: subs.update(extra_subs)