- ret, _, _ = \
- ssh.exec_command('sudo cp {src} {dest}'.
- format(src=self._vpp_startup_conf,
- dest=self._vpp_startup_conf_backup))
- if ret != 0:
- raise RuntimeError('Backup of config file failed on node '
- '{name}'.format(name=self._hostname))
-
- ret, _, _ = \
- ssh.exec_command('echo "{config}" | sudo tee {filename}'.
- format(config=self._vpp_config,
- filename=filename))
-
- if ret != 0:
- raise RuntimeError('Writing config file failed to node {name}'.
- format(name=self._hostname))
-
- if restart_vpp:
- DUTSetup.start_service(self._node, Constants.VPP_UNIT)
-
- # Sleep <waittime> seconds, up to <retry> times,
- # and verify if VPP is running.
- for _ in range(retries):
- time.sleep(1)
- ret, stdout, _ = \
- ssh.exec_command('echo show pci | nc 0 5002 || '
- 'echo "VPP not yet running"')
- if ret == 0 and 'VPP not yet running' not in stdout:
- break
- else:
- raise RuntimeError('VPP failed to restart on node {name}'.
- format(name=self._hostname))
+ cmd = f"cp {self._vpp_startup_conf} {self._vpp_startup_conf_backup}"
+ exec_cmd_no_error(
+ self._node, cmd, sudo=True, message=u"Copy config file failed!"
+ )