-
Notifications
You must be signed in to change notification settings - Fork 95
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
[fpmsyncd] Added CLI for Fpmsyncd Next Hop Table Enhancement #122
Open
ntt-omw
wants to merge
4
commits into
sonic-net:master
Choose a base branch
from
ntt-omw:ntt_fpmsyncd_enhanced
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/python | ||
########################################################################### | ||
# | ||
# Copyright (C) 2023 NIPPON TELEGRAPH AND TELEPHONE CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
########################################################################### | ||
|
||
import sys | ||
import cli_client as cc | ||
import re | ||
|
||
|
||
def config_nhg_feature(enable): | ||
body = None | ||
aa = cc.ApiClient() | ||
|
||
if enable: | ||
keypath = cc.Path("/restconf/data/sonic-device_metadata:sonic-device_metadata") | ||
body = { | ||
"sonic-device_metadata": { | ||
"DEVICE_METADATA": {"localhost": {"nexthop_group": "enabled"}} | ||
} | ||
} | ||
return aa.patch(keypath, body) | ||
else: | ||
keypath = cc.Path( | ||
"/restconf/data/sonic-device_metadata:sonic-device_metadata/DEVICE_METADATA/localhost/nexthop_group" | ||
) | ||
return aa.delete(keypath) | ||
|
||
|
||
def invoke(func, enable): | ||
if func == "configure_sonic_nexthop_groups": | ||
return config_nhg_feature(enable == "1") | ||
|
||
|
||
def run(func, enable): | ||
if func != "configure_sonic_nexthop_groups": | ||
print("%Error: Invalid function") | ||
return | ||
|
||
try: | ||
api_response = invoke(func, enable) | ||
except ValueError as err_msg: | ||
print( | ||
"%Error: An exception occurred while attempting to execute " | ||
"the requested RPC call: {}".format(err_msg) | ||
) | ||
|
||
if not api_response.ok(): | ||
# Print the message for a failing return code | ||
print("CLI transformer error: ") | ||
print(" status code: {}".format(api_response.status_code)) | ||
if ( | ||
"error" in api_response.errors() | ||
and len(api_response.errors()["error"]) >= 1 | ||
and "error-message" in api_response.errors()["error"][0] | ||
): | ||
print( | ||
" error: {}".format( | ||
api_response.errors()["error"][0]["error-message"] | ||
) | ||
) | ||
return | ||
|
||
print("Success") | ||
|
||
|
||
if __name__ == "__main__": | ||
run(sys.argv[1], sys.argv[2]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (C) 2023 NIPPON TELEGRAPH AND TELEPHONE CORPORATION. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
<CLISH_MODULE | ||
xmlns="http://www.dellemc.com/sonic/XMLSchema" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:xi="http://www.w3.org/2001/XInclude" | ||
xsi:schemaLocation="http://www.dellemc.com/sonic/XMLSchema | ||
http://www.dellemc.com/sonic/XMLSchema/clish.xsd" | ||
> | ||
<!--=========================================================================--> | ||
|
||
<VIEW name="configure-view"> | ||
|
||
<COMMAND name="feature" help="Configure additional feature"></COMMAND> | ||
<COMMAND name="feature next-hop-group" help="Next-hop Groups feature"></COMMAND> | ||
<COMMAND name="feature next-hop-group enable" help="Enable Next-hop Groups feature"> | ||
<ACTION> | ||
python3 $SONIC_CLI_ROOT/sonic-cli-feature.py configure_sonic_nexthop_groups 1 | ||
</ACTION> | ||
</COMMAND> | ||
|
||
<COMMAND name="no feature" help="Disable additional feature"></COMMAND> | ||
<COMMAND name="no feature next-hop-group" help="Disable Next-hop Groups feature"> | ||
<ACTION> | ||
python3 $SONIC_CLI_ROOT/sonic-cli-feature.py configure_sonic_nexthop_groups 0 | ||
</ACTION> | ||
</COMMAND> | ||
|
||
</VIEW> | ||
</CLISH_MODULE> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
In the HLD it is mentioned that the enable disable cannot be changed in run time. Then why do we have a CLI which can modify it? If it doesn't take effect we should have a log message asking the user to save and reboot