Merge "Separate negative tests  api/network/security_groups"
diff --git a/tempest/api/compute/admin/test_quotas.py b/tempest/api/compute/admin/test_quotas.py
index e744200..757dfc0 100644
--- a/tempest/api/compute/admin/test_quotas.py
+++ b/tempest/api/compute/admin/test_quotas.py
@@ -17,8 +17,10 @@
 
 from tempest.api.compute import base
 from tempest.common.utils.data_utils import rand_name
+from tempest import config
 from tempest import exceptions
 from tempest.test import attr
+from tempest.test import skip_because
 
 
 class QuotasAdminTestJSON(base.BaseComputeAdminTest):
@@ -158,6 +160,8 @@
                         instances=default_instances_quota)
         self.assertRaises(exceptions.OverLimit, self.create_server)
 
+    @skip_because(bug="1186354",
+                  condition=config.TempestConfig().service_available.neutron)
     @attr(type=['negative', 'gate'])
     def test_security_groups_exceed_limit(self):
         # Negative test: Creation Security Groups over limit should FAIL
@@ -180,6 +184,8 @@
                           self.sg_client.create_security_group,
                           "sg-overlimit", "sg-desc")
 
+    @skip_because(bug="1186354",
+                  condition=config.TempestConfig().service_available.neutron)
     @attr(type=['negative', 'gate'])
     def test_security_groups_rules_exceed_limit(self):
         # Negative test: Creation of Security Group Rules should FAIL
diff --git a/tempest/api/compute/floating_ips/test_floating_ips_actions.py b/tempest/api/compute/floating_ips/test_floating_ips_actions.py
index b747b46..a5a361e 100644
--- a/tempest/api/compute/floating_ips/test_floating_ips_actions.py
+++ b/tempest/api/compute/floating_ips/test_floating_ips_actions.py
@@ -15,8 +15,10 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+import uuid
+
 from tempest.api.compute import base
-from tempest.common.utils.data_utils import rand_name
+from tempest.common.utils import data_utils
 from tempest import exceptions
 from tempest.test import attr
 
@@ -46,7 +48,9 @@
         for i in range(len(body)):
             cls.floating_ip_ids.append(body[i]['id'])
         while True:
-            cls.non_exist_id = rand_name('999')
+            cls.non_exist_id = data_utils.rand_int_id(start=999)
+            if cls.config.service_available.neutron:
+                cls.non_exist_id = str(uuid.uuid4())
             if cls.non_exist_id not in cls.floating_ip_ids:
                 break
 
diff --git a/tempest/api/compute/floating_ips/test_list_floating_ips.py b/tempest/api/compute/floating_ips/test_list_floating_ips.py
index 3c76069..fb9610a 100644
--- a/tempest/api/compute/floating_ips/test_list_floating_ips.py
+++ b/tempest/api/compute/floating_ips/test_list_floating_ips.py
@@ -15,8 +15,10 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+import uuid
+
 from tempest.api.compute import base
-from tempest.common.utils.data_utils import rand_name
+from tempest.common.utils import data_utils
 from tempest import exceptions
 from tempest.test import attr
 
@@ -87,7 +89,9 @@
             floating_ip_id.append(body[i]['id'])
         # Creating a non-existent floatingIP id
         while True:
-            non_exist_id = rand_name('999')
+            non_exist_id = data_utils.rand_int_id(start=999)
+            if self.config.service_available.neutron:
+                non_exist_id = str(uuid.uuid4())
             if non_exist_id not in floating_ip_id:
                 break
         self.assertRaises(exceptions.NotFound,
diff --git a/tempest/api/compute/images/test_images_oneserver.py b/tempest/api/compute/images/test_images_oneserver.py
index 800b2de..bb04f1d 100644
--- a/tempest/api/compute/images/test_images_oneserver.py
+++ b/tempest/api/compute/images/test_images_oneserver.py
@@ -23,9 +23,12 @@
 from tempest.common.utils.data_utils import parse_image_id
 from tempest.common.utils.data_utils import rand_name
 from tempest import exceptions
+from tempest.openstack.common import log as logging
 from tempest.test import attr
 from tempest.test import skip_because
 
+LOG = logging.getLogger(__name__)
+
 
 class ImagesOneServerTestJSON(base.BaseComputeTest):
     _interface = 'json'
@@ -37,6 +40,19 @@
             self.image_ids.remove(image_id)
         super(ImagesOneServerTestJSON, self).tearDown()
 
+    def setUp(self):
+        # NOTE(afazekas): Normally we use the same server with all test cases,
+        # but if it has an issue, we build a new one
+        super(ImagesOneServerTestJSON, self).setUp()
+        # Check if the server is in a clean state after test
+        try:
+            self.client.wait_for_server_status(self.server_id, 'ACTIVE')
+        except Exception as exc:
+            LOG.exception(exc)
+            # Rebuild server if cannot reach the ACTIVE state
+            # Usually it means the server had a serius accident
+            self.rebuild_server()
+
     @classmethod
     def setUpClass(cls):
         super(ImagesOneServerTestJSON, cls).setUpClass()
@@ -46,7 +62,8 @@
             raise cls.skipException(skip_msg)
 
         try:
-            resp, cls.server = cls.create_server(wait_until='ACTIVE')
+            resp, server = cls.create_server(wait_until='ACTIVE')
+            cls.server_id = server['id']
         except Exception:
             cls.tearDownClass()
             raise
@@ -71,7 +88,7 @@
         # Return an error if the image name has multi-byte characters
         snapshot_name = rand_name('\xef\xbb\xbf')
         self.assertRaises(exceptions.BadRequest,
-                          self.client.create_image, self.server['id'],
+                          self.client.create_image, self.server_id,
                           snapshot_name)
 
     @attr(type=['negative', 'gate'])
@@ -80,7 +97,7 @@
         snapshot_name = rand_name('test-snap-')
         meta = {'': ''}
         self.assertRaises(exceptions.BadRequest, self.client.create_image,
-                          self.server['id'], snapshot_name, meta)
+                          self.server_id, snapshot_name, meta)
 
     @attr(type=['negative', 'gate'])
     def test_create_image_specify_metadata_over_limits(self):
@@ -88,7 +105,7 @@
         snapshot_name = rand_name('test-snap-')
         meta = {'a' * 260: 'b' * 260}
         self.assertRaises(exceptions.BadRequest, self.client.create_image,
-                          self.server['id'], snapshot_name, meta)
+                          self.server_id, snapshot_name, meta)
 
     def _get_default_flavor_disk_size(self, flavor_id):
         resp, flavor = self.flavors_client.get_flavor_details(flavor_id)
@@ -102,7 +119,7 @@
         # Create a new image
         name = rand_name('image')
         meta = {'image_type': 'test'}
-        resp, body = self.client.create_image(self.server['id'], name, meta)
+        resp, body = self.client.create_image(self.server_id, name, meta)
         self.assertEqual(202, resp.status)
         image_id = parse_image_id(resp['location'])
         self.client.wait_for_image_status(image_id, 'ACTIVE')
@@ -133,7 +150,7 @@
 
         # Create first snapshot
         snapshot_name = rand_name('test-snap-')
-        resp, body = self.client.create_image(self.server['id'],
+        resp, body = self.client.create_image(self.server_id,
                                               snapshot_name)
         self.assertEqual(202, resp.status)
         image_id = parse_image_id(resp['location'])
@@ -142,7 +159,7 @@
         # Create second snapshot
         alt_snapshot_name = rand_name('test-snap-')
         self.assertRaises(exceptions.Duplicate, self.client.create_image,
-                          self.server['id'], alt_snapshot_name)
+                          self.server_id, alt_snapshot_name)
         self.client.wait_for_image_status(image_id, 'ACTIVE')
 
     @attr(type=['negative', 'gate'])
@@ -151,14 +168,14 @@
 
         snapshot_name = rand_name('a' * 260)
         self.assertRaises(exceptions.BadRequest, self.client.create_image,
-                          self.server['id'], snapshot_name)
+                          self.server_id, snapshot_name)
 
     @attr(type=['negative', 'gate'])
     def test_delete_image_that_is_not_yet_active(self):
         # Return an error while trying to delete an image what is creating
 
         snapshot_name = rand_name('test-snap-')
-        resp, body = self.client.create_image(self.server['id'], snapshot_name)
+        resp, body = self.client.create_image(self.server_id, snapshot_name)
         self.assertEqual(202, resp.status)
         image_id = parse_image_id(resp['location'])
         self.image_ids.append(image_id)
diff --git a/tempest/api/compute/security_groups/test_security_group_rules.py b/tempest/api/compute/security_groups/test_security_group_rules.py
index cbc0080..5faa9a4 100644
--- a/tempest/api/compute/security_groups/test_security_group_rules.py
+++ b/tempest/api/compute/security_groups/test_security_group_rules.py
@@ -16,7 +16,7 @@
 #    under the License.
 
 from tempest.api.compute import base
-from tempest.common.utils.data_utils import rand_name
+from tempest.common.utils import data_utils
 from tempest import config
 from tempest import exceptions
 from tempest.test import attr
@@ -36,8 +36,8 @@
         # Positive test: Creation of Security Group rule
         # should be successful
         # Creating a Security Group to add rules to it
-        s_name = rand_name('securitygroup-')
-        s_description = rand_name('description-')
+        s_name = data_utils.rand_name('securitygroup-')
+        s_description = data_utils.rand_name('description-')
         resp, securitygroup = \
             self.client.create_security_group(s_name, s_description)
         securitygroup_id = securitygroup['id']
@@ -63,15 +63,15 @@
         secgroup1 = None
         secgroup2 = None
         # Creating a Security Group to add rules to it
-        s_name = rand_name('securitygroup-')
-        s_description = rand_name('description-')
+        s_name = data_utils.rand_name('securitygroup-')
+        s_description = data_utils.rand_name('description-')
         resp, securitygroup = \
             self.client.create_security_group(s_name, s_description)
         secgroup1 = securitygroup['id']
         self.addCleanup(self.client.delete_security_group, secgroup1)
         # Creating a Security Group so as to assign group_id to the rule
-        s_name2 = rand_name('securitygroup-')
-        s_description2 = rand_name('description-')
+        s_name2 = data_utils.rand_name('securitygroup-')
+        s_description2 = data_utils.rand_name('description-')
         resp, securitygroup = \
             self.client.create_security_group(s_name2, s_description2)
         secgroup2 = securitygroup['id']
@@ -100,7 +100,7 @@
         # Negative test: Creation of Security Group rule should FAIL
         # with invalid Parent group id
         # Adding rules to the invalid Security Group id
-        parent_group_id = rand_name('999')
+        parent_group_id = data_utils.rand_int_id(start=999)
         ip_protocol = 'tcp'
         from_port = 22
         to_port = 22
@@ -113,13 +113,13 @@
         # Negative test: Creation of Security Group rule should FAIL
         # with invalid ip_protocol
         # Creating a Security Group to add rule to it
-        s_name = rand_name('securitygroup-')
-        s_description = rand_name('description-')
+        s_name = data_utils.rand_name('securitygroup-')
+        s_description = data_utils.rand_name('description-')
         resp, securitygroup = self.client.create_security_group(s_name,
                                                                 s_description)
         # Adding rules to the created Security Group
         parent_group_id = securitygroup['id']
-        ip_protocol = rand_name('999')
+        ip_protocol = data_utils.rand_name('999')
         from_port = 22
         to_port = 22
 
@@ -133,14 +133,14 @@
         # Negative test: Creation of Security Group rule should FAIL
         # with invalid from_port
         # Creating a Security Group to add rule to it
-        s_name = rand_name('securitygroup-')
-        s_description = rand_name('description-')
+        s_name = data_utils.rand_name('securitygroup-')
+        s_description = data_utils.rand_name('description-')
         resp, securitygroup = self.client.create_security_group(s_name,
                                                                 s_description)
         # Adding rules to the created Security Group
         parent_group_id = securitygroup['id']
         ip_protocol = 'tcp'
-        from_port = rand_name('999')
+        from_port = data_utils.rand_int_id(start=999, end=65535)
         to_port = 22
         self.addCleanup(self.client.delete_security_group, securitygroup['id'])
         self.assertRaises(exceptions.BadRequest,
@@ -150,17 +150,17 @@
     @attr(type=['negative', 'gate'])
     def test_security_group_rules_create_with_invalid_to_port(self):
         # Negative test: Creation of Security Group rule should FAIL
-        # with invalid from_port
+        # with invalid to_port
         # Creating a Security Group to add rule to it
-        s_name = rand_name('securitygroup-')
-        s_description = rand_name('description-')
+        s_name = data_utils.rand_name('securitygroup-')
+        s_description = data_utils.rand_name('description-')
         resp, securitygroup = self.client.create_security_group(s_name,
                                                                 s_description)
         # Adding rules to the created Security Group
         parent_group_id = securitygroup['id']
         ip_protocol = 'tcp'
         from_port = 22
-        to_port = rand_name('999')
+        to_port = data_utils.rand_int_id(start=65536)
         self.addCleanup(self.client.delete_security_group, securitygroup['id'])
         self.assertRaises(exceptions.BadRequest,
                           self.client.create_security_group_rule,
@@ -171,8 +171,8 @@
         # Negative test: Creation of Security Group rule should FAIL
         # with invalid port range.
         # Creating a Security Group to add rule to it.
-        s_name = rand_name('securitygroup-')
-        s_description = rand_name('description-')
+        s_name = data_utils.rand_name('securitygroup-')
+        s_description = data_utils.rand_name('description-')
         resp, securitygroup = self.client.create_security_group(s_name,
                                                                 s_description)
         # Adding a rule to the created Security Group
@@ -193,15 +193,15 @@
         # with invalid rule id
         self.assertRaises(exceptions.NotFound,
                           self.client.delete_security_group_rule,
-                          rand_name('999'))
+                          data_utils.rand_int_id(start=999))
 
     @attr(type='gate')
     def test_security_group_rules_list(self):
         # Positive test: Created Security Group rules should be
         # in the list of all rules
         # Creating a Security Group to add rules to it
-        s_name = rand_name('securitygroup-')
-        s_description = rand_name('description-')
+        s_name = data_utils.rand_name('securitygroup-')
+        s_description = data_utils.rand_name('description-')
         resp, securitygroup = \
             self.client.create_security_group(s_name, s_description)
         securitygroup_id = securitygroup['id']
diff --git a/tempest/api/compute/security_groups/test_security_groups.py b/tempest/api/compute/security_groups/test_security_groups.py
index fba2f53..2d9c62d 100644
--- a/tempest/api/compute/security_groups/test_security_groups.py
+++ b/tempest/api/compute/security_groups/test_security_groups.py
@@ -18,7 +18,7 @@
 import testtools
 
 from tempest.api.compute import base
-from tempest.common.utils.data_utils import rand_name
+from tempest.common.utils import data_utils
 from tempest import config
 from tempest import exceptions
 from tempest.test import attr
@@ -43,8 +43,8 @@
         # Create 3 Security Groups
         security_group_list = list()
         for i in range(3):
-            s_name = rand_name('securitygroup-')
-            s_description = rand_name('description-')
+            s_name = data_utils.rand_name('securitygroup-')
+            s_description = data_utils.rand_name('description-')
             resp, securitygroup = \
                 self.client.create_security_group(s_name, s_description)
             self.assertEqual(200, resp.status)
@@ -68,8 +68,8 @@
     @attr(type='gate')
     def test_security_group_create_delete(self):
         # Security Group should be created, verified and deleted
-        s_name = rand_name('securitygroup-')
-        s_description = rand_name('description-')
+        s_name = data_utils.rand_name('securitygroup-')
+        s_description = data_utils.rand_name('description-')
         resp, securitygroup = \
             self.client.create_security_group(s_name, s_description)
         self.assertIn('id', securitygroup)
@@ -87,8 +87,8 @@
     @attr(type='gate')
     def test_security_group_create_get_delete(self):
         # Security Group should be created, fetched and deleted
-        s_name = rand_name('securitygroup-')
-        s_description = rand_name('description-')
+        s_name = data_utils.rand_name('securitygroup-')
+        s_description = data_utils.rand_name('description-')
         resp, securitygroup = \
             self.client.create_security_group(s_name, s_description)
         self.addCleanup(self._delete_security_group,
@@ -120,7 +120,7 @@
             security_group_id.append(body[i]['id'])
         # Creating a non-existent Security Group id
         while True:
-            non_exist_id = rand_name('999')
+            non_exist_id = data_utils.rand_int_id(start=999)
             if non_exist_id not in security_group_id:
                 break
         self.assertRaises(exceptions.NotFound, self.client.get_security_group,
@@ -132,7 +132,7 @@
     def test_security_group_create_with_invalid_group_name(self):
         # Negative test: Security Group should not be created with group name
         # as an empty string/with white spaces/chars more than 255
-        s_description = rand_name('description-')
+        s_description = data_utils.rand_name('description-')
         # Create Security Group with empty string as group name
         self.assertRaises(exceptions.BadRequest,
                           self.client.create_security_group, "", s_description)
@@ -152,7 +152,7 @@
     def test_security_group_create_with_invalid_group_description(self):
         # Negative test:Security Group should not be created with description
         # as an empty string/with white spaces/chars more than 255
-        s_name = rand_name('securitygroup-')
+        s_name = data_utils.rand_name('securitygroup-')
         # Create Security Group with empty string as description
         self.assertRaises(exceptions.BadRequest,
                           self.client.create_security_group, s_name, "")
@@ -171,8 +171,8 @@
     def test_security_group_create_with_duplicate_name(self):
         # Negative test:Security Group with duplicate name should not
         # be created
-        s_name = rand_name('securitygroup-')
-        s_description = rand_name('description-')
+        s_name = data_utils.rand_name('securitygroup-')
+        s_description = data_utils.rand_name('description-')
         resp, security_group =\
             self.client.create_security_group(s_name, s_description)
         self.assertEqual(200, resp.status)
@@ -209,7 +209,7 @@
             security_group_id.append(body[i]['id'])
         # Creating non-existent Security Group
         while True:
-            non_exist_id = rand_name('999')
+            non_exist_id = data_utils.rand_int_id(start=999)
             if non_exist_id not in security_group_id:
                 break
         self.assertRaises(exceptions.NotFound,
@@ -228,19 +228,19 @@
         # and not deleted if the server is active.
         # Create a couple security groups that we will use
         # for the server resource this test creates
-        sg_name = rand_name('sg')
-        sg_desc = rand_name('sg-desc')
+        sg_name = data_utils.rand_name('sg')
+        sg_desc = data_utils.rand_name('sg-desc')
         resp, sg = self.client.create_security_group(sg_name, sg_desc)
         sg_id = sg['id']
 
-        sg2_name = rand_name('sg')
-        sg2_desc = rand_name('sg-desc')
+        sg2_name = data_utils.rand_name('sg')
+        sg2_desc = data_utils.rand_name('sg-desc')
         resp, sg2 = self.client.create_security_group(sg2_name, sg2_desc)
         sg2_id = sg2['id']
 
         # Create server and add the security group created
         # above to the server we just created
-        server_name = rand_name('server')
+        server_name = data_utils.rand_name('server')
         resp, server = self.servers_client.create_server(server_name,
                                                          self.image_ref,
                                                          self.flavor_ref)
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index 255beb7..f073ebc 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -197,41 +197,6 @@
                 required time (%s s).' % (self.server_id, self.build_timeout)
                 raise exceptions.TimeoutException(message)
 
-    @attr(type=['negative', 'gate'])
-    def test_resize_server_using_nonexist_flavor(self):
-        flavor_id = -1
-        self.assertRaises(exceptions.BadRequest,
-                          self.client.resize, self.server_id, flavor_id)
-
-    @attr(type=['negative', 'gate'])
-    def test_resize_server_using_null_flavor(self):
-        flavor_id = ""
-        self.assertRaises(exceptions.BadRequest,
-                          self.client.resize, self.server_id, flavor_id)
-
-    @attr(type=['negative', 'gate'])
-    def test_reboot_nonexistent_server_soft(self):
-        # Negative Test: The server reboot on non existent server should return
-        # an error
-        self.assertRaises(exceptions.NotFound, self.client.reboot, 999, 'SOFT')
-
-    @attr(type=['negative', 'gate'])
-    def test_rebuild_nonexistent_server(self):
-        # Negative test: The server rebuild for a non existing server
-        # should not be allowed
-        meta = {'rebuild': 'server'}
-        new_name = rand_name('server')
-        file_contents = 'Test server rebuild.'
-        personality = [{'path': '/etc/rebuild.txt',
-                        'contents': base64.b64encode(file_contents)}]
-        self.assertRaises(exceptions.NotFound,
-                          self.client.rebuild,
-                          999, self.image_ref_alt,
-                          name=new_name,
-                          metadata=meta,
-                          personality=personality,
-                          adminPass='rebuild')
-
     @attr(type='gate')
     def test_get_console_output(self):
         # Positive test:Should be able to GET the console output
@@ -245,14 +210,6 @@
             self.assertEqual(lines, 10)
         self.wait_for(get_output)
 
-    @attr(type=['negative', 'gate'])
-    def test_get_console_output_invalid_server_id(self):
-        # Negative test: Should not be able to get the console output
-        # for an invalid server_id
-        self.assertRaises(exceptions.NotFound,
-                          self.servers_client.get_console_output,
-                          '!@#$%^&*()', 10)
-
     @skip_because(bug="1014683")
     @attr(type='gate')
     def test_get_console_output_server_id_in_reboot_status(self):
diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index c896224..7062a3b 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -15,6 +15,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+import base64
 import sys
 import uuid
 
@@ -99,6 +100,26 @@
                           self.create_server, accessIPv6=IPv6)
 
     @attr(type=['negative', 'gate'])
+    def test_resize_server_with_non_existent_flavor(self):
+        # Resize a server with non-existent flavor
+        nonexistent_flavor = str(uuid.uuid4())
+        self.assertRaises(exceptions.BadRequest, self.client.resize,
+                          self.server_id, flavor_ref=nonexistent_flavor)
+
+    @attr(type=['negative', 'gate'])
+    def test_resize_server_with_null_flavor(self):
+        # Resize a server with null flavor
+        self.assertRaises(exceptions.BadRequest, self.client.resize,
+                          self.server_id, flavor_ref="")
+
+    @attr(type=['negative', 'gate'])
+    def test_reboot_non_existent_server(self):
+        # Reboot a non existent server
+        nonexistent_server = str(uuid.uuid4())
+        self.assertRaises(exceptions.NotFound, self.client.reboot,
+                          nonexistent_server, 'SOFT')
+
+    @attr(type=['negative', 'gate'])
     def test_reboot_deleted_server(self):
         # Reboot a deleted server
         self.client.delete_server(self.server_id)
@@ -126,6 +147,23 @@
                           self.server_id, self.image_ref_alt)
 
     @attr(type=['negative', 'gate'])
+    def test_rebuild_non_existent_server(self):
+        # Rebuild a non existent server
+        nonexistent_server = str(uuid.uuid4())
+        meta = {'rebuild': 'server'}
+        new_name = rand_name('server')
+        file_contents = 'Test server rebuild.'
+        personality = [{'path': '/etc/rebuild.txt',
+                        'contents': base64.b64encode(file_contents)}]
+        self.assertRaises(exceptions.NotFound,
+                          self.client.rebuild,
+                          nonexistent_server,
+                          self.image_ref_alt,
+                          name=new_name, meta=meta,
+                          personality=personality,
+                          adminPass='rebuild')
+
+    @attr(type=['negative', 'gate'])
     def test_create_numeric_server_name(self):
         # Create a server with a numeric name
         if self.__class__._interface == "xml":
@@ -258,20 +296,23 @@
     @attr(type=['negative', 'gate'])
     def test_stop_non_existent_server(self):
         # Stop a non existent server
+        nonexistent_server = str(uuid.uuid4())
         self.assertRaises(exceptions.NotFound, self.servers_client.stop,
-                          str(uuid.uuid4()))
+                          nonexistent_server)
 
     @attr(type=['negative', 'gate'])
     def test_pause_non_existent_server(self):
         # pause a non existent server
+        nonexistent_server = str(uuid.uuid4())
         self.assertRaises(exceptions.NotFound, self.client.pause_server,
-                          str(uuid.uuid4()))
+                          nonexistent_server)
 
     @attr(type=['negative', 'gate'])
     def test_unpause_non_existent_server(self):
         # unpause a non existent server
+        nonexistent_server = str(uuid.uuid4())
         self.assertRaises(exceptions.NotFound, self.client.unpause_server,
-                          str(uuid.uuid4()))
+                          nonexistent_server)
 
     @attr(type=['negative', 'gate'])
     def test_unpause_server_invalid_state(self):
@@ -283,8 +324,9 @@
     @attr(type=['negative', 'gate'])
     def test_suspend_non_existent_server(self):
         # suspend a non existent server
+        nonexistent_server = str(uuid.uuid4())
         self.assertRaises(exceptions.NotFound, self.client.suspend_server,
-                          str(uuid.uuid4()))
+                          nonexistent_server)
 
     @attr(type=['negative', 'gate'])
     def test_suspend_server_invalid_state(self):
@@ -299,8 +341,9 @@
     @attr(type=['negative', 'gate'])
     def test_resume_non_existent_server(self):
         # resume a non existent server
+        nonexistent_server = str(uuid.uuid4())
         self.assertRaises(exceptions.NotFound, self.client.resume_server,
-                          str(uuid.uuid4()))
+                          nonexistent_server)
 
     @attr(type=['negative', 'gate'])
     def test_resume_server_invalid_state(self):
@@ -309,6 +352,14 @@
                           self.client.resume_server,
                           self.server_id)
 
+    @attr(type=['negative', 'gate'])
+    def test_get_console_output_of_non_existent_server(self):
+        # get the console output for a non existent server
+        nonexistent_server = str(uuid.uuid4())
+        self.assertRaises(exceptions.NotFound,
+                          self.client.get_console_output,
+                          nonexistent_server, 10)
+
 
 class ServersNegativeTestXML(ServersNegativeTestJSON):
     _interface = 'xml'
diff --git a/tempest/api/compute/volumes/test_volumes_negative.py b/tempest/api/compute/volumes/test_volumes_negative.py
index 9ca1380..90e6946 100644
--- a/tempest/api/compute/volumes/test_volumes_negative.py
+++ b/tempest/api/compute/volumes/test_volumes_negative.py
@@ -15,8 +15,10 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+import uuid
+
 from tempest.api.compute import base
-from tempest.common.utils.data_utils import rand_name
+from tempest.common.utils import data_utils
 from tempest import exceptions
 from tempest.test import attr
 
@@ -36,39 +38,23 @@
     def test_volume_get_nonexistant_volume_id(self):
         # Negative: Should not be able to get details of nonexistant volume
         # Creating a nonexistant volume id
-        volume_id_list = list()
-        resp, body = self.client.list_volumes()
-        for i in range(len(body)):
-            volume_id_list.append(body[i]['id'])
-        while True:
-            non_exist_id = rand_name('999')
-            if non_exist_id not in volume_id_list:
-                break
         # Trying to GET a non existant volume
         self.assertRaises(exceptions.NotFound, self.client.get_volume,
-                          non_exist_id)
+                          str(uuid.uuid4()))
 
     @attr(type=['negative', 'gate'])
     def test_volume_delete_nonexistant_volume_id(self):
         # Negative: Should not be able to delete nonexistant Volume
         # Creating nonexistant volume id
-        volume_id_list = list()
-        resp, body = self.client.list_volumes()
-        for i in range(len(body)):
-            volume_id_list.append(body[i]['id'])
-        while True:
-            non_exist_id = rand_name('999')
-            if non_exist_id not in volume_id_list:
-                break
         # Trying to DELETE a non existant volume
         self.assertRaises(exceptions.NotFound, self.client.delete_volume,
-                          non_exist_id)
+                          str(uuid.uuid4()))
 
     @attr(type=['negative', 'gate'])
     def test_create_volume_with_invalid_size(self):
         # Negative: Should not be able to create volume with invalid size
         # in request
-        v_name = rand_name('Volume-')
+        v_name = data_utils.rand_name('Volume-')
         metadata = {'Type': 'work'}
         self.assertRaises(exceptions.BadRequest, self.client.create_volume,
                           size='#$%', display_name=v_name, metadata=metadata)
@@ -77,7 +63,7 @@
     def test_create_volume_with_out_passing_size(self):
         # Negative: Should not be able to create volume without passing size
         # in request
-        v_name = rand_name('Volume-')
+        v_name = data_utils.rand_name('Volume-')
         metadata = {'Type': 'work'}
         self.assertRaises(exceptions.BadRequest, self.client.create_volume,
                           size='', display_name=v_name, metadata=metadata)
@@ -85,7 +71,7 @@
     @attr(type=['negative', 'gate'])
     def test_create_volume_with_size_zero(self):
         # Negative: Should not be able to create volume with size zero
-        v_name = rand_name('Volume-')
+        v_name = data_utils.rand_name('Volume-')
         metadata = {'Type': 'work'}
         self.assertRaises(exceptions.BadRequest, self.client.create_volume,
                           size='0', display_name=v_name, metadata=metadata)
diff --git a/tempest/api/identity/admin/test_users.py b/tempest/api/identity/admin/test_users.py
index 66d35cb..906fad3 100644
--- a/tempest/api/identity/admin/test_users.py
+++ b/tempest/api/identity/admin/test_users.py
@@ -18,7 +18,7 @@
 from testtools.matchers import Contains
 
 from tempest.api.identity import base
-from tempest.common.utils.data_utils import rand_name
+from tempest.common.utils import data_utils
 from tempest.test import attr
 
 
@@ -28,11 +28,11 @@
     @classmethod
     def setUpClass(cls):
         super(UsersTestJSON, cls).setUpClass()
-        cls.alt_user = rand_name('test_user_')
-        cls.alt_password = rand_name('pass_')
+        cls.alt_user = data_utils.rand_name('test_user_')
+        cls.alt_password = data_utils.rand_name('pass_')
         cls.alt_email = cls.alt_user + '@testmail.tm'
-        cls.alt_tenant = rand_name('test_tenant_')
-        cls.alt_description = rand_name('desc_')
+        cls.alt_tenant = data_utils.rand_name('test_tenant_')
+        cls.alt_description = data_utils.rand_name('desc_')
 
     @attr(type='smoke')
     def test_create_user(self):
@@ -49,7 +49,7 @@
     def test_create_user_with_enabled(self):
         # Create a user with enabled : False
         self.data.setup_test_tenant()
-        name = rand_name('test_user_')
+        name = data_utils.rand_name('test_user_')
         resp, user = self.client.create_user(name, self.alt_password,
                                              self.data.tenant['id'],
                                              self.alt_email, enabled=False)
@@ -62,7 +62,7 @@
     @attr(type='smoke')
     def test_update_user(self):
         # Test case to check if updating of user attributes is successful.
-        test_user = rand_name('test_user_')
+        test_user = data_utils.rand_name('test_user_')
         self.data.setup_test_tenant()
         resp, user = self.client.create_user(test_user, self.alt_password,
                                              self.data.tenant['id'],
@@ -70,7 +70,7 @@
         # Delete the User at the end of this method
         self.addCleanup(self.client.delete_user, user['id'])
         # Updating user details with new values
-        u_name2 = rand_name('user2-')
+        u_name2 = data_utils.rand_name('user2-')
         u_email2 = u_name2 + '@testmail.tm'
         resp, update_user = self.client.update_user(user['id'], name=u_name2,
                                                     email=u_email2,
@@ -90,7 +90,7 @@
     @attr(type='smoke')
     def test_delete_user(self):
         # Delete a user
-        test_user = rand_name('test_user_')
+        test_user = data_utils.rand_name('test_user_')
         self.data.setup_test_tenant()
         resp, user = self.client.create_user(test_user, self.alt_password,
                                              self.data.tenant['id'],
@@ -144,7 +144,7 @@
         self.data.setup_test_tenant()
         user_ids = list()
         fetched_user_ids = list()
-        alt_tenant_user1 = rand_name('tenant_user1_')
+        alt_tenant_user1 = data_utils.rand_name('tenant_user1_')
         resp, user1 = self.client.create_user(alt_tenant_user1, 'password1',
                                               self.data.tenant['id'],
                                               'user1@123')
@@ -152,7 +152,7 @@
         user_ids.append(user1['id'])
         self.data.users.append(user1)
 
-        alt_tenant_user2 = rand_name('tenant_user2_')
+        alt_tenant_user2 = data_utils.rand_name('tenant_user2_')
         resp, user2 = self.client.create_user(alt_tenant_user2, 'password2',
                                               self.data.tenant['id'],
                                               'user2@123')
@@ -187,7 +187,7 @@
                                                   role['id'])
         self.assertEqual('200', resp['status'])
 
-        alt_user2 = rand_name('second_user_')
+        alt_user2 = data_utils.rand_name('second_user_')
         resp, second_user = self.client.create_user(alt_user2, 'password1',
                                                     self.data.tenant['id'],
                                                     'user2@123')
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index c3a66c5..b6c2679 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -20,8 +20,11 @@
 from tempest import clients
 from tempest.common.utils.data_utils import rand_name
 from tempest import exceptions
+from tempest.openstack.common import log as logging
 import tempest.test
 
+LOG = logging.getLogger(__name__)
+
 
 class BaseNetworkTest(tempest.test.BaseTestCase):
 
@@ -61,26 +64,79 @@
         cls.vips = []
         cls.members = []
         cls.health_monitors = []
+        cls.vpnservices = []
 
     @classmethod
     def tearDownClass(cls):
-        for health_monitor in cls.health_monitors:
-            cls.client.delete_health_monitor(health_monitor['id'])
-        for member in cls.members:
-            cls.client.delete_member(member['id'])
-        for vip in cls.vips:
-            cls.client.delete_vip(vip['id'])
-        for pool in cls.pools:
-            cls.client.delete_pool(pool['id'])
-        for port in cls.ports:
-            cls.client.delete_port(port['id'])
+        has_exception = False
+        for vpnservice in cls.vpnservices:
+            try:
+                cls.client.delete_vpn_service(vpnservice['id'])
+            except Exception as exc:
+                LOG.exception(exc)
+                has_exception = True
+
         for router in cls.routers:
-            cls.client.delete_router(router['id'])
+            try:
+                resp, body = cls.client.list_router_interfaces(router['id'])
+                interfaces = body['ports']
+                for i in interfaces:
+                    cls.client.remove_router_interface_with_subnet_id(
+                        router['id'], i['fixed_ips'][0]['subnet_id'])
+            except Exception as exc:
+                LOG.exception(exc)
+                has_exception = True
+            try:
+                cls.client.delete_router(router['id'])
+            except Exception as exc:
+                LOG.exception(exc)
+                has_exception = True
+
+        for health_monitor in cls.health_monitors:
+            try:
+                cls.client.delete_health_monitor(health_monitor['id'])
+            except Exception as exc:
+                LOG.exception(exc)
+                has_exception = True
+        for member in cls.members:
+            try:
+                cls.client.delete_member(member['id'])
+            except Exception as exc:
+                LOG.exception(exc)
+                has_exception = True
+        for vip in cls.vips:
+            try:
+                cls.client.delete_vip(vip['id'])
+            except Exception as exc:
+                LOG.exception(exc)
+                has_exception = True
+        for pool in cls.pools:
+            try:
+                cls.client.delete_pool(pool['id'])
+            except Exception as exc:
+                LOG.exception(exc)
+                has_exception = True
+        for port in cls.ports:
+            try:
+                cls.client.delete_port(port['id'])
+            except Exception as exc:
+                LOG.exception(exc)
+                has_exception = True
         for subnet in cls.subnets:
-            cls.client.delete_subnet(subnet['id'])
+            try:
+                cls.client.delete_subnet(subnet['id'])
+            except Exception as exc:
+                LOG.exception(exc)
+                has_exception = True
         for network in cls.networks:
-            cls.client.delete_network(network['id'])
+            try:
+                cls.client.delete_network(network['id'])
+            except Exception as exc:
+                LOG.exception(exc)
+                has_exception = True
         super(BaseNetworkTest, cls).tearDownClass()
+        if has_exception:
+            raise exceptions.TearDownException()
 
     @classmethod
     def create_network(cls, network_name=None):
@@ -179,3 +235,19 @@
         health_monitor = body['health_monitor']
         cls.health_monitors.append(health_monitor)
         return health_monitor
+
+    @classmethod
+    def create_router_interface(cls, router_id, subnet_id):
+        """Wrapper utility that returns a router interface."""
+        resp, interface = cls.client.add_router_interface_with_subnet_id(
+            router_id, subnet_id)
+
+    @classmethod
+    def create_vpnservice(cls, subnet_id, router_id):
+        """Wrapper utility that returns a test vpn service."""
+        resp, body = cls.client.create_vpn_service(
+            subnet_id, router_id, admin_state_up=True,
+            name=rand_name("vpnservice-"))
+        vpnservice = body['vpnservice']
+        cls.vpnservices.append(vpnservice)
+        return vpnservice
diff --git a/tempest/api/network/test_vpnaas_extensions.py b/tempest/api/network/test_vpnaas_extensions.py
new file mode 100644
index 0000000..7a8128b
--- /dev/null
+++ b/tempest/api/network/test_vpnaas_extensions.py
@@ -0,0 +1,96 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 OpenStack Foundation
+# All Rights Reserved.
+#
+#    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.
+
+from tempest.api.network import base
+from tempest.common.utils.data_utils import rand_name
+from tempest.test import attr
+
+
+class VPNaaSJSON(base.BaseNetworkTest):
+    _interface = 'json'
+
+    """
+    Tests the following operations in the Neutron API using the REST client for
+    Neutron:
+
+        List VPN Services
+        Show VPN Services
+        Create VPN Services
+        Update VPN Services
+        Delete VPN Services
+    """
+
+    @classmethod
+    def setUpClass(cls):
+        super(VPNaaSJSON, cls).setUpClass()
+        cls.network = cls.create_network()
+        cls.subnet = cls.create_subnet(cls.network)
+        cls.router = cls.create_router(rand_name("router-"))
+        cls.create_router_interface(cls.router['id'], cls.subnet['id'])
+        cls.vpnservice = cls.create_vpnservice(cls.subnet['id'],
+                                               cls.router['id'])
+
+    @attr(type='smoke')
+    def test_list_vpn_services(self):
+        # Verify the VPN service exists in the list of all VPN services
+        resp, body = self.client.list_vpn_services()
+        self.assertEqual('200', resp['status'])
+        vpnservices = body['vpnservices']
+        self.assertIn(self.vpnservice['id'], [v['id'] for v in vpnservices])
+
+    @attr(type='smoke')
+    def test_create_update_delete_vpn_service(self):
+        # Creates a VPN service
+        name = rand_name('vpn-service-')
+        resp, body = self.client.create_vpn_service(self.subnet['id'],
+                                                    self.router['id'],
+                                                    name=name,
+                                                    admin_state_up=True)
+        self.assertEqual('201', resp['status'])
+        vpnservice = body['vpnservice']
+        # Assert if created vpnservices are not found in vpnservices list
+        resp, body = self.client.list_vpn_services()
+        vpn_services = [vs['id'] for vs in body['vpnservices']]
+        self.assertIsNotNone(vpnservice['id'])
+        self.assertIn(vpnservice['id'], vpn_services)
+
+        # TODO(raies): implement logic to update  vpnservice
+        # VPNaaS client function to update is implemented.
+        # But precondition is that current state of vpnservice
+        # should be "ACTIVE" not "PENDING*"
+
+        # Verification of vpn service delete
+        resp, body = self.client.delete_vpn_service(vpnservice['id'])
+        self.assertEqual('204', resp['status'])
+        # Asserting if vpn service is found in the list after deletion
+        resp, body = self.client.list_vpn_services()
+        vpn_services = [vs['id'] for vs in body['vpnservices']]
+        self.assertNotIn(vpnservice['id'], vpn_services)
+
+    @attr(type='smoke')
+    def test_show_vpn_service(self):
+        # Verifies the details of a vpn service
+        resp, body = self.client.show_vpn_service(self.vpnservice['id'])
+        self.assertEqual('200', resp['status'])
+        vpnservice = body['vpnservice']
+        self.assertEqual(self.vpnservice['id'], vpnservice['id'])
+        self.assertEqual(self.vpnservice['name'], vpnservice['name'])
+        self.assertEqual(self.vpnservice['description'],
+                         vpnservice['description'])
+        self.assertEqual(self.vpnservice['router_id'], vpnservice['router_id'])
+        self.assertEqual(self.vpnservice['subnet_id'], vpnservice['subnet_id'])
+        self.assertEqual(self.vpnservice['tenant_id'], vpnservice['tenant_id'])
diff --git a/tempest/services/network/json/network_client.py b/tempest/services/network/json/network_client.py
index 4b87b91..92c1faf 100644
--- a/tempest/services/network/json/network_client.py
+++ b/tempest/services/network/json/network_client.py
@@ -600,3 +600,53 @@
         resp, body = self.get(uri, headers=self.headers)
         body = json.loads(body)
         return resp, body
+
+    def list_vpn_services(self):
+        uri = '%s/vpn/vpnservices' % (self.uri_prefix)
+        resp, body = self.get(uri, self.headers)
+        body = json.loads(body)
+        return resp, body
+
+    def create_vpn_service(self, subnet_id, router_id, **kwargs):
+        post_body = {
+            "vpnservice": {
+                "subnet_id": subnet_id,
+                "router_id": router_id
+            }
+        }
+        for key, val in kwargs.items():
+            post_body['vpnservice'][key] = val
+        body = json.dumps(post_body)
+        uri = '%s/vpn/vpnservices' % (self.uri_prefix)
+        resp, body = self.post(uri, headers=self.headers, body=body)
+        body = json.loads(body)
+        return resp, body
+
+    def show_vpn_service(self, uuid):
+        uri = '%s/vpn/vpnservices/%s' % (self.uri_prefix, uuid)
+        resp, body = self.get(uri, self.headers)
+        body = json.loads(body)
+        return resp, body
+
+    def delete_vpn_service(self, uuid):
+        uri = '%s/vpn/vpnservices/%s' % (self.uri_prefix, uuid)
+        resp, body = self.delete(uri, self.headers)
+        return resp, body
+
+    def update_vpn_service(self, uuid, description):
+        put_body = {
+            "vpnservice": {
+                "description": description
+            }
+        }
+        body = json.dumps(put_body)
+        uri = '%s/vpn/vpnservices/%s' % (self.uri_prefix, uuid)
+        resp, body = self.put(uri, body=body, headers=self.headers)
+        body = json.loads(body)
+        return resp, body
+
+    def list_router_interfaces(self, uuid):
+        uri = '%s/ports?device_id=%s' % (self.uri_prefix, uuid)
+        resp, body = self.get(uri, self.headers)
+        body = json.loads(body)
+        return resp, body
diff --git a/tempest/services/network/xml/network_client.py b/tempest/services/network/xml/network_client.py
index cf8154a..04ad86f 100755
--- a/tempest/services/network/xml/network_client.py
+++ b/tempest/services/network/xml/network_client.py
@@ -547,6 +547,13 @@
         body = _root_tag_fetcher_and_xml_to_json_parse(body)
         return resp, body
 
+    def list_router_interfaces(self, uuid):
+        uri = '%s/ports?device_id=%s' % (self.uri_prefix, uuid)
+        resp, body = self.get(uri, self.headers)
+        ports = self._parse_array(etree.fromstring(body))
+        ports = {"ports": ports}
+        return resp, ports
+
 
 def _root_tag_fetcher_and_xml_to_json_parse(xml_returned_body):
     body = ET.fromstring(xml_returned_body)