Skip to content

feat(scripts): created convenience shell scripts#4

Open
mrdrew213 wants to merge 1 commit into
cambrianworks:mainfrom
mrdrew213:main
Open

feat(scripts): created convenience shell scripts#4
mrdrew213 wants to merge 1 commit into
cambrianworks:mainfrom
mrdrew213:main

Conversation

@mrdrew213
Copy link
Copy Markdown

Shell scripts to get, set, check config
Shell script to power off a port

# Output file name
fname="request.jsonl"

echo '{ "method": "icfg.status.copy.get", "params": [], "id": 99 }' > "$fname"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator

@MichaelF-CW MichaelF-CW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ 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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
gs-rpc post -f $fname

# just the filename (file must be in the tftp dir
CONFIG=$(basename "$2")

# Output file name
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
gs-rpc post -f $fname

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

Successfully merging this pull request may close these issues.

2 participants