Description
While using the script lxca_rest.py, I encountered an issue in the input validation for the parameter "Rack-Tower Server". The script raises an exception even though there is handling for this type. It appears the validation logic does not account for the correct naming.
Additionally, the value "Rack-Tower Server" is returned by Lenovo XClarity Administrator (LXCA) in the REST API call /nodes.
Issue
The condition if type not in type_list: does not account for "Rack-Tower Server", which should be mapped to "Rack-Tower". As a result, passing "Rack-Tower Server" as the input parameter causes an exception.
Impact
The script fails to execute correctly for Rack-Tower servers, and the exception prevents completion of related operations.
Details
The problematic lines are located in the file lxca_rest.py, around lines 439-440:
# Fetch type value from input
type_list = ["Chassis","Rackswitch","ThinkServer","Storage","Rack-Tower","Edge"]
if type not in type_list:
raise Exception("Invalid Type Specified")
if type == "ThinkServer": type = "Lenovo ThinkServer"
elif type == "Storage": type = "Lenovo Storage"
elif type == "Rack-Tower": type = "Rack-Tower Server"
elif type == "Edge": type = "Edge Server"
Expected Behavior
The script should correctly validate "Rack-Tower Server" as a valid type and execute without raising an exception.
Actual Behavior
The script raises an exception due to the input validation mismatch.
Proposed Fix
Update the type_list to include "Rack-Tower Server", or adjust the conditional logic to handle the conversion properly.
Add a conversion step
type_list = ["Chassis","Rackswitch","ThinkServer","Storage","Rack-Tower","Edge"]
if type == "Rack-Tower Server":
type = "Rack-Tower"
if type not in type_list:
raise Exception("Invalid Type Specified")
if type == "ThinkServer": type = "Lenovo ThinkServer"
elif type == "Storage": type = "Lenovo Storage"
elif type == "Rack-Tower": type = "Rack-Tower Server"
elif type == "Edge": type = "Edge Server"
Additional Context
The value "Rack-Tower Server" is retrieved from LXCA when making the REST API call to /nodes, and this value should be properly handled by the script to ensure compatibility with LXCA's responses.
Description
While using the script
lxca_rest.py, I encountered an issue in the input validation for the parameter"Rack-Tower Server". The script raises an exception even though there is handling for this type. It appears the validation logic does not account for the correct naming.Additionally, the value
"Rack-Tower Server"is returned by Lenovo XClarity Administrator (LXCA) in the REST API call/nodes.Issue
The condition
if type not in type_list:does not account for"Rack-Tower Server", which should be mapped to"Rack-Tower". As a result, passing"Rack-Tower Server"as the input parameter causes an exception.Impact
The script fails to execute correctly for Rack-Tower servers, and the exception prevents completion of related operations.
Details
The problematic lines are located in the file
lxca_rest.py, around lines 439-440:Expected Behavior
The script should correctly validate "Rack-Tower Server" as a valid type and execute without raising an exception.
Actual Behavior
The script raises an exception due to the input validation mismatch.
Proposed Fix
Update the type_list to include "Rack-Tower Server", or adjust the conditional logic to handle the conversion properly.
Add a conversion step
Additional Context
The value "Rack-Tower Server" is retrieved from LXCA when making the REST API call to /nodes, and this value should be properly handled by the script to ensure compatibility with LXCA's responses.