diff options
| author | Richard Theis <rtheis@us.ibm.com> | 2016-01-15 15:23:08 -0600 |
|---|---|---|
| committer | Richard Theis <rtheis@us.ibm.com> | 2016-02-02 08:08:25 -0600 |
| commit | 4d332defbc4231f77b7459d4abda88a36a65d37d (patch) | |
| tree | 5690f01cd067e1ecea8117b4e38180f95d884705 /openstackclient/tests/network | |
| parent | f36177ebdd4ea25028337efaf667c23d62e3bf9e (diff) | |
| download | python-openstackclient-4d332defbc4231f77b7459d4abda88a36a65d37d.tar.gz | |
Support listing network availability zones
Update the "os availability zone list" command to support listing
network availability zones along with the currently listed compute
and volume availability zones. This adds the --network option to
the command in order to only list network availability zones. By
default, all availability zones are listed. The --long option
was also updated to include a "Zone Resource" column which is
applicable to network availability zones. Example zone resources
include "network" and "router".
If the Network API does not support listing availability zones
then a warning message will be issued when the --network option
is specified.
This support requires an updated release of the SDK in order
to pull in [1].
[1] https://bugs.launchpad.net/python-openstacksdk/+bug/1532274
Change-Id: I78811d659b793d9d2111ea54665d5fe7e4887264
Closes-Bug: #1534202
Diffstat (limited to 'openstackclient/tests/network')
| -rw-r--r-- | openstackclient/tests/network/v2/fakes.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/openstackclient/tests/network/v2/fakes.py b/openstackclient/tests/network/v2/fakes.py index 4c862bd3..6f03d797 100644 --- a/openstackclient/tests/network/v2/fakes.py +++ b/openstackclient/tests/network/v2/fakes.py @@ -69,6 +69,59 @@ class TestNetworkV2(utils.TestCommand): ) +class FakeAvailabilityZone(object): + """Fake one or more network availability zones (AZs).""" + + @staticmethod + def create_one_availability_zone(attrs={}, methods={}): + """Create a fake AZ. + + :param Dictionary attrs: + A dictionary with all attributes + :param Dictionary methods: + A dictionary with all methods + :return: + A FakeResource object with name, state, etc. + """ + # Set default attributes. + availability_zone = { + 'name': uuid.uuid4().hex, + 'state': 'available', + 'resource': 'network', + } + + # Overwrite default attributes. + availability_zone.update(attrs) + + availability_zone = fakes.FakeResource( + info=copy.deepcopy(availability_zone), + methods=methods, + loaded=True) + return availability_zone + + @staticmethod + def create_availability_zones(attrs={}, methods={}, count=2): + """Create multiple fake AZs. + + :param Dictionary attrs: + A dictionary with all attributes + :param Dictionary methods: + A dictionary with all methods + :param int count: + The number of AZs to fake + :return: + A list of FakeResource objects faking the AZs + """ + availability_zones = [] + for i in range(0, count): + availability_zone = \ + FakeAvailabilityZone.create_one_availability_zone( + attrs, methods) + availability_zones.append(availability_zone) + + return availability_zones + + class FakeNetwork(object): """Fake one or more networks.""" |
