feat(scripts): created convenience shell scripts#4
Conversation
| # Output file name | ||
| fname="request.jsonl" | ||
|
|
||
| echo '{ "method": "icfg.status.copy.get", "params": [], "id": 99 }' > "$fname" |
There was a problem hiding this comment.
I think we can simplify a little with post -d to just inline the request so we don't have to generate (or overwrite) request.jsonl.
If the id isn't important, one will be filled in by gs-rpc if omitted.
Could also simplify to:
gs-rpc call icfg.status.copy.get
MichaelF-CW
left a comment
There was a problem hiding this comment.
Some suggestions inlined. If those are accepted, it leaves some lines that can be removed and files to rename.
| @@ -0,0 +1,14 @@ | |||
| #!/bin/bash | |||
| # Usage: ./check_config_status.sh | |||
There was a problem hiding this comment.
| # Usage: ./check_config_status.sh | |
| # Usage: ./check_copy_status.sh | |
| # The status indicates the status of current copy operation. | |
| # none(0) means no copy operation. | |
| # success(1) means copy operation is successful. | |
| # inProgress(2) means current copy operation is in progress. | |
| # errOtherInProcessing(3) means copy operation is failed due to other in processing. | |
| # errNoSuchFile(4) means copy operation is failed due to file not existing. | |
| # errSameSrcDst(5) means copy operation is failed due to the source and destination are the same. | |
| # errPermissionDenied(6) means copy operation is failed due to the destination is not permitted to modify. | |
| # errLoadSrc(7) means copy operation is failed due to the error to load source file. | |
| # errSaveDst(8) means copy operation is failed due to the error to save or commit destination." |
There was a problem hiding this comment.
^ This is just inlined from the json-rpc spec comments.
|
|
||
| # strip leading "/" from CONFIG if present | ||
| # CONFIG=${2#/} | ||
| # just the filename (file must be in the tftp dir |
There was a problem hiding this comment.
| # just the filename (file must be in the tftp dir | |
| # just the filename (file must be in the top tftp dir) |
| # Output file name | ||
| fname="request.jsonl" | ||
|
|
||
| echo '{ "method": "icfg.control.copy.set", "params": [{ "Copy": true, "SourceConfigType": "runningConfig", "SourceConfigFile": "", "DestinationConfigType": "configFile", "DestinationConfigFile": "tftp://'"$TFTP_SERVER_IP"'/'"$CONFIG"'", "Merge": false }], "id": 1 }' > "$fname" |
There was a problem hiding this comment.
| echo '{ "method": "icfg.control.copy.set", "params": [{ "Copy": true, "SourceConfigType": "runningConfig", "SourceConfigFile": "", "DestinationConfigType": "configFile", "DestinationConfigFile": "tftp://'"$TFTP_SERVER_IP"'/'"$CONFIG"'", "Merge": false }], "id": 1 }' > "$fname" | |
| gr-rpc post -d '{ "method": "icfg.control.copy.set", "params": [{ "Copy": true, "SourceConfigType": "runningConfig", "SourceConfigFile": "", "DestinationConfigType": "configFile", "DestinationConfigFile": "tftp://'"$TFTP_SERVER_IP"'/'"$CONFIG"'", "Merge": false }], "id": 1 }' |
| fname="request.jsonl" | ||
|
|
||
| echo '{ "method": "icfg.control.copy.set", "params": [{ "Copy": true, "SourceConfigType": "runningConfig", "SourceConfigFile": "", "DestinationConfigType": "configFile", "DestinationConfigFile": "tftp://'"$TFTP_SERVER_IP"'/'"$CONFIG"'", "Merge": false }], "id": 1 }' > "$fname" | ||
| gs-rpc post -f $fname |
There was a problem hiding this comment.
| gs-rpc post -f $fname |
| # just the filename (file must be in the tftp dir | ||
| CONFIG=$(basename "$2") | ||
|
|
||
| # Output file name |
There was a problem hiding this comment.
Shouldn't need to create a file artifact.
|
|
||
| if [[ "$port_num" == $MANAGEMENT_PORT ]]; then | ||
| echo "Warning, do not modify the management port power mode" | ||
| echo "If you really want to turn of the management port, type:" |
There was a problem hiding this comment.
| echo "If you really want to turn of the management port, type:" | |
| echo "If you really want to alter the management port, type:" |
| @@ -0,0 +1,19 @@ | |||
| #!/bin/bash | |||
| # Usage: ./set_running_config <tftp_server_ip> <config> | |||
There was a problem hiding this comment.
| # Usage: ./set_running_config <tftp_server_ip> <config> | |
| # Usage: ./set_running_config <tftp_server_ip> <config> | |
| # Update running-config by copying <config> file from tftp server. |
| # just the filename (file must be in the tftp dir) | ||
| CONFIG=$(basename "$2") | ||
|
|
||
| # Output file name |
There was a problem hiding this comment.
Can remove saving to output file.
| # Output file name | ||
| fname="request.jsonl" | ||
|
|
||
| echo '{ "method": "icfg.control.copy.set", "params": [{ "Copy": true, "DestinationConfigType": "runningConfig", "DestinationConfigFile": "", "SourceConfigType": "configFile", "SourceConfigFile": "tftp://'"$TFTP_SERVER_IP"'/'"$CONFIG"'", "Merge": false }], "id": 1 }' > "$fname" |
There was a problem hiding this comment.
| echo '{ "method": "icfg.control.copy.set", "params": [{ "Copy": true, "DestinationConfigType": "runningConfig", "DestinationConfigFile": "", "SourceConfigType": "configFile", "SourceConfigFile": "tftp://'"$TFTP_SERVER_IP"'/'"$CONFIG"'", "Merge": false }], "id": 1 }' > "$fname" | |
| gs-rpc post -d '{ "method": "icfg.control.copy.set", "params": [{ "Copy": true, "DestinationConfigType": "runningConfig", "DestinationConfigFile": "", "SourceConfigType": "configFile", "SourceConfigFile": "tftp://'"$TFTP_SERVER_IP"'/'"$CONFIG"'", "Merge": false }], "id": 1 }' |
| fname="request.jsonl" | ||
|
|
||
| echo '{ "method": "icfg.control.copy.set", "params": [{ "Copy": true, "DestinationConfigType": "runningConfig", "DestinationConfigFile": "", "SourceConfigType": "configFile", "SourceConfigFile": "tftp://'"$TFTP_SERVER_IP"'/'"$CONFIG"'", "Merge": false }], "id": 1 }' > "$fname" | ||
| gs-rpc post -f $fname |
There was a problem hiding this comment.
| gs-rpc post -f $fname |
Shell scripts to get, set, check config
Shell script to power off a port