示例#1
0
文件: gui.py 项目: thomassa/xenrt
 def writeResultsFile(self):
     if not self.results:
         raise xenrt.XRTFailure(
             "An omnishambles has occured - no results to report")
     file("%s/%s" % (xenrt.TEC().getLogdir(), self.RESULT_FILE_NAME),
          "w").write(self.results)
     log("Output file written: %s" % self.RESULT_FILE_NAME)
示例#2
0
文件: txt.py 项目: johnmdilley/xenrt
    def __runCommand(self, hostRef, session, command, args):
        try:
            self.__logDebug("HostRef: " + hostRef, "Plugin: " + self.__PLUGIN_NAME, "Command: " + command, "Args: " + str(args))
            output = session.xenapi.host.call_plugin(hostRef, self.__PLUGIN_NAME, command, args)
            return output
        except:
            traceback.print_exc(file=sys.stderr)
            exc_type, exc_value, exc_traceback = sys.exc_info()

            xenrt.TEC().logverbose("HostRef: %s, Plugin: %s, Command: %s Args: %s" % (hostRef, self.__PLUGIN_NAME, command, str(args)))
            hostName = session.xenapi.host.get_record(hostRef)['hostname']
            log("Host name %s" % hostName)
            hosts = xenrt.TEC().registry.hostFind(hostName)

            if len(hosts) < 1:
                xenrt.TEC().logverbose("Hostname not found")
                raise

            host = hosts[0]
            if host:
                xenrt.TEC().logverbose(host.execdom0("find /etc/xapi.d/plugins -name tpm"))
                xenrt.TEC().logverbose("Host is %s" % hostName)
                m = re.search('xentpm\[[0-9]*\]', str(exc_value))
                if m:
                    xenrt.TEC().logverbose(host.execdom0("grep -F '%s' /var/log/messages" % m.group(0)))

            errorMessage = self.__attemptLogParse(host)
            if errorMessage:
                raise xenrt.XRTFailure(errorMessage)
            raise
示例#3
0
    def run(self, arglist=[]):
        if self.updateMachineWithAutoFlaggerTag:
            params = xenrt.APIFactory().get_machine(self.machineName)['params']
            if "AUTOFLAGGERTAG" in params and params["AUTOFLAGGERTAG"] == self.updateMachineWithAutoFlaggerTag:
                comment("Machine %s has already been checked. Exiting." % self.machineName)
                return

        for flag,flagData in self.flags.iteritems():
            if "seqFile" in flagData:
                seqFile=flagData["seqFile"]
            elif "productType" in flagData or "productVersion" in flagData or "version" in flagData:
                seqFile = self.createTempSeq(**flagData)
            else:
                warning("Unimplemented")
            log("Using Temp Seq File : %s" % seqFile)

            passed = False
            try:
                self.doSequence(seqFile)
                passed = True
            except Exception, e:
                warning(str(e))

            if passed == flagData["isSetIfPass"] and not self.isPropAlreadySet(flag):
                comment("Adding flag '%s' to machine '%s'" % (flag, self.machineName))
                xenrt.APIFactory().update_machine(self.machineName, addflags=[flag])
            elif passed != flagData["isSetIfPass"] and self.isPropAlreadySet(flag):
                comment("Removing flag '%s' from machine '%s'" % (flag, self.machineName))
                xenrt.APIFactory().update_machine(self.machineName, delflags=[flag])
            else:
                comment("Machine '%s' %s flag '%s'" % (self.machineName,"is already having required" if self.isPropAlreadySet(flag) else "neither need nor has", flag))
示例#4
0
 def run(self, arglist=None):
     """Do testing tasks in run"""
     
     xenrt.TEC().logverbose("Importing WinPDB libs.")
     #install rpdb2 to enable WinPDB remote debugging session.
     #os.system("scp [email protected]:~/debugger_test/rpdb2.py /tmp/")
     os.system("wget https://winpdb.googlecode.com/hg/rpdb2.py -O /tmp/rpdb2.py")
     sys.path.append(r"/tmp")
     import rpdb2
     xenrt.TEC().logverbose("Import done. Trying wait remote debugger.")
     rpdb2.start_embedded_debugger('abc', fAllowRemote = True)
     log("Hello, world!")
     log("My host name is %s" % self.host.getName())
     
     a = 10
     b = 0
     log("print a + b = %d" % a + b);
     log("print a - b = %d" % a - b);
     log("print a / b = %d" % a / b);
     
     # you can SSH to a guest by doing:
     ret = self.guest0.execguest("ls")
     
     # or to a host by doing:
     ret = self.host.execdom0("ls")
示例#5
0
 def getExistingLAGs(self, setChRange=False, quiet=False):
     lines = self.commandWithResponse('show interfaces port-channel')
     re_ch = re.compile("%s\d+" % self.CHANNELPREFIX)
     re_no_ch = re.compile('[^c]')
     re_wrapped = re.compile("\s+((?:%s,?\s?)+)" % self.PORTREGEX)
     # fix wrapped second column of the list
     for i in range(1, len(lines)):
         if re_no_ch.match(lines[i]) and re_ch.match(lines[i - 1]):
             m = re_wrapped.match(lines[i])
             if m:
                 wrapped = m.group(1).strip()
                 s1, s2 = lines[i - 1].rsplit(None, 1)
                 lines[i - 1] = s1 + ", " + wrapped + s2
     lines = filter(re_ch.match, lines)
     if setChRange is True:
         # find last chX line and set maxCh to X
         self.maxCh = int(
             re.match("%s(\d+)" % self.CHANNELPREFIX, lines[-1]).group(1))
     re_noports = re.compile("%s\d+\s+No Configured Ports" %
                             self.CHANNELPREFIX)
     lines = filter(lambda x: not re_noports.match(x), lines)
     LAGs = []
     members = []
     if len(lines) > 0:
         log("Existing configured channels found: \n%s" % "\n".join(lines))
         # convert \d+ into integers and return list of existing LAG numbers
         LAGs = map(
             lambda line: int(
                 re.match("%s(\d+)" % self.CHANNELPREFIX, line).group(1)),
             lines)
         members = [re.findall(self.PORTREGEX, line) for line in lines]
     return (LAGs, members)
示例#6
0
 def getExistingLAGs(self, setChRange=False, quiet=False):
     lines = self.commandWithResponse('show interfaces port-channel')
     re_ch = re.compile("%s\d+" % self.CHANNELPREFIX)
     re_no_ch = re.compile('[^c]')
     re_wrapped = re.compile("\s+((?:%s,?\s?)+)" % self.PORTREGEX)
     # fix wrapped second column of the list
     for i in range(1,len(lines)):
         if re_no_ch.match(lines[i]) and re_ch.match(lines[i-1]):
             m = re_wrapped.match(lines[i])
             if m:
                 wrapped = m.group(1).strip()
                 s1, s2 = lines[i-1].rsplit(None, 1)
                 lines[i-1] = s1 + ", " + wrapped + s2
     lines = filter(re_ch.match,lines)
     if setChRange is True:
         # find last chX line and set maxCh to X
         self.maxCh = int(re.match("%s(\d+)" % self.CHANNELPREFIX, lines[-1]).group(1))
     re_noports = re.compile("%s\d+\s+No Configured Ports" % self.CHANNELPREFIX)
     lines = filter(lambda x: not re_noports.match(x) , lines)
     LAGs = []
     members = []
     if len(lines)>0:
         log("Existing configured channels found: \n%s" % "\n".join(lines))
         # convert \d+ into integers and return list of existing LAG numbers
         LAGs = map(lambda line : int(re.match("%s(\d+)" % self.CHANNELPREFIX, line).group(1)), lines)
         members =  [re.findall(self.PORTREGEX, line) for line in lines]
     return (LAGs, members)
示例#7
0
    def setLACP(self):
        # Check that no port has LAG/LACP already set
        for port in self.ports:
            self.checkPortHasNoLagSet(port)
        # Set LAG and enable LACP on all the ports
        proposedLAG = self.proposeLAG()
        ports = self.ports[:]
        firstPort = ports.pop(0)
        # Avoid the (unlikely) situation where two TCs try to set up the same LAG 
        # (let the other TC win, revert and re-propose LAG)
        for i in range(self.MAX_ATTEMPTS):
            log("Trying LAG number %s." % proposedLAG)
            self.setLagOnPort(firstPort, proposedLAG)
            if self.checkLagIsOnlyOnPort(proposedLAG, firstPort):
                break
            else:
                log("Reverting, LAG %s seems to be used by another port." % proposedLAG) 
                self.unsetLagOnPort(firstPort)
                proposedLAG = self.proposeLAG()
        else:
            raise xenrt.XRTError("%s attempts to set up LAC on port %s failed." % (self.MAX_ATTEMPTS, firstPort) )

        # Set up chosen LAG on the remaining ports
        self.lag = proposedLAG
        for port in ports:
            self.setLagOnPort(port, self.lag)
        
        # Set the port-channel interface
        self.portChannelInterfaceConfigure()
        self.disconnect()
示例#8
0
    def run(self, arglist=None):
        """Do testing tasks in run"""

        xenrt.TEC().logverbose("Importing WinPDB libs.")
        #install rpdb2 to enable WinPDB remote debugging session.
        #os.system("scp [email protected]:~/debugger_test/rpdb2.py /tmp/")
        os.system(
            "wget https://winpdb.googlecode.com/hg/rpdb2.py -O /tmp/rpdb2.py")
        sys.path.append(r"/tmp")
        import rpdb2
        xenrt.TEC().logverbose("Import done. Trying wait remote debugger.")
        rpdb2.start_embedded_debugger('abc', fAllowRemote=True)
        log("Hello, world!")
        log("My host name is %s" % self.host.getName())

        a = 10
        b = 0
        log("print a + b = %d" % a + b)
        log("print a - b = %d" % a - b)
        log("print a / b = %d" % a / b)

        # you can SSH to a guest by doing:
        ret = self.guest0.execguest("ls")

        # or to a host by doing:
        ret = self.host.execdom0("ls")
示例#9
0
 def getExistingLAGs(self, setChRange=False, quiet=False):
     lines = self.commandWithResponse('show etherchannel summary')
     re_ch = re.compile("\d+\s+%s\d+" % self.CHANNELPREFIX)
     re_no_ch = re.compile('[^0-9]')
     re_wrapped = re.compile("\s+((?:%s,?\s?)+)" % self.PORTREGEX)
     # fix wrapped second column of the list
     for i in range(1, len(lines)):
         if re_no_ch.match(lines[i]) and re_ch.match(lines[i - 1]):
             m = re_wrapped.match(lines[i])
             if m:
                 wrapped = m.group(1).strip()
                 s1, s2 = lines[i - 1].rsplit(None, 1)
                 lines[i - 1] = s1 + ", " + wrapped + s2
     lines = filter(re_ch.match, lines)
     lines = filter(lambda x: len(x.split()) > 3, lines)
     LAGs = []
     members = []
     if len(lines) > 0:
         log("Existing configured channels found: \n%s" % "\n".join(lines))
         # convert \d+ into integers and return list of existing LAG numbers
         LAGs = map(
             lambda line: int(
                 re.search("%s(\d+)" % self.CHANNELPREFIX, line).group(1)),
             lines)
         members = [re.findall(self.PORTREGEX, line) for line in lines]
     return (LAGs, members)
示例#10
0
    def setLACP(self):
        # Check that no port has LAG/LACP already set
        for port in self.ports:
            self.checkPortHasNoLagSet(port)
        # Set LAG and enable LACP on all the ports
        proposedLAG = self.proposeLAG()
        ports = self.ports[:]
        firstPort = ports.pop(0)
        # Avoid the (unlikely) situation where two TCs try to set up the same LAG
        # (let the other TC win, revert and re-propose LAG)
        for i in range(self.MAX_ATTEMPTS):
            log("Trying LAG number %s." % proposedLAG)
            self.setLagOnPort(firstPort, proposedLAG)
            if self.checkLagIsOnlyOnPort(proposedLAG, firstPort):
                break
            else:
                log("Reverting, LAG %s seems to be used by another port." %
                    proposedLAG)
                self.unsetLagOnPort(firstPort)
                proposedLAG = self.proposeLAG()
        else:
            raise xenrt.XRTError(
                "%s attempts to set up LAC on port %s failed." %
                (self.MAX_ATTEMPTS, firstPort))

        # Set up chosen LAG on the remaining ports
        self.lag = proposedLAG
        for port in ports:
            self.setLagOnPort(port, self.lag)

        # Set the port-channel interface
        self.portChannelInterfaceConfigure()
        self.disconnect()
示例#11
0
    def __writeOnDom0(self):
        """Run writing concurrently."""

        # prepare scripts
        if self.sequential:
            cmd = "dd if=/dev/zero of=/dev/\\${DEVICE} bs=1M count=%d" % \
                (self.vdisize / xenrt.MEGA)
            chkcmd = "ps -efl | grep '[d]d if=/dev/zero'"
        else:
            cmd = "%s/remote/patterns.py /dev/\\${DEVICE} %d write 3" % \
                (xenrt.TEC().lookup("REMOTE_SCRIPTDIR"), self.vdisize)
            chkcmd = "ps -efl | grep '[p]atterns.py'"

        cmd = "while [ -f /tmp/hold_running ] ; do sleep 0.1 ; done ; %s" % cmd

        self.host.execdom0("echo \"%s\" > /tmp/cmd.sh" % cmd)
        self.host.execdom0("chmod u+x /tmp/cmd.sh")

        # Run all commands with bash scripts first.
        self.host.execdom0("touch /tmp/hold_running")
        for vdi in self.vdis:
            self.host.execdom0("(/opt/xensource/debug/with-vdi %s /tmp/cmd.sh) >/dev/null 2>&1 </dev/null &" % vdi)
        # Triggering all the process at once.
        self.host.execdom0("rm -f /tmp/hold_running")

        waiting = 120 # mins.
        while waiting > 0:
            xenrt.sleep(300, log=False)
            waiting -= 5
            try:
                pslist = self.host.execdom0(chkcmd).strip().splitlines()
            except:
                pslist = []
            if len(pslist) == 0:
                log("Cannot find running process.")
                break
            log("Found %d processes running." % len(pslist))

        log("Checking processes.")
        ptotal = []
        pkilled = []
        pfailed = []
        try:
            pslist = self.host.execdom0(chkcmd).strip().splitlines()
        except:
            palist = []
        for line in pslist:
            pid = line.split()[3]
            ptotal.append(pid)
            try:
                self.host.dom0("kill -9 %s" % pid)
                pkilled.append(pid)
            except:
                pfailed.append(pid)

        if ptotal:
            warning("Found %d processes are still running." % len(ptotal))
            log("Killed: %s" % pkilled)
            log("Failed to killed: %s" % pfailed)
示例#12
0
 def getArgs(self, arglist):
     args = self.parseArgsKeyValue(arglist)
     log("Args: %s" % args)
     lowlevel = args["lowlevel"] in (
         "yes", "true") if "lowlevel" in args else False
     both = args["bothChecks"] in (
         "yes", "true") if "bothChecks" in args else False
     return lowlevel, both
示例#13
0
文件: gui.py 项目: johnmdilley/xenrt
    def triageTestOutput(self):
        for bad in self.__BADNESS:
            if bad in self.results:
                log("Found the horror: %s in the output" % bad)
                raise xenrt.XRTFailure("A failure message was found in the output")

        if self.__vmCount + 1 != len(self._host.listGuests()):
            raise xenrt.XRTFailure("Unexpected guest count: expecting 1 VM more than the test started with")
示例#14
0
文件: gui.py 项目: johnmdilley/xenrt
 def runTests(self):
     localSrName = next(sr for sr in self._host.xapiObject.localSRs if sr.isLocalStorage).name
     try:
         self.__results[self.__currentTest] = self.__runVmOps(localSrName)
         self.__results[self.__currentTest] = self.__runGetRecords()
     except xenrt.XRTFailure, e:
         log("Test failed: %s" % e)
         self.__results[self.__currentTest] = (e.data)
示例#15
0
 def run(self, instance):
     migrateToList = instance.canMigrateTo
     if not migrateToList:
         msg = "The toolstack cannot find a suitable location to migrate to"
         raise xenrt.XRTError(msg)
     migrateTo = instance.canMigrateTo[0]
     log("Instance migrating to %s" % migrateTo)
     instance.migrate(migrateTo)
示例#16
0
 def run(self, instance):
     migrateToList = instance.canMigrateTo
     if not migrateToList:
         msg = "The toolstack cannot find a suitable location to migrate to"
         raise xenrt.XRTError(msg)
     migrateTo = instance.canMigrateTo[0]
     log("Instance migrating to %s" % migrateTo)
     instance.migrate(migrateTo)
示例#17
0
文件: gui.py 项目: thomassa/xenrt
 def runTests(self):
     try:
         self.__results = self._runner.execguest(
             "cd %s && java -cp .:*: %s %s root xenroot" %
             (self._srcPath, self.__TEST_RUNNER, str(self._host.getIP())))
     except xenrt.XRTFailure, e:
         log("Running the tests has failed - caputuring the errors for later triage"
             )
         self.__results = str(e.data)
示例#18
0
    def startFuzzing(self, guest, seed = None):
        if not seed:
            seed = "%x" % random.randint(0, 0xffffffff)

        log("Starting Fuzzing with random seed: " + seed)
        self.host.xenstoreWrite("demufuzzer/randomseed", seed) # 1 is default. accpets unsigned long in C.
        # cannot use guest.start() as it run healthCheck, which will fail.
        self.host.getCLIInstance().execute("vm-start uuid=%s" % guest.getUUID())
        xenrt.sleep(10)
示例#19
0
文件: gui.py 项目: thomassa/xenrt
 def runTests(self):
     localSrName = next(sr for sr in self._host.xapiObject.localSRs
                        if sr.isLocalStorage).name
     try:
         self.__results[self.__currentTest] = self.__runVmOps(localSrName)
         self.__results[self.__currentTest] = self.__runGetRecords()
     except xenrt.XRTFailure, e:
         log("Test failed: %s" % e)
         self.__results[self.__currentTest] = (e.data)
示例#20
0
    def __chooseSR(self, arglist, host):
        """Select the zeroth sr from the SR_INSTALL_NAME variable

        :returns: sr-uuid -- of the named sr else local as default
        """
        srName = xenrt.TEC().lookup("SR_INSTALL_NAME", None)
        if srName:
            log("Attempting to use SR called {srname}".format(srname=srName))

        return host.getSRByName(srName)[0] if srName else host.getLocalSR()
示例#21
0
    def __chooseSR(self, arglist, host):
        """Select the zeroth sr from the SR_INSTALL_NAME variable

        :returns: sr-uuid -- of the named sr else local as default
        """
        srName = xenrt.TEC().lookup("SR_INSTALL_NAME", None)
        if srName:
            log("Attempting to use SR called {srname}".format(srname=srName))

        return host.getSRByName(srName)[0] if srName else host.getLocalSR()
示例#22
0
 def guest2guestPing(self, srcGuest, destIP):
     # ping a guest from another guest
     try: 
         data = srcGuest.xmlrpcExec("ping -6 -n 3 -l 2000 %s" % destIP, returndata=True)
         if (not re.search("\(0% loss\)", data) or
                 re.search("Destination host unreachable", data)) :
             raise xenrt.XRTFailure("Pinging target failed.")
     except Exception, e:
         log('Exception encountered: \n%s\n' % e)
         raise xenrt.XRTFailure('Sending a large ping packet to %s failed' % destIP)
示例#23
0
 def pingGuest(self, ip6):
     try:
         # ping a guest on its IPv6 address from the controller 
         command = "ping6 -c 3 -w 10 -s 2000 %s"
         retCode = xenrt.command((command % ip6), retval="code")
         if retCode != 0:
             raise xenrt.XRTFailure('Command "%s" returned code %s' % (command, retCode) )
     except Exception, e:
         log('Exception encountered: \n%s\n' % e)
         raise xenrt.XRTFailure('Sending a large ping packet to %s failed' % ip6)
示例#24
0
文件: gui.py 项目: thomassa/xenrt
 def __get_sdk_location(self):
     """
     Look for the SDK location in a named flag otherwise provide the default
     """
     log("Look for override in %s" % self.SDK_OVERRIDE)
     try:
         location = xenrt.TEC().lookup(self.SDK_OVERRIDE)
         log("Found override.....")
         return location
     except:
         return "xe-phase-2/%s" % self._packageName
示例#25
0
文件: gui.py 项目: johnmdilley/xenrt
 def _getSdk(self):
     self.removePackage()
     step("Getting SDK....")
     target = self.__get_sdk_location()
     sdkfile = xenrt.TEC().getFile(target)
     sftp = self._runner.sftpClient()
     targetLocation = os.path.join(self.TARGET_ROOT, self._packageName)
     sftp.copyTo(sdkfile, targetLocation)
     log("Target location: %s" % targetLocation)
     sftp.close()
     return targetLocation
示例#26
0
文件: gui.py 项目: thomassa/xenrt
    def triageTestOutput(self):
        for bad in self.__BADNESS:
            if bad in self.results:
                log("Found the horror: %s in the output" % bad)
                raise xenrt.XRTFailure(
                    "A failure message was found in the output")

        if self.__vmCount + 1 != len(self._host.listGuests()):
            raise xenrt.XRTFailure(
                "Unexpected guest count: expecting 1 VM more than the test started with"
            )
示例#27
0
文件: gui.py 项目: johnmdilley/xenrt
 def __get_sdk_location(self):
     """
     Look for the SDK location in a named flag otherwise provide the default
     """
     log("Look for override in %s" % self.SDK_OVERRIDE)
     try:
         location = xenrt.TEC().lookup(self.SDK_OVERRIDE)
         log("Found override.....")
         return location
     except:
         return "xe-phase-2/%s" % self._packageName
示例#28
0
 def __rawXSUninstallVMSerial(self):
     log("Uninstalling %d VMs." % len(self.cloneGuests))
     self.logs.append("Uninstalling %d VMs" % len(self.cloneGuests))
     for guest in self.cloneGuests:
         result = self.host.execdom0("%s %s" % (self.SCRIPT_UNINSTALL_PATH, guest), retval="code")
         output = self.host.execdom0("cat %s" % self.OUTPUT_PATH).splitlines()
         if result:
             logline = "%s Failed uninstalling %s with error: %s" % (output[-1], guest, " ".join(output[:-1]))
         else:
             logline = "%s Uninstalled: %s" % (output[-1], " ".join(output[:-1]))
         self.logs.append(logline)
示例#29
0
文件: gui.py 项目: thomassa/xenrt
 def _getSdk(self):
     self.removePackage()
     step("Getting SDK....")
     target = self.__get_sdk_location()
     sdkfile = xenrt.TEC().getFile(target)
     sftp = self._runner.sftpClient()
     targetLocation = os.path.join(self.TARGET_ROOT, self._packageName)
     sftp.copyTo(sdkfile, targetLocation)
     log("Target location: %s" % targetLocation)
     sftp.close()
     return targetLocation
示例#30
0
    def createTempSeq(self, productType=None, productVersion=None, version=None, **kargs):
        seqContent  = """<xenrt><prepare><host id="0" """
        seqContent += 'productType="%s" ' % productType if productType else ""
        seqContent += 'productVersion="%s" '% productVersion if productVersion else ""
        seqContent += 'version="%s" ' % version if version else ""
        seqContent += """/></prepare></xenrt>"""

        seqFile =xenrt.TEC().tempFile()
        with open(seqFile, 'w') as file:
            file.write(seqContent)
        log("Temp Seq file content : %s" % seqContent)
        return seqFile
示例#31
0
 def clearPrompt(self):
     regex = re.compile('\s*' + self.prompt + '#')
     prompt = self.command('')
     for i in range(5):
         if not regex.match(prompt):
             prompt = self.command('exit')
         else:
             break
     else:
         log("Failed to clear switch patch, reconnecting.")
         self.disconnect()
         self.connectToSwitch()
示例#32
0
    def createTempSeq(self, productType=None, productVersion=None, version=None, **kargs):
        seqContent = """<xenrt><prepare><host id="0" """
        seqContent += 'productType="%s" ' % productType if productType else ""
        seqContent += 'productVersion="%s" ' % productVersion if productVersion else ""
        seqContent += 'version="%s" ' % version if version else ""
        seqContent += """/></prepare></xenrt>"""

        seqFile = xenrt.TEC().tempFile()
        with open(seqFile, "w") as file:
            file.write(seqContent)
        log("Temp Seq file content : %s" % seqContent)
        return seqFile
示例#33
0
    def startFuzzing(self, guest, seed=None):
        if not seed:
            seed = "%x" % random.randint(0, 0xffffffff)

        log("Starting Fuzzing with random seed: " + seed)
        self.host.xenstoreWrite(
            "demufuzzer/randomseed",
            seed)  # 1 is default. accpets unsigned long in C.
        # cannot use guest.start() as it run healthCheck, which will fail.
        self.host.getCLIInstance().execute("vm-start uuid=%s" %
                                           guest.getUUID())
        xenrt.sleep(10)
示例#34
0
 def clearPrompt(self):
     regex = re.compile('\s*'+self.prompt+'#')
     prompt = self.command('')
     for i in range(5):
         if not regex.match(prompt):
             prompt = self.command('exit')
         else:
             break
     else:
         log("Failed to clear switch patch, reconnecting." )
         self.disconnect()
         self.connectToSwitch()
示例#35
0
 def __rawXSCloneVMSerial(self):
     # Avoiding using lib code to overhead of xenrt/python
     log("Cloning the %d guests" % self.numvms)
     self.logs.append("Start cloning %d VMs" % self.numvms)
     for i in xrange(self.numvms):
         result = self.host.execdom0(self.SCRIPT_CLONE_PATH, retval="code")
         output = self.host.execdom0("cat %s" % self.OUTPUT_PATH).splitlines()
         if result:
             logline = "%s Failed cloning with error: %s" % (output[-1], " ".join(output[:-1]))
         else:
             logline = "%s Cloned: %s" % (output[-1], " ".join(output[:-1]))
             self.cloneGuests.append(output[0])
         self.logs.append(logline)
示例#36
0
 def command(self, command):
     # execute a quiet command - one that should not produce any output but prompt
     self.checkForPrompt()
     if command != '' or self.DEBUG:
         log("Executing switch command '%s'" % command)
     self.telnet.write('%s\r' % command)
     out = self.telnet.read_until('#', timeout=self.TIMEOUT)
     self.checkPrompt(out, subtract=command)
     out = self.telnet.read_eager()
     if out.strip():
         log("Remaining output read from switch console '%s'" % out)
         raise xenrt.XRTError("Unexpected output read from switch console!")
     prompt = self.checkForPrompt()
     return prompt
示例#37
0
 def command(self, command):
     # execute a quiet command - one that should not produce any output but prompt
     self.checkForPrompt()
     if command != '' or self.DEBUG:
         log("Executing switch command '%s'" % command)
     self.telnet.write('%s\r' % command)
     out = self.telnet.read_until('#', timeout=self.TIMEOUT)
     self.checkPrompt(out, subtract=command)
     out = self.telnet.read_eager()
     if out.strip():
         log("Remaining output read from switch console '%s'" % out)
         raise xenrt.XRTError("Unexpected output read from switch console!")
     prompt = self.checkForPrompt()
     return prompt
示例#38
0
文件: vbd.py 项目: thomassa/xenrt
 def run(self, arglist):
     host = self.getDefaultHost()
     guest = host.getGuest("winguest2")
     try:
         guest.createDisk("1073741824",
                          sruuid=host.getLocalSR(),
                          plug=True,
                          mode="RO")
     except Exception, ex:
         if "All VBDs of type 'disk' must be read/write for HVM guests" in str(
                 ex):
             log("Read only disk failed to attach to the Windows machine")
         else:
             raise
示例#39
0
 def __noneXSUninstallVMSerial(self):
     log("Uninstalling %d VMs." % len(self.cloneGuests))
     for guest in self.cloneGuests:
         try:
             before = xenrt.util.timenow(float=True)
             guest = self.guest.uninstall()
             after = xenrt.util.timenow(float=True)
             message = "Uninstalled %s" % guest.getUUID()
         except Exception as e:
             after = xenrt.util.timenow(float=True)
             message = "Uninstalling '%s' of uuid '%s' failed with exception '%s': " % (guest, guest.getUUID(), str(e))
         finally:
             logline = "%.6f %s" % ((after - before), message) 
             self.logs.append(logline)
示例#40
0
 def __noneXSCloneVMSerial(self):
     log("Cloning the %d guests" % self.numvms)
     for i in xrange(self.numvms):
         try:
             before = xenrt.util.timenow(float=True)
             guest = self.guest.cloneVM()
             after = xenrt.util.timenow(float=True)
             self.cloneGuests.append(guest)
             message = "Cloned %s" % guest.getUUID()
         except Exception as e:
             after = xenrt.util.timenow(float=True)
             message = "Cloning the VM '%s' of uuid '%s' failed with exception '%s': " % (self.guest, self.guest.getUUID(), str(e))
         finally:
             logline = "%.6f %s" % ((after - before), message) 
             self.logs.append(logline)
示例#41
0
    def prepare(self, arglist):
        self.vmName = self.parseArgsKeyValue(arglist)["vm"]
        log("Using vm %s" % self.vmName)
        self.vm = self.getGuest(self.vmName)
        self.srtype = self.vm.xapiObject.VDIs[0].SR.srType

        if self.vm.getState() != "UP":
            self.vm.start()

        self._applyMaxLicense()
        host = self.getDefaultHost()
        rcc = host.getReadCachingController()
        rcc.setVM(self.vm)
        rcc.enable()
        self._defaultLifeCycle(self.vm)
示例#42
0
    def prepare(self, arglist):
        self.vmName = self.parseArgsKeyValue(arglist)["vm"]
        log("Using vm %s" % self.vmName)
        self.vm = self.getGuest(self.vmName)
        self.srtype = self.vm.xapiObject.VDIs[0].SR.srType

        if self.vm.getState() != "UP":
            self.vm.start()

        self._applyMaxLicense()
        host = self.getDefaultHost()
        rcc = host.getReadCachingController()
        rcc.setVM(self.vm)
        rcc.enable()
        self._defaultLifeCycle(self.vm)
示例#43
0
    def createVLANs(self):
        durkeys = ["network-create"]
        for h in self.normalHosts:
            durkeys.append("%s_vlan-create" % h)
            durkeys.append("%s_pif-plug" % h)
        durkeys.append("vif-create")
        durkeys.append("vif-plug")
        self.log(self.createLog, "# vlan %s  total" % (",".join(durkeys)))

        for i in range(1, self.numvlans+1):
            if i%200 == 0 and xenrt.TEC().lookup("WORKAROUND_CA95084", False, boolean=True):
                log("rebooting vm after creating %s vlans" % i)
                self.testVM.reboot()
            dur = self.createSingleVLAN(i)
            xenrt.TEC().logverbose("total duration for creating VLAN %d was %f" % (i, dur))
示例#44
0
    def run(self, arglist):
        self.host = self.getDefaultHost()
        session = self.host.getAPISession()
        hostRef = session.xenapi.host.get_all()[0]

        end = time.time() + self.__DURATION
        log("This test will end in %s secs" % str(end))

        try:
            while time.time() < end:
                step("Fetch the attestation id....")
                log(xenrt.txt.TXTCommand().getAttestationId(hostRef, session))
                step("Reboot host....")
                self.host.reboot()
        except:
            raise xenrt.XRTFailure("Failure occurred whilst calling the attestation id api repeatedly")
示例#45
0
    def prepare(self, arglist=[]):

        self.host = self.getDefaultHost()
        self.pool = self.host.pool
        if self.pool:
            self.host = self.pool.master
        self.sr = self.host.lookupDefaultSR()
        self.timeout = 180 * 60 # timeout of 3 hours per iteration.

        self.__obtainTestVars(arglist, printAfterObtain = True)

        self.guests = []
        if self.runOnGuest:
            xenrt.pfarm([xenrt.PTask(self.prepareGuests, host) for host in self.pool.getHosts()])
        else:
            log("Test are running on the host.")
示例#46
0
文件: txt.py 项目: johnmdilley/xenrt
 def fromHostFile(cls, host, *filename):
     """
     Alt. constructor. Read marker matches from the log
     on the host and then construct this class
     host: a host object
     filename: the file name on the host to parse
     """
     data = []
     for fname in filename:
         for m in cls.MARKERS:
             grep = "grep '%s' %s" % (m, fname)
             if host.execcmd(grep, retval="code") < 1:
                 data += host.execcmd(grep).split('\n')
             else:
                 log("grep failed for %s in file %s - no data found" % (m, fname))
     return cls(data)
示例#47
0
 def fromHostFile(cls, host, *filename):
     """
     Alt. constructor. Read marker matches from the log
     on the host and then construct this class
     host: a host object
     filename: the file name on the host to parse
     """
     data = []
     for fname in filename:
         for m in cls.MARKERS:
             grep = "grep '%s' %s" % (m, fname)
             if host.execcmd(grep, retval="code") < 1:
                 data += host.execcmd(grep).split('\n')
             else:
                 log("grep failed for %s in file %s - no data found" %
                     (m, fname))
     return cls(data)
示例#48
0
    def createVLANs(self):
        durkeys = ["network-create"]
        for h in self.normalHosts:
            durkeys.append("%s_vlan-create" % h)
            durkeys.append("%s_pif-plug" % h)
        durkeys.append("vif-create")
        durkeys.append("vif-plug")
        self.log(self.createLog, "# vlan %s  total" % (",".join(durkeys)))

        for i in range(1, self.numvlans + 1):
            if i % 200 == 0 and xenrt.TEC().lookup(
                    "WORKAROUND_CA95084", False, boolean=True):
                log("rebooting vm after creating %s vlans" % i)
                self.testVM.reboot()
            dur = self.createSingleVLAN(i)
            xenrt.TEC().logverbose(
                "total duration for creating VLAN %d was %f" % (i, dur))
示例#49
0
文件: rrd.py 项目: johnmdilley/xenrt
    def run(self,arglist):
        pool = self.getDefaultPool()
        master = pool.master
        slave = pool.getSlaves()[0]

        step("Execute host_rrd on slave")
        startTime = xenrt.util.timenow() 
        while xenrt.util.timenow() < startTime + 10: 
           slave.execdom0("wget http://root:%s@%s/host_rrd" %(slave.password, slave.getIP()))
        
        step("Searching for the HOST_IS_SLAVE exception in xensource.log")
        msg = "Got exception HOST_IS_SLAVE"
        grepReturnValue = slave.execdom0("grep '%s' /var/log/xensource.log" %(msg),retval = "code")
        if grepReturnValue == 0:
            raise xenrt.XRTFailure("host_rrd request for slave causes HOST_IS_SLAVE exception.")
        else:
            log("host_rrd request for slave doesn't cause any HOST_IS_SLAVE exception")
示例#50
0
 def _checkContent(self, content):
     # Check that we have three fields in every line
     # This check was implemented, as occasionally we see malformatted lines
     # It can be removed once we get to root cause of this behaviour
     candidateContent = content
     content = content.rstrip()
     if len(content) == 0:
         return
     lines = content.rstrip().split("\n")
     for l in lines:
         fields = l.split()
         if len(fields) != 3:
             warning('Problem in switch.py library - attempt to write a malformatted line')
             current = self._readAll()
             log('current data:\n%s' % current)
             log('candidate data:\n"%s"' % candidateContent)
             raise xenrt.XRTError('Attempted to write a malformatted line "%s" '
                     'in LACP clean-up flags file.' % l)
示例#51
0
 def prepare(self, arglist):
     self.snappoint = None
     self.host = self.getDefaultHost()
     self.sr = self.__chooseSR(arglist, self.host)
     log("SR UUID is {sruuid}".format(sruuid=self.sr))
     self.host.addExtraLogFile("/var/log/SMlog")
     if not self.EXISTING_GUEST:
         self.guest = None
         for arg in arglist:
             l = string.split(arg, "=", 1)
             if l[0] == "guest":
                 self.guest = self.getGuest("%s" % l[1])
                 self.guest.setName(l[1])
     if not self.guest and not self.SMOKETEST:
         name = "%s-%s" % (self.VM, self.DISTRO)
         self.guest = self.getGuest(name)
     if not self.guest:
         if self.SMOKETEST:
             self.guest = xenrt.lib.xenserver.guest.createVM(\
                 self.host,
                 xenrt.randomGuestName(),
                 distro=self.DISTRO,
                 arch=self.ARCH,
                 memory=1024,
                 sr=self.sr,
                 vifs=xenrt.lib.xenserver.Guest.DEFAULT)
         elif self.DISTRO == "DEFAULT":
             self.guest = self.host.createGenericLinuxGuest(name=name,
                                                            sr=self.sr)
         else:
             self.guest = self.host.createGenericWindowsGuest(
                 distro=self.DISTRO, memory=1024, sr=self.sr)
             self.guest.setName(name)
         if not self.SMOKETEST:
             xenrt.TEC().registry.guestPut(name, self.guest)
     try:
         if self.guest.getState() == "DOWN":
             self.guest.start()
         else:
             self.guest.reboot()
         self.guest.checkHealth()
     except xenrt.XRTFailure, e:
         raise xenrt.XRTError("Guest broken before we started: %s" %
                              (str(e)))
示例#52
0
    def run(self, arglist=[]):
        if self.IS_VALID_CLIENTTHREADS or self.IS_VALID_CLIENTPARALLELCONN:
            for t,p in self.clientTnP:
                step("Test segment started")
                if self.IS_VALID_CLIENTTHREADS:
                    self.httpClientThreads=int(t)
                    log("Test Parameter: httpClientThreads = %d" % (self.httpClientThreads))
                if self.IS_VALID_CLIENTPARALLELCONN:
                    self.httpClientParallelconn=int(p)
                    log("Test Parameter: httpClientParallelconn = %d" % (self.httpClientParallelconn))

                self.startWorkload()
                self.runTest()
                self.stopWorkload()
                step("Test segment finished")
        else:
            self.startWorkload()
            self.runTest()
            self.stopWorkload()
示例#53
0
文件: ipv6.py 项目: johnmdilley/xenrt
 def installIpv6WinGuest(self, host):
     guest = host.createBasicGuest(distro=self.DISTRO, use_ipv6=True )
     self._guestsToUninstall.append(guest)
     # check IPv4 address - assume that we'll just have "eth0 VIF on the guest
     mac, ip, network = guest.getVIFs()["eth0"]
     if ip is None:
         raise xenrt.XRTFailure("IPv4 not found on freshly installed guest")
     else:
         if re.match('\d+\.\d+.\d+\.\d+', ip):
             log("IPv4 address of the guest: %s" % ip)
         else:
             raise xenrt.XRTFailure("Unexpected IP format: '%s'" % ip)
         
     # disable IPv4
     guest.disableIPv4()
     mac, ip, network = guest.getVIFs()["eth0"]
     if ip:
         raise xenrt.XRTFailure("IPv4 address still seems to exist on the guest: %s" % ip)
     return guest