diff --git a/README.md b/README.md
index cd9aca9..4dca06a 100644
--- a/README.md
+++ b/README.md
@@ -16,15 +16,9 @@ Lenovo XClarity Administrator REST APIs to automate functions such as:
* Configuring servers through the use of Configuration Patterns
* Applying firmware updates to endpoints
-Whats New in 2.4.0
+Whats New in 2.5.0
------------------
-* Argument Parsing library replaced from optparse to argparse.
-* Support for subcmd under various commands.
-* New commands supported under shell
- osimages
- managementserver
- resourcegroups
-* Better Error handling.
+* Few bug fixes for views and jobs command
Installation
------------
@@ -49,7 +43,7 @@ Complete the following steps to install the PYLXCA CLI.
$lxca_shell
--------------------------------------------------
- Welcome to PyLXCA Shell v2.4.0
+ Welcome to PyLXCA Shell v2.5.0
Type "help" at any time for a list of commands.
Type "pyshell" at any time to get interactive python shell
--------------------------------------------------
@@ -60,7 +54,7 @@ Complete the following steps to install the PYLXCA CLI.
$lxca_shell --api
- Interactive Python Shell for Lenovo XClarity Administrator v2.4.0
+ Interactive Python Shell for Lenovo XClarity Administrator v2.5.0
Type "dir()" or "help(lxca command object)" for more information.
>>>
@@ -77,12 +71,11 @@ API Reference
-------------
PyLXCA command reference is available at
- http://ralfss30.labs.lenovo.com:8120/help/topic/com.lenovo.lxca.doc/pycli_overview.html
-
+ https://sysmgt.lenovofiles.com/help/index.jsp?topic=%2Fcom.lenovo.lxca_restapis.doc%2Fpycli_overview.html&cp=1_23_1
PyLXCA API Help can be seen from Interactive Python Shell as follows.
$lxca_shell --api
- Interactive Python Shell for Lenovo XClarity Administrator v2.4.0
+ Interactive Python Shell for Lenovo XClarity Administrator v2.5.0
Type "dir()" or "help(lxca command object)" for more information.
>>>
>>> help(connect)
diff --git a/pylxca/__init__.py b/pylxca/__init__.py
index 9add7be..135b3ca 100644
--- a/pylxca/__init__.py
+++ b/pylxca/__init__.py
@@ -1,6 +1,6 @@
# Version of the pylxca package
-__version__ = '2.4.0'
+__version__ = '2.5.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 045a211..870ea39 100644
--- a/pylxca/pylxca_api/lxca_api.py
+++ b/pylxca/pylxca_api/lxca_api.py
@@ -551,9 +551,14 @@ def get_configprofiles( self, dict_handler = None ):
elif subcmd == 'activate' and endpoint and restart:
resp = lxca_rest().post_configprofiles(self.con.get_url(), self.con.get_session(), profileid, endpoint, restart)
elif subcmd == 'delete' and profileid:
- resp = lxca_rest().delete_configprofiles(self.con.get_url(), self.con.get_session(), profileid)
+ resp = lxca_rest().delete_configprofiles(self.con.get_url(), self.con.get_session(), profileid)
elif subcmd == 'unassign' and profileid:
- resp = lxca_rest().unassign_configprofiles(self.con.get_url(), self.con.get_session(), profileid, powerdown, resetimm, resetswitch, force)
+ resp = lxca_rest().unassign_configprofiles(self.con.get_url(), self.con.get_session(), profileid, powerdown, resetimm, resetswitch, force)
+ if len(resp.text):
+ py_obj = json.loads(resp.text)
+ py_obj['dummy'] = {'status': []}
+ return py_obj
+
elif subcmd == 'list':
resp = lxca_rest().get_configprofiles(self.con.get_url(),self.con.get_session(),profileid)
@@ -797,6 +802,7 @@ def get_set_tasks(self, dict_handler=None):
action = None
status = None
cmd_updateList = None
+ template = None
if not self.con:
raise ConnectionError("Connection is not Initialized.")
@@ -806,6 +812,7 @@ def get_set_tasks(self, dict_handler=None):
includeChildren = next((item for item in [ dict_handler.get('children')] if item is not None), "true")
action = next((item for item in [dict_handler.get('action')] if item is not None), None)
updateList = next((item for item in [dict_handler.get('updateList')] if item is not None), None)
+ template = next((item for item in [dict_handler.get('template')] if item is not None), None)
#if updateList:
# updateList = updateList['taskList']
@@ -819,6 +826,9 @@ def get_set_tasks(self, dict_handler=None):
elif action in ['update']:
resp = lxca_rest().put_tasks_update(self.con.get_url(), self.con.get_session(), updateList)
py_obj = resp.status_code
+ elif action in ['create']:
+ resp = lxca_rest().post_tasks(self.con.get_url(), self.con.get_session(), template)
+ py_obj = resp
else:
resp = lxca_rest().get_tasks(self.con.get_url(), self.con.get_session(), job_uuid, includeChildren)
py_obj = json.loads(resp.text)
@@ -1087,7 +1097,7 @@ def get_set_storedcredentials(self, dict_handler=None):
elif user_name and password:
resp = lxca_rest().post_storedcredentials(self.con.get_url(), self.con.get_session(), user_name, password, description)
py_obj = json.loads(resp.text)
- resp = {'storedcredentialsList': py_obj['response']}
+ resp = {'storedcredentialsList': [py_obj['response']]}
else:
resp = lxca_rest().get_storedcredentials(self.con.get_url(), self.con.get_session(), id)
py_obj = json.loads(resp.text)
diff --git a/pylxca/pylxca_api/lxca_rest.py b/pylxca/pylxca_api/lxca_rest.py
index 4001acd..cf85df2 100644
--- a/pylxca/pylxca_api/lxca_rest.py
+++ b/pylxca/pylxca_api/lxca_rest.py
@@ -1172,6 +1172,24 @@ def get_tasks(self,url, session, job_uid, includeChildren):
raise re
return resp
+ def post_tasks(self, url, session, post_dict):
+ '''
+ Handle action post
+ '''
+
+
+ url = url + '/tasks'
+
+ payload = post_dict
+
+ try:
+ resp = session.post(url, data=json.dumps(payload), verify=False, timeout=REST_TIMEOUT)
+ resp.raise_for_status()
+ except HTTPError as re:
+ logger.error("REST API Exception: Exception = %s", re)
+ raise re
+ return resp
+
def put_tasks(self, url, session, job_uuid, action):
'''
Handle action cancel
@@ -1212,9 +1230,9 @@ def put_tasks_update(self, url, session, updated_dict):
'''
- url = url + '/tasks'
+ url = url + '/tasks' + '/' + updated_dict[0]['jobUID']
- payload = updated_dict
+ payload = updated_dict[0]
try:
resp = resp = session.put(url, data=json.dumps(payload), verify=False, timeout=REST_TIMEOUT)
diff --git a/pylxca/pylxca_cmd/lxca_cmd_data.json b/pylxca/pylxca_cmd/lxca_cmd_data.json
index cf45819..8d58a46 100644
--- a/pylxca/pylxca_cmd/lxca_cmd_data.json
+++ b/pylxca/pylxca_cmd/lxca_cmd_data.json
@@ -43,13 +43,6 @@
"disconnect": {
"description": "Disconnect session from LXCA",
"cmd_args": [
- [{
- "args": "-c,--con",
- "opt_dict": {
- "help": "connection object"
- }
- }
- ]
]
},
@@ -425,6 +418,14 @@
"storedcredentials": {
"description": "Retrieve and update stored credentials on lxca.",
+ "additional_detail": ["Example List all storedcredentials",
+ "storedcredentials",
+ "Example Create storedcredentials",
+ "storedcredentials -u admin -p Passw0rd -d \"Test User\" -v create",
+ "Example modify storedcredentials",
+ "storedcredentials -i 2056 -u admin -p Passw0rd -d \"Test User\" -v result",
+ "Example delete storedcredentials",
+ "storedcredentials --delete_id 2056 -v result"],
"cmd_args": [
[{
"args": "-i,--id",
@@ -495,7 +496,8 @@
"tasks -a update -u '[{\"jobUID\":\"9\",\"percentage\":50}]'"],
"valid_combination": {"global":[[], ["children"], ["jobUID"], ["jobUID","children"],
["jobUID", "action"],
- ["action", "updateList"]
+ ["action", "updateList"],
+ ["action", "template"]
]
},
"cmd_args": [
@@ -525,7 +527,7 @@
"args": "-a,--action",
"opt_dict": {
"help": "action to perform",
- "choices": ["cancel", "update", "delete"]
+ "choices": ["cancel", "update", "delete","create"]
}
}
],
@@ -536,8 +538,16 @@
"type": "ast.literal_eval"
}
}
- ]
- ]
+ ],
+ [{
+ "args": "-t,--template",
+ "opt_dict": {
+ "help": "Template for creating new task",
+ "type": "json.loads"
+ }
+ }
+ ]
+ ]
},
"unmanage": {
"description": "Unmanage device on LXCA",
@@ -571,7 +581,13 @@
{
"args": "-f,--force",
"opt_dict": {
- "help": "Force manage"
+ "help": "Force manage",
+ "choices": [
+ "True",
+ "true",
+ "False",
+ "false"
+ ]
}
}
]
@@ -665,7 +681,13 @@
[{
"args": "-f,--force",
"opt_dict": {
- "help": "Force manage"
+ "help": "Force manage",
+ "choices": [
+ "True",
+ "true",
+ "False",
+ "false"
+ ]
}
}
]
@@ -1047,21 +1069,39 @@
{
"args": "-p,--powerdown",
"opt_dict": {
- "help": "Identifies whether to power off the server"
+ "help": "Identifies whether to power off the server",
+ "choices": [
+ "True",
+ "true",
+ "False",
+ "false"
+ ]
}
}
],
[{
"args": "--resetimm",
"opt_dict": {
- "help": "Identifies whether to reset the baseboard management controller."
+ "help": "Identifies whether to reset the baseboard management controller.",
+ "choices": [
+ "True",
+ "true",
+ "False",
+ "false"
+ ]
}
}
],
[{
"args": "--resetswitch",
"opt_dict": {
- "help": "Identifies whether to reset the switch internal port settings to default values"
+ "help": "Identifies whether to reset the switch internal port settings to default values",
+ "choices": [
+ "True",
+ "true",
+ "False",
+ "false"
+ ]
}
}
],
@@ -1069,7 +1109,13 @@
{
"args": "-f,--force",
"opt_dict": {
- "help": "Identifies whether to force profile deactivation"
+ "help": "Identifies whether to force profile deactivation",
+ "choices": [
+ "True",
+ "true",
+ "False",
+ "false"
+ ]
}
}
]
diff --git a/pylxca/pylxca_cmd/lxca_filters.xml b/pylxca/pylxca_cmd/lxca_filters.xml
index 0057221..6f2fdf7 100644
--- a/pylxca/pylxca_cmd/lxca_filters.xml
+++ b/pylxca/pylxca_cmd/lxca_filters.xml
@@ -533,6 +533,23 @@
managementPatternPresent
rackID
+
+
+ identifier
+
+
+ locationIds
+ endPointNames
+ uuidsFailed
+ jobRecordId
+ jobName
+ endPointIds
+ locationIdsFailed
+ message
+
+
+
+ message
ID
@@ -589,6 +606,16 @@
description
id
+
+ id
+
+
+ result
+
+ explanation
+ text
+
+
result
diff --git a/pylxca/pylxca_cmd/lxca_ishell.py b/pylxca/pylxca_cmd/lxca_ishell.py
index 9c31c54..11510a5 100644
--- a/pylxca/pylxca_cmd/lxca_ishell.py
+++ b/pylxca/pylxca_cmd/lxca_ishell.py
@@ -142,7 +142,6 @@ def __init__(self,
self.add_command(lxca_cmd.cmms(self))
self.add_command(lxca_cmd.scalablesystem(self))
self.add_command(lxca_cmd.ostream(self))
- self.add_command(lxca_cmd.jobs(self))
self.add_command(lxca_cmd.discover(self))
self.add_command(lxca_cmd.manage(self))
self.add_command(lxca_cmd.unmanage(self))
diff --git a/pylxca/pylxca_cmd/lxca_pyshell.py b/pylxca/pylxca_cmd/lxca_pyshell.py
index 4dd34cc..e76daf6 100644
--- a/pylxca/pylxca_cmd/lxca_pyshell.py
+++ b/pylxca/pylxca_cmd/lxca_pyshell.py
@@ -46,7 +46,6 @@ def set_interactive():
"discover": discover,
"manage": manage,
"unmanage": unmanage,
- "jobs": jobs,
"users": users,
"lxcalog": lxcalog,
"ffdc": ffdc,
@@ -152,7 +151,7 @@ def disconnect(*args, **kwargs):
mutually_exclusive_keys,
param_dict, *args, **kwargs)
- out_obj = SHELL_OBJ.handle_input_dict(command_name, con, param_dict)
+ out_obj = SHELL_OBJ.handle_input_dict(command_name, con, param_dict, False)
return out_obj
@@ -821,6 +820,13 @@ def configprofiles(*args, **kwargs):
param_dict, *args, **kwargs)
out_obj = SHELL_OBJ.handle_input_dict(command_name, con, param_dict)
+
+ #remove dummy field added for view
+ if 'dummy' in out_obj:
+ out_obj.pop('dummy')
+ return out_obj
+
+
return out_obj
@@ -1381,7 +1387,7 @@ def tasks(*args, **kwargs):
con Connection Object to Lenovo XClarity Administrator
jobUID uuid of job
children result will include children if True
- action cancel/update
+ action cancel/update/create
updateList required for update action , string containing list of update
@example
@@ -1399,9 +1405,9 @@ def tasks(*args, **kwargs):
con = None
long_short_key_map = {'jobUID': 'j', 'children': 'c',
- 'action': 'a', 'updateList': 'u'}
- keylist = ['con', 'jobUID', 'children', 'action', 'updateList']
- optional_keylist = ['con', 'jobUID', 'children', 'action', 'updateList']
+ 'action': 'a', 'updateList': 'u', 'template': 't'}
+ keylist = ['con', 'jobUID', 'children', 'action', 'updateList','template']
+ optional_keylist = ['con', 'jobUID', 'children', 'action', 'updateList','template']
mutually_exclusive_keys = []
mandatory_options_list = {}