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.