Fix cinder client initialization vimconn_openstack 71/14771/2 v14.0 v14.0.3
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Thu, 28 Nov 2024 16:46:13 +0000 (17:46 +0100)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Thu, 28 Nov 2024 21:19:45 +0000 (22:19 +0100)
This commit changes the setup of cinder client version, trying first
version v3 if the service exists, instead of the default client which
was v2.

Change-Id: I9c63a0d3a5fa44597d633cc5db79ae0a783c66ff
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py
releasenotes/notes/fix_cinder_client_initialization-802020147bc03b26.yaml [new file with mode: 0644]

index 2017d56..9f7499c 100644 (file)
@@ -314,17 +314,19 @@ class vimconnector(vimconn.VimConnector):
                 )
 
             sess = session.Session(auth=auth, verify=self.verify)
-            # addedd region_name to keystone, nova, neutron and cinder to support distributed cloud for Wind River
+            # added region_name to keystone, nova, neutron and cinder to support distributed cloud for Wind River
             # Titanium cloud and StarlingX
             region_name = self.config.get("region_name")
 
             if self.api_version3:
+                self.logger.debug(f"Using Keystone client v3 for VIM {self.id}")
                 self.keystone = ksClient_v3.Client(
                     session=sess,
                     endpoint_type=self.endpoint_type,
                     region_name=region_name,
                 )
             else:
+                self.logger.debug(f"Using Keystone client v2 for VIM {self.id}")
                 self.keystone = ksClient_v2.Client(
                     session=sess, endpoint_type=self.endpoint_type
                 )
@@ -356,7 +358,18 @@ class vimconnector(vimconn.VimConnector):
                 region_name=region_name,
             )
 
-            if sess.get_all_version_data(service_type="volumev2"):
+            if sess.get_all_version_data(service_type="volumev3"):
+                self.logger.debug(f"Using Cinder client v3 for VIM {self.id}")
+                self.cinder = self.session["cinder"] = cClient.Client(
+                    3,
+                    session=sess,
+                    endpoint_type=self.endpoint_type,
+                    region_name=region_name,
+                )
+            elif sess.get_all_version_data(service_type="volumev2"):
+                self.logger.debug(
+                    f"Service type volumev3 not found. Using Cinder client v2 for VIM {self.id}"
+                )
                 self.cinder = self.session["cinder"] = cClient.Client(
                     2,
                     session=sess,
@@ -364,6 +377,9 @@ class vimconnector(vimconn.VimConnector):
                     region_name=region_name,
                 )
             else:
+                self.logger.debug(
+                    f"Service type not found. Using Cinder client v3 for VIM {self.id}"
+                )
                 self.cinder = self.session["cinder"] = cClient.Client(
                     3,
                     session=sess,
diff --git a/releasenotes/notes/fix_cinder_client_initialization-802020147bc03b26.yaml b/releasenotes/notes/fix_cinder_client_initialization-802020147bc03b26.yaml
new file mode 100644 (file)
index 0000000..3111b95
--- /dev/null
@@ -0,0 +1,23 @@
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#######################################################################################
+---
+fixes:
+  - |
+    This commit changes the setup of cinder client version, trying first version
+    v3 if the service exists in Openstack, instead of the default client which
+    was v2. In that way, the highest available cinder client version will be used.
+