コード例 #1
0
    def run(self, arglist=None):
        # Send yngwie to host
        sftp = self.host.sftpClient()
        sftp.copyTo("/home/xenrtd/felipef/yngwie", "/root/yngwie")

	# Initialize devpaths as an empty list of device paths
        xenrt.TEC().progress("Commencing measurements...")
        devpaths = [ ]
        vm = [ ]

        # Choose a template for the desired distro
        self.template = xenrt.lib.xenserver.getTemplate(self.host, self.distro, arch=self.arch)

        for i in range(1, self.numofdevs+1):
            xenrt.TEC().progress("Installing VM %d" % i)

            # Create an empty guest object
            vm += [ self.host.guestFactory()("vm%02d" % i, self.template, self.host) ]
            #self.uninstallOnCleanup(guest)
            #self.getLogsFrom(guest)

            # Get the repository location
            r = xenrt.getLinuxRepo(self.distro, self.arch, self.method)
            self.repo = string.split(r)[0]

            # Install from network repository into the VM
            vm[i].arch = self.arch
            vm[i].install(self.host,
                          pxe=False,
                          repository=self.repo,
                          distro=self.distro,
                          notools=False,
                          method=self.method,
                          isoname=xenrt.DEFAULT)
            vm[i].check()
コード例 #2
0
ファイル: upgrade.py プロジェクト: thomassa/xenrt
 def upgradeCommand(self):
     centOsurl = xenrt.getLinuxRepo("centos7", "x86-64", "HTTP")
     #import the centos key
     self.guest.execguest("rpm --import %s/RPM-GPG-KEY-CentOS-7" %
                          (centOsurl))
     return "redhat-upgrade-tool --network 7.0 --force --instrepo %s" % (
         centOsurl)
コード例 #3
0
ファイル: vminstall.py プロジェクト: thomassa/xenrt
    def prepare(self, arglist):
        (self.distro, self.arch) = xenrt.getDistroAndArch(self.tcsku)
        self.host = self.getDefaultHost()

        if self.METHOD == "CDROM":
            self.repository = "cdrom"
        else:
            r = xenrt.getLinuxRepo(self.distro, self.arch, self.METHOD)
            self.repository = string.split(r)[0]
コード例 #4
0
ファイル: upgrade.py プロジェクト: johnmdilley/xenrt
    def preconfigureGuest(self):

        newDistro = self.args['upgradeto']
        distroName = self.DISTRO_NAME_MAP[newDistro][0]
        self.releaseName = self.DISTRO_NAME_MAP[newDistro][1]
        distroUrl  = xenrt.getLinuxRepo(newDistro, self.guest.arch, "HTTP")
        sourceList = "/etc/apt/sources.list"

        self.configureSources(sourceList, distroUrl, distroName)

        self.guest.execguest("apt-get update")
        xenrt.TEC().comment("apt-get update completed")
        if self.args['upgradeto'] == "debian80":
            self.guest.execguest("apt-get -y --force-yes install libperl4-corelibs-perl")
コード例 #5
0
ファイル: upgrade.py プロジェクト: thomassa/xenrt
    def preconfigureGuest(self):

        newDistro = self.args['upgradeto']
        distroName = self.DISTRO_NAME_MAP[newDistro][0]
        self.releaseName = self.DISTRO_NAME_MAP[newDistro][1]
        distroUrl = xenrt.getLinuxRepo(newDistro, self.guest.arch, "HTTP")
        sourceList = "/etc/apt/sources.list"

        self.configureSources(sourceList, distroUrl, distroName)

        self.guest.execguest("apt-get update")
        xenrt.TEC().comment("apt-get update completed")
        if self.args['upgradeto'] == "debian80":
            self.guest.execguest(
                "apt-get -y --force-yes install libperl4-corelibs-perl")
コード例 #6
0
    def createlinuxhvm(self, host):
        xenrt.TEC().logverbose("creating Linux HVM guest...")

        linuxhvm = host.guestFactory()(\
            "linuxhvm", host.chooseTemplate("TEMPLATE_NAME_WINDOWS_XP"))
        linuxhvm.windows = False
        linuxhvm.setMemory(256)
        method = "HTTP"
        repository = xenrt.getLinuxRepo("rhel5", "x86-32", method)
        linuxhvm.install(host,
                         distro="rhel5",
                         repository=repository,
                         method=method,
                         pxe=True,
                         extrapackages=["dosfstools"],
                         sr=sruuid)
        linuxhvm.check()
        xenrt.TEC().registry.guestPut("linuxhvm", linuxhvm)

        ltmp = string.strip(linuxhvm.execguest("mktemp -d /tmp/XXXXXX"))
        lsftp = linuxhvm.sftpClient()
        lsftp.copyTo("%s/api/rhel5/ocaml-3.09.1-1.2.el5.rf.i386.rpm" %
                     (xenrt.TEC().getWorkdir()),
                     "%s/ocaml-3.09.1-1.2.el5.rf.i386.rpm" % (ltmp))
        linuxhvm.execguest("rpm --install "
                           "%s/ocaml-3.09.1-1.2.el5.rf.i386.rpm"
                           % (ltmp))
        for f in glob.glob(linuxagentsrc):
            lsftp.copyTo(f, "%s/%s" % (ltmp, os.path.basename(f)))
        if linuxagentmake:
            linuxhvm.execguest("make -C %s" % (ltmp))
            linuxhvm.execguest("cp %s/gtserver /root/gtserver" %
                               (ltmp))
        else:
            linuxhvm.execguest("cd %s; "
                               "ocamlc -o /root/gtserver unix.cma"
                               " gtmessages.ml gtcomms.ml "
                               " gtlinuxops.ml "
                               " gtserver_linux.ml" % (ltmp))
        linuxhvm.execguest("chmod 755 /root/gtserver")
        linuxhvm.execguest("echo 'exec /root/gtserver &' >> "
                           "/etc/rc.local")
        linuxhvm.execguest("/sbin/chkconfig iptables off || true")

        return linuxhvm
コード例 #7
0
ファイル: debian.py プロジェクト: johnmdilley/xenrt
 def generateIsoAnswerfile(self):
     preseedfile = "preseed-%s.cfg" % (self.parent._osParent_name)
     filename = "%s/%s" % (xenrt.TEC().getLogdir(), preseedfile)
     ps = DebianPreseedFile(self.distro,
                            xenrt.getLinuxRepo(self.distro, self.arch, "HTTP"),
                            filename,
                            arch=self.arch)
     ps.generate()
     installIP = self.getIP(trafficType="OUTBOUND", timeout=600)
     path = "%s/%s" % (xenrt.TEC().lookup("GUESTFILE_BASE_PATH"), installIP)
     self.cleanupdir = path
     try:
         os.makedirs(path)
     except:
         pass
     xenrt.rootops.sudo("chmod -R a+w %s" % path)
     xenrt.command("rm -f %s/preseed.stamp" % path)
     shutil.copyfile(filename, "%s/preseed" % (path))
コード例 #8
0
ファイル: debian.py プロジェクト: thomassa/xenrt
 def generateIsoAnswerfile(self):
     preseedfile = "preseed-%s.cfg" % (self.parent._osParent_name)
     filename = "%s/%s" % (xenrt.TEC().getLogdir(), preseedfile)
     ps = DebianPreseedFile(self.distro,
                            xenrt.getLinuxRepo(self.distro, self.arch,
                                               "HTTP"),
                            filename,
                            arch=self.arch)
     ps.generate()
     installIP = self.getIP(trafficType="OUTBOUND", timeout=600)
     path = "%s/%s" % (xenrt.TEC().lookup("GUESTFILE_BASE_PATH"), installIP)
     self.cleanupdir = path
     try:
         os.makedirs(path)
     except:
         pass
     xenrt.rootops.sudo("chmod -R a+w %s" % path)
     xenrt.command("rm -f %s/preseed.stamp" % path)
     shutil.copyfile(filename, "%s/preseed" % (path))
コード例 #9
0
ファイル: tc_hvmlinuxworkload.py プロジェクト: thomassa/xenrt
    def createlinuxhvm(self, host):
        xenrt.TEC().logverbose("creating Linux HVM guest...")

        linuxhvm = host.guestFactory()(\
            "linuxhvm", host.chooseTemplate("TEMPLATE_NAME_WINDOWS_XP"))
        linuxhvm.windows = False
        linuxhvm.setMemory(256)
        method = "HTTP"
        repository = xenrt.getLinuxRepo("rhel5", "x86-32", method)
        linuxhvm.install(host,
                         distro="rhel5",
                         repository=repository,
                         method=method,
                         pxe=True,
                         extrapackages=["dosfstools"],
                         sr=sruuid)
        linuxhvm.check()
        xenrt.TEC().registry.guestPut("linuxhvm", linuxhvm)

        ltmp = string.strip(linuxhvm.execguest("mktemp -d /tmp/XXXXXX"))
        lsftp = linuxhvm.sftpClient()
        lsftp.copyTo(
            "%s/api/rhel5/ocaml-3.09.1-1.2.el5.rf.i386.rpm" %
            (xenrt.TEC().getWorkdir()),
            "%s/ocaml-3.09.1-1.2.el5.rf.i386.rpm" % (ltmp))
        linuxhvm.execguest("rpm --install "
                           "%s/ocaml-3.09.1-1.2.el5.rf.i386.rpm" % (ltmp))
        for f in glob.glob(linuxagentsrc):
            lsftp.copyTo(f, "%s/%s" % (ltmp, os.path.basename(f)))
        if linuxagentmake:
            linuxhvm.execguest("make -C %s" % (ltmp))
            linuxhvm.execguest("cp %s/gtserver /root/gtserver" % (ltmp))
        else:
            linuxhvm.execguest("cd %s; "
                               "ocamlc -o /root/gtserver unix.cma"
                               " gtmessages.ml gtcomms.ml "
                               " gtlinuxops.ml "
                               " gtserver_linux.ml" % (ltmp))
        linuxhvm.execguest("chmod 755 /root/gtserver")
        linuxhvm.execguest("echo 'exec /root/gtserver &' >> " "/etc/rc.local")
        linuxhvm.execguest("/sbin/chkconfig iptables off || true")

        return linuxhvm
コード例 #10
0
ファイル: __init__.py プロジェクト: johnmdilley/xenrt
 def ca6753(self):
     host = self.host
     g = None
     try:
         # Create an HVM guest
         repository = xenrt.getLinuxRepo("rhel5", "x86-32", "HTTP")
         template = host.chooseTemplate("TEMPLATE_NAME_UNSUPPORTED_HVM")
         g = host.guestFactory()(xenrt.randomGuestName(), template)
         self.guestsToClean.append(g)
         g.windows = False
         g.setVCPUs(1)
         g.setMemory(256)
         g.arch = "x86-32"
         g.install(host, repository=repository, distro="rhel5", 
                   method="HTTP", pxe=True)		
         if g.getState() == "DOWN":
             g.start()
     except xenrt.XRTFailure, e:
         # This is not a failure of the testcase
         raise xenrt.XRTError(e.reason)
コード例 #11
0
ファイル: unsupported.py プロジェクト: johnmdilley/xenrt
    def run(self, arglist):
        # Get a host to install on
        host = self.getDefaultHost()
        distro = host.lookup(self.DISTRO)
        arch = self.ARCH

        repository = xenrt.getLinuxRepo(distro, arch, "HTTP")

        # Choose a template
        template = host.chooseTemplate("TEMPLATE_NAME_UNSUPPORTED_HVM")

        # Create an empty guest object
        guest = host.guestFactory()(xenrt.randomGuestName(), template)
        self.uninstallOnCleanup(guest)
        self.getLogsFrom(guest)

        # Install from RPM repo into the VM
        guest.arch = arch
        guest.windows = False
        guest.setVCPUs(2)
        guest.setMemory(1024)
        guest.install(host,
                      repository=repository,
                      distro=distro,
                      method="HTTP",
                      pxe=True,
                      notools=True)
        guest.check()

        # Quick check of basic functionality
        guest.reboot()
        guest.pretendToHaveXenTools()
        guest.suspend()
        guest.resume()
        guest.check()
        guest.shutdown()
        guest.start()
        guest.check()

        # Shutdown the VM
        guest.shutdown()
コード例 #12
0
    def run(self, arglist):
        # Get a host to install on
        host = self.getDefaultHost()
        distro = host.lookup(self.DISTRO)
        arch = self.ARCH

        repository = xenrt.getLinuxRepo(distro, arch, "HTTP")

        # Choose a template
        template = host.chooseTemplate("TEMPLATE_NAME_UNSUPPORTED_HVM")

        # Create an empty guest object
        guest = host.guestFactory()(xenrt.randomGuestName(), template)
        self.uninstallOnCleanup(guest)
        self.getLogsFrom(guest)

        # Install from RPM repo into the VM
        guest.arch = arch
        guest.windows = False
        guest.setVCPUs(2)
        guest.setMemory(1024)
        guest.install(host,
                      repository=repository,
                      distro=distro,
                      method="HTTP",
                      pxe=True,
                      notools=True)
        guest.check()

        # Quick check of basic functionality
        guest.reboot()
        guest.pretendToHaveXenTools()
        guest.suspend()
        guest.resume()
        guest.check()
        guest.shutdown()
        guest.start()
        guest.check()

        # Shutdown the VM
        guest.shutdown()
コード例 #13
0
ファイル: __init__.py プロジェクト: thomassa/xenrt
 def ca6753(self):
     host = self.host
     g = None
     try:
         # Create an HVM guest
         repository = xenrt.getLinuxRepo("rhel5", "x86-32", "HTTP")
         template = host.chooseTemplate("TEMPLATE_NAME_UNSUPPORTED_HVM")
         g = host.guestFactory()(xenrt.randomGuestName(), template)
         self.guestsToClean.append(g)
         g.windows = False
         g.setVCPUs(1)
         g.setMemory(256)
         g.arch = "x86-32"
         g.install(host,
                   repository=repository,
                   distro="rhel5",
                   method="HTTP",
                   pxe=True)
         if g.getState() == "DOWN":
             g.start()
     except xenrt.XRTFailure, e:
         # This is not a failure of the testcase
         raise xenrt.XRTError(e.reason)
コード例 #14
0
    def run(self, arglist=None):
        machine = "RESOURCE_HOST_0"
        distro = "rhel5"
        arch = "x86-32"
        method = "HTTP"
        gname = None

        # First argument is the Windows guest to use to run the tests from
        # (ideally on a second host)
        for arg in arglist:
            l = string.split(arg, "=", 1)
            if l[0] == "guest":
                gname = l[1]
            elif l[0] == "config":
                matching = xenrt.TEC().registry.guestLookup(\
                            **xenrt.util.parseXMLConfigString(l[1]))
                for n in matching:
                    xenrt.TEC().comment("Found matching guest(s): %s" %
                                        (matching))
                if matching:
                    gname = matching[0]
        if not gname:
            raise xenrt.XRTError("You must specify a Windows guest")

        winGuest = xenrt.TEC().registry.guestGet(gname)
        if not winGuest:
            raise xenrt.XRTError("Cannot find guest %s" % (gname))

        self.winGuest = winGuest

        # Unpack the tarball
        self.workdir = winGuest.xmlrpcTempDir()
        winGuest.xmlrpcUnpackTarball(
            "%s/dvdstore.tgz" % (xenrt.TEC().lookup("TEST_TARBALL_BASE")),
            self.workdir)

        # Set up the template guest
        extrapackages = [
            "mysql", "mysql-server", "mysql-devel", "php", "php-mysql"
        ]
        repository = xenrt.getLinuxRepo(distro, arch, method)

        host = xenrt.TEC().registry.hostGet(machine)
        if not host:
            raise xenrt.XRTError("Unable to find host %s in registry" %
                                 (machine))
        self.getLogsFrom(host)

        # Find out how much memory we have available
        memFree = host.getFreeMemory()
        # Get the number of 256M guests we can create
        maxGuests = memFree / 256
        # We need to create at least two
        if maxGuests < 2:
            raise xenrt.XRTError("Need at least 512MB free memory on host, "
                                 "got %u" % (memFree))

        template = xenrt.lib.xenserver.getTemplate(host, distro, arch=arch)

        guestToClone = host.guestFactory()("dvdstoreMaster", template)
        g = guestToClone
        self.guestsToClean.append(g)
        g.windows = False
        g.arch = arch
        g.install(host,
                  repository=repository,
                  distro=distro,
                  method=method,
                  extrapackages=extrapackages)
        g.check()

        workdir = g.execguest("mktemp -d /tmp/workXXXXXX").strip()

        # Unpack tarball
        g.execguest("wget '%s/dvdstore.tgz' -O - | tar -zx -C %s" %
                    (xenrt.TEC().lookup("TEST_TARBALL_BASE"), workdir))

        # Set up MySQL etc on the guest

        # Disable SELinux
        g.execguest("grep -ve '^SELINUX=' /etc/selinux/config > "
                    "/etc/selinux/config2 && echo 'SELINUX=disabled' >> "
                    "/etc/selinux/config2 && mv /etc/selinux/config2 "
                    "/etc/selinux/config")
        g.execguest("echo 0 > /selinux/enforce")

        # Add a 20GB disk
        g.createDisk(sizebytes=21474836480)
        time.sleep(10)
        g.execguest("chown mysql:mysql /dev/xvdb")
        g.execguest(
            "echo \"chown mysql:mysql /dev/xvdb\" >> /etc/rc.d/rc.local")

        # Copy in our my.cnf file
        g.execguest("cp -f %s/dvdstore/my.cnf /etc/my.cnf" % (workdir))
        # Start MySQL
        g.execguest("/usr/bin/mysql_install_db")
        g.execguest("/etc/init.d/mysqld start", retval="code")

        # Wait for the log to show it's created the raw file (with 30m timeout)
        st = xenrt.util.timenow()
        deadline = st + (30 * 60)
        while True:
            if g.execguest("grep \"InnoDB: Started\" /var/log/mysqld.log",
                           retval="code") == 0:
                break
            if xenrt.util.timenow() > deadline:
                raise xenrt.XRTError(
                    "InnoDB did not initialise within timeout "
                    "period")
            time.sleep(20)

        # Stop MySQL
        g.execguest("/etc/init.d/mysqld stop")
        # Apply our my.cnf patch
        g.execguest("cd /etc && patch -p0 < %s/dvdstore/cnfpatch" % (workdir))
        # Start MySQL again
        g.execguest("/etc/init.d/mysqld start")
        # Set it to autostart (have to do it this way as otherwise our chown won't have
        # happened in time and it won't start...
        g.execguest("echo \"/etc/init.d/mysqld start\" >> /etc/rc.d/rc.local")

        # Set up dvdstore (this takes a while!)
        g.execguest("cd %s/dvdstore && ./setup.sh" % (workdir), timeout=7200)

        # Set up the web bits
        g.execguest("mkdir /var/www/html/ds2 && cp "
                    "%s/dvdstore/ds2/mysqlds2/web/php5/* /var/www/html/ds2/" %
                    (workdir))
        g.execguest("/etc/init.d/httpd start")
        g.execguest("chkconfig --add httpd && chkconfig --level 345 httpd on")
        g.execguest("echo \"GRANT ALL ON DS2.* TO apache@localhost\" | mysql")

        # Disable iptables
        g.execguest("chkconfig --del iptables")

        # Prepare the VM for cloning, and shut it down
        g.preCloneTailor()
        g.shutdown()

        # Start with 2 clones, run the tests and get an OPM value
        guests = []
        guests.append(g.cloneVM())
        guests.append(g.cloneVM())

        for g in guests:
            self.guestsToClean.append(g)
            g.start()
        time.sleep(30)

        opm = self.runTest(guests)
        xenrt.TEC().comment("2 guests gives OPM value %u" % (opm))

        # Now keep adding clones until the OPM value is lower than previous one
        # Or we run out of resources
        guestCount = 2
        lastopm = opm
        while guestCount < maxGuests:
            numGuests = len(guests)
            g = guestToClone.cloneVM()
            g.start()
            self.guestsToClean.append(g)
            guests.append(g)
            time.sleep(30)
            opm = self.runTest(guests)
            xenrt.TEC().comment("%u guests gives OPM value %u" %
                                (len(guests), opm))
            if opm < lastopm:
                break

            lastopm = opm
            guestCount += 1

        if guestCount == maxGuests and opm >= lastopm:
            xenrt.TEC().warning("Could not create more guests due to lack of "
                                "memory.")

        # Return as results the maximum OPM and the number of clones used for it
        xenrt.TEC().value("MaxOPM", lastopm)
        xenrt.TEC().value("GuestCount", numGuests)
コード例 #15
0
ファイル: upgrade.py プロジェクト: johnmdilley/xenrt
 def upgradeCommand(self):
     oel7Url = xenrt.getLinuxRepo("oel7","x86-64", "HTTP")
     return "redhat-upgrade-tool --network 7.0 --force --instrepo %s" %(oel7Url)
コード例 #16
0
ファイル: upgrade.py プロジェクト: johnmdilley/xenrt
 def upgradeCommand(self):
     centOsurl = xenrt.getLinuxRepo("centos7","x86-64", "HTTP")
     #import the centos key
     self.guest.execguest("rpm --import %s/RPM-GPG-KEY-CentOS-7" %(centOsurl))
     return "redhat-upgrade-tool --network 7.0 --force --instrepo %s" %(centOsurl)
コード例 #17
0
def createVM(host,
             guestname,
             distro,
             vcpus=None,
             corespersocket=None,
             memory=None,
             vifs=[],
             bridge=None,
             sr=None,
             guestparams=[],
             arch="x86-32",
             disks=[],
             postinstall=[],
             pxe=True,
             template=None,
             notools=False,
             bootparams=None,
             use_ipv6=False,
             suffix=None,
             ips={},
             **kwargs):

    if not isinstance(host, xenrt.GenericHost):
        host = xenrt.TEC().registry.hostGet(host)

    if distro.startswith("generic-"):
        distro = distro[8:]
        if not vifs:
            # Some tests rely on getting a VIF by default for generic VMs.
            vifs = xenrt.lib.hyperv.Guest.DEFAULT
    if distro.lower() == "windows" or distro.lower() == "linux":
        distro = host.lookup("GENERIC_" + distro.upper() + "_OS"
                             + (arch.endswith("64") and "_64" or ""),
                             distro)
    # Create the guest object.
    g = host.guestFactory()(guestname,
                            template,
                            password=xenrt.TEC().lookup("DEFAULT_PASSWORD"))
    g.arch = arch
    if re.search("[vw]", distro):
        g.windows = True
        g.vifstem = g.VIFSTEMHVM
        g.hasSSH = False
    else:
        g.windows = False
        g.vifstem = g.VIFSTEMPV
        g.hasSSH = True

    if vifs == xenrt.lib.hyperv.Guest.DEFAULT:
        vifs = [("0",
                 host.getPrimaryBridge(),
                 xenrt.randomMAC(),
                 None)]

    update = []
    for v in vifs:
        device, bridge, mac, ip = v
        device = "%s%s" % (g.vifstem, device)
        if not bridge:
            bridge = host.getPrimaryBridge()

        if not bridge:
            raise xenrt.XRTError("Failed to choose a bridge for createVM on "
                                 "host !%s" % (host.getName()))
        update.append([device, bridge, mac, ip])
    vifs = update

    # The install method doesn't do this for us.
    if vcpus:
        g.setVCPUs(vcpus)
    if memory:
        g.setMemory(memory)

    # TODO: boot params

    # Try and determine the repository.
    repository = xenrt.getLinuxRepo(distro, arch, "HTTP", None)

    # Work out the ISO name.
    if not repository:
        isoname = xenrt.DEFAULT
    else:
        isoname = None

    rootdisk = xenrt.lib.hyperv.Guest.DEFAULT
    for disk in disks:
        device, size, format = disk
        if device == "0":
            rootdisk = int(size)*xenrt.GIGA

    # Install the guest.
    g.install(host,
              distro=distro,
              vifs=vifs,
              bridge=bridge,
              sr=sr,
              guestparams=guestparams,
              isoname=isoname,
              rootdisk=rootdisk,
              repository=repository,
              pxe=pxe,
              notools=notools,
              use_ipv6=use_ipv6)

    if g.windows:
        g.xmlrpcShutdown()
    else:
        g.execguest("/sbin/shutdown -h now")
    g.poll("DOWN")

    diskstoformat = []
    for disk in disks:
        device, size, format = disk
        if str(device) != "0":
            d = g.createDisk(sizebytes=int(size)*xenrt.GIGA,userdevice=device)
            if format:
                diskstoformat.append(d)

    g.start()

    for d in diskstoformat:
        if g.windows:
            letter = g.xmlrpcPartition(d)
            g.xmlrpcFormat(letter, timeout=3600)
        else:
            # FIXME: this is probably wrong
            letter = g.DEVICE_DISK_PREFIX + chr(int(d)+ord('a'))
            g.execguest("mkfs.ext2 /dev/%s" % (letter))
            g.execguest("mount /dev/%s /mnt" % (letter))

    # Store the object in the registry.
    xenrt.TEC().registry.guestPut(guestname, g)
    xenrt.TEC().registry.configPut(guestname, vcpus=vcpus,
                                   memory=memory,
                                   distro=distro)

    for p in postinstall:
        if type(p) == tuple:
            data, format = p
            if format == "cmd":
                g.xmlrpcWriteFile("c:\\postrun.cmd", data)
                g.xmlrpcExec("c:\\postrun.cmd")
                g.xmlrpcRemoveFile("c:\\postrun.cmd")
            elif format == "vbs":
                g.xmlrpcWriteFile("c:\\postrun.vbs", data)
                g.xmlrpcExec("cscript //b //NoLogo c:\\postrun.vbs")
                g.xmlrpcRemoveFile("c:\\postrun.vbs")
        else:
            eval("g.%s()" % (p))

    return g
コード例 #18
0
ファイル: rhel.py プロジェクト: thomassa/xenrt
 def installURL(self):
     return xenrt.getLinuxRepo(self.distro, self.arch, "HTTP", None)
コード例 #19
0
ファイル: stress.py プロジェクト: johnmdilley/xenrt
    def run(self,arglist=None):
        machine = "RESOURCE_HOST_0"
        distro = "rhel5"
        arch = "x86-32"
        method = "HTTP"
        gname = None

        # First argument is the Windows guest to use to run the tests from
        # (ideally on a second host)
        for arg in arglist:
            l = string.split(arg, "=", 1)
            if l[0] == "guest":
                gname = l[1]
            elif l[0] == "config":
                matching = xenrt.TEC().registry.guestLookup(\
                            **xenrt.util.parseXMLConfigString(l[1]))
                for n in matching:
                    xenrt.TEC().comment("Found matching guest(s): %s" % (matching))
                if matching:
                    gname = matching[0]
        if not gname:
            raise xenrt.XRTError("You must specify a Windows guest")

        winGuest = xenrt.TEC().registry.guestGet(gname)
        if not winGuest:
            raise xenrt.XRTError("Cannot find guest %s" % (gname))

        self.winGuest = winGuest

        # Unpack the tarball
        self.workdir = winGuest.xmlrpcTempDir()
        winGuest.xmlrpcUnpackTarball("%s/dvdstore.tgz" % 
                                     (xenrt.TEC().lookup("TEST_TARBALL_BASE")),
                                     self.workdir)

        # Set up the template guest
        extrapackages = ["mysql","mysql-server","mysql-devel","php","php-mysql"]
        repository = xenrt.getLinuxRepo(distro, arch, method)

        host = xenrt.TEC().registry.hostGet(machine)
        if not host:
            raise xenrt.XRTError("Unable to find host %s in registry" %
                                 (machine))
        self.getLogsFrom(host)

        # Find out how much memory we have available
        memFree = host.getFreeMemory()
        # Get the number of 256M guests we can create
        maxGuests = memFree / 256
        # We need to create at least two
        if maxGuests < 2:
            raise xenrt.XRTError("Need at least 512MB free memory on host, "
                                 "got %u" % (memFree))

        template = xenrt.lib.xenserver.getTemplate(host,distro,arch=arch)

        guestToClone = host.guestFactory()("dvdstoreMaster", template)
        g = guestToClone
        self.guestsToClean.append(g)
        g.windows = False
        g.arch = arch
        g.install(host, repository=repository, distro=distro, method=method, 
                  extrapackages=extrapackages)
        g.check()

        workdir = g.execguest("mktemp -d /tmp/workXXXXXX").strip()

        # Unpack tarball
        g.execguest("wget '%s/dvdstore.tgz' -O - | tar -zx -C %s" %
                    (xenrt.TEC().lookup("TEST_TARBALL_BASE"),
                    workdir))

        # Set up MySQL etc on the guest

        # Disable SELinux
        g.execguest("grep -ve '^SELINUX=' /etc/selinux/config > "
                    "/etc/selinux/config2 && echo 'SELINUX=disabled' >> "
                    "/etc/selinux/config2 && mv /etc/selinux/config2 "
                    "/etc/selinux/config")
        g.execguest("echo 0 > /selinux/enforce")

        # Add a 20GB disk
        g.createDisk(sizebytes=21474836480)
        time.sleep(10)
        g.execguest("chown mysql:mysql /dev/xvdb")
        g.execguest("echo \"chown mysql:mysql /dev/xvdb\" >> /etc/rc.d/rc.local")
        
        # Copy in our my.cnf file
        g.execguest("cp -f %s/dvdstore/my.cnf /etc/my.cnf" % (workdir))
        # Start MySQL
        g.execguest("/usr/bin/mysql_install_db")
        g.execguest("/etc/init.d/mysqld start",retval="code")

        # Wait for the log to show it's created the raw file (with 30m timeout)
        st = xenrt.util.timenow()
        deadline = st + (30 * 60)
        while True:
            if g.execguest("grep \"InnoDB: Started\" /var/log/mysqld.log",
                           retval="code") == 0:
                break
            if xenrt.util.timenow() > deadline:
                raise xenrt.XRTError("InnoDB did not initialise within timeout "
                                     "period")
            time.sleep(20)

        # Stop MySQL
        g.execguest("/etc/init.d/mysqld stop")
        # Apply our my.cnf patch
        g.execguest("cd /etc && patch -p0 < %s/dvdstore/cnfpatch" % (workdir))
        # Start MySQL again
        g.execguest("/etc/init.d/mysqld start")
        # Set it to autostart (have to do it this way as otherwise our chown won't have
        # happened in time and it won't start...
        g.execguest("echo \"/etc/init.d/mysqld start\" >> /etc/rc.d/rc.local")

        # Set up dvdstore (this takes a while!)
        g.execguest("cd %s/dvdstore && ./setup.sh" % (workdir),timeout=7200)

        # Set up the web bits
        g.execguest("mkdir /var/www/html/ds2 && cp "
                    "%s/dvdstore/ds2/mysqlds2/web/php5/* /var/www/html/ds2/" % 
                    (workdir))
        g.execguest("/etc/init.d/httpd start")
        g.execguest("chkconfig --add httpd && chkconfig --level 345 httpd on")
        g.execguest("echo \"GRANT ALL ON DS2.* TO apache@localhost\" | mysql")

        # Disable iptables
        g.execguest("chkconfig --del iptables")

        # Prepare the VM for cloning, and shut it down
        g.preCloneTailor()
        g.shutdown()

        # Start with 2 clones, run the tests and get an OPM value
        guests = []
        guests.append(g.cloneVM())
        guests.append(g.cloneVM())

        for g in guests:
            self.guestsToClean.append(g)
            g.start()
        time.sleep(30)

        opm = self.runTest(guests)
        xenrt.TEC().comment("2 guests gives OPM value %u" % (opm))

        # Now keep adding clones until the OPM value is lower than previous one
        # Or we run out of resources
        guestCount = 2
        lastopm = opm
        while guestCount < maxGuests:
            numGuests = len(guests)
            g = guestToClone.cloneVM()
            g.start()
            self.guestsToClean.append(g)
            guests.append(g)
            time.sleep(30)
            opm = self.runTest(guests)
            xenrt.TEC().comment("%u guests gives OPM value %u" % (len(guests),
                                                                  opm))
            if opm < lastopm:
                break

            lastopm = opm
            guestCount += 1

        if guestCount == maxGuests and opm >= lastopm:
            xenrt.TEC().warning("Could not create more guests due to lack of "
                                "memory.")

        # Return as results the maximum OPM and the number of clones used for it
        xenrt.TEC().value("MaxOPM",lastopm)
        xenrt.TEC().value("GuestCount",numGuests)
コード例 #20
0
ファイル: upgrade.py プロジェクト: thomassa/xenrt
 def upgradeCommand(self):
     oel7Url = xenrt.getLinuxRepo("oel7", "x86-64", "HTTP")
     return "redhat-upgrade-tool --network 7.0 --force --instrepo %s" % (
         oel7Url)
コード例 #21
0
ファイル: rhel.py プロジェクト: johnmdilley/xenrt
 def installURL(self):
     return xenrt.getLinuxRepo(self.distro, self.arch, "HTTP", None)