Merge "Remove unnecessary resource_setup in DvrRoutersNegativeTest"
diff --git a/doc/source/library/credential_providers.rst b/doc/source/library/credential_providers.rst
index 7e831cc..f4eb37d 100644
--- a/doc/source/library/credential_providers.rst
+++ b/doc/source/library/credential_providers.rst
@@ -6,7 +6,7 @@
 These library interfaces are used to deal with allocating credentials on demand
 either dynamically by calling keystone to allocate new credentials, or from
 a list of preprovisioned credentials. These 2 modules are implementations of
-the same abstract credential providers class and can be used interchangably.
+the same abstract credential providers class and can be used interchangeably.
 However, each implementation has some additional parameters that are used to
 influence the behavior of the modules. The API reference at the bottom of this
 doc shows the interface definitions for both modules, however that may be a bit
diff --git a/tempest/api/compute/servers/test_list_server_filters.py b/tempest/api/compute/servers/test_list_server_filters.py
index a4ed8e1..14aecfd 100644
--- a/tempest/api/compute/servers/test_list_server_filters.py
+++ b/tempest/api/compute/servers/test_list_server_filters.py
@@ -262,7 +262,7 @@
         # so as to ensure only one server is returned.
         ip_list = {}
         self.s1 = self.client.show_server(self.s1['id'])['server']
-        # Get first ip address inspite of v4 or v6
+        # Get first ip address in spite of v4 or v6
         ip_addr = self.s1['addresses'][self.fixed_network_name][0]['addr']
         ip_list[ip_addr] = self.s1['id']
 
diff --git a/tempest/api/compute/servers/test_novnc.py b/tempest/api/compute/servers/test_novnc.py
index 90b0665..d9581e3 100644
--- a/tempest/api/compute/servers/test_novnc.py
+++ b/tempest/api/compute/servers/test_novnc.py
@@ -166,7 +166,7 @@
         self._validate_novnc_html(body['url'])
         # Do the WebSockify HTTP Request to novncproxy to do the RFB connection
         self._websocket = compute.create_websocket(body['url'])
-        # Validate that we succesfully connected and upgraded to Web Sockets
+        # Validate that we successfully connected and upgraded to Web Sockets
         self._validate_websocket_upgrade()
         # Validate the RFB Negotiation to determine if a valid VNC session
         self._validate_rfb_negotiation()
diff --git a/tempest/common/utils/linux/remote_client.py b/tempest/common/utils/linux/remote_client.py
index 99a628e..52ccfa9 100644
--- a/tempest/common/utils/linux/remote_client.py
+++ b/tempest/common/utils/linux/remote_client.py
@@ -70,7 +70,7 @@
         if selected:
             return "\n".join(selected)
         else:
-            msg = "'TYPE' column is requred but the output doesn't have it: "
+            msg = "'TYPE' column is required but the output doesn't have it: "
             raise tempest.lib.exceptions.TempestException(msg + output)
 
     def get_boot_time(self):
diff --git a/tempest/common/validation_resources.py b/tempest/common/validation_resources.py
index 9e83a07..84f1c9d 100644
--- a/tempest/common/validation_resources.py
+++ b/tempest/common/validation_resources.py
@@ -13,20 +13,14 @@
 
 from oslo_log import log as logging
 
-from tempest import config
-
 from tempest.lib.common.utils import data_utils
 from tempest.lib import exceptions as lib_exc
 
-CONF = config.CONF
 LOG = logging.getLogger(__name__)
 
 
-def _create_neutron_sec_group_rules(os, sec_group):
+def _create_neutron_sec_group_rules(os, sec_group, ethertype='IPv4'):
     sec_group_rules_client = os.security_group_rules_client
-    ethertype = 'IPv4'
-    if CONF.validation.ip_version_for_ssh == 6:
-        ethertype = 'IPv6'
 
     sec_group_rules_client.create_security_group_rule(
         security_group_id=sec_group['id'],
@@ -42,7 +36,8 @@
         direction='ingress')
 
 
-def create_ssh_security_group(os, add_rule=False):
+def create_ssh_security_group(os, add_rule=False, ethertype='IPv4',
+                              use_neutron=True):
     security_groups_client = os.compute_security_groups_client
     security_group_rules_client = os.compute_security_group_rules_client
     sg_name = data_utils.rand_name('securitygroup-')
@@ -50,8 +45,9 @@
     security_group = security_groups_client.create_security_group(
         name=sg_name, description=sg_description)['security_group']
     if add_rule:
-        if CONF.service_available.neutron:
-            _create_neutron_sec_group_rules(os, security_group)
+        if use_neutron:
+            _create_neutron_sec_group_rules(os, security_group,
+                                            ethertype=ethertype)
         else:
             security_group_rules_client.create_security_group_rule(
                 parent_group_id=security_group['id'], ip_protocol='tcp',
@@ -64,7 +60,10 @@
     return security_group
 
 
-def create_validation_resources(os, validation_resources=None):
+def create_validation_resources(os, validation_resources=None,
+                                ethertype='IPv4', use_neutron=True,
+                                floating_network_id=None,
+                                floating_network_name=None):
     # Create and Return the validation resources required to validate a VM
     validation_data = {}
     if validation_resources:
@@ -78,11 +77,12 @@
             if validation_resources['security_group_rules']:
                 add_rule = True
             validation_data['security_group'] = \
-                create_ssh_security_group(os, add_rule)
+                create_ssh_security_group(
+                    os, add_rule, use_neutron=use_neutron, ethertype=ethertype)
         if validation_resources['floating_ip']:
-            if CONF.service_available.neutron:
+            if use_neutron:
                 floatingip = os.floating_ips_client.create_floatingip(
-                    floating_network_id=CONF.network.public_network_id)
+                    floating_network_id=floating_network_id)
                 # validation_resources['floating_ip'] has historically looked
                 # like a compute API POST /os-floating-ips response, so we need
                 # to mangle it a bit for a Neutron response with different
@@ -96,7 +96,7 @@
                 # floating IPs using the compute API should be capped at 2.35.
                 validation_data.update(
                     os.compute_floating_ips_client.create_floating_ip(
-                        pool=CONF.network.floating_network_name))
+                        pool=floating_network_name))
     return validation_data
 
 
diff --git a/tempest/test.py b/tempest/test.py
index 00f99d7..47cbb5e 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -373,9 +373,18 @@
     @classmethod
     def resource_setup(cls):
         """Class level resource setup for test cases."""
+        if (CONF.validation.ip_version_for_ssh not in (4, 6) and
+            CONF.service_available.neutron):
+            msg = "Invalid IP version %s in ip_version_for_ssh. Use 4 or 6"
+            raise lib_exc.InvalidConfiguration(
+                msg % CONF.validation.ip_version_for_ssh)
         if hasattr(cls, "os_primary"):
             cls.validation_resources = vresources.create_validation_resources(
-                cls.os_primary, cls.validation_resources)
+                cls.os_primary, cls.validation_resources,
+                use_neutron=CONF.service_available.neutron,
+                ethertype='IPv' + str(CONF.validation.ip_version_for_ssh),
+                floating_network_id=CONF.network.public_network_id,
+                floating_network_name=CONF.network.floating_network_name)
         else:
             LOG.warning("Client manager not found, validation resources not"
                         " created")