Skip to content

Commit

Permalink
Merge pull request #42 from e-sonic/merge-0217/broadcom_sonic_share-t…
Browse files Browse the repository at this point in the history
…o-dell_sonic_share

sync from broadcom_sonic_share to dell_sonic_share - 0217
  • Loading branch information
sameerlokray authored and GitHub Enterprise committed Feb 17, 2022
2 parents 4072024 + 5d4a141 commit f9edd88
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 20 deletions.
20 changes: 18 additions & 2 deletions CLI/actioner/sonic_cli_if_autoneg.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ def getPortInfo(if_list):

return if_dict

def getPortValidSpeeds(port):
link = "/restconf/data/sonic-port:sonic-port/PORT/PORT_LIST={0}/valid_speeds".format(
port.replace("/", "%2F"))
resp = aa.get(cc.Path(link))
if resp is None or not resp.ok() or 'sonic-port:valid_speeds' not in resp.content:
return ""
return resp.content['sonic-port:valid_speeds'].replace(' ', '')

def run(func, args):
path = None
Expand Down Expand Up @@ -197,8 +204,17 @@ def run(func, args):
for port in if_list:
if autoneg and not hasAutoNegSupport(port):
print(
("Error: {}: This feature is not supported".format(port)))
continue
("%Error: AutoNeg is not supported on {}".format(port)))
return
valid_speeds = getPortValidSpeeds(port).split(',')
bailout = False
for speed in advspds.split(','):
if speed not in valid_speeds:
print("%Error: Speed {} is not supported on {}, valid speeds={}".format(speed, port, ",".join(valid_speeds)))
bailout = True
break
if bailout:
return
data = {
"name": port,
"openconfig-if-ethernet:ethernet": {
Expand Down
34 changes: 17 additions & 17 deletions CLI/actioner/sonic_cli_snmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,19 +983,21 @@ def invoke(func, args):
u["group"] = grpResponse["name"]
break

auth = row["auth"]
if "md5" in auth:
u["auth"] = "md5"
elif "sha" in auth:
u["auth"] = "sha"
else:
u["auth"] = "None"
key = auth[u["auth"]]
value = key["key"]
value = value.encode("ascii")
value = value.translate(None, b":")
if value == "00000000000000000000000000000000":
u["auth"] = "None"
u["auth"] = "None"
if "auth" in row:
auth = row["auth"]
if "md5" in auth:
u["auth"] = "md5"
elif "sha" in auth:
u["auth"] = "sha"
else:
u["auth"] = "None"
key = auth[u["auth"]]
value = key["key"]
value = value.encode("ascii")
value = value.translate(None, b":")
if value == "00000000000000000000000000000000":
u["auth"] = "None"

u["priv"] = "None"
if "priv" in row:
Expand Down Expand Up @@ -1073,16 +1075,14 @@ def invoke(func, args):
args.pop(0) # remove 'priv-password'
privPassword = args.pop(0)

if authType == None:
authType = "md5"
privType = "des"
authKey = authPassword
privKey = privPassword

payload = {}
payload["name"] = user
payload["encrypted"] = encrypted
payload["auth"] = {authType: {"key": authKey}}
if not authType == None:
payload["auth"] = {authType: {"key": authKey}}
if not privType == None:
payload["priv"] = {privType: {"key": privKey}}

Expand Down
1 change: 1 addition & 0 deletions rest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ $(CERTGEN_BIN):
$(STATIC_CHECK): $(REST_GO_SRCS) | $$(@D)/.
$(MGMT_COMMON_DIR)/tools/test/static-check.sh \
--log=$(@D)/staticcheck.log \
--pkgtype=$(firstword $(MGMT_PKGS)) \
$(sort $(dir $?))
touch $@

Expand Down
14 changes: 13 additions & 1 deletion tools/test/cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ case "$1" in
-host) HOST=$2; shift 2 ;;
-port) PORT=$2; shift 2 ;;
-auth) AUTH=1; shift ;;
--printenv) PRINTENV=y; shift;;
PKG=*|-pkg=*|--pkg=*) PKG=${1#*=}; shift;;
*) ARGS+=("$1"); shift ;;
esac
Expand Down Expand Up @@ -92,7 +93,18 @@ export LD_LIBRARY_PATH=${KLISH_BIN}/.libs:${LD_LIBRARY_PATH}
DBCLI="$(type -t sonic-db-cli > /dev/null && echo sonic-db-cli CONFIG_DB || echo redis-cli -n 4)"

export SONIC_CLI_IFACE_MODE=$(${DBCLI} hget "DEVICE_METADATA|localhost" intf_naming_mode)
[[ -z ${DEBUG} ]] || echo "SONIC_CLI_IFACE_MODE = '${SONIC_CLI_IFACE_MODE}'"

if [[ ${PRINTENV} == y ]]; then
echo "export PYTHONPATH=${PYTHONPATH}"
echo "export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}"
echo "export REST_API_ROOT=${REST_API_ROOT}"
echo "export SONIC_CLI_ROOT=${SONIC_CLI_ROOT}"
echo "export SHOW_CONFIG_TOOLS=${SHOW_CONFIG_TOOLS}"
echo "export RENDERER_TEMPLATE_PATH=${RENDERER_TEMPLATE_PATH}"
echo "export SONIC_BRANDING_FILE=${SONIC_BRANDING_FILE}"
echo "export SONIC_CLI_IFACE_MODE=${SONIC_CLI_IFACE_MODE}"
exit 0
fi

(cd ${BUILDDIR} && ${KLISH_BIN}/clish "${ARGS[@]}")

0 comments on commit f9edd88

Please sign in to comment.