def test_show_events(self): dut01Obj = self.topoObj.deviceObjGet(device="dut01") retValue = evtlogfeature_cli(dut01Obj) if retValue == 1: LogOutput('info', "Event log CLI -passed") else: LogOutput('info', "Event log CLI -failed")
def test_show_events_severity(self): dut01Obj = self.topoObj.deviceObjGet(device="dut01") retValue = evtlogfilterSeverity_cli(dut01Obj) if retValue == 1: LogOutput('info', "Event log category filter CLI -passed") else: LogOutput('info', "Event log category filter CLI -failed")
def checkShowTechFeatureUnicastRouting(dut01Obj): LogOutput('info', "\n##################################################") LogOutput('info', "7.0 Running Show tech Feature Unicast Routing Test ") LogOutput('info', "##################################################\n") # Variables overallBuffer = [] finalReturnCode = 0 # Get into vtyshelll returnStructure = dut01Obj.VtyshShell(enter=True) overallBuffer.append(returnStructure.buffer()) returnCode = returnStructure.returnCode() if returnCode != 0: LogOutput('error', "Failed to get vtysh prompt") for curLine in overallBuffer: LogOutput('info', str(curLine)) return False # Run Show Tech UCast Routing Command returnDevInt = dut01Obj.DeviceInteract(command="show tech ucast-routing") # exit the vtysh shell returnStructure = dut01Obj.VtyshShell(enter=False) overallBuffer.append(returnStructure.buffer()) returnCode = returnStructure.returnCode() if returnCode != 0: LogOutput('error', "Failed to exit vtysh prompt") for curLine in overallBuffer: LogOutput('info', str(curLine)) return False # Verify if the expected cli commands for u-cast routing is seen in the # output buffer expected_commands = [ 'show ip route', 'show ipv6 route', 'show rib', 'show ip interface', 'show ipv6 interface', 'show arp', 'show ipv6 neighbors', 'show ip ecmp' ] finalReturnCode = returnDevInt['returnCode'] overallBuffer.append(returnDevInt['buffer']) if finalReturnCode != 0: LogOutput( 'error', "Failed to run 'show tech ucast-routing' " + " on device " + str(dut01Obj.device)) return False else: for command in expected_commands: if command not in returnDevInt['buffer']: LogOutput( 'error', "Failed to run 'show tech ucast-routing' " + "cli commands on device " + str(dut01Obj.device)) return False LogOutput( 'info', " Show Tech Feature Unicast Routing Ran Successfully" "on device " + str(dut01Obj.device)) return True
def checkShowTechFeatureSourceIpSelection(dut01Obj): LogOutput('info', "\n#################################################") LogOutput('info', "7.0 Running Show tech Feature Source IP Selection ") LogOutput('info', "#################################################\n") # Variables overallBuffer = [] finalReturnCode = 0 # Get into vtyshelll returnStructure = dut01Obj.VtyshShell(enter=True) overallBuffer.append(returnStructure.buffer()) returnCode = returnStructure.returnCode() if returnCode != 0: LogOutput('error', "Failed to get vtysh prompt") for curLine in overallBuffer: LogOutput('info', str(curLine)) return False # Run Show Tech Source IP Selection Command returnDevInt = dut01Obj.DeviceInteract(command="show tech \ source-interface-selection") # exit the vtysh shell returnStructure = dut01Obj.VtyshShell(enter=False) overallBuffer.append(returnStructure.buffer()) returnCode = returnStructure.returnCode() if returnCode != 0: LogOutput('error', "Failed to exit vtysh prompt") for curLine in overallBuffer: LogOutput('info', str(curLine)) return False # Verify if the expected cli commands for u-cast routing is seen in the # output buffer expected_commands = [ 'show ip source-interface', 'show ip source-interface tftp' ] finalReturnCode = returnDevInt['returnCode'] overallBuffer.append(returnDevInt['buffer']) if finalReturnCode != 0: LogOutput( 'error', "Failed to run 'show tech source-interface-selection' " + " on device " + str(dut01Obj.device)) return False else: for command in expected_commands: if command not in returnDevInt['buffer']: LogOutput( 'error', "Failed to run 'show tech '" "'source-interface-selection' " + " cli commands on device " + str(dut01Obj.device)) return False LogOutput( 'info', " Show Tech Feature Source IP Selection Ran Successfully \ on device " + str(dut01Obj.device)) return True
def checkShowVlog(dut01Obj): LogOutput('info', "\n############################################") LogOutput('info', "1.3 Running show vlog config test ") LogOutput('info', "############################################\n") # Get Into VtyshShell assert (getIntoVtysh(dut01Obj)) returnDevInt = dut01Obj.DeviceInteract(command="show vlog config") # Clean Up assert (getOutOfVtysh(dut01Obj)) finalReturnCode = returnDevInt['returnCode'] LogOutput('info', returnDevInt['buffer']) if finalReturnCode != 0: LogOutput('error', "show vlog failed") return False else: if "Feature" not in returnDevInt['buffer']: LogOutput('error', "show vlog failed") return False if "Daemon" not in returnDevInt['buffer']: LogOutput('error', "show vlog failed") return False if "Syslog" not in returnDevInt['buffer']: LogOutput('error', "show vlog failed") return False if "lldp" not in returnDevInt['buffer']: LogOutput('error', "show vlog failed") return False return True
def evtlogfeature_cli(dut01): LogOutput('info', "\n############################################") LogOutput('info', " Running Event Log Test Script") LogOutput('info', "############################################\n") overallBuffer = [] finalReturnCode = 0 #Get in to vtysh shell retStruct = dut01.VtyshShell(enter=True) overallBuffer.append(retStruct.buffer()) returnCode = retStruct.returnCode() if returnCode != 0: LogOutput('error', "Failed to enter vtysh prompt") for curLine in overallBuffer: LogOutput('info', str(curLine)) return False # enable lldp dut01.DeviceInteract(command="configure terminal") dut01.DeviceInteract(command="lldp enable") #disable lldp dut01.DeviceInteract(command="no lldp enable") dut01.DeviceInteract(command="lldp timer 100") dut01.DeviceInteract(command="end") print "-" * 10 print "=====----" print "-" * 10 returnDevInt = dut01.DeviceInteract(command="show events") retStruct = dut01.VtyshShell(enter=False) overallBuffer.append(retStruct.buffer()) returnCode = retStruct.returnCode() if returnCode != 0: LogOuput('error', "Failed to exit vtysh prompt") for curLine in overallBuffer: LogOutput('info', str(curLine)) return False finalReturnCode = returnDevInt['returnCode'] overallBuffer.append(returnDevInt['buffer']) if finalReturnCode != 0: LogOutput('error', "Failed to run show events " + "on device" + str(dut01)) return False else: if "LLDP Enabled" or "LLDP Disabled" in returnDevInt.get('buffer'): LogOutput('info', "Test Case passed, please refer output below") for outputs in overallBuffer: LogOutput('info', str(outputs)) return True else: return False
def checkUnsupportedDaemon(dut01Obj, daemon): # Variables overallBuffer = [] finalReturnCode = 0 str_check = 'Diagnostic dump ' + daemon + ' feature failed for' feature = daemon vtysh_cmd = 'diag-dump ' + feature + ' basic' tc_desc = vtysh_cmd + ' test ' LogOutput('info', "\n############################################") LogOutput('info', "2.1 Running" + tc_desc) LogOutput('info', "############################################\n") shell_cmd = gen_shell_cmd_backup_conf() returnDevInt = dut01Obj.DeviceInteract(command=shell_cmd) LogOutput('info', str(returnDevInt['buffer'])) shell_cmd = gen_shell_cmd_add_conf(daemon, feature) dut01Obj.DeviceInteract(command=shell_cmd) LogOutput('info', str(returnDevInt['buffer'])) dut01Obj.VtyshShell(enter=True) returnDevInt = dut01Obj.DeviceInteract(command=vtysh_cmd) LogOutput('info', str(returnDevInt['buffer'])) dut01Obj.VtyshShell(enter=False) finalReturnCode = returnDevInt['returnCode'] overallBuffer.append(returnDevInt['buffer']) shell_cmd = gen_shell_cmd_restore_conf() dut01Obj.DeviceInteract(command=shell_cmd) if finalReturnCode != 0: LogOutput('error', "Failed to run " + tc_desc + " on device " + str(dut01Obj.device)) return False else: if (str_check not in returnDevInt['buffer']): LogOutput( 'error', tc_desc + "Test Case Failure,refer output below") for outputs in overallBuffer: LogOutput('info', str(outputs)) return False else: LogOutput('info', tc_desc + "ran successfully on device " + str(dut01Obj.device)) return True
def checkShowTechUnSupportedFeatureAndSubFeature(dut01Obj): LogOutput('info', "\n#########################################################") LogOutput( 'info', "2.5 Running Show tech Command with Unsupported Feature and \ Sub Feature Name ") LogOutput( 'info', "############################################################\n") # Variables overallBuffer = [] # Get into vtyshelll returnStructure = dut01Obj.VtyshShell(enter=True) overallBuffer.append(returnStructure.buffer()) returnCode = returnStructure.returnCode() if returnCode != 0: LogOutput('error', "Failed to get vtysh prompt") for curLine in overallBuffer: LogOutput('info', str(curLine)) return False returnDevInt = dut01Obj.DeviceInteract( command="show tech !@#$%^&*^%$#! !@#$%^&*^%$#!", errorCheck=False) # exit the vtysh shell returnStructure = dut01Obj.VtyshShell(enter=False) overallBuffer.append(returnStructure.buffer()) returnCode = returnStructure.returnCode() if returnCode != 0: LogOutput('error', "Failed to exit vtysh prompt") for curLine in overallBuffer: LogOutput('info', str(curLine)) return False overallBuffer.append(returnDevInt['buffer']) if ("Sub Feature !@#$%^&*^%$#! is not supported" not in returnDevInt['buffer']): LogOutput('error', "Test Case Failure,refer output below") for outputs in overallBuffer: LogOutput('info', str(outputs)) return False else: LogOutput( 'info', " Test Show tech Command with both Unsupported Feature and \ Unsupported SubFeature ran successfully on device " + str(dut01Obj.device)) return True
def TestNoShowTechConfigfile(dut01Obj): LogOutput('info', "\n############################################") LogOutput('info', "3.1 Running No Show Tech Config File Test") LogOutput('info', "############################################\n") # Variables command = "mv /etc/openswitch/supportability/ops_showtech.yaml\ /etc/openswitch/supportability/ops_showtech.yaml2 " returnDevInt = dut01Obj.DeviceInteract(command=command) LogOutput('info', returnDevInt['buffer']) command = "ls /etc/openswitch/supportability " returnDevInt = dut01Obj.DeviceInteract(command=command) LogOutput('info', returnDevInt['buffer']) dut01Obj.VtyshShell(enter=True) returnDevInt = dut01Obj.DeviceInteract(command="show tech list") LogOutput('info', returnDevInt['buffer']) dut01Obj.VtyshShell(enter=False) dut01Obj.DeviceInteract(command="mv \ /etc/openswitch/supportability/ops_showtech.yaml2 \ /etc/openswitch/supportability/ops_showtech.yaml") if "Unknown command" in returnDevInt['buffer']: return True else: LogOutput('error', "Test Case Failure,refer output below") LogOutput('info', str(returnDevInt['buffer'])) return False return False
def getOutOfConfig(dut01Obj): returnStructure = dut01Obj.ConfigVtyShell(enter=False) returnCode = returnStructure.returnCode() if returnCode != 0: LogOutput('error', "Failed to exit config terminal") return False return True
def getOutOfVtysh(dut01Obj): returnStructure = dut01Obj.VtyshShell(enter=False) returnCode = returnStructure.returnCode() if returnCode != 0: LogOutput('error', "Failed to get out of vtysh prompt") return False return True
def checkCorruptedYamlFile(dut01Obj): # Variables overallBuffer = [] finalReturnCode = 0 str_check = 'Diagnostic dump captured for feature' daemon = 'lldp' vtysh_cmd = 'diag-dump ' + daemon + ' basic' tc_desc = vtysh_cmd + ' test ' LogOutput('info', "\n############################################") LogOutput('info', "3.3 Running" + tc_desc) LogOutput('info', "############################################\n") shell_cmd = gen_shell_cmd_backup_conf() returnDevInt = dut01Obj.DeviceInteract(command=shell_cmd) LogOutput('info', str(returnDevInt['buffer'])) shell_cmd = 'printf --- - feature_name: \"lldp\"' + \ ' feature_desc: \"Link Layer Discovery Protocol\" ' + \ ' daemon: - \"ops-lldpd\" xxxxxxxxxxxxxxxxxxxxxxxxx ' + \ ' aksjsjjdkdkdjddj kdkdkdkdkdkdkdk --- ' + \ ' - feature_name: \"lldp\" ' + \ ' feature_desc: \"Link Layer Discovery Protocol\" ' + \ ' daemon: - \"ops-lldpd\" xxxxxxxxxxxxxxxxxxxxxxxxx ' + \ ' aksjsjjdkdkdjddj kdkdkdkdkdkdkdk ' + \ ' --- - feature_name: \"lldp\" feature_desc: ' + \ ' \"Link Layer Discovery Protocol\" daemon: - \"ops-lldpd\"'\ + ' xxxxxxxxxxxxxxxxxxxxxxxxx aksjsjjdkdkdjddj kdkdkdkdkdkdkdk' + \ ' >> /etc/openswitch/supportability/ops_featuremapping.yaml' dut01Obj.DeviceInteract(command=shell_cmd) LogOutput('info', str(returnDevInt['buffer'])) dut01Obj.VtyshShell(enter=True) returnDevInt = dut01Obj.DeviceInteract(command=vtysh_cmd) LogOutput('info', str(returnDevInt['buffer'])) dut01Obj.VtyshShell(enter=False) finalReturnCode = returnDevInt['returnCode'] overallBuffer.append(returnDevInt['buffer']) shell_cmd = gen_shell_cmd_restore_conf() dut01Obj.DeviceInteract(command=shell_cmd) if finalReturnCode == 3: LogOutput('info', tc_desc + "ran successfully on device " + str(dut01Obj.device)) return True else: LogOutput('error', "Failed to run " + tc_desc + " on device " + str(dut01Obj.device)) return False
def test_show_events_eventID(self): dut01Obj = self.topoObj.deviceObjGet(device="dut01") # Positive test case retValue = evtlogfilterEventID_cli_pass(dut01Obj) if retValue == 1: LogOutput('info', "Event log event ID filter positive case -passed") else: LogOutput('info', "Event log event ID filter positive case -failed") # Negative retValue = evtlogfilterEventID_cli_fail(dut01Obj) if retValue == 1: LogOutput('info', "Event log event ID filter negative case -passed") else: LogOutput('info', "Event log event ID filter negative case -failed")
def checkShowTechInvalidParameters(dut01Obj): LogOutput('info', "\n#################################################") LogOutput('info', "2.2 Running Show tech Command with extra Parameter ") LogOutput('info', "##################################################\n") # Variables overallBuffer = [] # Get into vtyshelll returnStructure = dut01Obj.VtyshShell(enter=True) overallBuffer.append(returnStructure.buffer()) returnCode = returnStructure.returnCode() if returnCode != 0: LogOutput('error', "Failed to get vtysh prompt") for curLine in overallBuffer: LogOutput('info', str(curLine)) return False # Run Show Tech lldp statistics Command returnDevInt = dut01Obj.DeviceInteract( command="show tech lldp statistics extraparameter", errorCheck=False) # exit the vtysh shell returnStructure = dut01Obj.VtyshShell(enter=False) overallBuffer.append(returnStructure.buffer()) returnCode = returnStructure.returnCode() if returnCode != 0: LogOutput('error', "Failed to exit vtysh prompt") for curLine in overallBuffer: LogOutput('info', str(curLine)) return False overallBuffer.append(returnDevInt['buffer']) if ("% Unknown command" not in returnDevInt['buffer']): LogOutput('error', "Test Case Failure,refer output below") for outputs in overallBuffer: LogOutput('info', str(outputs)) return False else: LogOutput( 'info', " Test Show tech Command with extra Parameter ran \ successfully on device " + str(dut01Obj.device)) return True
def checkInvalidSubCommand(dut01Obj): LogOutput('info', "\n############################################") LogOutput('info', "2.3 Run Show vlog invalid subcommand ") LogOutput('info', "############################################\n") # Get Into VtyshShell assert (getIntoVtysh(dut01Obj)) returnDevInt = dut01Obj.DeviceInteract( command="show vlog config adsf@f$*ASDfjaklsdf@#Q@3r") # Clean Up assert (getOutOfVtysh(dut01Obj)) LogOutput('info', str(returnDevInt['buffer'])) if ("Unknown command" not in returnDevInt['buffer']): LogOutput('error', "show vlog for invalid subcommand failed") return False return True
def checkInvalidFeature(dut01Obj): LogOutput('info', "\n############################################") LogOutput('info', "2.2 Run Show vlog for invalid feature ") LogOutput('info', "############################################\n") # Get Into VtyshShell assert (getIntoVtysh(dut01Obj)) returnDevInt = dut01Obj.DeviceInteract( command="show vlog config feature adsf@f$*ASDfjaklsdf@#Q@3r") # Clean Up assert (getOutOfVtysh(dut01Obj)) LogOutput('info', str(returnDevInt['buffer'])) if ("Feature not present" not in returnDevInt['buffer']): LogOutput('error', "show vlog for invalid feature failed") return False return True
def checkVlogConfigInvalidLogLevel(dut01Obj): LogOutput('info', "\n############################################") LogOutput('info', "2.7 Check Vlog Configuration for Invaild Loglevel ") LogOutput('info', "############################################\n") # Get Into VtyshShell assert (getIntoVtysh(dut01Obj)) assert (getIntoConfig(dut01Obj)) returnDevInt = dut01Obj.DeviceInteract( command="vlog feature lldpd syslog adsf@f$*ASDfjaklsdf@#Q@3r") # Clean Up assert (getOutOfConfig(dut01Obj)) assert (getOutOfVtysh(dut01Obj)) if ("Unknown command" not in returnDevInt['buffer']): LogOutput('error', "config vlog for invalid loglevel failed") return False return True
def checkVlogConfigInvalidFeature(dut01Obj): LogOutput('info', "\n############################################") LogOutput('info', "2.4 Check Vlog Configuration for Invaild Feature ") LogOutput('info', "############################################\n") # Get Into VtyshShell assert (getIntoVtysh(dut01Obj)) assert (getIntoConfig(dut01Obj)) returnDevInt = dut01Obj.DeviceInteract( command="vlog feature adsf@f$*ASDfjaklsdf@#Q@3r syslog info") # Clean Up assert (getOutOfConfig(dut01Obj)) assert (getOutOfVtysh(dut01Obj)) if ("Feature not present" not in returnDevInt['buffer']): LogOutput('error', "config vlog for invalid feature failed") return False return True
def checkVlogConfigInvalidDaemon(dut01Obj): LogOutput('info', "\n############################################") LogOutput('info', "2.5 Check Vlog Configuration for Invaild Daemon ") LogOutput('info', "############################################\n") # Get Into VtyshShell assert (getIntoVtysh(dut01Obj)) assert (getIntoConfig(dut01Obj)) returnDevInt = dut01Obj.DeviceInteract( command="vlog daemon adsf@f$*ASDfjaklsdf@#Q@3r syslog info") # Clean Up assert (getOutOfConfig(dut01Obj)) assert (getOutOfVtysh(dut01Obj)) if ("Not able to communicate with daemon adsf@f$*ASDfjaklsdf@#Q@3r" not in returnDevInt['buffer']): LogOutput('error', "config vlog for invalid daemon failed") return False return True
def TestShowTechConfigDuplicateEntries(dut01Obj): LogOutput('info', "\n############################################") LogOutput('info', "3.3 Running Show Tech Duplicated Config Entries Test") LogOutput('info', "############################################\n") # Variables command = "cp /etc/openswitch/supportability/ops_showtech.yaml\ /etc/openswitch/supportability/ops_showtech.yaml2 " returnDevInt = dut01Obj.DeviceInteract(command=command) LogOutput('info', returnDevInt['buffer']) command = "printf '\n feature:\n -\n feature_desc: \"sttest\"\n\ feature_name: test1234\n cli_cmds:\n - \"show testing\"' >> \ /etc/openswitch/supportability/ops_showtech.yaml" dut01Obj.DeviceInteract(command=command) dut01Obj.DeviceInteract(command=command) dut01Obj.DeviceInteract(command=command) dut01Obj.VtyshShell(enter=True) returnDevInt = dut01Obj.DeviceInteract(command="show tech basic") dut01Obj.VtyshShell(enter=False) dut01Obj.DeviceInteract(command="mv \ /etc/openswitch/supportability/ops_showtech.yaml2 \ /etc/openswitch/supportability/ops_showtech.yaml") if "Show Tech commands executed successfully" in returnDevInt['buffer']: return True else: LogOutput('error', "Test Case Failure,refer output below") LogOutput('info', str(returnDevInt['buffer'])) return False return False
def evtlogfilterEventID_cli_fail(dut01): LogOutput('info', "\n############################################") LogOutput('info', " Running Event Log Test Script 1.2") LogOutput('info', "############################################\n") overallBuffer = [] finalReturnCode = 0 #Get in to vtysh shell retStruct = dut01.VtyshShell(enter=True) overallBuffer.append(retStruct.buffer()) returnCode = retStruct.returnCode() if returnCode != 0: LogOutput('error', "Failed to enter vtysh prompt") for curLine in overallBuffer: LogOutput('info', str(curLine)) return False print "-" * 10 print "=====----" print "-" * 10 returnDevInt = dut01.DeviceInteract(command="show events event-id 999998") retStruct = dut01.VtyshShell(enter=False) overallBuffer.append(retStruct.buffer()) returnCode = retStruct.returnCode() if returnCode != 0: LogOuput('error', "Failed to exit vtysh prompt") for curLine in overallBuffer: LogOutput('info', str(curLine)) return False finalReturnCode = returnDevInt['returnCode'] overallBuffer.append(returnDevInt['buffer']) if finalReturnCode != 0: LogOutput('error', "Failed to run show events " + "on device" + str(dut01)) return False else: if "No event match the filter provided" in returnDevInt.get('buffer'): LogOutput('info', "Test Case passed, please refer output below") for outputs in overallBuffer: LogOutput('info', str(outputs)) return True else: return False
def TestShowTechCorruptedConfigFile(dut01Obj): LogOutput('info', "\n############################################") LogOutput('info', "3.2 Running Show Tech Corrupted Config File Test") LogOutput('info', "############################################\n") # Variables command = "cp /etc/openswitch/supportability/ops_showtech.yaml\ /etc/openswitch/supportability/ops_showtech.yaml2 " returnDevInt = dut01Obj.DeviceInteract(command=command) LogOutput('info', returnDevInt['buffer']) command = "printf '\n feature:\n -\n feature_desc:\"sttest\"\n\ \t\t\tfeature_name:test1234\nasdfjlj$923 - :23;23klj23' >> \ /etc/openswitch/supportability/ops_showtech.yaml" returnDevInt = dut01Obj.DeviceInteract(command=command) command = "ls /etc/openswitch/supportability " returnDevInt = dut01Obj.DeviceInteract(command=command) LogOutput('info', returnDevInt['buffer']) dut01Obj.VtyshShell(enter=True) returnDevInt = dut01Obj.DeviceInteract(command="show tech list") LogOutput('info', returnDevInt['buffer']) dut01Obj.VtyshShell(enter=False) dut01Obj.DeviceInteract(command="mv \ /etc/openswitch/supportability/ops_showtech.yaml2 \ /etc/openswitch/supportability/ops_showtech.yaml") if "Failed to obtain show tech configuration" in returnDevInt['buffer']: return True else: LogOutput('error', "Test Case Failure,refer output below") LogOutput('info', str(returnDevInt['buffer'])) return False return False
def checkInvalidDaemon(dut01Obj): LogOutput('info', "\n############################################") LogOutput('info', "2.1 Run Show vlog for invalid daemon ") LogOutput('info', "############################################\n") # Get Into VtyshShell assert (getIntoVtysh(dut01Obj)) # simply@#$*beland returnDevInt = dut01Obj.DeviceInteract( command="show vlog config daemon adsf@f$*ASDfjaklsdf@#Q@3r") # Clean Up assert (getOutOfVtysh(dut01Obj)) LogOutput('info', str(returnDevInt['returnCode'])) LogOutput('info', str(returnDevInt['buffer'])) if ("Not able to communicate with daemon adsf@f$*ASDfjaklsdf@#Q@3r" not in returnDevInt['buffer']): LogOutput('error', "show vlog for invalid daemon failed") return False return True
def lldp_tlv(**kwargs): device1 = kwargs.get('device1', None) device2 = kwargs.get('device2', None) # Configuring no routing on interface # Entering VTYSH terminal retStruct = device1.VtyshShell(enter=True) retCode = retStruct.returnCode() assert retCode == 0, "Failed to enter vtysh prompt" # Entering confi terminal SW1 retStruct = device1.ConfigVtyShell(enter=True) retCode = retStruct.returnCode() assert retCode == 0, "Failed to enter config terminal" # Entering interface LogOutput( 'info', "Switch 1 interface is : " + str(device1.linkPortMapping['lnk01'])) devIntRetStruct = device1.DeviceInteract( command="interface " + str(device1.linkPortMapping['lnk01'])) retCode = devIntRetStruct.get('returnCode') assert retCode == 0, "Failed to enter interface" devIntRetStruct = device1.DeviceInteract(command="no routing") retCode = devIntRetStruct.get('returnCode') assert retCode == 0, "Failed to disable routing" # Exiting interface devIntRetStruct = device1.DeviceInteract(command="exit") retCode = devIntRetStruct.get('returnCode') assert retCode == 0, "Failed to exit interface" # Exiting Config terminal retStruct = device1.ConfigVtyShell(enter=False) retCode = retStruct.returnCode() assert retCode == 0, "Failed to come out of config terminal" # Exiting VTYSH terminal retStruct = device1.VtyshShell(enter=False) retCode = retStruct.returnCode() assert retCode == 0, "Failed to exit vtysh prompt" # Configuring no routing on interface # Entering VTYSH terminal retStruct = device2.VtyshShell(enter=True) retCode = retStruct.returnCode() assert retCode == 0, "Failed to enter vtysh prompt" # Entering confi terminal SW1 retStruct = device2.ConfigVtyShell(enter=True) retCode = retStruct.returnCode() assert retCode == 0, "Failed to enter config terminal" # Entering interface 1 LogOutput( 'info', "Switch 2 interface is : " + str(device2.linkPortMapping['lnk01'])) devIntRetStruct = device2.DeviceInteract( command="interface " + str(device2.linkPortMapping['lnk01'])) retCode = devIntRetStruct.get('returnCode') assert retCode == 0, "Failed to enter interface" devIntRetStruct = device2.DeviceInteract(command="no routing") retCode = devIntRetStruct.get('returnCode') assert retCode == 0, "Failed to disable routing" # Exiting interface devIntRetStruct = device2.DeviceInteract(command="exit") retCode = devIntRetStruct.get('returnCode') assert retCode == 0, "Failed to exit interface" # Exiting config terminal retStruct = device2.ConfigVtyShell(enter=False) retCode = retStruct.returnCode() assert retCode == 0, "Failed to come out of config terminal" # Exiting VTYSH terminal retStruct = device2.VtyshShell(enter=False) retCode = retStruct.returnCode() assert retCode == 0, "Failed to exit vtysh prompt" # Setting tx time to 5 sec on SW1 and SW2 # Entering vtysh SW1 retStruct = device1.VtyshShell(enter=True) retCode = retStruct.returnCode() assert retCode == 0, "Failed to enter vtysh prompt" # Entering confi terminal SW1 retStruct = device1.ConfigVtyShell(enter=True) retCode = retStruct.returnCode() assert retCode == 0, "Failed to enter config terminal" # Setting tx time to 5 seconds on SW1 LogOutput('info', "\nConfiguring transmit time of 5 sec on SW1") devIntRetStruct = device1.DeviceInteract(command="lldp timer 5") retCode = devIntRetStruct.get('returnCode') assert retCode == 0, "Failed to set transmit time" # Entering vtysh SW2 retStruct = device2.VtyshShell(enter=True) retCode = retStruct.returnCode() assert retCode == 0, "Failed to get vtysh prompt" # Entering config terminal SW2 devIntRetStruct = device2.ConfigVtyShell(enter=True) retCode = devIntRetStruct.returnCode() assert retCode == 0, "\nFailed to enter config mode" # Setting tx time to 5 seconds on SW2 LogOutput('info', "\nConfiguring transmit time of 5 sec on SW2") devIntRetStruct = device2.DeviceInteract(command="lldp timer 5") retCode = devIntRetStruct.get('returnCode') assert retCode == 0, "\nFailed to configure transmit time" # Exiting Config terminal SW1 retStruct = device1.ConfigVtyShell(enter=False) retCode = retStruct.returnCode() assert retCode == 0, "Failed to come out of config terminal" # Exiting Config terminal SW2 retStruct = device2.ConfigVtyShell(enter=False) retCode = retStruct.returnCode() assert retCode == 0, "Failed to come out of config terminal" # Exiting vtysh terminal SW1 retStruct = device1.VtyshShell(enter=False) retCode = retStruct.returnCode() assert retCode == 0, "Failed to exit vtysh prompt" # Exiting vtysh terminal SW2 retStruct = device2.VtyshShell(enter=False) retCode = retStruct.returnCode() assert retCode == 0, "Failed to exit vtysh prompt" # Configuring lldp on SW1 LogOutput('info', "\n\n\nConfig lldp on SW1") retStruct = LldpConfig(deviceObj=device1, enable=True) retCode = retStruct.returnCode() assert retCode == 0, "Unable to configure LLDP on SW1" # Enabling interface 1 SW1 LogOutput('info', "Enabling interface on SW1") retStruct = InterfaceEnable(deviceObj=device1, enable=True, interface=device1.linkPortMapping['lnk01']) retCode = retStruct.returnCode() assert retCode == 0, "Unable to enabling interafce on SW1" # Configuring lldp on SW2 LogOutput('info', "\n\n\nConfig lldp on SW2") retStruct = LldpConfig(deviceObj=device2, enable=True) retCode = retStruct.returnCode() assert retCode == 0, "Configure lldp on SW2" # Enabling interface 1 SW2 LogOutput('info', "Enabling interface on SW2") retStruct = InterfaceEnable(deviceObj=device2, enable=True, interface=device2.linkPortMapping['lnk01']) retCode = retStruct.returnCode() assert retCode == 0, "Unable to enable interface on SW2" # Waiting for neighbour to advertise Sleep(seconds=25, message="\nWaiting") # Set my default context to linux temporarily device1.setDefaultContext(context="linux") # Start loop for retry in range(1, 3): # Parsing neighbour info for SW1 LogOutput('info', "\nShowing Lldp neighbourship on SW1") retStruct = ShowLldpNeighborInfo(deviceObj=device1, port=device1.linkPortMapping['lnk01']) retCode = retStruct.returnCode() assert retCode == 0, "Failed to show neighbour info" LogOutput('info', "CLI_Switch1") retStruct.printValueString() lnk01PrtStats = retStruct.valueGet(key='portStats') LogOutput( 'info', "\nExpected Neighbor Port ID: " + str(lnk01PrtStats[ device1.linkPortMapping['lnk01']]['Neighbor_portID']).rstrip()) neiPortId = str(lnk01PrtStats[device1.linkPortMapping['lnk01']] ['Neighbor_portID']).rstrip() if neiPortId.isdigit() is True or re.match(r'\d{1,2}-\d{1}', neiPortId): break else: # Dump out the ovs-vsctl interface information LogOutput( 'info', "Didn't receive integer value for " "Neightbor_portID, dumping ovs-vsctl interface stats...") devCmd = "ovs-vsctl list interface "\ + str(device1.linkPortMapping['lnk01'])\ + " | grep lldp_neighbor_info" neighbor_output = device1.cmd(devCmd) opstestfw.LogOutput( 'info', "ovs-vsctl list interface output:\n" + str(neighbor_output)) devCmd = "ip netns exec swns ifconfig "\ + str(device1.linkPortMapping['lnk01']) ifconfig_output = device1.cmd(devCmd) opstestfw.LogOutput('info', devCmd + " output\n" + str(ifconfig_output)) Sleep(seconds=10, message="Delay") # end loop # Set my default context to linux temporarily device1.setDefaultContext(context="vtyShell") assert str((lnk01PrtStats[device1.linkPortMapping['lnk01']] ['Neighbor_portID']).rstrip()) == device2.linkPortMapping['lnk01'], \ "Case Failed, No Neighbor present for SW1" assert ("null" not in lnk01PrtStats[device1.linkPortMapping['lnk01']] ['Neighbor_chassisName']), \ "Case Failed, Neighbor Chassis-Name is not present" assert ("null" not in lnk01PrtStats[device1.linkPortMapping['lnk01']] ['Neighbor_chassisDescription']), \ "Case Failed, Neighbor Chassis-Description is not present" assert ("Bridge, Router" in lnk01PrtStats[device1.linkPortMapping['lnk01']] ['Chassis_Capabilities_Available']), \ "Case Failed, Neighbor Chassis-Capabilities is not available" if (lnk01PrtStats[device1.linkPortMapping['lnk01']]['Neighbor_portID']): LogOutput('info', "\nCase Passed, Neighborship established by SW1") LogOutput( 'info', "\nNeighbor Chassis-Name :" + str(lnk01PrtStats[ device1.linkPortMapping['lnk01']]['Neighbor_chassisName'])) LogOutput( 'info', "\nNeighbor Chassis-Description :" + str(lnk01PrtStats[device1.linkPortMapping['lnk01']] ['Neighbor_chassisDescription'])) LogOutput( 'info', "\nChassie Capabilities available : " + str(lnk01PrtStats[device1.linkPortMapping['lnk01']] ['Chassis_Capabilities_Available'])) LogOutput( 'info', "\nChassis Capabilities Enabled : " + str(lnk01PrtStats[device1.linkPortMapping['lnk01']] ['Chassis_Capabilities_Enabled'])) # Parsing neighbour info for SW2 # Loop for switch 2 device2.setDefaultContext(context="linux") for retry in range(1, 3): LogOutput('info', "\nShowing Lldp neighborship on SW2") retStruct = ShowLldpNeighborInfo(deviceObj=device2, port=device2.linkPortMapping['lnk01']) retCode = retStruct.returnCode() assert retCode == 0, "Failed to show neighour info" LogOutput('info', "CLI_Switch2 Output:\n" + str(retStruct.buffer())) LogOutput('info', "CLI_Switch2 Return Structure") retStruct.printValueString() lnk01PrtStats = retStruct.valueGet(key='portStats') LogOutput( 'info', "\nExpected Neighbor Port ID: " + str(lnk01PrtStats[ device2.linkPortMapping['lnk01']]['Neighbor_portID']).rstrip()) neiPortId = str(lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Neighbor_portID']).rstrip() if neiPortId.isdigit() is True or re.match(r'\d{1,2}-\d{1}', neiPortId): break else: # Dump out the ovs-vsctl interface information LogOutput( 'info', "Didn't receive integer value for " "Neightbor_portID, dumping ovs-vsctl interface stats...") devCmd = "ovs-vsctl list interface "\ + str(device2.linkPortMapping['lnk01'])\ + " | grep lldp_neighbor_info" neighbor_output = device2.cmd(devCmd) opstestfw.LogOutput( 'info', "ovs-vsctl list interface output:\n" + str(neighbor_output)) devCmd = "ip netns exec swns ifconfig "\ + str(device2.linkPortMapping['lnk01']) ifconfig_output = device2.cmd(devCmd) opstestfw.LogOutput('info', devCmd + " output\n" + str(ifconfig_output)) Sleep(seconds=10, message="Delay") device2.setDefaultContext(context="vtyShell") assert str((lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Neighbor_portID']).rstrip()) == device1.linkPortMapping['lnk01'], \ "Case Failed, No Neighbor present for SW1" assert ("null" not in lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Neighbor_chassisName']), \ "Case Failed, Neighbor Chassis-Name is not present" assert ("null" not in lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Neighbor_chassisDescription']), \ "Case Failed, Neighbor Chassis-Description is not present" assert ("Bridge, Router" in lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Chassis_Capabilities_Available']), \ "Case Failed, Neighbor Chassis-Capabilities is not available" if (lnk01PrtStats[device2.linkPortMapping['lnk01']]['Neighbor_portID']): LogOutput('info', "\nCase Passed, Neighborship established by SW2") LogOutput( 'info', "\nNeighbor Chassis-Name :" + str(lnk01PrtStats[ device2.linkPortMapping['lnk01']]['Neighbor_chassisName'])) LogOutput( 'info', "\nNeighbor Chassis-Description :" + str(lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Neighbor_chassisDescription'])) LogOutput( 'info', "\nChassie Capablities available : " + str(lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Chassis_Capabilities_Available'])) LogOutput( 'info', "\nChassis Capabilities Enabled : " + str(lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Chassis_Capabilities_Enabled'])) # Disabling chassie name for neighbor # Entering vtysh SW1 retStruct = device1.VtyshShell(enter=True) retCode = retStruct.returnCode() assert retCode == 0, "Failed to enter vtysh prompt" # Entering confi terminal SW1 retStruct = device1.ConfigVtyShell(enter=True) retCode = retStruct.returnCode() assert retCode == 0, "Failed to enter config terminal" # Disabling system-name on SW1 LogOutput('info', "\nDisabling system-name for SW1") devIntRetStruct = \ device1.DeviceInteract(command="no lldp select-tlv system-name") retCode = devIntRetStruct.get('returnCode') assert retCode == 0, "Failed to set no lldp select-tlv system-name" # Checking SW2 to see if system-name is removed device2.setDefaultContext(context="linux") for retry in range(1, 3): LogOutput('info', "\n\nCase 1:System-Name Disabled") retStruct = ShowLldpNeighborInfo(deviceObj=device2, port=device2.linkPortMapping['lnk01']) retCode = retStruct.returnCode() assert retCode == 0, "\nFailed to show neighbor info" LogOutput('info', "CLI_Switch2") lnk01PrtStats = retStruct.valueGet(key='portStats') if (lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Neighbor_chassisName']) == "": break else: # Dump out the ovs-vsctl interface information LogOutput('info', "Didn't clear Neighbor Chassis-Name") devCmd = "ovs-vsctl list interface "\ + str(device2.linkPortMapping['lnk01'])\ + " | grep lldp_neighbor_info" neighbor_output = device2.cmd(devCmd) opstestfw.LogOutput( 'info', "ovs-vsctl list interface output:\n" + str(neighbor_output)) devCmd = "ip netns exec swns ifconfig "\ + str(device2.linkPortMapping['lnk01']) ifconfig_output = device2.cmd(devCmd) opstestfw.LogOutput('info', devCmd + " output\n" + str(ifconfig_output)) Sleep(seconds=10, message="Delay") device2.setDefaultContext(context="vtyShell") assert (lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Neighbor_chassisName']) == "", \ "Case Failed, Neighbor Chassis-Name is present" LogOutput('info', "#Case Passed,No neighbor Chassis-Name present#") # Enabling System-Name LogOutput('info', "\nEnabling System-Name for SW1") devIntRetStruct = \ device1.DeviceInteract(command="lldp select-tlv system-name") retCode = devIntRetStruct.get('returnCode') assert retCode == 0, "Failed to set lldp select-tlv system-name" # Checking SW2 to see if system-name is reset LogOutput('info', "\n\nCase 2 :System-Name Enabled") # Parsing lldp neighbour info SW2 device2.setDefaultContext(context="linux") for retry in range(1, 3): retStruct = ShowLldpNeighborInfo(deviceObj=device2, port=device2.linkPortMapping['lnk01']) retCode = retStruct.returnCode() assert retCode == 0, "\nFailed to show neighbor info" LogOutput('info', "CLI_Switch2") lnk01PrtStats = retStruct.valueGet(key='portStats') if ("null" not in lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Neighbor_chassisName']): break else: # Dump out the ovs-vsctl interface information LogOutput('info', "Didn't receive Chassis-Name") devCmd = "ovs-vsctl list interface "\ + str(device2.linkPortMapping['lnk01'])\ + " | grep lldp_neighbor_info" neighbor_output = device2.cmd(devCmd) opstestfw.LogOutput( 'info', "ovs-vsctl list interface output:\n" + str(neighbor_output)) devCmd = "ip netns exec swns ifconfig "\ + str(device2.linkPortMapping['lnk01']) ifconfig_output = device2.cmd(devCmd) opstestfw.LogOutput('info', devCmd + " output\n" + str(ifconfig_output)) Sleep(seconds=10, message="Delay") device2.setDefaultContext(context="vtyShell") assert ("null" not in lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Neighbor_chassisName']), \ "Case Failed, Neighbor Chassis-Name is not present" LogOutput('info', "#Case Passed,Neighbor Chassis-Name is present#") # Disabling Neighbor Chassis-Description LogOutput('info', "\nDisabling System-Description for SW1") devIntRetStruct = \ device1.DeviceInteract(command="no lldp select-tlv system-description") retCode = devIntRetStruct.get('returnCode') assert retCode == 0, "Failed to set no lldp select-tlv system-description" # Checking SW2 to see if system-description is removed LogOutput('info', "\n\nCase 3: System-Description Disabled") # Parsing lldp neighbour info SW2 device2.setDefaultContext(context="linux") for retry in range(1, 3): retStruct = ShowLldpNeighborInfo(deviceObj=device2, port=device2.linkPortMapping['lnk01']) retCode = retStruct.returnCode() assert retCode == 0, "\nFailed to show neighbor info" LogOutput('info', "CLI_Switch2") lnk01PrtStats = retStruct.valueGet(key='portStats') if (lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Neighbor_chassisDescription']) == "": break else: # Dump out the ovs-vsctl interface information LogOutput('info', "Didn't receive System-Description") devCmd = "ovs-vsctl list interface "\ + str(device2.linkPortMapping['lnk01'])\ + " | grep lldp_neighbor_info" neighbor_output = device2.cmd(devCmd) opstestfw.LogOutput( 'info', "ovs-vsctl list interface output:\n" + str(neighbor_output)) devCmd = "ip netns exec swns ifconfig "\ + str(device2.linkPortMapping['lnk01']) ifconfig_output = device2.cmd(devCmd) opstestfw.LogOutput('info', devCmd + " output\n" + str(ifconfig_output)) Sleep(seconds=10, message="Delay") device2.setDefaultContext(context="vtyShell") assert (lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Neighbor_chassisDescription']) == "", \ "Case Failed, Neighbor Chassis-Description is present" LogOutput('info', "#Case Passed,No neighbor Chassis-Description present#") # Enabling System-Description LogOutput('info', "\nEnabling System-description for SW1") devIntRetStruct = \ device1.DeviceInteract(command="lldp select-tlv system-description") retCode = devIntRetStruct.get('returnCode') assert retCode == 0, "Failed to set lldp select-tlv system-description" # Checking SW2 to see if system-name is reset LogOutput('info', "\n\nCase 4: System-Description Enabled") # Parsing lldp neighbour info SW2 device2.setDefaultContext(context="linux") for retry in range(1, 3): retStruct = ShowLldpNeighborInfo(deviceObj=device2, port=device2.linkPortMapping['lnk01']) retCode = retStruct.returnCode() assert retCode == 0, "\nFailed to show neighbor info" LogOutput('info', "CLI_Switch2") lnk01PrtStats = retStruct.valueGet(key='portStats') if ("null" not in lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Neighbor_chassisDescription']): break else: # Dump out the ovs-vsctl interface information LogOutput('info', "Didn't receive System-Description") devCmd = "ovs-vsctl list interface "\ + str(device2.linkPortMapping['lnk01'])\ + " | grep lldp_neighbor_info" neighbor_output = device2.cmd(devCmd) opstestfw.LogOutput( 'info', "ovs-vsctl list interface output:\n" + str(neighbor_output)) devCmd = "ip netns exec swns ifconfig "\ + str(device2.linkPortMapping['lnk01']) ifconfig_output = device2.cmd(devCmd) opstestfw.LogOutput('info', devCmd + " output\n" + str(ifconfig_output)) Sleep(seconds=10, message="Delay") device2.setDefaultContext(context="vtyShell") assert ("null" not in lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Neighbor_chassisDescription']), \ "Case Failed, Neighbor Chassis-Description is not present" LogOutput('info', "#Case Passed,Neighbor Chassis-Description is present#") # Disabling System-Capabilities LogOutput('info', "\nDisabling Neighor Chassis-Capabilities for SW1") devIntRetStruct = device1.DeviceInteract( command="no lldp select-tlv system-capabilities") retCode = devIntRetStruct.get('returnCode') assert retCode == 0, "Failed to set no lldp select-tlv system-capabilities" # Checking SW2 to see if system-Capabilities is removed LogOutput('info', "\n\nCase 5: System-Capabilities disabled") device2.setDefaultContext(context="linux") for retry in range(1, 3): retStruct = ShowLldpNeighborInfo(deviceObj=device2, port=device2.linkPortMapping['lnk01']) retCode = retStruct.returnCode() assert retCode == 0, "\nFailed to show neighbor info" LogOutput('info', "CLI_Switch2") lnk01PrtStats = retStruct.valueGet(key='portStats') if (lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Chassis_Capabilities_Available']) == "" and \ (lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Chassis_Capabilities_Enabled']) == "": break else: # Dump out the ovs-vsctl interface information LogOutput('info', "Didn't receive System-Capabilities") devCmd = "ovs-vsctl list interface "\ + str(device2.linkPortMapping['lnk01'])\ + " | grep lldp_neighbor_info" neighbor_output = device2.cmd(devCmd) opstestfw.LogOutput( 'info', "ovs-vsctl list interface output:\n" + str(neighbor_output)) devCmd = "ip netns exec swns ifconfig "\ + str(device2.linkPortMapping['lnk01']) ifconfig_output = device2.cmd(devCmd) opstestfw.LogOutput('info', devCmd + " output\n" + str(ifconfig_output)) Sleep(seconds=10, message="Delay") device2.setDefaultContext(context="vtyShell") assert (lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Chassis_Capabilities_Available']) == "", \ "Case Failed, Neighbor Chassis-Capabilities is available" LogOutput('info', "#Case Passed,No neighbor Chassis-capablities available#") assert (lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Chassis_Capabilities_Enabled']) == "", \ "Case Failed, Neighbor Chassis-Capabilities is enabled" LogOutput('info', "#Case Passed,No neighbor Chassis-capablities enabled#") # System-Capabilities Enabled LogOutput('info', "\nEnabling Neighbor Chassis-Capabilities for SW1") devIntRetStruct = \ device1.DeviceInteract(command="lldp select-tlv system-capabilities") retCode = devIntRetStruct.get('returnCode') assert retCode == 0, "Failed to set lldp select-tlv system-capabilities" # Checking SW2 to see if system-name is reset LogOutput('info', "\n\nCase 6: System-Capabilities enabled") device2.setDefaultContext(context="linux") for retry in range(1, 3): retStruct = ShowLldpNeighborInfo(deviceObj=device2, port=device2.linkPortMapping['lnk01']) retCode = retStruct.returnCode() assert retCode == 0, "\nFailed to show neighbor info" LogOutput('info', "CLI_Switch2") lnk01PrtStats = retStruct.valueGet(key='portStats') if ("Bridge, Router" in lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Chassis_Capabilities_Available']) and\ "Bridge, Router" in (lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Chassis_Capabilities_Enabled']): break else: # Dump out the ovs-vsctl interface information LogOutput('info', "Didn't receive System-Capabilities") devCmd = "ovs-vsctl list interface "\ + str(device2.linkPortMapping['lnk01'])\ + " | grep lldp_neighbor_info" neighbor_output = device2.cmd(devCmd) opstestfw.LogOutput( 'info', "ovs-vsctl list interface output:\n" + str(neighbor_output)) devCmd = "ip netns exec swns ifconfig "\ + str(device2.linkPortMapping['lnk01']) ifconfig_output = device2.cmd(devCmd) opstestfw.LogOutput('info', devCmd + " output\n" + str(ifconfig_output)) Sleep(seconds=10, message="Delay") device2.setDefaultContext(context="vtyShell") assert ("Bridge, Router" in lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Chassis_Capabilities_Available']), \ "Case Failed, Neighbor Chassis-Capabilities is not available" LogOutput('info', "#Case Passed,Neighbor Chassis-capablities available#") assert ("Bridge, Router" in lnk01PrtStats[device2.linkPortMapping['lnk01']] ['Chassis_Capabilities_Enabled']), \ "Case Failed, Neighbor Chassis-Capabilities is not enabled" LogOutput('info', "#Case Passed,Neighbor Chassis-capablities enabled#") retStruct = device1.ConfigVtyShell(enter=False) retCode = retStruct.returnCode() assert retCode == 0, "Failed to come out of config terminal" retStruct = device1.VtyshShell(enter=False) retCode = retStruct.returnCode() assert retCode == 0, "Failed to exit vtysh prompt"
def checkShowTechFeatureSFLOW(dut01Obj): LogOutput('info', "\n##################################################") LogOutput('info', "6.0 Running Show tech Feature sFlow Test ") LogOutput('info', "##################################################\n") # Variables overallBuffer = [] finalReturnCode = 0 # Get into vtyshell returnStructure = dut01Obj.VtyshShell(enter=True) overallBuffer.append(returnStructure.buffer()) returnCode = returnStructure.returnCode() if returnCode != 0: LogOutput('error', "Failed to get vtysh prompt") for curLine in overallBuffer: LogOutput('info', str(curLine)) return False # Run Show Tech SFLOW Command returnDevInt = dut01Obj.DeviceInteract(command="show tech sflow") # exit the vtysh shell returnStructure = dut01Obj.VtyshShell(enter=False) overallBuffer.append(returnStructure.buffer()) returnCode = returnStructure.returnCode() if returnCode != 0: LogOutput('error', "Failed to exit vtysh prompt") for curLine in overallBuffer: LogOutput('info', str(curLine)) return False finalReturnCode = returnDevInt['returnCode'] overallBuffer.append(returnDevInt['buffer']) if finalReturnCode != 0: LogOutput( 'error', "Failed to run 'show tech sflow' " + " on device " + str(dut01Obj.device)) return False else: if ("Show Tech commands executed successfully" not in returnDevInt['buffer']): LogOutput('error', "Test Case Failure,refer output below") for outputs in overallBuffer: LogOutput('info', str(outputs)) return False else: LogOutput( 'info', " Show Tech Feature sFlow Ran Successfully on device " + str(dut01Obj.device)) return True
def checkEmptyFile(dut01Obj): # Variables vtysh_cmd = 'diag-dump list' overallBuffer = [] finalReturnCode = 0 tc_desc = vtysh_cmd + ' test ' str_check = 'Feature to daemon mapping failed. Unable to retrieve the daemon name.' LogOutput('info', "\n############################################") LogOutput('info', "3.2 Running diag-dump empty config file test") LogOutput('info', "############################################\n") shell_cmd = gen_shell_cmd_backup_conf() returnDevInt = dut01Obj.DeviceInteract(command=shell_cmd) LogOutput('info', str(returnDevInt['buffer'])) shell_cmd = "touch /etc/openswitch/supportability/ops_featuremapping.yaml" returnDevInt = dut01Obj.DeviceInteract(command=shell_cmd) LogOutput('info', str(returnDevInt['buffer'])) dut01Obj.VtyshShell(enter=True) returnDevInt = dut01Obj.DeviceInteract(command=vtysh_cmd) LogOutput('info', str(returnDevInt['buffer'])) shell_cmd = gen_shell_cmd_restore_conf() dut01Obj.VtyshShell(enter=False) dut01Obj.DeviceInteract(command=shell_cmd) LogOutput('info', str(returnDevInt['buffer'])) finalReturnCode = returnDevInt['returnCode'] overallBuffer.append(returnDevInt['buffer']) if finalReturnCode != 0: LogOutput('error', "Failed to run " + tc_desc + " on device " + str(dut01Obj.device)) return False else: if (str_check not in returnDevInt['buffer']): LogOutput( 'error', tc_desc + "Test Case Failure,refer output below") for outputs in overallBuffer: LogOutput('info', str(outputs)) return False else: LogOutput('info', tc_desc + "ran successfully on device " + str(dut01Obj.device)) return True
def checkVlogConfigDaemon(dut01Obj): LogOutput('info', "\n############################################") LogOutput('info', "1.5 Check basic Vlog Configuration for Daemon ") LogOutput('info', "############################################\n") # Get Into VtyshShell assert (getIntoVtysh(dut01Obj)) assert (getIntoConfig(dut01Obj)) returnDevInt = dut01Obj.DeviceInteract( command="vlog daemon ops-lacpd syslog info") returnDevInt = dut01Obj.DeviceInteract( command="vlog daemon ops-lacpd file dbg") # Clean Up assert (getOutOfConfig(dut01Obj)) finalReturnCode = returnDevInt['returnCode'] LogOutput('info', str(returnDevInt['buffer'])) if finalReturnCode != 0: LogOutput('error', "vlog configuration failed") return False returnDevInt = dut01Obj.DeviceInteract( command="show vlog config daemon ops-lacpd") assert (getOutOfVtysh(dut01Obj)) LogOutput('info', str(returnDevInt['buffer'])) regex = re.compile(r"ops-lacpd\s+INFO\s+DBG") if re.search(regex, returnDevInt['buffer']) is None: LogOutput('error', "vlog configuration has not effect : failed") return False # Now change the setting to DBG and check whether it changes # Get Into VtyshShell assert (getIntoVtysh(dut01Obj)) assert (getIntoConfig(dut01Obj)) returnDevInt = dut01Obj.DeviceInteract( command="vlog daemon ops-lacpd syslog dbg") returnDevInt = dut01Obj.DeviceInteract( command="vlog daemon ops-lacpd file info") # Clean Up assert (getOutOfConfig(dut01Obj)) finalReturnCode = returnDevInt['returnCode'] LogOutput('info', str(returnDevInt['buffer'])) if finalReturnCode != 0: LogOutput('error', "vlog configuration failed") return False returnDevInt = dut01Obj.DeviceInteract( command="show vlog config daemon ops-lacpd") assert (getOutOfVtysh(dut01Obj)) LogOutput('info', str(returnDevInt['buffer'])) regex = re.compile(r"ops-lacpd\s+DBG\s+INFO") if re.search(regex, returnDevInt['buffer']) is None: LogOutput('error', "vlog configuration has not effect : failed") return False return True
def checkDiagDumpList(dut01Obj): # Variables overallBuffer = [] finalReturnCode = 0 str_check = 'Diagnostic Dump Supported Features List' vtysh_cmd = 'diag-dump list' tc_desc = vtysh_cmd + ' test ' LogOutput('info', "\n############################################") LogOutput('info', '1.1 Running' + tc_desc) LogOutput('info', "############################################\n") # Get into vtyshelll returnStructure = dut01Obj.VtyshShell(enter=True) overallBuffer.append(returnStructure.buffer()) returnCode = returnStructure.returnCode() if returnCode != 0: LogOutput('error', "Failed to get vtysh prompt") for curLine in overallBuffer: LogOutput('info', str(curLine)) return False returnDevInt = dut01Obj.DeviceInteract(command=vtysh_cmd) LogOutput('info', str(returnDevInt['buffer'])) # exit the vtysh shell returnStructure = dut01Obj.VtyshShell(enter=False) overallBuffer.append(returnStructure.buffer()) returnCode = returnStructure.returnCode() if returnCode != 0: LogOutput('error', "Failed to exit vtysh prompt") for curLine in overallBuffer: LogOutput('info', str(curLine)) return False finalReturnCode = returnDevInt['returnCode'] overallBuffer.append(returnDevInt['buffer']) if finalReturnCode != 0: LogOutput('error', "Failed to run " + tc_desc + " on device " + str(dut01Obj.device)) return False else: if (str_check not in returnDevInt['buffer']): LogOutput( 'error', tc_desc + "Test Case Failure,refer output below") for outputs in overallBuffer: LogOutput('info', str(outputs)) return False else: LogOutput('info', tc_desc + "ran successfully on device " + str(dut01Obj.device)) return True
def checkInvalidCommandFailure(dut01Obj): LogOutput('info', "\n############################################") LogOutput('info', "2.1 Running Show tech Cli Command Failure") LogOutput('info', "############################################\n") # Variables overallBuffer = [] # Backup the Default Yaml File command = "cp /etc/openswitch/supportability/ops_showtech.yaml \ /etc/openswitch/supportability/ops_showtech.yaml2 " returnDevInt = dut01Obj.DeviceInteract(command=command) LogOutput('info', str(returnDevInt['buffer'])) command = "ls /etc/openswitch/supportability " returnDevInt = dut01Obj.DeviceInteract(command=command) LogOutput('info', str(returnDevInt['buffer'])) # Add Test Feature with invalid show command (feature_name: test1234) command = "printf '\n feature:\n -\n feature_desc: \"sttest\"\n\ feature_name: test1234\n cli_cmds:\n - \"show testing\"' >> \ /etc/openswitch/supportability/ops_showtech.yaml" returnDevInt = dut01Obj.DeviceInteract(command=command) LogOutput('info', str(returnDevInt['buffer'])) # Get into vtyshelll returnStructure = dut01Obj.VtyshShell(enter=True) overallBuffer.append(returnStructure.buffer()) returnCode = returnStructure.returnCode() if returnCode != 0: LogOutput('error', "Failed to get vtysh prompt") for curLine in overallBuffer: LogOutput('info', str(curLine)) return False # Run Show Tech test1234 Command returnDevInt = dut01Obj.DeviceInteract(command="show tech test1234", errorCheck=False, CheckError="NOPlease") LogOutput('info', str(returnDevInt['buffer'])) # exit the vtysh shell returnStructure = dut01Obj.VtyshShell(enter=False) overallBuffer.append(returnStructure.buffer()) returnCode = returnStructure.returnCode() if returnCode != 0: LogOutput('error', "Failed to exit vtysh prompt") for curLine in overallBuffer: LogOutput('info', str(curLine)) return False dut01Obj.DeviceInteract(command="mv \ /etc/openswitch/supportability/ops_showtech.yaml2 \ /etc/openswitch/supportability/ops_showtech.yaml") overallBuffer.append(returnDevInt['buffer']) if ("failed to execute" not in returnDevInt['buffer']): LogOutput('error', "Test Case Failure,refer output below") for outputs in overallBuffer: LogOutput('info', str(outputs)) return False else: LogOutput( 'info', "Show Tech Invalid Cli Command Ran Successfully on device" + str(dut01Obj.device)) return True
def checkShowTechToFile(dut01Obj): LogOutput('info', "\n############################################") LogOutput('info', "1.5 Running Show tech to File ") LogOutput('info', "############################################\n") # Variables overallBuffer = [] finalReturnCode = 0 outputfile = str(uuid.uuid4()) + ".txt" # Get into vtyshell returnStructure = dut01Obj.VtyshShell(enter=True) overallBuffer.append(returnStructure.buffer()) returnCode = returnStructure.returnCode() if returnCode != 0: LogOutput('error', "Failed to get vtysh prompt") for curLine in overallBuffer: LogOutput('info', str(curLine)) return False # Run Show Tech Command and store output to file returnDevInt = dut01Obj.DeviceInteract(command="show tech localfile " + outputfile) # exit the vtysh shell returnStructure = dut01Obj.VtyshShell(enter=False) overallBuffer.append(returnStructure.buffer()) returnCode = returnStructure.returnCode() if returnCode != 0: LogOutput('error', "Failed to exit vtysh prompt") for curLine in overallBuffer: LogOutput('info', str(curLine)) return False finalReturnCode = returnDevInt['returnCode'] overallBuffer.append(returnDevInt['buffer']) if finalReturnCode != 0: LogOutput( 'error', "Failed to run Show Tech to localfile" + " on device " + str(dut01Obj.device)) return False else: # Read the file and check the output returnDevInt = dut01Obj.DeviceInteract(command="cat /tmp/" + outputfile) if ("Show Tech commands executed successfully" not in returnDevInt['buffer']): LogOutput('error', "Test Case Failure,refer output below") for outputs in overallBuffer: LogOutput('info', str(outputs)) return False else: LogOutput( 'info', " Show Tech Feature Ran Successfully on device " + str(dut01Obj.device)) return True