X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FPapiExecutor.py;h=8e59eff5104980c55d2c5f836438f1a5a8a32b0b;hp=792fa4c3b362dcd0b975162d89fef6898acdc3bc;hb=a4c6a63b84f537b3ae660eab7d2a96ffb7740514;hpb=29726f92698452f51033fc3ab52f112b74eae594 diff --git a/resources/libraries/python/PapiExecutor.py b/resources/libraries/python/PapiExecutor.py index 792fa4c3b3..8e59eff510 100644 --- a/resources/libraries/python/PapiExecutor.py +++ b/resources/libraries/python/PapiExecutor.py @@ -15,6 +15,7 @@ """ import binascii +import copy import glob import json import shutil @@ -131,7 +132,7 @@ class PapiSocketExecutor(object): api_json_directory = None crc_checker_instance = None - def __init__(self, node, remote_vpp_socket="/run/vpp-api.sock"): + def __init__(self, node, remote_vpp_socket=Constants.SOCKSVR_PATH): """Store the given arguments, declare managed variables. :param node: Node to connect to and forward unix domain socket from. @@ -148,8 +149,7 @@ class PapiSocketExecutor(object): self._ssh_control_socket = None self._local_vpp_socket = None - @property - def crc_checker(self): + def create_crc_checker(self): """Return the cached instance or create new one from directory. It is assumed self.api_json_directory is set, as a class variable. @@ -204,7 +204,7 @@ class PapiSocketExecutor(object): cls.api_json_directory = tmp_dir + "/usr/share/vpp/api" # Perform initial checks before .api.json files are gone, # by accessing the property (which also creates its instance). - self.crc_checker + self.create_crc_checker() # When present locally, we finally can find the installation path. package_path = glob.glob(tmp_dir + installed_papi_glob)[0] # Package path has to be one level above the vpp_papi directory. @@ -333,9 +333,11 @@ class PapiSocketExecutor(object): def add(self, csit_papi_command, history=True, **kwargs): """Add next command to internal command list; return self. + Unless disabled, new entry to papi history is also added at this point. The argument name 'csit_papi_command' must be unique enough as it cannot be repeated in kwargs. - Unless disabled, new entry to papi history is also added at this point. + The kwargs dict is deep-copied, so it is safe to use the original + with partial modifications for subsequent commands. Any pending conflicts from .api.json processing are raised. Then the command name is checked for known CRCs. @@ -355,13 +357,11 @@ class PapiSocketExecutor(object): :rtype: PapiSocketExecutor :raises RuntimeError: If unverified or conflicting CRC is encountered. """ - self.crc_checker.report_initial_conflicts() if history: PapiHistory.add_to_papi_history( self._node, csit_papi_command, **kwargs) - self.crc_checker.check_api_name(csit_papi_command) self._api_command_list.append( - dict(api_name=csit_papi_command, api_args=kwargs)) + dict(api_name=csit_papi_command, api_args=copy.deepcopy(kwargs))) return self def get_replies(self, err_msg="Failed to get replies."): @@ -519,7 +519,6 @@ class PapiSocketExecutor(object): if not isinstance(reply, list): reply = [reply] for item in reply: - self.crc_checker.check_api_name(item.__class__.__name__) dict_item = dictize(item) if "retval" in dict_item.keys(): # *_details messages do not contain retval. @@ -604,6 +603,8 @@ class PapiExecutor(object): The argument name 'csit_papi_command' must be unique enough as it cannot be repeated in kwargs. + The kwargs dict is deep-copied, so it is safe to use the original + with partial modifications for subsequent commands. :param csit_papi_command: VPP API command. :param history: Enable/disable adding command to PAPI command history. @@ -617,8 +618,8 @@ class PapiExecutor(object): if history: PapiHistory.add_to_papi_history( self._node, csit_papi_command, **kwargs) - self._api_command_list.append(dict(api_name=csit_papi_command, - api_args=kwargs)) + self._api_command_list.append(dict( + api_name=csit_papi_command, api_args=copy.deepcopy(kwargs))) return self def get_stats(self, err_msg="Failed to get statistics.", timeout=120):