Merge "Add API reference for metering_label_rules_client"
diff --git a/tempest/api/compute/images/test_images.py b/tempest/api/compute/images/test_images.py
index c8221c2..7cf26fb 100644
--- a/tempest/api/compute/images/test_images.py
+++ b/tempest/api/compute/images/test_images.py
@@ -47,6 +47,10 @@
     def test_delete_saving_image(self):
         server = self.create_test_server(wait_until='ACTIVE')
         self.addCleanup(self.servers_client.delete_server, server['id'])
+        # wait for server active to avoid conflict when deleting server
+        # in task_state image_snapshot
+        self.addCleanup(waiters.wait_for_server_status, self.servers_client,
+                        server['id'], 'ACTIVE')
         image = self.create_image_from_server(server['id'],
                                               wait_until='SAVING')
         self.client.delete_image(image['id'])
diff --git a/tempest/scenario/test_network_advanced_server_ops.py b/tempest/scenario/test_network_advanced_server_ops.py
index 5f6dae8..f03e9de 100644
--- a/tempest/scenario/test_network_advanced_server_ops.py
+++ b/tempest/scenario/test_network_advanced_server_ops.py
@@ -200,7 +200,8 @@
             self.assertEqual(resize_flavor, server['flavor']['id'])
         else:
             flavor = self.flavors_client.show_flavor(resize_flavor)['flavor']
-            for key in ['original_name', 'ram', 'vcpus', 'disk']:
+            self.assertEqual(flavor['name'], server['original_name'])
+            for key in ['ram', 'vcpus', 'disk']:
                 self.assertEqual(flavor[key], server['flavor'][key])
         self._wait_server_status_and_check_network_connectivity(
             server, keypair, floating_ip)
diff --git a/tempest/tests/lib/services/volume/v3/test_group_types_client.py b/tempest/tests/lib/services/volume/v3/test_group_types_client.py
index a333b81..8b853d7 100644
--- a/tempest/tests/lib/services/volume/v3/test_group_types_client.py
+++ b/tempest/tests/lib/services/volume/v3/test_group_types_client.py
@@ -22,10 +22,13 @@
 class TestGroupTypesClient(base.BaseServiceTest):
     FAKE_CREATE_GROUP_TYPE = {
         "group_type": {
-            "name": "group-type-001",
-            "description": "Test group type 1",
-            "group_specs": {},
+            "id": "6685584b-1eac-4da6-b5c3-555430cf68ff",
+            "name": "grp-type-001",
+            "description": "group type 001",
             "is_public": True,
+            "group_specs": {
+                "consistent_group_snapshot_enabled": "<is> False"
+            }
         }
     }
 
@@ -35,7 +38,6 @@
             "name": "group-type-001",
             "description": "Test group type 1",
             "is_public": True,
-            "created_at": "20127-06-20T03:50:07Z",
             "group_specs": {},
         }
     }
@@ -57,24 +59,27 @@
                 "name": "group-type-001",
                 "description": "Test group type 1",
                 "is_public": True,
-                "created_at": "2017-06-20T03:50:07Z",
-                "group_specs": {},
+                "group_specs": {
+                    "consistent_group_snapshot_enabled": "<is> False"
+                }
             },
             {
                 "id": "e479997c-650b-40a4-9dfe-77655818b0d2",
                 "name": "group-type-002",
                 "description": "Test group type 2",
                 "is_public": True,
-                "created_at": "2017-06-19T01:52:47Z",
-                "group_specs": {},
+                "group_specs": {
+                    "consistent_group_snapshot_enabled": "<is> False"
+                }
             },
             {
                 "id": "c5c4769e-213c-40a6-a568-8e797bb691d4",
                 "name": "group-type-003",
                 "description": "Test group type 3",
                 "is_public": True,
-                "created_at": "2017-06-18T06:34:32Z",
-                "group_specs": {},
+                "group_specs": {
+                    "consistent_group_snapshot_enabled": "<is> False"
+                }
             }
         ]
     }
@@ -140,15 +145,12 @@
 
     def _test_update_group_types(self, bytes_body=False):
         resp_body = copy.deepcopy(self.FAKE_INFO_GROUP_TYPE)
-        resp_body['group_type'].pop('created_at')
-
         self.check_service_client_function(
             self.client.update_group_type,
             'tempest.lib.common.rest_client.RestClient.put',
             resp_body,
             bytes_body,
-            group_type_id="3fbbcccf-d058-4502-8844-6feeffdf4cb5",
-            name='updated-group-type-name')
+            group_type_id="3fbbcccf-d058-4502-8844-6feeffdf4cb5")
 
     def _test_create_or_update_group_type_specs(self, bytes_body=False):
         group_specs = self.FAKE_CREATE_GROUP_TYPE_SPECS['group_specs']
diff --git a/tools/generate-tempest-plugins-list.py b/tools/generate-tempest-plugins-list.py
index f1003a0..165af45 100644
--- a/tools/generate-tempest-plugins-list.py
+++ b/tools/generate-tempest-plugins-list.py
@@ -27,14 +27,8 @@
 import re
 import sys
 
-try:
-    # For Python 3.0 and later
-    from urllib.error import HTTPError
-    import urllib.request as urllib
-except ImportError:
-    # Fall back to Python 2's urllib2
-    import urllib2 as urllib
-    from urllib2 import HTTPError
+import urllib3
+from urllib3.util import retry
 
 # List of projects having tempest plugin stale or unmaintained for a long time
 # (6 months or more)
@@ -69,23 +63,21 @@
   },
 '''
 
+http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED')
+retries = retry.Retry(status_forcelist=[500], backoff_factor=1.0)
 
-# Rather than returning a 404 for a nonexistent file, cgit delivers a
-# 0-byte response to a GET request.  It also does not provide a
-# Content-Length in a HEAD response, so the way we tell if a file exists
-# is to check the length of the entire GET response body.
+
 def has_tempest_plugin(proj):
     try:
-        r = urllib.urlopen(
-            "https://opendev.org/%s/raw/branch/"
-            "master/setup.cfg" % proj)
-    except HTTPError as err:
-        if err.code == 404:
+        r = http.request('GET', "https://opendev.org/%s/raw/branch/"
+                         "master/setup.cfg" % proj, retries=retries)
+        if r.status == 404:
             return False
+    except urllib3.exceptions.MaxRetryError as err:
         # We should not ignore non 404 errors.
         raise err
     p = re.compile(r'^tempest\.test_plugins', re.M)
-    if p.findall(r.read().decode('utf-8')):
+    if p.findall(r.data.decode('utf-8')):
         return True
     else:
         False
@@ -98,11 +90,11 @@
     # So, this exits here.
     sys.exit()
 
-r = urllib.urlopen(url)
+r = http.request('GET', url, retries=retries)
 # Gerrit prepends 4 garbage octets to the JSON, in order to counter
 # cross-site scripting attacks.  Therefore we must discard it so the
 # json library won't choke.
-content = r.read().decode('utf-8')[4:]
+content = r.data.decode('utf-8')[4:]
 projects = sorted(json.loads(content))
 
 # Retrieve projects having no deployment tool repo (such as deb,
diff --git a/tools/verify-ipv6-only-deployments.sh b/tools/verify-ipv6-only-deployments.sh
index 90807a3..2596395 100755
--- a/tools/verify-ipv6-only-deployments.sh
+++ b/tools/verify-ipv6-only-deployments.sh
@@ -15,10 +15,14 @@
 source $TOP_DIR/openrc admin admin
 
 function verify_devstack_ipv6_setting {
-    local _service_host=$(echo $SERVICE_HOST | tr -d [])
-    local _host_ipv6=$(echo $HOST_IPV6 | tr -d [])
-    local _service_listen_address=$(echo $SERVICE_LISTEN_ADDRESS | tr -d [])
-    local _service_local_host=$(echo $SERVICE_LOCAL_HOST | tr -d [])
+    local _service_host=''
+    _service_host=$(echo $SERVICE_HOST | tr -d [])
+    local _host_ipv6=''
+    _host_ipv6=$(echo $HOST_IPV6 | tr -d [])
+    local _service_listen_address=''
+    _service_listen_address=$(echo $SERVICE_LISTEN_ADDRESS | tr -d [])
+    local _service_local_host=''
+    _service_local_host=$(echo $SERVICE_LOCAL_HOST | tr -d [])
     if [[ "$SERVICE_IP_VERSION" != 6 ]]; then
         echo $SERVICE_IP_VERSION "SERVICE_IP_VERSION is not set to 6 which is must for devstack to deploy services with IPv6 address."
         exit 1
@@ -61,9 +65,11 @@
     local all_ipv6=True
     endpoints=$(openstack endpoint list -f value -c URL)
     for endpoint in ${endpoints}; do
-        local endpoint_address=$(echo "$endpoint" | awk -F/ '{print $3}' | awk -F] '{print $1}')
+        local endpoint_address=''
+        endpoint_address=$(echo "$endpoint" | awk -F/ '{print $3}' | awk -F] '{print $1}')
         endpoint_address=$(echo $endpoint_address | tr -d [])
-        local is_endpoint_ipv6=$(python3 -c 'import oslo_utils.netutils as nutils; print(nutils.is_valid_ipv6("'$endpoint_address'"))')
+        local is_endpoint_ipv6=''
+        is_endpoint_ipv6=$(python3 -c 'import oslo_utils.netutils as nutils; print(nutils.is_valid_ipv6("'$endpoint_address'"))')
         if [[ "$is_endpoint_ipv6" != "True" ]]; then
             all_ipv6=False
             echo $endpoint ": This is not ipv6 endpoint which means corresponding service is not listening on IPv6 address."
diff --git a/tox.ini b/tox.ini
index b6ea143..ca4bb3f 100644
--- a/tox.ini
+++ b/tox.ini
@@ -327,7 +327,7 @@
          -not \( -type d -name .?\* -prune \) \
          -type f                              \
          -name \*.sh                          \
-         -print0 | xargs -0 bashate -v"
+         -print0 | xargs -0 bashate -v -eE005,E042 -i E006"
 
 [testenv:pip-check-reqs]
 # Do not install test-requirements as that will pollute the virtualenv for