diff options
author | Klement Sekera <ksekera@cisco.com> | 2017-03-01 09:53:19 +0100 |
---|---|---|
committer | Ole Trøan <otroan@employees.org> | 2017-03-03 07:58:23 +0000 |
commit | 7112c542eac53d28861062b13b602a2817dc4052 (patch) | |
tree | 103512272737c2088c8603645c96555fe1c4a594 /test/vpp_papi_provider.py | |
parent | a80ab84531fb1abd1e896d1adfa7e50fed80db39 (diff) |
python API: work towards python/vpp api separation
This change improves vpp_papi behaviour by introducing alternate way of
calling vpp APIs.
The common code is the same:
vpp = VPP(...)
vpp.connect(...)
Calling VPP API is different, instead of deprecated:
vpp.show_version() # deprecated
one should write
vpp.api.show_version()
this allows VPP messages like "connect" and "disconnect" to be used,
once the old API is dropped (in 17.07). Also part of this patch is a
check for name conflict, to prevent VPP object overwriting its own
functionality with generated code based on json files.
Change-Id: I22e573b6a45f8b2a1f0340c5c2597c194fe42ca4
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'test/vpp_papi_provider.py')
-rw-r--r-- | test/vpp_papi_provider.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/test/vpp_papi_provider.py b/test/vpp_papi_provider.py index de189c3eeaf..5d4d6b7ef0c 100644 --- a/test/vpp_papi_provider.py +++ b/test/vpp_papi_provider.py @@ -1,5 +1,4 @@ import os -import socket import fnmatch import time from hook import Hook @@ -56,7 +55,7 @@ class VppPapiProvider(object): for filename in fnmatch.filter(filenames, '*.api.json'): jsonfiles.append(os.path.join(root, filename)) - self.papi = VPP(jsonfiles) + self.vpp = VPP(jsonfiles) self._events = deque() def __enter__(self): @@ -124,12 +123,13 @@ class VppPapiProvider(object): def connect(self): """Connect the API to VPP""" - self.papi.connect(self.name, self.shm_prefix) - self.papi.register_event_callback(self) + self.vpp.connect(self.name, self.shm_prefix) + self.papi = self.vpp.api + self.vpp.register_event_callback(self) def disconnect(self): """Disconnect the API from VPP""" - self.papi.disconnect() + self.vpp.disconnect() def api(self, api_fn, api_args, expected_retval=0): """ Call API function and check it's return value. @@ -190,7 +190,7 @@ class VppPapiProvider(object): def show_version(self): """ """ - return self.papi.show_version() + return self.api(self.papi.show_version, {}) def pg_create_interface(self, pg_index): """ |