def apply_config(self, filename=None, retries=60, restart_vpp=True): """Generate and apply VPP configuration for node. Use data from calls to this class to form a startup.conf file and replace /etc/vpp/startup.conf with it on node. :param filename: Startup configuration file name. :param retries: Number of times (default 60) to re-try waiting. :param restart_vpp: Whether to restart VPP. :type filename: str :type retries: int :type restart_vpp: bool. :raises RuntimeError: If writing config file failed or restart of VPP failed or backup of VPP startup.conf failed. """ self.dump_config(self._nodeconfig) ssh = SSH() ssh.connect(self._node) if filename is None: filename = self._vpp_startup_conf if self._vpp_startup_conf_backup is not None: 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))
def start_vpp_service(node): """Start VPP service on the specified node. :param node: VPP node. :type node: dict :raises RuntimeError: If VPP service fails to start. """ DUTSetup.start_service(node, Constants.VPP_UNIT) DUTSetup.get_service_logs(node, Constants.VPP_UNIT)
def verify_vpp_on_all_duts(nodes): """Verify that VPP is installed on all DUT nodes. :param nodes: Nodes in the topology. :type nodes: dict """ for node in nodes.values(): if node['type'] == NodeType.DUT: DUTSetup.start_service(node, Constants.VPP_UNIT) VPPUtil.vpp_show_version_verbose(node) VPPUtil.vpp_show_interfaces(node)