Validate instances are accessible before messing with their disks

This should help to isolate failures that are generic from specific test
failures related to barbican. If a test can't pass simple connectivity
check, it's probably broken, and there is no point to attach disks,
because it won't work.

Related-Bug: #1742936
Change-Id: I96cd35392f638c0e5b668f4f3b15cf4cd6114b71
diff --git a/barbican_tempest_plugin/tests/scenario/manager.py b/barbican_tempest_plugin/tests/scenario/manager.py
index 8a8ca9d..1aa009e 100644
--- a/barbican_tempest_plugin/tests/scenario/manager.py
+++ b/barbican_tempest_plugin/tests/scenario/manager.py
@@ -32,7 +32,9 @@
 LOG = log.getLogger(__name__)
 
 
-class ScenarioTest(manager.ScenarioTest):
+# we inherit from NetworkScenarioTest since some test cases need access to
+# check_*_connectivity methods to validate instances are up and accessible
+class ScenarioTest(manager.NetworkScenarioTest):
     """Base class for scenario tests. Uses tempest own clients. """
 
     credentials = ['primary']
diff --git a/barbican_tempest_plugin/tests/scenario/test_volume_encryption.py b/barbican_tempest_plugin/tests/scenario/test_volume_encryption.py
index c654608..95ba5d5 100644
--- a/barbican_tempest_plugin/tests/scenario/test_volume_encryption.py
+++ b/barbican_tempest_plugin/tests/scenario/test_volume_encryption.py
@@ -55,17 +55,11 @@
         return self.create_volume(volume_type=volume_type['name'])
 
     def attach_detach_volume(self, server, volume, keypair):
-        # test if server is accessible
-        server_ip = self.get_server_ip(server)
-        self.get_remote_client(
-            server_ip,
-            private_key=keypair['private_key']
-        )
-
         # Attach volume
         attached_volume = self.nova_volume_attach(server, volume)
 
         # Write a timestamp to volume
+        server_ip = self.get_server_ip(server)
         timestamp = self.create_timestamp(
             server_ip,
             dev_name=CONF.compute.volume_device_name,
@@ -95,6 +89,11 @@
             security_groups=[{'name': security_group['name']}],
             wait_until='ACTIVE'
         )
+
+        # check that instance is accessible before messing with its disks
+        self.check_tenant_network_connectivity(
+            server, CONF.validation.image_ssh_user, keypair['private_key'])
+
         volume = self.create_encrypted_volume('nova.volume.encryptors.'
                                               'luks.LuksEncryptor',
                                               volume_type='luks')
@@ -115,6 +114,11 @@
             security_groups=[{'name': security_group['name']}],
             wait_until='ACTIVE'
         )
+
+        # check that instance is accessible before messing with its disks
+        self.check_tenant_network_connectivity(
+            server, CONF.validation.image_ssh_user, keypair['private_key'])
+
         volume = self.create_encrypted_volume('nova.volume.encryptors.'
                                               'cryptsetup.CryptsetupEncryptor',
                                               volume_type='cryptsetup')