diff --git a/README b/README index 8a7a3c2..fdaa0fe 100644 --- a/README +++ b/README @@ -104,8 +104,6 @@ command-line interface (CLI) to manage endpoints. The sample scripts are location in the following directory: lib/python2.7/site-packages/pylxca-1.0-py2.7.egg/pylxca\test - License ------- - Apache Software License (http://www.apache.org/licenses/LICENSE-2.0) diff --git a/pylxca/__init__.py b/pylxca/__init__.py index 0dbd506..2d44dcd 100644 --- a/pylxca/__init__.py +++ b/pylxca/__init__.py @@ -1,6 +1,6 @@ # Version of the pylxca package -__version__ = '2.1.0' +__version__ = '2.2.0' # There are submodules, but clients shouldn't need to know about them. diff --git a/pylxca/pylxca_api/lxca_api.py b/pylxca/pylxca_api/lxca_api.py index 265d5d4..3978c85 100644 --- a/pylxca/pylxca_api/lxca_api.py +++ b/pylxca/pylxca_api/lxca_api.py @@ -186,7 +186,7 @@ def disconnect( self, dict_handler=None): def get_log_level(self, dict_handler=None): lvl = None if dict_handler: - lvl = dict_handler['l'] or dict_handler['lvl'] + lvl = next((item for item in [dict_handler.get('l') , dict_handler.get('lvl')] if item is not None),None) if lvl == None: lvl = lxca_rest().get_log_level() else: @@ -581,6 +581,8 @@ def get_jobs( self, dict_handler = None ): try: if jobid: py_obj = json.loads(resp.text) + py_obj = {'jobsList': [py_obj]} + return py_obj if canceljobid or deletejobid: return resp else: diff --git a/pylxca/pylxca_api/lxca_rest.py b/pylxca/pylxca_api/lxca_rest.py index cf01645..4594d9c 100644 --- a/pylxca/pylxca_api/lxca_rest.py +++ b/pylxca/pylxca_api/lxca_rest.py @@ -225,10 +225,13 @@ def set_log_config(self): def get_log_level(self): logger.debug("Current Log Level is: " + str(logger.getEffectiveLevel())) - return logger.getEffectiveLevel() + return logging.getLevelName(logger.getEffectiveLevel()) def set_log_level(self,log_value): logger.setLevel(log_value) + for handler in logger.handlers: + handler.setLevel(log_value) + logger.debug("Current Log Level is: " + str(logger.getEffectiveLevel())) return def do_discovery(self,url, session, ip_addr,jobid): @@ -847,7 +850,7 @@ def do_updatecomp(self, url, session, query, mode, action, server, switch, stora url= url + "?action=" + action - if not mode == None and mode == "immediate" or mode == "delayed" : + if not mode == None and mode == "immediate" or mode == "delayed" or mode == "prioritized": url= url + "&activationMode=" + mode else: raise Exception("Invalid argument mode") @@ -926,7 +929,7 @@ def do_updatecomp_all(self, url, session, action, mode,dev_list): if action == "apply" or action == "cancelApply": url = url + "?action=" + action - if not mode == None and mode == "immediate" or mode == "delayed": + if not mode == None and mode == "immediate" or mode == "delayed" or mode == "prioritized": url = url + "&activationMode=" + mode else: raise Exception("Invalid argument mode") @@ -1273,7 +1276,6 @@ def get_osimage(self, osimages_info, **kwargs): url = '' kwargs.pop("url", None) kwargs.pop("session", None) - if not osimages_info and ('id' not in kwargs or 'fileName' not in kwargs): url = baseurl + '/osImages' if 'hostPlatforms' in osimages_info: diff --git a/pylxca/pylxca_cmd/lxca_cmd.py b/pylxca/pylxca_cmd/lxca_cmd.py index 71ac2d0..c9635c4 100644 --- a/pylxca/pylxca_cmd/lxca_cmd.py +++ b/pylxca/pylxca_cmd/lxca_cmd.py @@ -115,7 +115,7 @@ class log(InteractiveCommand): """ def handle_no_input(self,con_obj = None): api = pylxca.pylxca_api.lxca_api() - self.sprint("Current Log Level is set to " + str(logging.getLevelName(api.get_log_level()))) + self.sprint("Current Log Level is set to " + str(api.get_log_level())) message = """ Possible Log Levels, Please use following values to set desired log level. @@ -132,7 +132,7 @@ def handle_no_input(self,con_obj = None): def handle_output(self, out_obj): api = pylxca.pylxca_api.lxca_api() if out_obj == True: - self.sprint("Current Log Level is set to " + logging.getLevelName(api.get_log_level())) + self.sprint("Current Log Level is set to " + api.get_log_level()) else: self.sprint("Fail to set Log Level") message = """ @@ -513,7 +513,7 @@ class ffdc(InteractiveCommand): Retrieve and Manage information about ffdc USAGE: - ffdc [-u ] + ffdc -u OPTIONS: -u, --uuid @@ -620,6 +620,8 @@ class updatecomp(InteractiveCommand): -m, --mode Indicates when to activate the update. This can be one of the following values. immediate - Uses Immediate Activation mode when applying firmware updates to the selected endpoints. delayed - Uses Delayed Activation mode when applying firmware updates to the selected endpoints. + prioritized - Firmware updates on the baseboard management controller are activated immediately + -a, --action The action to take. This can be one of the following values. apply - Applies the associated firmware to the submitted components. power - Perform power action on selected endpoint. diff --git a/pylxca/pylxca_cmd/lxca_pyshell.py b/pylxca/pylxca_cmd/lxca_pyshell.py index 850be7a..44f977e 100644 --- a/pylxca/pylxca_cmd/lxca_pyshell.py +++ b/pylxca/pylxca_cmd/lxca_pyshell.py @@ -928,6 +928,7 @@ def updatecomp(*args, **kwargs): mode Indicates when to activate the update. This can be one of the following values. immediate - Uses Immediate Activaton mode when applying firmware updates to the selected endpoints. delayed - Uses Delayed Activaton mode when applying firmware updates to the selected endpoints. + prioritized. Firmware updates on the baseboard management controller are activated immediately action The action to take. This can be one of the following values. apply - Applies the associated firmware to the submitted components. @@ -1033,9 +1034,10 @@ def ffdc(*args, **kwargs): @param The parameters for this command are as follows - uuid UUID of the target endpoint + uuid UUID of the target endpoint this is manadatory parameter -@example +@example + ffdc(con = lxca_con, uuid='UUID of endpoint") ''' global shell_obj @@ -1067,25 +1069,40 @@ def log(*args, **kwargs): Where KeyList is as follows - keylist = ['con','filter'] + keylist = ['con','lvl'] @param The parameters for this command are as follows - filter filter for the event + lvl log level to be set + Possible Log Levels, Please use following values to set desired log level. + + DEBUG: Detailed information, typically of interest only when diagnosing problems. + INFO: Confirmation that things are working as expected. + WARNING: An indication that something unexpected happened, or indicative of some problem in the near future. + ERROR: Due to a more serious problem, the software has not been able to perform some function. + CRITICAL: A serious error, indicating that the program itself may be unable to continue running. @example ''' global shell_obj command_name = sys._getframe().f_code.co_name - keylist = ['lvl'] - for i in range(len(args)): - kwargs[keylist[i]] = args[i] + param_dict = {} + con = None + + long_short_key_map = {'lvl':'l'} + keylist = ['con','lvl'] + optional_keylist = ['con', 'lvl'] + mutually_exclusive_keys = [] + mandatory_options_list = {} - ch = shell_obj.handle_input_args(command_name, args=args, kwargs=kwargs) - return ch + con = _validate_param(keylist, long_short_key_map, mandatory_options_list, optional_keylist, mutually_exclusive_keys, + param_dict, *args, **kwargs) + + out_obj = shell_obj.handle_input_dict(command_name, con, param_dict) + return out_obj def lxcalog(*args, **kwargs): ''' @@ -1376,6 +1393,12 @@ def _validate_param(keylist, long_short_key_map, mandatory_options_list, optiona me_key, str(mutually_exclusive_keys))) raise AttributeError("Invalid command invocation") me_key_found = True + + if not set(keylist + long_short_key_map.values()).issuperset(set(kwargs.keys())): + logger.error(" Invalid Input args: %s unsupported argument passed" + % list(set(kwargs.keys()).difference(set(keylist + long_short_key_map.values())))) + raise ValueError("Invalid Input Arguments") + return con def osimages(*args, **kwargs): @@ -1444,6 +1467,7 @@ def osimages(*args, **kwargs): con = None param_dict = {} param_dict = kwargs + kwargs = {} # this is required to avoid invalid argument error in _validate_param command_name = sys._getframe().f_code.co_name long_short_key_map = {'osimages_info':'i'}