from collections import deque
from six import moves, iteritems
-from vpp_papi import VPP, mac_pton
+from vpp_papi import VPPApiClient, mac_pton
from hook import Hook
from vpp_ip_route import MPLS_IETF_MAX_LABEL, MPLS_LABEL_INVALID
-class QOS_SOURCE:
- EXT = 0
- VLAN = 1
- MPLS = 2
- IP = 3
-
-
-class SYSLOG_SEVERITY:
- EMERG = 0
- ALERT = 1
- CRIT = 2
- ERR = 3
- WARN = 4
- NOTICE = 5
- INFO = 6
- DBG = 7
-
-
#
# Dictionary keyed on message name to override default values for
# named parameters
'ip_punt_redirect': {'is_add': 1, },
'ip_table_add_del': {'is_add': 1, },
'ip_unnumbered_dump': {'sw_if_index': 4294967295, },
- 'ipip_add_tunnel': {'is_ipv6': 1, 'instance': 4294967295, },
'ipsec_interface_add_del_spd': {'is_add': 1, },
'ipsec_sad_entry_add_del': {'is_add': 1, },
'ipsec_spd_add_del': {'is_add': 1, },
}
+class CliFailedCommandError(Exception):
+ """ cli command failed."""
+
+
+class CliSyntaxError(Exception):
+ """ cli command had a syntax error."""
+
+
class UnexpectedApiReturnValueError(Exception):
""" exception raised when the API return value is unexpected """
pass
self._expect_api_retval = self._zero
self._expect_stack = []
- install_dir = os.getenv('VPP_INSTALL_PATH')
-
- # Vapi requires 'VPP_API_DIR', not set when run from Makefile.
- if 'VPP_API_DIR' not in os.environ:
- os.environ['VPP_API_DIR'] = os.getenv('VPP_INSTALL_PATH')
+ # install_dir is a class attribute. We need to set it before
+ # calling the constructor.
+ VPPApiClient.apidir = os.getenv('VPP_INSTALL_PATH')
use_socket = False
try:
use_socket = True
except KeyError:
pass
- self.vpp = VPP(logger=test_class.logger,
- read_timeout=read_timeout,
- use_socket=use_socket,
- server_address=test_class.api_sock)
+
+ self.vpp = VPPApiClient(logger=test_class.logger,
+ read_timeout=read_timeout,
+ use_socket=use_socket,
+ server_address=test_class.api_sock)
self._events = deque()
def __enter__(self):
cli += '\n'
r = self.papi.cli_inband(cmd=cli)
self.hook.after_cli(cli)
+ if r.retval == -156:
+ raise CliSyntaxError(r.reply)
+ if r.retval != 0:
+ raise CliFailedCommandError(r.reply)
if hasattr(r, 'reply'):
return r.reply