Skip to content

Commit 1241e3e

Browse files
committed
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
1 parent 68d4cb4 commit 1241e3e

File tree

65 files changed

+137
-138
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+137
-138
lines changed

api-ref/source/os-availability-zone.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.. -*- rst -*-
22
3+
.. _os-availability-zone:
4+
35
===========================================
46
Availability zones (os-availability-zone)
57
===========================================

api-ref/source/parameters.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4842,18 +4842,21 @@ os-availability-zone:availability_zone:
48424842
want your instance to be built. Typically, an admin user will use
48434843
availability zones to arrange OpenStack compute hosts into logical
48444844
groups.
4845+
48454846
An availability zone provides a form of physical isolation and redundancy from
48464847
other availability zones. For instance, if some racks in your data center are
48474848
on a separate power source, you can put servers in those racks in their own availability
48484849
zone. Availability zones can also help separate different classes of hardware. By
48494850
segregating resources into availability zones, you can ensure that your application
48504851
resources are spread across disparate machines to achieve high availability in
4851-
the event of hardware or other failure.
4852+
the event of hardware or other failure. See
4853+
`Availability Zones (AZs) <https://docs.openstack.org/nova/latest/user/aggregates.html#availability-zones-azs>`_ for more information.
4854+
48524855
You can list the available availability zones by calling the
4853-
os-availability-zone API, but you should avoid using the default
4854-
availability zone when booting the instance. In general, the
4855-
default availability zone is named ``nova``. This AZ is only shown
4856-
when listing the availability zones as an admin.
4856+
:ref:`os-availability-zone` API, but you should avoid using the `default
4857+
availability zone <https://docs.openstack.org/nova/latest/configuration/config.html#DEFAULT.default_availability_zone>`_
4858+
when creating the server. The default availability zone is named ``nova``.
4859+
This AZ is only shown when listing the availability zones as an admin.
48574860
in: body
48584861
required: false
48594862
type: string

doc/api_samples/os-availability-zone/availability-zone-post-req.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

doc/api_samples/os-availability-zone/availability-zone-post-resp.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

doc/api_samples/os-rescue/server-get-resp-rescue.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"user_id": "fake",
5555
"config_drive": "",
5656
"OS-DCF:diskConfig": "AUTO",
57-
"OS-EXT-AZ:availability_zone": "nova",
57+
"OS-EXT-AZ:availability_zone": "us-west",
5858
"OS-EXT-SRV-ATTR:host": "b8b357f7100d4391828f2177c922ef93",
5959
"OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini",
6060
"OS-EXT-SRV-ATTR:instance_name": "instance-00000001",

doc/api_samples/os-rescue/server-get-resp-unrescue.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"user_id": "fake",
5656
"config_drive": "",
5757
"OS-DCF:diskConfig": "AUTO",
58-
"OS-EXT-AZ:availability_zone": "nova",
58+
"OS-EXT-AZ:availability_zone": "us-west",
5959
"OS-EXT-SRV-ATTR:host": "b8b357f7100d4391828f2177c922ef93",
6060
"OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini",
6161
"OS-EXT-SRV-ATTR:instance_name": "instance-00000001",

doc/api_samples/os-server-tags/v2.26/server-tags-show-details-resp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"description": null,
5959
"config_drive": "",
6060
"OS-DCF:diskConfig": "AUTO",
61-
"OS-EXT-AZ:availability_zone": "nova",
61+
"OS-EXT-AZ:availability_zone": "us-west",
6262
"OS-EXT-SRV-ATTR:host": "b8b357f7100d4391828f2177c922ef93",
6363
"OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini",
6464
"OS-EXT-SRV-ATTR:instance_name": "instance-00000001",

doc/api_samples/os-server-tags/v2.26/servers-tags-details-resp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"description": null,
6060
"config_drive": "",
6161
"OS-DCF:diskConfig": "AUTO",
62-
"OS-EXT-AZ:availability_zone": "nova",
62+
"OS-EXT-AZ:availability_zone": "us-west",
6363
"OS-EXT-SRV-ATTR:host": "c3f14e9812ad496baf92ccfb3c61e15f",
6464
"OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini",
6565
"OS-EXT-SRV-ATTR:instance_name": "instance-00000001",

doc/api_samples/servers/server-create-req-v237.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name" : "new-server-test",
66
"imageRef" : "70a599e0-31e7-49b7-b260-868f441e862b",
77
"flavorRef" : "1",
8-
"availability_zone": "nova",
8+
"availability_zone": "us-west",
99
"OS-DCF:diskConfig": "AUTO",
1010
"metadata" : {
1111
"My Server Name" : "Apache1"

doc/api_samples/servers/server-create-req-v257.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name" : "new-server-test",
66
"imageRef" : "70a599e0-31e7-49b7-b260-868f441e862b",
77
"flavorRef" : "http://openstack.example.com/flavors/1",
8-
"availability_zone": "nova",
8+
"availability_zone": "us-west",
99
"OS-DCF:diskConfig": "AUTO",
1010
"metadata" : {
1111
"My Server Name" : "Apache1"

doc/api_samples/servers/server-create-req.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name" : "new-server-test",
66
"imageRef" : "70a599e0-31e7-49b7-b260-868f441e862b",
77
"flavorRef" : "1",
8-
"availability_zone": "nova",
8+
"availability_zone": "us-west",
99
"OS-DCF:diskConfig": "AUTO",
1010
"metadata" : {
1111
"My Server Name" : "Apache1"

doc/api_samples/servers/server-get-resp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"name": "new-server-test",
5151
"config_drive": "",
5252
"OS-DCF:diskConfig": "AUTO",
53-
"OS-EXT-AZ:availability_zone": "nova",
53+
"OS-EXT-AZ:availability_zone": "us-west",
5454
"OS-EXT-SRV-ATTR:host": "b8b357f7100d4391828f2177c922ef93",
5555
"OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini",
5656
"OS-EXT-SRV-ATTR:instance_name": "instance-00000001",

doc/api_samples/servers/servers-details-resp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"name": "new-server-test",
5252
"config_drive": "",
5353
"OS-DCF:diskConfig": "AUTO",
54-
"OS-EXT-AZ:availability_zone": "nova",
54+
"OS-EXT-AZ:availability_zone": "us-west",
5555
"OS-EXT-SRV-ATTR:host": "c3f14e9812ad496baf92ccfb3c61e15f",
5656
"OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini",
5757
"OS-EXT-SRV-ATTR:instance_name": "instance-00000001",

doc/api_samples/servers/v2.16/server-get-resp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"name": "new-server-test",
4949
"config_drive": "",
5050
"OS-DCF:diskConfig": "AUTO",
51-
"OS-EXT-AZ:availability_zone": "nova",
51+
"OS-EXT-AZ:availability_zone": "us-west",
5252
"OS-EXT-SRV-ATTR:host": "c5f474bf81474f9dbbc404d5b2e4e9b3",
5353
"OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini",
5454
"OS-EXT-SRV-ATTR:instance_name": "instance-00000001",

doc/api_samples/servers/v2.16/servers-details-resp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"name": "new-server-test",
5050
"config_drive": "",
5151
"OS-DCF:diskConfig": "AUTO",
52-
"OS-EXT-AZ:availability_zone": "nova",
52+
"OS-EXT-AZ:availability_zone": "us-west",
5353
"OS-EXT-SRV-ATTR:host": "bc8efe4fdb7148a4bb921a2b03d17de6",
5454
"OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini",
5555
"OS-EXT-SRV-ATTR:instance_name": "instance-00000001",

doc/api_samples/servers/v2.3/server-get-resp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"name": "new-server-test",
5151
"config_drive": "",
5252
"OS-DCF:diskConfig": "AUTO",
53-
"OS-EXT-AZ:availability_zone": "nova",
53+
"OS-EXT-AZ:availability_zone": "us-west",
5454
"OS-EXT-SRV-ATTR:host": "b8b357f7100d4391828f2177c922ef93",
5555
"OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini",
5656
"OS-EXT-SRV-ATTR:instance_name": "instance-00000001",

doc/api_samples/servers/v2.3/servers-details-resp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"name": "new-server-test",
5252
"config_drive": "",
5353
"OS-DCF:diskConfig": "AUTO",
54-
"OS-EXT-AZ:availability_zone": "nova",
54+
"OS-EXT-AZ:availability_zone": "us-west",
5555
"OS-EXT-SRV-ATTR:host": "c3f14e9812ad496baf92ccfb3c61e15f",
5656
"OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini",
5757
"OS-EXT-SRV-ATTR:instance_name": "instance-00000001",

doc/api_samples/servers/v2.47/server-create-req.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name" : "new-server-test",
66
"imageRef" : "70a599e0-31e7-49b7-b260-868f441e862b",
77
"flavorRef" : "6",
8-
"availability_zone": "nova",
8+
"availability_zone": "us-west",
99
"OS-DCF:diskConfig": "AUTO",
1010
"metadata" : {
1111
"My Server Name" : "Apache1"

doc/api_samples/servers/v2.47/server-get-resp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"server": {
33
"OS-DCF:diskConfig": "AUTO",
4-
"OS-EXT-AZ:availability_zone": "nova",
4+
"OS-EXT-AZ:availability_zone": "us-west",
55
"OS-EXT-SRV-ATTR:host": "compute",
66
"OS-EXT-SRV-ATTR:hostname": "new-server-test",
77
"OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini",

doc/api_samples/servers/v2.47/servers-details-resp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"servers": [
33
{
44
"OS-DCF:diskConfig": "AUTO",
5-
"OS-EXT-AZ:availability_zone": "nova",
5+
"OS-EXT-AZ:availability_zone": "us-west",
66
"OS-EXT-SRV-ATTR:host": "compute",
77
"OS-EXT-SRV-ATTR:hostname": "new-server-test",
88
"OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini",

doc/api_samples/servers/v2.52/server-create-req.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name" : "new-server-test",
66
"imageRef" : "70a599e0-31e7-49b7-b260-868f441e862b",
77
"flavorRef" : "http://openstack.example.com/flavors/1",
8-
"availability_zone": "nova",
8+
"availability_zone": "us-west",
99
"OS-DCF:diskConfig": "AUTO",
1010
"metadata" : {
1111
"My Server Name" : "Apache1"

doc/api_samples/servers/v2.52/server-get-resp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"server": {
33
"OS-DCF:diskConfig": "AUTO",
4-
"OS-EXT-AZ:availability_zone": "nova",
4+
"OS-EXT-AZ:availability_zone": "us-west",
55
"OS-EXT-SRV-ATTR:host": "compute",
66
"OS-EXT-SRV-ATTR:hostname": "new-server-test",
77
"OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini",

doc/api_samples/servers/v2.52/servers-details-resp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"servers": [
33
{
44
"OS-DCF:diskConfig": "AUTO",
5-
"OS-EXT-AZ:availability_zone": "nova",
5+
"OS-EXT-AZ:availability_zone": "us-west",
66
"OS-EXT-SRV-ATTR:host": "compute",
77
"OS-EXT-SRV-ATTR:hostname": "new-server-test",
88
"OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini",

doc/api_samples/servers/v2.57/server-create-req.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name" : "new-server-test",
66
"imageRef" : "70a599e0-31e7-49b7-b260-868f441e862b",
77
"flavorRef" : "http://openstack.example.com/flavors/1",
8-
"availability_zone": "nova",
8+
"availability_zone": "us-west",
99
"OS-DCF:diskConfig": "AUTO",
1010
"metadata" : {
1111
"My Server Name" : "Apache1"

doc/api_samples/servers/v2.63/server-create-req.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name" : "new-server-test",
66
"imageRef" : "70a599e0-31e7-49b7-b260-868f441e862b",
77
"flavorRef" : "6",
8-
"availability_zone": "nova",
8+
"availability_zone": "%(availability_zone)s",
99
"OS-DCF:diskConfig": "AUTO",
1010
"metadata" : {
1111
"My Server Name" : "Apache1"

doc/api_samples/servers/v2.63/server-get-resp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"server": {
33
"OS-DCF:diskConfig": "AUTO",
4-
"OS-EXT-AZ:availability_zone": "nova",
4+
"OS-EXT-AZ:availability_zone": "us-west",
55
"OS-EXT-SRV-ATTR:host": "compute",
66
"OS-EXT-SRV-ATTR:hostname": "new-server-test",
77
"OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini",

doc/api_samples/servers/v2.63/servers-details-resp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"servers": [
33
{
44
"OS-DCF:diskConfig": "AUTO",
5-
"OS-EXT-AZ:availability_zone": "nova",
5+
"OS-EXT-AZ:availability_zone": "us-west",
66
"OS-EXT-SRV-ATTR:host": "compute",
77
"OS-EXT-SRV-ATTR:hostname": "new-server-test",
88
"OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini",

doc/api_samples/servers/v2.66/server-create-req.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name" : "new-server-test",
66
"imageRef" : "70a599e0-31e7-49b7-b260-868f441e862b",
77
"flavorRef" : "6",
8-
"availability_zone": "nova",
8+
"availability_zone": "us-west",
99
"OS-DCF:diskConfig": "AUTO",
1010
"metadata" : {
1111
"My Server Name" : "Apache1"

doc/api_samples/servers/v2.66/servers-details-with-changes-before.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"servers": [
33
{
44
"OS-DCF:diskConfig": "AUTO",
5-
"OS-EXT-AZ:availability_zone": "nova",
5+
"OS-EXT-AZ:availability_zone": "us-west",
66
"OS-EXT-SRV-ATTR:host": "compute",
77
"OS-EXT-SRV-ATTR:hostname": "new-server-test",
88
"OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini",

doc/api_samples/servers/v2.9/server-get-resp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"name": "new-server-test",
5151
"config_drive": "",
5252
"OS-DCF:diskConfig": "AUTO",
53-
"OS-EXT-AZ:availability_zone": "nova",
53+
"OS-EXT-AZ:availability_zone": "us-west",
5454
"OS-EXT-SRV-ATTR:host": "b8b357f7100d4391828f2177c922ef93",
5555
"OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini",
5656
"OS-EXT-SRV-ATTR:instance_name": "instance-00000001",

doc/api_samples/servers/v2.9/servers-details-resp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"name": "new-server-test",
5252
"config_drive": "",
5353
"OS-DCF:diskConfig": "AUTO",
54-
"OS-EXT-AZ:availability_zone": "nova",
54+
"OS-EXT-AZ:availability_zone": "us-west",
5555
"OS-EXT-SRV-ATTR:host": "c3f14e9812ad496baf92ccfb3c61e15f",
5656
"OS-EXT-SRV-ATTR:hypervisor_hostname": "fake-mini",
5757
"OS-EXT-SRV-ATTR:instance_name": "instance-00000001",

doc/source/user/aggregates.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ between aggregates and availability zones:
5050
availability zone
5151
- by default a host is part of a default availability zone even if it doesn't
5252
belong to an aggregate (the configuration option is named
53-
``default_availability_zone``)
53+
:oslo.config:option:`default_availability_zone`)
5454

5555
.. warning:: That last rule can be very error-prone. Since the user can see the
5656
list of availability zones, they have no way to know whether the default

nova/tests/fixtures.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,3 +2117,44 @@ def stub_target_cell(ctxt, cell_mapping):
21172117
'nova.context.scatter_gather_cells', stub_scatter_gather_cells))
21182118
self.useFixture(fixtures.MonkeyPatch(
21192119
'nova.context.target_cell', stub_target_cell))
2120+
2121+
2122+
class AvailabilityZoneFixture(fixtures.Fixture):
2123+
"""Fixture to stub out the nova.availability_zones module
2124+
2125+
The list of ``zones`` provided to the fixture are what get returned from
2126+
``get_availability_zones``.
2127+
2128+
``get_instance_availability_zone`` will return the availability_zone
2129+
requested when creating a server otherwise the instance.availabilty_zone
2130+
or default_availability_zone is returned.
2131+
"""
2132+
def __init__(self, zones):
2133+
self.zones = zones
2134+
2135+
def setUp(self):
2136+
super(AvailabilityZoneFixture, self).setUp()
2137+
2138+
def fake_get_availability_zones(
2139+
ctxt, get_only_available=False, with_hosts=False):
2140+
# A 2-item tuple is returned if get_only_available=False.
2141+
if not get_only_available:
2142+
return self.zones, []
2143+
return self.zones
2144+
self.useFixture(fixtures.MonkeyPatch(
2145+
'nova.availability_zones.get_availability_zones',
2146+
fake_get_availability_zones))
2147+
2148+
def fake_get_instance_availability_zone(ctxt, instance):
2149+
# If the server was created with a specific AZ, return it.
2150+
reqspec = objects.RequestSpec.get_by_instance_uuid(
2151+
ctxt, instance.uuid)
2152+
requested_az = reqspec.availability_zone
2153+
if requested_az:
2154+
return requested_az
2155+
# Otherwise return the instance.availability_zone if set else
2156+
# the default AZ.
2157+
return instance.availability_zone or CONF.default_availability_zone
2158+
self.useFixture(fixtures.MonkeyPatch(
2159+
'nova.availability_zones.get_instance_availability_zone',
2160+
fake_get_instance_availability_zone))

0 commit comments

Comments
 (0)