Merge "Add subnet_id option"
diff --git a/roles/run-tempest/README.rst b/roles/run-tempest/README.rst
index 1f7fb70..91b0b5f 100644
--- a/roles/run-tempest/README.rst
+++ b/roles/run-tempest/README.rst
@@ -20,14 +20,12 @@
    It works only when used with some specific tox environments
    ('all', 'all-plugin'.)
 
-   Multi-line and commented regexs can be achieved by doing this:
+   In the following example only api scenario and third party tests
+   will be executed.
 
        ::
            vars:
-             tempest_test_regex: |
-               (?x)    # Ignore comments and whitespaces
-               # Line with only a comment.
-               (tempest\.(api|scenario|thirdparty)).*$    # Run only api scenario and third party
+             tempest_test_regex: (tempest\.(api|scenario|thirdparty)).*$
 
 .. zuul:rolevar:: tempest_test_blacklist
 
@@ -48,14 +46,9 @@
    It works only when used with some specific tox environments
    ('all', 'all-plugin'.)
 
-   Multi-line and commented regexs can be achieved by doing this:
-
        ::
            vars:
-             tempest_black_regex: |
-               (?x)    # Ignore comments and whitespaces
-               # Line with only a comment.
-               (tempest.api.identity).*$
+             tempest_black_regex: (tempest.api.identity).*$
 
 .. zuul:rolevar:: tox_extra_args
    :default: ''
diff --git a/tempest/cmd/cleanup_service.py b/tempest/cmd/cleanup_service.py
index 5b3b72a..9b591bc 100644
--- a/tempest/cmd/cleanup_service.py
+++ b/tempest/cmd/cleanup_service.py
@@ -13,6 +13,7 @@
 #    under the License.
 
 from oslo_log import log as logging
+from six.moves.urllib import parse as urllib
 
 from tempest import clients
 from tempest.common import credentials_factory as credentials
@@ -833,7 +834,15 @@
 
     def list(self):
         client = self.client
-        images = client.list_images(params={"all_tenants": True})['images']
+        response = client.list_images()
+        images = []
+        images.extend(response['images'])
+        while 'next' in response:
+            parsed = urllib.urlparse(response['next'])
+            marker = urllib.parse_qs(parsed.query)['marker'][0]
+            response = client.list_images(params={"marker": marker})
+            images.extend(response['images'])
+
         if not self.is_save_state:
             images = [image for image in images if image['id']
                       not in self.saved_state_json['images'].keys()]
diff --git a/tempest/tests/lib/services/identity/v3/test_application_credentials_client.py b/tempest/tests/lib/services/identity/v3/test_application_credentials_client.py
index 2774c44..8aed7d7 100644
--- a/tempest/tests/lib/services/identity/v3/test_application_credentials_client.py
+++ b/tempest/tests/lib/services/identity/v3/test_application_credentials_client.py
@@ -20,78 +20,116 @@
 class TestApplicationCredentialsClient(base.BaseServiceTest):
     FAKE_CREATE_APP_CRED = {
         "application_credential": {
-            "description": "fake application credential",
+            "name": "monitoring",
+            "secret": "rEaqvJka48mpv",
+            "description": "Application credential for monitoring.",
+            "expires_at": "2018-02-27T18:30:59Z",
             "roles": [
+                {"name": "Reader"}
+            ],
+            "access_rules": [
                 {
-                    "id": "c60fdd45",
-                    "domain_id": None,
-                    "name": "Member"
+                    "path": "/v2.0/metrics",
+                    "method": "GET",
+                    "service": "monitoring"
                 }
             ],
-            "expires_at": "2019-02-27T18:30:59.999999Z",
-            "secret": "_BVq0xU5L",
-            "unrestricted": None,
-            "project_id": "ddef321",
-            "id": "5499a186",
-            "name": "one"
+            "unrestricted": False
         }
     }
 
     FAKE_LIST_APP_CREDS = {
+        "links": {
+            "self": "http://example.com/identity/v3/users/" +
+                    "fd786d56402c4d1691372e7dee0d00b5/application_credentials",
+            "previous": None,
+            "next": None
+        },
         "application_credentials": [
             {
-                "description": "fake application credential",
+                "description": "Application credential for backups.",
                 "roles": [
                     {
                         "domain_id": None,
-                        "name": "Member",
-                        "id": "c60fdd45",
+                        "name": "Writer",
+                        "id": "6aff702516544aeca22817fd3bc39683"
                     }
                 ],
-                "expires_at": "2018-02-27T18:30:59.999999Z",
-                "unrestricted": None,
-                "project_id": "ddef321",
-                "id": "5499a186",
-                "name": "one"
+                "access_rules": [
+                ],
+                "links": {
+                    "self": "http://example.com/identity/v3/users/" +
+                            "fd786d56402c4d1691372e7dee0d00b5/" +
+                            "application_credentials/" +
+                            "308a7e905eee4071aac5971744c061f6"
+                },
+                "expires_at": "2018-02-27T18:30:59.000000",
+                "unrestricted": False,
+                "project_id": "231c62fb0fbd485b995e8b060c3f0d98",
+                "id": "308a7e905eee4071aac5971744c061f6",
+                "name": "backups"
             },
             {
-                "description": None,
+                "description": "Application credential for monitoring.",
                 "roles": [
                     {
-                        "id": "0f1837c8",
+                        "id": "6aff702516544aeca22817fd3bc39683",
                         "domain_id": None,
-                        "name": "anotherrole"
-                    },
-                    {
-                        "id": "c60fdd45",
-                        "domain_id": None,
-                        "name": "Member"
+                        "name": "Reader"
                     }
                 ],
-                "expires_at": None,
-                "unrestricted": None,
-                "project_id": "c5403d938",
-                "id": "d441c904f",
-                "name": "two"
+                "access_rules": [
+                    {
+                        "path": "/v2.0/metrics",
+                        "id": "07d719df00f349ef8de77d542edf010c",
+                        "service": "monitoring",
+                        "method": "GET"
+                    }
+                ],
+                "links": {
+                    "self": "http://example.com/identity/v3/users/" +
+                            "fd786d56402c4d1691372e7dee0d00b5/" +
+                            "application_credentials/" +
+                            "58d61ff8e6e34accb35874016d1dba8b"
+                },
+                "expires_at": "2018-02-27T18:30:59.000000",
+                "unrestricted": False,
+                "project_id": "231c62fb0fbd485b995e8b060c3f0d98",
+                "id": "58d61ff8e6e34accb35874016d1dba8b",
+                "name": "monitoring"
             }
         ]
     }
 
     FAKE_APP_CRED_INFO = {
         "application_credential": {
-            "description": None,
+            "description": "Application credential for monitoring.",
             "roles": [
                 {
+                    "id": "6aff702516544aeca22817fd3bc39683",
                     "domain_id": None,
-                    "name": "Member",
-                    "id": "c60fdd45",
+                    "name": "Reader"
                 }
             ],
-            "expires_at": None,
-            "unrestricted": None,
-            "project_id": "ddef321",
-            "id": "5499a186",
-            "name": "one"
+            "access_rules": [
+                {
+                    "path": "/v2.0/metrics",
+                    "id": "07d719df00f349ef8de77d542edf010c",
+                    "service": "monitoring",
+                    "method": "GET"
+                }
+            ],
+            "links": {
+                "self": "http://example.com/identity/v3/users/" +
+                        "fd786d56402c4d1691372e7dee0d00b5/" +
+                        "application_credentials/" +
+                        "58d61ff8e6e34accb35874016d1dba8b"
+            },
+            "expires_at": "2018-02-27T18:30:59.000000",
+            "unrestricted": False,
+            "project_id": "231c62fb0fbd485b995e8b060c3f0d98",
+            "id": "58d61ff8e6e34accb35874016d1dba8b",
+            "name": "monitoring"
         }
     }
 
@@ -118,7 +156,7 @@
             self.FAKE_APP_CRED_INFO,
             bytes_body,
             user_id="123456",
-            application_credential_id="5499a186")
+            application_credential_id="58d61ff8e6e34accb35874016d1dba8b")
 
     def _test_list_app_creds(self, bytes_body=False):
         self.check_service_client_function(
@@ -152,5 +190,5 @@
             'tempest.lib.common.rest_client.RestClient.delete',
             {},
             user_id="123456",
-            application_credential_id="5499a186",
+            application_credential_id="58d61ff8e6e34accb35874016d1dba8b",
             status=204)