- logger.debug('Writing config file failed to node {}'.\
- format(hostname))
- logger.debug('stdout: {}'.format(stdout))
- logger.debug('stderr: {}'.format(stderr))
- raise RuntimeError('Writing config file failed to node {}'.\
- format(hostname))
-
- # Instead of restarting, we'll do separate start and stop
- # actions. This way we don't care whether VPP was running
- # to begin with.
- ssh.exec_command('sudo initctl stop {}'.format(VPP_SERVICE_NAME))
- (ret, stdout, stderr) = \
- ssh.exec_command('sudo initctl start {}'.format(VPP_SERVICE_NAME))
- if ret != 0:
- logger.debug('Restarting VPP failed on node {}'.\
- format(hostname))
- logger.debug('stdout: {}'.format(stdout))
- logger.debug('stderr: {}'.format(stderr))
- raise RuntimeError('Restarting VPP failed on node {}'.\
- format(hostname))
-
- # Sleep <waittime> seconds, up to <retry> times,
- # and verify if VPP is running.
- vpp_is_running = False
- retries_left = retries
- while (not vpp_is_running) and (retries_left > 0):
- time.sleep(waittime)
- retries_left -= 1
-
- # FIXME: Need to find a good way to check if VPP is operational.
- #
- # If VatTerminal/VatExecutor is anything like vppctl or
- # vpp_api_test, then in case VPP is NOT running it will block for
- # 30 seconds or so and not even return if VPP becomes alive during
- # that time. This makes it unsuitable in this case. We either need
- # a call that returns immediately, indicating whether VPP is
- # healthy or not, or a call that waits (up to a defined length
- # of time) and returns immediately if VPP is or becomes healthy.
- (ret, stdout, stderr) = \
- ssh.exec_command('echo show hardware-interfaces | '\
- 'nc 0 5002')
-
- if ret == 0:
- vpp_is_running = True
+ raise RuntimeError('Writing config file failed to node {}'.
+ format(self._hostname))
+
+ if restart_vpp:
+ # Instead of restarting, we'll do separate start and stop
+ # actions. This way we don't care whether VPP was running
+ # to begin with.
+ ssh.exec_command('sudo service {} stop'
+ .format(self._vpp_service_name))
+ (ret, _, _) = \
+ ssh.exec_command('sudo service {} start'
+ .format(self._vpp_service_name))
+ if ret != 0:
+ raise RuntimeError('Restarting VPP failed on node {}'.
+ format(self._hostname))
+
+ # Sleep <waittime> seconds, up to <retry> times,
+ # and verify if VPP is running.
+ for _ in range(retries):
+ time.sleep(waittime)
+ (ret, _, _) = \
+ ssh.exec_command('echo show hardware-interfaces | '
+ 'nc 0 5002 || echo "VPP not yet running"')
+ if ret == 0:
+ break