diff options
author | Luc Provoost <luc.provoost@intel.com> | 2021-07-16 11:40:11 +0200 |
---|---|---|
committer | Luc Provoost <luc.provoost@intel.com> | 2021-07-16 11:40:11 +0200 |
commit | 8a12bf3b9202cfb02102c9f179dc2cc15be79a63 (patch) | |
tree | 4881c61876131a6c7eb24ecfa53b7a2f2927c1c0 /VNFs/DPPD-PROX/helper-scripts/rapid/rapid_machine.py | |
parent | 1c4e666aef045b3aa5eb9999e66b44db00cd47c7 (diff) |
Using paramiko for all ssh & scp
By using paramiko, we can now also use differnt credentials to login into
the PROX instances. In the ssh section of the environment file, you can
now also add the password parameter.
Change-Id: I08d31cbf0d02d7e82b7fbe34268851f73ff5dde0
Signed-off-by: Luc Provoost <luc.provoost@intel.com>
Diffstat (limited to 'VNFs/DPPD-PROX/helper-scripts/rapid/rapid_machine.py')
-rw-r--r-- | VNFs/DPPD-PROX/helper-scripts/rapid/rapid_machine.py | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_machine.py b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_machine.py index 515bea55..c4b7247f 100644 --- a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_machine.py +++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_machine.py @@ -25,12 +25,13 @@ class RapidMachine(object): """ Class to deal with a PROX instance (VM, bare metal, container) """ - def __init__(self, key, user, vim, rundir, resultsdir, machine_params, - configonly): + def __init__(self, key, user, password, vim, rundir, resultsdir, + machine_params, configonly): self.name = machine_params['name'] self.ip = machine_params['admin_ip'] self.key = key self.user = user + self.password = password self.rundir = rundir self.resultsdir = resultsdir self.dp_ports = [] @@ -58,11 +59,6 @@ class RapidMachine(object): PROXConfigfile.close() self.all_tasks_for_this_cfg = set(re.findall("task\s*=\s*(\d+)",PROXConfig)) - def __del__(self): - if ((not self.configonly) and self.machine_params['prox_socket']): - self._client.scp_get('/prox.log', '{}/{}.prox.log'.format( - self.resultsdir, self.name)) - def get_cores(self): return (self.machine_params['cores']) @@ -190,26 +186,36 @@ class RapidMachine(object): def start_prox(self, autostart=''): if self.machine_params['prox_socket']: - self._client = prox_ctrl(self.ip, self.key, self.user) - self._client.connect() + self._client = prox_ctrl(self.ip, self.key, self.user, + self.password) + self._client.test_connection() if self.vim in ['OpenStack']: self.devbind() if self.vim in ['kubernetes']: self.read_cpuset() self.read_cpuset_mems() self.remap_all_cpus() - _, prox_config_file_name = os.path.split(self.machine_params['config_file']) + _, prox_config_file_name = os.path.split(self. + machine_params['config_file']) self.generate_lua() - self._client.scp_put(self.machine_params['config_file'], '{}/{}'.format(self.rundir, prox_config_file_name)) - if ((not self.configonly) and self.machine_params['prox_launch_exit']): - cmd = 'sudo {}/prox {} -t -o cli -f {}/{}'.format(self.rundir, autostart, self.rundir, prox_config_file_name) - RapidLog.debug("Starting PROX on {}: {}".format(self.name, cmd)) - result = self._client.run_cmd(cmd, 'PROX Testing on {}'.format(self.name)) - RapidLog.debug("Finished PROX on {}: {}".format(self.name, cmd)) + self._client.scp_put(self.machine_params['config_file'], '{}/{}'. + format(self.rundir, prox_config_file_name)) + if ((not self.configonly) and + self.machine_params['prox_launch_exit']): + cmd = 'sudo {}/prox {} -t -o cli -f {}/{}'.format(self.rundir, + autostart, self.rundir, prox_config_file_name) + RapidLog.debug("Starting PROX on {}: {}".format(self.name, + cmd)) + result = self._client.run_cmd(cmd) + RapidLog.debug("Finished PROX on {}: {}".format(self.name, + cmd)) def close_prox(self): - if (not self.configonly) and self.machine_params['prox_socket'] and self.machine_params['prox_launch_exit']: + if (not self.configonly) and self.machine_params[ + 'prox_socket'] and self.machine_params['prox_launch_exit']: self.socket.quit_prox() + self._client.scp_get('/prox.log', '{}/{}.prox.log'.format( + self.resultsdir, self.name)) def connect_prox(self): if self.machine_params['prox_socket']: |