From f85896af2b044abc2c966f874414b38aae5b0d06 Mon Sep 17 00:00:00 2001
From: Ghanshyam Mann <gmann@ghanshyammann.com>
Date: Sun, 26 Jul 2020 17:37:51 -0500
Subject: [PATCH] [goal] Migrate python-cinderclient jobs to focal

As per victoria cycle testing runtime and community goal[1]
we need to migrate upstream CI/CD to Ubuntu Focal(20.04).

Fixing:
- bug#1886298
Bump the lower constraints for required deps which added python3.8 support
in their later version.
- pep8 error
- Set bionic nodeset for py36 and py37 job.


[1] https://governance.openstack.org/tc/goals/selected/victoria/migrate-ci-cd-jobs-to-ubuntu-fo$

Story: #2007865
Task: #40179

Change-Id: Ibab96807a7747738282732fe0069b9bc197da0ee
---
 .zuul.yaml                                     |  1 +
 cinderclient/client.py                         | 10 ++++++----
 cinderclient/shell.py                          |  9 +++++----
 cinderclient/tests/unit/fake_actions_module.py |  2 +-
 cinderclient/tests/unit/test_utils.py          |  2 +-
 cinderclient/v3/messages.py                    |  2 +-
 cinderclient/v3/volume_backups.py              |  4 ++--
 cinderclient/v3/volumes.py                     |  6 +++---
 lower-constraints.txt                          |  6 +++---
 9 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/.zuul.yaml b/.zuul.yaml
index 1f51c0481..68aef3297 100644
--- a/.zuul.yaml
+++ b/.zuul.yaml
@@ -16,6 +16,7 @@
 - job:
     name: python-cinderclient-functional-py36
     parent: python-cinderclient-functional-base
+    nodeset: openstack-single-node-bionic
     vars:
       python_version: 3.6
       tox_envlist: functional-py36
diff --git a/cinderclient/client.py b/cinderclient/client.py
index b013c1eb8..fdf1f363e 100644
--- a/cinderclient/client.py
+++ b/cinderclient/client.py
@@ -33,10 +33,6 @@ from keystoneauth1.identity import base
 from oslo_utils import encodeutils
 from oslo_utils import importutils
 from oslo_utils import strutils
-try:
-    osprofiler_web = importutils.try_import("osprofiler.web")
-except Exception:
-    pass
 import requests
 from six.moves import urllib
 import six.moves.urllib.parse as urlparse
@@ -56,6 +52,12 @@ try:
 except ImportError:
     import simplejson as json
 
+try:
+    osprofiler_web = importutils.try_import("osprofiler.web")
+except Exception:
+    pass
+
+
 _VALID_VERSIONS = ['v2', 'v3']
 V3_SERVICE_TYPE = 'volumev3'
 V2_SERVICE_TYPE = 'volumev2'
diff --git a/cinderclient/shell.py b/cinderclient/shell.py
index 09a55b811..de71bcfde 100644
--- a/cinderclient/shell.py
+++ b/cinderclient/shell.py
@@ -31,10 +31,6 @@ from keystoneauth1 import loading
 from keystoneauth1 import session
 from oslo_utils import encodeutils
 from oslo_utils import importutils
-try:
-    osprofiler_profiler = importutils.try_import("osprofiler.profiler")
-except Exception:
-    pass
 import requests
 import six
 import six.moves.urllib.parse as urlparse
@@ -46,6 +42,11 @@ from cinderclient import client
 from cinderclient import exceptions as exc
 from cinderclient import utils
 
+try:
+    osprofiler_profiler = importutils.try_import("osprofiler.profiler")
+except Exception:
+    pass
+
 
 DEFAULT_MAJOR_OS_VOLUME_API_VERSION = "3"
 DEFAULT_CINDER_ENDPOINT_TYPE = 'publicURL'
diff --git a/cinderclient/tests/unit/fake_actions_module.py b/cinderclient/tests/unit/fake_actions_module.py
index 5c023066d..07e7d29b4 100644
--- a/cinderclient/tests/unit/fake_actions_module.py
+++ b/cinderclient/tests/unit/fake_actions_module.py
@@ -27,7 +27,7 @@ def do_fake_action():
 
 
 @api_versions.wraps("3.2", "3.3")  # noqa: F811
-def do_fake_action():
+def do_fake_action():  # noqa
     return "fake_action 3.2 to 3.3"
 
 
diff --git a/cinderclient/tests/unit/test_utils.py b/cinderclient/tests/unit/test_utils.py
index 8b3b7a6e1..1243b0a62 100644
--- a/cinderclient/tests/unit/test_utils.py
+++ b/cinderclient/tests/unit/test_utils.py
@@ -72,7 +72,7 @@ class FakeManagerWithApi(base.Manager):
         return '3.1'
 
     @api_versions.wraps('3.2')  # noqa: F811
-    def return_api_version(self):
+    def return_api_version(self):  # noqa
         return '3.2'
 
 
diff --git a/cinderclient/v3/messages.py b/cinderclient/v3/messages.py
index 3dc538881..2c620c206 100644
--- a/cinderclient/v3/messages.py
+++ b/cinderclient/v3/messages.py
@@ -52,7 +52,7 @@ class MessageManager(base.ManagerWithFind):
         return self._list(url, resource_type)
 
     @api_versions.wraps('3.5')  # noqa: F811
-    def list(self, search_opts=None, marker=None, limit=None, sort=None):
+    def list(self, search_opts=None, marker=None, limit=None, sort=None):  # noqa
         """Lists all messages.
 
         :param search_opts: Search options to filter out volumes.
diff --git a/cinderclient/v3/volume_backups.py b/cinderclient/v3/volume_backups.py
index b07ecfb4c..7dd85603b 100644
--- a/cinderclient/v3/volume_backups.py
+++ b/cinderclient/v3/volume_backups.py
@@ -61,7 +61,7 @@ class VolumeBackupManager(volume_backups.VolumeBackupManager):
                                    incremental, force, snapshot_id)
 
     @api_versions.wraps("3.43")  # noqa: F811
-    def create(self, volume_id, container=None,
+    def create(self, volume_id, container=None,  # noqa
                name=None, description=None,
                incremental=False, force=False,
                snapshot_id=None,
@@ -85,7 +85,7 @@ class VolumeBackupManager(volume_backups.VolumeBackupManager):
                                    incremental, force, snapshot_id, metadata)
 
     @api_versions.wraps("3.51")  # noqa: F811
-    def create(self, volume_id, container=None, name=None, description=None,
+    def create(self, volume_id, container=None, name=None, description=None,  # noqa
                incremental=False, force=False, snapshot_id=None, metadata=None,
                availability_zone=None):
         return self._create_backup(volume_id, container, name, description,
diff --git a/cinderclient/v3/volumes.py b/cinderclient/v3/volumes.py
index fac5effce..974bcfcfe 100644
--- a/cinderclient/v3/volumes.py
+++ b/cinderclient/v3/volumes.py
@@ -160,7 +160,7 @@ class VolumeManager(volumes.VolumeManager):
         return common_base.ListWithMeta([], response_list)
 
     @api_versions.wraps("3.15")  # noqa: F811
-    def delete_metadata(self, volume, keys):
+    def delete_metadata(self, volume, keys):  # noqa
         """Delete specified keys from volumes metadata.
 
         :param volume: The :class:`Volume`.
@@ -191,7 +191,7 @@ class VolumeManager(volumes.VolumeManager):
                              'disk_format': disk_format})
 
     @api_versions.wraps("3.1")  # noqa: F811
-    def upload_to_image(self, volume, force, image_name, container_format,
+    def upload_to_image(self, volume, force, image_name, container_format,  # noqa
                         disk_format, visibility, protected):
         """Upload volume to image service as image.
         :param volume: The :class:`Volume` to upload.
@@ -265,7 +265,7 @@ class VolumeManager(volumes.VolumeManager):
         return self._get('/scheduler-stats/get_pools%s' % query_string, None)
 
     @api_versions.wraps("3.33")  # noqa: F811
-    def get_pools(self, detail, search_opts):
+    def get_pools(self, detail, search_opts):  # noqa
         """Show pool information for backends."""
         # pylint: disable=function-redefined
         options = {'detail': detail}
diff --git a/lower-constraints.txt b/lower-constraints.txt
index db75ae4ac..bd2915f75 100644
--- a/lower-constraints.txt
+++ b/lower-constraints.txt
@@ -1,9 +1,9 @@
 asn1crypto==0.23.0
-cffi==1.7.0
+cffi==1.14.0
 cliff==2.8.0
 cmd2==0.8.0
 coverage==4.0
-cryptography==2.1
+cryptography==2.7
 ddt==1.0.1
 debtcollector==1.2.0
 extras==1.0.0
@@ -39,7 +39,7 @@ python-dateutil==2.5.3
 python-mimeparse==1.6.0
 python-subunit==1.0.0
 pytz==2013.6
-PyYAML==3.12
+PyYAML==3.13
 reno==3.1.0
 requests-mock==1.2.0
 requests==2.14.2