add option to connect to non-standard ssh port
[yardstick.git] / yardstick / benchmark / scenarios / availability / attacker / attacker_general.py
index 018362a..5e7716e 100644 (file)
@@ -24,13 +24,16 @@ class GeneralAttacker(BaseAttacker):
         host = self._context.get(self._config['host'], None)
         ip = host.get("ip", None)
         user = host.get("user", "root")
+        ssh_port = host.get("ssh_port", ssh.DEFAULT_PORT)
         key_filename = host.get("key_filename", "~/.ssh/id_rsa")
 
-        self.connection = ssh.SSH(user, ip, key_filename=key_filename)
+        self.connection = ssh.SSH(user, ip, key_filename=key_filename,
+                                  port=ssh_port)
         self.connection.wait(timeout=600)
         LOG.debug("ssh host success!")
 
         self.key = self._config['key']
+        self.attack_key = self._config['attack_key']
 
         if "action_parameter" in self._config:
             actionParameter = self._config['action_parameter']
@@ -50,7 +53,7 @@ class GeneralAttacker(BaseAttacker):
             l = list(item for item in rollbackParameter.values())
             self.rollback_param = str.format(*l)
 
-        self.fault_cfg = BaseAttacker.attacker_cfgs.get(self.key)
+        self.fault_cfg = BaseAttacker.attacker_cfgs.get(self.attack_key)
         self.inject_script = self.get_script_fullpath(
             self.fault_cfg['inject_script'])
         self.recovery_script = self.get_script_fullpath(