From 4d71bc46185054430ed2139899c27168b76365e1 Mon Sep 17 00:00:00 2001 From: Dante Su Date: Tue, 15 Feb 2022 07:32:56 +0000 Subject: [PATCH 1/4] [JIRA SONIC-57236] SONIC4.0.0: as5835-54T-auto neg config does not validate the value input, services restarted. Signed-off-by: Dante Su Change-Id: If51d0e49a8913e1a74a4e4e4a001d4d3bdad5014 --- CLI/actioner/sonic_cli_if_autoneg.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/CLI/actioner/sonic_cli_if_autoneg.py b/CLI/actioner/sonic_cli_if_autoneg.py index 587f87ad3f..35ae04b3cb 100644 --- a/CLI/actioner/sonic_cli_if_autoneg.py +++ b/CLI/actioner/sonic_cli_if_autoneg.py @@ -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 @@ -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": { From 5ca92377dbd21f5d97a10f268a76783ff4e3e0c1 Mon Sep 17 00:00:00 2001 From: suresh-rupanagudi Date: Tue, 15 Feb 2022 02:22:11 -0800 Subject: [PATCH 2/4] [JIRA SONIC-56510] creating snmp user without authentication and privacy Change-Id: I5bc488be0e617bf9b522975fd04438682547ff4e --- CLI/actioner/sonic_cli_snmp.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/CLI/actioner/sonic_cli_snmp.py b/CLI/actioner/sonic_cli_snmp.py index 9ecae4c313..d46e030672 100755 --- a/CLI/actioner/sonic_cli_snmp.py +++ b/CLI/actioner/sonic_cli_snmp.py @@ -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: @@ -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}} From b56126185ae92a0418fe657d794366f03761f7de Mon Sep 17 00:00:00 2001 From: Sachin Holla Date: Tue, 15 Feb 2022 19:09:55 +0530 Subject: [PATCH 3/4] [JIRA SONIC-57337] Option to print env variables for test cli New option --printenv is added to the test cli launcher, which prints the env variables set by the script. Useful for recreating the actioner/renderer runtime env outside klish. Example: tools/test/env.sh -port 2200 --printenv Change-Id: Ib4ed846f64334ec75f0d9c255f94314a9087d975 --- tools/test/cli.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/test/cli.sh b/tools/test/cli.sh index 2a520cbc7f..7caecfba00 100755 --- a/tools/test/cli.sh +++ b/tools/test/cli.sh @@ -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 @@ -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[@]}") From 29cc3a22439966e97f3dc6cd6670c10e55be976e Mon Sep 17 00:00:00 2001 From: Sachin Holla Date: Tue, 15 Feb 2022 19:27:53 +0530 Subject: [PATCH 4/4] [JIRA SONIC-57347] Fix go static checker for campus-only build Change-Id: I58558107da20d8fa4d963dd99b7be17822b5af5e --- rest/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/rest/Makefile b/rest/Makefile index cb659ccd93..374913e02c 100644 --- a/rest/Makefile +++ b/rest/Makefile @@ -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 $@