- :raises PapiError: If no reply received for show_version API command.
- """
- # TODO: move composition of api data to separate method
- api_data = list()
- api = dict(api_name='show_version')
- api_args = dict()
- api['api_args'] = api_args
- api_data.append(api)
-
- api_reply = None
- with PapiExecutor(node) as papi_executor:
- papi_executor.execute_papi(api_data)
- try:
- papi_executor.papi_should_have_passed()
- except AssertionError:
- raise RuntimeError('Failed to get VPP version on host: {host}'.
- format(host=node['host']))
- api_reply = papi_executor.get_papi_reply()
-
- if api_reply is not None:
- version_data = api_reply[0]['api_reply']['show_version_reply']
- ver = version_data['version'].rstrip('\0x00')
- if verbose:
- date = version_data['build_date'].rstrip('\0x00')
- loc = version_data['build_directory'].rstrip('\0x00')
- version = \
- 'VPP Version: {ver}\n' \
- 'Compile date: {date}\n' \
- 'Compile location: {loc}\n '\
- .format(ver=ver, date=date, loc=loc)
- else:
- version = 'VPP version:{ver}'.format(ver=ver)
- logger.info(version)
- else:
- raise PapiError('No reply received for show_version API command on '
- 'host {host}'.format(host=node['host']))
-
- @staticmethod
- def vpp_show_version_verbose(node):
- """Run "show_version" API command and return verbose string of version
- data.
-
- :param node: Node to run command on.
- :type node: dict