Fix positional formatting and add skip check

This patch fixes an offset positonal argument in a string format that
was throwing an IndexError exception. It also adds a skip check to check
if the required amphora SSH key file is readable.

Additionally, the iptables-based active-standby test has now a better
amphora_ssh_key default value to match with the default path set by the
Octavia Devstack plugin.

Story: 2006259
Task: 35876

Change-Id: Ic887c726dfe151ea582a1bd935ae0b30582f14ea
diff --git a/octavia_tempest_plugin/config.py b/octavia_tempest_plugin/config.py
index 7c4ed2f..d951a44 100644
--- a/octavia_tempest_plugin/config.py
+++ b/octavia_tempest_plugin/config.py
@@ -173,7 +173,7 @@
                default='ubuntu',
                help='The amphora SSH user.'),
     cfg.StrOpt('amphora_ssh_key',
-               default='/tmp/octavia_ssh_key',
+               default='/etc/octavia/.ssh/octavia_ssh_key',
                help='The amphora SSH key file.'),
     # Environment specific options
     # These are used to accomodate clouds with specific limitations
diff --git a/octavia_tempest_plugin/tests/act_stdby_scenario/v2/test_active_standby_iptables.py b/octavia_tempest_plugin/tests/act_stdby_scenario/v2/test_active_standby_iptables.py
index 97886b5..7e6f7e8 100644
--- a/octavia_tempest_plugin/tests/act_stdby_scenario/v2/test_active_standby_iptables.py
+++ b/octavia_tempest_plugin/tests/act_stdby_scenario/v2/test_active_standby_iptables.py
@@ -13,7 +13,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import os
 import testtools
 
 from oslo_log import log as logging
@@ -50,6 +49,8 @@
             raise cls.skipException("Configured load balancer topology is not "
                                     "%s." % const.ACTIVE_STANDBY)
 
+        cls._get_amphora_ssh_key()
+
     @classmethod
     def resource_setup(cls):
         """Setup resources needed by the tests."""
@@ -230,13 +231,12 @@
     @classmethod
     def _get_amphora_ssh_key(cls):
         key_file = CONF.load_balancer.amphora_ssh_key
-        if not key_file:
-            raise Exception("SSH key file not provided.")
-        if not os.path.isfile(key_file):
-            raise Exception("Could not find amphora ssh key file {1}."
+        try:
+            with open(key_file, 'r') as f:
+                return f.read()
+        except IOError:
+            raise Exception("Could not open amphora SSH key file {0}."
                             .format(key_file))
-        with open(key_file, 'r') as f:
-            return f.read()
 
     @testtools.skipIf(CONF.load_balancer.test_with_noop,
                       'Active/Standby tests will not work in noop mode.')
diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml
index 42643ed..aa204fd 100644
--- a/zuul.d/jobs.yaml
+++ b/zuul.d/jobs.yaml
@@ -561,6 +561,7 @@
             load_balancer:
               check_timeout: 180
               loadbalancer_topology: 'ACTIVE_STANDBY'
+              amphora_ssh_key: '/tmp/octavia_ssh_key'
       tempest_test_regex: ^octavia_tempest_plugin.tests.act_stdby_scenario.v2.test_active_standby_iptables
       tox_envlist: all