-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[sonic-py-common] Add platform.json to port_config files candidates only if interfaces are present within platform.json #5538
[sonic-py-common] Add platform.json to port_config files candidates only if interfaces are present within platform.json #5538
Conversation
Signed-off-by: vaibhav-dahiya <vdahiya@microsoft.com>
Signed-off-by: vaibhav-dahiya <vdahiya@microsoft.com>
if os.path.isfile(os.path.join(platform_path, PLATFORM_JSON_FILE)): | ||
json_file = os.path.join(platform_path, PLATFORM_JSON_FILE) | ||
platform_data = json.loads(open(json_file).read()) | ||
if len(platform_data.get("interfaces")) > 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you should also first check for the presence of the "interfaces" key. That way, if either the key is not present OR it is empty, we don't consider platform.json a candidate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Signed-off-by: vaibhav-dahiya <vdahiya@microsoft.com>
This reverts commit 166603d.
Signed-off-by: vaibhav-dahiya <vdahiya@microsoft.com>
Signed-off-by: vaibhav-dahiya <vdahiya@microsoft.com>
Retest this please |
Retest mellanox please |
Signed-off-by: vaibhav-dahiya <vdahiya@microsoft.com>
if interfaces: | ||
if len(interfaces) > 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe if interfaces:
should be enough, as it will return false if either interfaces
is None
or its length is 0. If you want to be more explicit, I recommend if interfaces is not None and len(interfaces) > 0:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Signed-off-by: vaibhav-dahiya <vdahiya@microsoft.com>
Retest this please |
Retest vsimage please |
1 similar comment
Retest vsimage please |
…nly if interfaces are present within platform.json (sonic-net#5538) * [sonic-py-common] add platform.json to port_config Signed-off-by: vaibhav-dahiya <vdahiya@microsoft.com>
Summary:
For this PR the motivation is to add logic so that platform.json is considered for port configuration candidates only if platform.json has an interfaces key
and the length of the key is greater than zero. This happened with new platform.json file utilized to test platform_api's infrastructure which in turn had interfaces key without any port configs.
Type of change
Approach
What is the motivation for this PR?
To make sure platform.json is not used for sonic-cfggen if it does not have "interfaces" key populated
How did you do it?
added logic to check if platform.json is present, check if "interfaces" key size is greater than zero
How did you verify/test it?
Run it on a mellanox-acs2700 platform and verify cfggen does not cause errors
Any platform specific information?
platform.json should be present without "interfaces" key populated
Signed-off-by: vaibhav-dahiya vdahiya@microsoft.com