From 1e379145023484e50bf60e57bb257dcd1fe53da5 Mon Sep 17 00:00:00 2001
From: hassanasghar <hassanasghar666@gmail.com>
Date: Thu, 7 Apr 2022 19:26:01 +0000
Subject: [PATCH] Fix share network create command with the AZ option

Previously, "share network create" command was trying to look up
the availability-zone provided by the user. However, this is not supported
by the AvailabilityZoneManager.

Drop the AZ lookup if the option is used and pass the user provided value
to the API.

Closes-Bug: 1962288
Change-Id: I3ec926122eed932caebcb31b9afd0f811f1f3c8e
---
 manilaclient/osc/v2/share_networks.py                         | 4 +---
 ...8-fixed-share-network-create-command-879dc3deca131ef9.yaml | 4 ++++
 2 files changed, 5 insertions(+), 3 deletions(-)
 create mode 100644 releasenotes/notes/bug-1962288-fixed-share-network-create-command-879dc3deca131ef9.yaml

diff --git a/manilaclient/osc/v2/share_networks.py b/manilaclient/osc/v2/share_networks.py
index d6a3f5ae3..ef15d1a8c 100644
--- a/manilaclient/osc/v2/share_networks.py
+++ b/manilaclient/osc/v2/share_networks.py
@@ -295,9 +295,7 @@ class CreateShareNetwork(command.ShowOne):
                 "Availability zone can be specified only with manila API "
                 "version >= 2.51")
         elif parsed_args.availability_zone:
-            availability_zone = oscutils.find_resource(
-                share_client.availability_zones,
-                parsed_args.availability_zone).name
+            availability_zone = parsed_args.availability_zone
 
         share_network = share_client.share_networks.create(
             name=parsed_args.name,
diff --git a/releasenotes/notes/bug-1962288-fixed-share-network-create-command-879dc3deca131ef9.yaml b/releasenotes/notes/bug-1962288-fixed-share-network-create-command-879dc3deca131ef9.yaml
new file mode 100644
index 000000000..f2a26cc3b
--- /dev/null
+++ b/releasenotes/notes/bug-1962288-fixed-share-network-create-command-879dc3deca131ef9.yaml
@@ -0,0 +1,4 @@
+fixes:
+  - |
+    Fixed the use of the "--availability-zone" option with the
+    "openstack share network create" command.