def errExit(self, str): # print erros from netplugin log file for node in self.nodes: node.checkForNetpluginErrors() # exit the script tutils.exit(str)
def errExit(self, str): # print erros from netplugin log file for node in self.nodes: node.chekForNetpluginErrors() # exit the script tutils.exit(str)
def sshConnect(self, username, password): ssh_object = paramiko.SSHClient() ssh_object.set_missing_host_key_policy(paramiko.AutoAddPolicy()) print "Connecting to " + self.addr + " with userid: " + username + " password: "******"Authentication failed")
def sshConnect(self, username, password): ssh_object = paramiko.SSHClient() ssh_object.set_missing_host_key_policy( paramiko.AutoAddPolicy() ) print "Connecting to " + self.addr + " with userid: " + username + " password: "******"Authentication failed")
def getIpAddr(self, intfName="eth0"): if intfName == "eth0": return self.eth0Addr # Read interface ip out, err, exitCode = self.execCmd("ifconfig " + intfName) if err != [] or exitCode != 0: print "Error during docker exec" print err tutils.exit("Failed to get IP address") return out[1].split('addr')[1].split(' ')[0].split(':')[1]
def __init__(self, node, cid, cntName=""): self.node = node self.cid = cid self.cntName = cntName # Read interface ip out, err, exitCode = self.execCmd('ip addr show dev eth0 | grep "inet "') if err != [] or exitCode != 0: print "Error during docker exec" print err tutils.exit("Failed to get IP address") self.eth0Addr = out[0].strip().split(' ')[1].split('/')[0]
def checkPingFailure(self, ipAddr): tutils.log("Checking ping failure from " + self.myId() + " to " + ipAddr) out, err, exitCode = self.execCmd("ping -c 5 -i 0.5 -W 1 " + ipAddr) pingOutput = ''.join(out) if err != [] or exitCode != 0: print "ping exit(" + str(exitCode) + ") Output: " + pingOutput tutils.log("Ping failed as expected.") return True # Check if ping succeeded if "0 received, 100% packet loss" in pingOutput: tutils.log("Ping failed as expected. Output: " + pingOutput) return True tutils.log("ping from " + self.myId() + " to " + ipAddr + " succeeded while expecting failure") tutils.exit("Ping succeeded while expecting failure")
def checkPingFailure(self, ipAddr): tutils.log("Checking ping failure from " + self.myId() + " to " + ipAddr) out, err, exitCode = self.execCmd("ping -c 5 -i 0.5 -W 1 " + ipAddr) pingOutput = ''.join(out) if err != [] or exitCode != 0: print "ping exit(" + str(exitCode) + ") Output: " + pingOutput tutils.log("Ping failed as expected.") return True # Check if ping succeded if "0 received, 100% packet loss" in pingOutput: tutils.log("Ping failed as expected. Output: " + pingOutput) return True tutils.log("ping from " + self.myId() + " to " + ipAddr + " succeeded while expecting failure") tutils.exit("Ping succeeded while expecting failure")
def checkPing(self, ipAddr): tutils.log("Checking ping from " + self.myId() + " to " + ipAddr) out, err, exitCode = self.execCmd("ping -c 5 -i 0.2 " + ipAddr) if err != [] or exitCode != 0: print "ping exit(" + str(exitCode) + ") Output: " + ''.join(out) print "Error during ping" print err tutils.exit("Ping failed") # Check if ping succeeded pingOutput = ''.join(out) if "0 received, 100% packet loss" in pingOutput: print "Ping failed. Output: " + pingOutput tutils.exit("Ping failed") tutils.log("ping from " + self.myId() + " to " + ipAddr + " Successful!") return True
def checkPing(self, ipAddr): tutils.log("Checking ping from " + self.myId() + " to " + ipAddr) out, err, exitCode = self.execCmd("ping -c 5 -i 0.2 " + ipAddr) if err != [] or exitCode != 0: print "ping exit(" + str(exitCode) + ") Output: " + pingOutput print "Error during ping" print err tutils.exit("Ping failed") # Check if ping succeded pingOutput = ''.join(out) if "0 received, 100% packet loss" in pingOutput: print "Ping failed. Output: " + pingOutput tutils.exit("Ping failed") tutils.log("ping from " + self.myId() + " to " + ipAddr + " Successful!") return True
def checkForNetpluginErrors(self): for node in self.nodes: ret = node.checkForNetpluginErrors() if ret == False and self.failOnError: tutils.exit("Errors in log file")
def errorExit(self, str, out, err): print str + " " + self.myId() print "Output: " + ''.join(out) print "Error: " + ''.join(err) tutils.exit(str)
def chekForNetpluginErrors(self): for node in self.nodes: ret = node.chekForNetpluginErrors() if ret == False and self.failOnError: tutils.exit("Errors in log file")