From d8d7acff96990df4c5fbbbd5e1bb5cf000cb119f Mon Sep 17 00:00:00 2001 From: morozovalekseywot Date: Wed, 15 May 2024 19:50:33 +0300 Subject: [PATCH] Don't set availability_zone for 2.32 version of api Closes-Bug: #2065769 Change-Id: Id0c7dc63e6dca5d32cf1cf8983588d44601b4338 (cherry picked from commit ae363bdf089831685ca963a829514ebfb69c640e) (cherry picked from commit 2db76103b64e00a898d40b410a4155b88c047ceb) --- manilaclient/osc/v2/share_networks.py | 17 ++++++++++------- .../tests/unit/osc/v2/test_share_networks.py | 3 +-- ...x-share-network-create-fa76f38f1b640001.yaml | 7 +++++++ 3 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 releasenotes/notes/bug-2065769-fix-share-network-create-fa76f38f1b640001.yaml diff --git a/manilaclient/osc/v2/share_networks.py b/manilaclient/osc/v2/share_networks.py index 556f2ac48..a99a43a68 100644 --- a/manilaclient/osc/v2/share_networks.py +++ b/manilaclient/osc/v2/share_networks.py @@ -308,13 +308,16 @@ class CreateShareNetwork(command.ShowOne): elif parsed_args.availability_zone: availability_zone = parsed_args.availability_zone - share_network = share_client.share_networks.create( - name=parsed_args.name, - description=parsed_args.description, - neutron_net_id=parsed_args.neutron_net_id, - neutron_subnet_id=parsed_args.neutron_subnet_id, - availability_zone=availability_zone, - ) + kwargs = { + "name": parsed_args.name, + "description": parsed_args.description, + "neutron_net_id": parsed_args.neutron_net_id, + "neutron_subnet_id": parsed_args.neutron_subnet_id, + } + if availability_zone: + kwargs['availability_zone'] = availability_zone + share_network = share_client.share_networks.create(**kwargs) + share_network_data = share_network._info share_network_data.pop('links', None) if parsed_args.formatter == 'table': diff --git a/manilaclient/tests/unit/osc/v2/test_share_networks.py b/manilaclient/tests/unit/osc/v2/test_share_networks.py index b3da45c38..a66efb7ab 100644 --- a/manilaclient/tests/unit/osc/v2/test_share_networks.py +++ b/manilaclient/tests/unit/osc/v2/test_share_networks.py @@ -79,8 +79,7 @@ class TestShareNetworkCreate(TestShareNetwork): name=None, description=None, neutron_net_id=None, - neutron_subnet_id=None, - availability_zone=None) + neutron_subnet_id=None) self.assertCountEqual(self.columns, columns) self.assertCountEqual(expected_data.values(), data) diff --git a/releasenotes/notes/bug-2065769-fix-share-network-create-fa76f38f1b640001.yaml b/releasenotes/notes/bug-2065769-fix-share-network-create-fa76f38f1b640001.yaml new file mode 100644 index 000000000..4bd6a83bd --- /dev/null +++ b/releasenotes/notes/bug-2065769-fix-share-network-create-fa76f38f1b640001.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Share network create command failed with 2.32 version of api, due to set + availability zone argument for old version of create function, which doesn't have + this argument. The bug was fixed by adding a check that the user set the + availability zone in query.