Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Input validation for "Rack-Tower Server" not handled correctly in lxca_rest.py #23

Open
VirtuSapiens opened this issue Dec 21, 2024 · 0 comments

Comments

@VirtuSapiens
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant