Exemplo n.º 1
0
    def prepare(self, arglist):

        self.host = self.getDefaultHost()
        self.vm1 = self.host.createGenericLinuxGuest(name=xenrt.randomGuestName())
        self.uninstallOnCleanup(self.vm1)
        self.vm2 = self.host.createGenericLinuxGuest(name=xenrt.randomGuestName())
        self.uninstallOnCleanup(self.vm2)
Exemplo n.º 2
0
    def createGuest(self,
                    host,
                    distro=None,
                    arch=None,
                    srtype=None,
                    disksize=None):
        """Create a guest to be exported, return the guest object"""
        sr = None
        if srtype:
            srs = host.getSRs(type=srtype)
            if not srs:
                raise xenrt.XRTError("No %s SR found on host." % (srtype))
            sr = srs[0]
        if not distro:
            if disksize:
                raise xenrt.XRTError("TC does not support override of "
                                     "disk size for default distro")
            guest = host.createGenericLinuxGuest(arch=arch, sr=sr)
            self.getLogsFrom(guest)
            guest.preCloneTailor()
            return guest
        elif distro in ["debian", "sarge", "etch"]:
            if disksize:
                raise xenrt.XRTError("TC does not support override of "
                                     "disk size for legacy Debian VMs")
            guest = host.guestFactory()(
                xenrt.randomGuestName(),
                host.getTemplate(distro),
                password=xenrt.TEC().lookup("ROOT_PASSWORD_DEBIAN"))
            self.getLogsFrom(guest)
            guest.install(host, distro=distro, sr=sr)
            guest.check()
            return guest
        else:
            if not arch:
                if re.search(r"64$", distro):
                    arch = "x86-64"
                else:
                    arch = "x86-32"
            disks = []
            if disksize:
                disks.append(("0", disksize, False))
            guest = xenrt.lib.xenserver.guest.createVM(
                host,
                xenrt.randomGuestName(),
                distro,
                arch=arch,
                sr=sr,
                vifs=[("0", host.getPrimaryBridge(), xenrt.randomMAC(), None)],
                disks=disks)
            self.getLogsFrom(guest)
            if guest.windows:
                guest.installDrivers()

            return guest
Exemplo n.º 3
0
    def createGuest(self, host, distro=None, arch=None, srtype=None, disksize=None):
        """Create a guest to be exported, return the guest object"""
        sr = None
        if srtype:
            srs = host.getSRs(type=srtype)
            if not srs:
                raise xenrt.XRTError("No %s SR found on host." % (srtype))
            sr = srs[0]
        if not distro:
            if disksize:
                raise xenrt.XRTError("TC does not support override of "
                                     "disk size for default distro")
            guest = host.createGenericLinuxGuest(arch=arch, sr=sr)
            self.getLogsFrom(guest)
            guest.preCloneTailor()
            return guest
        elif distro in ["debian","sarge","etch"]:            
            if disksize:
                raise xenrt.XRTError("TC does not support override of "
                                     "disk size for legacy Debian VMs")
            guest = host.guestFactory()(xenrt.randomGuestName(),
                                        host.getTemplate(distro),
                                        password=xenrt.TEC().lookup("ROOT_PASSWORD_DEBIAN"))
            self.getLogsFrom(guest)
            guest.install(host, distro=distro, sr=sr)
            guest.check()
            return guest
        else:
            if not arch:
                if re.search(r"64$", distro):
                    arch = "x86-64"
                else:
                    arch = "x86-32"
            disks = []
            if disksize:
                disks.append(("0", disksize, False))
            guest = xenrt.lib.xenserver.guest.createVM(host,
                                                       xenrt.randomGuestName(),
                                                       distro,
                                                       arch=arch,
                                                       sr=sr,
                                                       vifs=[("0",
                                                        host.getPrimaryBridge(),
                                                        xenrt.randomMAC(),
                                                        None)],
                                                       disks=disks)
            self.getLogsFrom(guest)
            if guest.windows:
                guest.installDrivers()

            return guest
Exemplo n.º 4
0
    def createGenericLinuxGuest(self,
                                name=None,
                                arch=None,
                                start=True,
                                sr=None,
                                bridge=None,
                                vcpus=None,
                                memory=512,
                                allowUpdateKernel=True,
                                disksize=None,
                                use_ipv6=False):
        """Installs a generic Linux VM for non-OS-specific tests."""

        if not name:
            name = xenrt.randomGuestName()

        t = xenrt.lib.libvirt.createVM(self,
                                       name,
                                       "rhel62",
                                       vifs=xenrt.lib.libvirt.Guest.DEFAULT,
                                       vcpus=vcpus,
                                       memory=memory)

        if start and t.getState() == "DOWN":
            t.start()
        return t
Exemplo n.º 5
0
 def _snapDelete(self, memorySnapshot=False):
     snapName = xenrt.randomGuestName()
     self.instance.createSnapshot(snapName, memory=memorySnapshot)
     self.instance.deleteSnapshot(snapName)
     # Revert to base snapshot to prevent snapshot chain getting too long
     self._snapshotRevert("%s-base" % self.instance.name,
                          memorySnapshot=False)
Exemplo n.º 6
0
    def prepare(self, arglist):
        self.vmuuid = None
        self.host = self.getDefaultHost()
        cli = self.host.getCLIInstance()
        self.sruuid = self.host.getLocalSR()
        vdiuuid = cli.execute(
            "vdi-create", "sr-uuid=%s name-label=NullVDI type=user "
            "virtual-size=4GiB" % (self.sruuid)).strip()
        self.vmuuid = cli.execute(
            "vm-install", "new-name-label=%s "
            "template=\"Other install media\"" %
            (xenrt.randomGuestName())).strip()
        device = cli.execute(
            "vm-param-get", "uuid=%s param-name=allowed-VBD-devices" %
            (self.vmuuid)).split("; ")[0]
        vbd = cli.execute(
            "vbd-create", "vm-uuid=%s device=%s vdi-uuid=%s bootable=true "
            "type=Disk mode=RW unpluggable=True" %
            (self.vmuuid, device, vdiuuid))

        rebootscript = """#!/bin/bash
for (( i=0;i<%u;i++ )); do
    time xe vm-reboot uuid=%s --force
done
""" % (self.SAMPLES_PER_DATAPOINT, self.vmuuid)
        fn = xenrt.TEC().tempFile()
        f = file(fn, "w")
        f.write(rebootscript)
        f.close()
        sftp = self.host.sftpClient()
        try:
            sftp.copyTo(fn, "/root/rebooter.sh")
        finally:
            sftp.close()
Exemplo n.º 7
0
    def prepare(self, arglist=None):
        _TCXSA.prepare(self, arglist)
        self.name = xenrt.randomGuestName()

        self.downloadKernel()

        if isinstance(self.host, xenrt.lib.xenserver.ClearwaterHost):
            self.host.execdom0("echo '%s' > /root/minios.cfg" % self.getCfg())
            return

        # hack the DLVM script so that it uses mini-os for its kernel
        if isinstance(self.host, xenrt.lib.xenserver.TampaHost):
            insert = 'run("cp \/root\/mini-os-xsa.gz %s\/boot\/%s" % (mountpoint, "xenu-linux-2.6.18.8.xs6.1.0.16.450"))'
        elif isinstance(self.host, xenrt.lib.xenserver.BostonHost
                        ) and self.host.productVersion == "Sanibel":
            insert = 'run("cp \/root\/mini-os-xsa.gz %s\/boot\/%s" % (mountpoint, "xenu-linux-2.6.18.8.xs6.0.2.16.450"))'
        elif isinstance(self.host, xenrt.lib.xenserver.BostonHost):
            insert = 'run("cp \/root\/mini-os-xsa.gz %s\/boot\/%s" % (mountpoint, "xenu-linux-2.6.18.8.xs6.0.0.16.450"))'
        elif isinstance(self.host, xenrt.lib.xenserver.MNRHost) and (
                self.host.productVersion == "Cowley"
                or self.host.productVersion == "Oxford"):
            insert = 'run("cp \/root\/mini-os-xsa.gz %s\/boot\/%s" % (mountpoint, "xenu-linux-2.6.18.8.xs5.6.100.16.450"))'
        elif isinstance(self.host, xenrt.lib.xenserver.MNRHost):
            insert = 'run("cp \/root\/mini-os-xsa.gz %s\/boot\/%s" % (mountpoint, "xenu-linux-2.6.18.8.xs5.6.0.15.449"))'
        elif isinstance(self.host, xenrt.lib.xenserver.Host
                        ) and self.host.productVersion == "George":
            insert = 'run("cp \/root\/mini-os-xsa.gz %s\/boot\/%s" % (mountpoint, "xenu-linux-2.6.18.8.xs5.5.0.13.442"))'
        elif isinstance(self.host, xenrt.lib.xenserver.Host):
            insert = 'run("cp \/root\/mini-os-xsa.gz %s\/boot\/%s" % (mountpoint, "xenu-linux-2.6.18.8.xs5.0.0.10.439"))'

        self.host.execdom0(
            "sed -i '/root.tar.bz2/ s/$/; %s/' /opt/xensource/packages/post-install-scripts/debian-etch"
            % insert)
        self.host.execdom0(
            "cat /opt/xensource/packages/post-install-scripts/debian-etch")
Exemplo n.º 8
0
    def installOS(self):

        disks = []
        if self.ROOTDISK:
            disks = [("0", self.ROOTDISK, False)]

        self.guestName = xenrt.randomGuestName(self.distro, self.arch)
        self.guest = xenrt.lib.xenserver.guest.createVM(
            self.host,
            self.guestName,
            self.distro,
            vcpus=self.vcpus,
            corespersocket=self.cps,
            memory=self.memory,
            arch=self.arch,
            vifs=xenrt.lib.xenserver.Guest.DEFAULT,
            template=self.template,
            notools=self.distro.startswith("solaris"),
            disks=disks)

        self.getLogsFrom(self.guest)
        self.guest.check()

        # Check the in-guest memory matches what we expect
        self.checkGuestMemory(self.memory)
Exemplo n.º 9
0
 def _snapRevert(self, memorySnapshot=False):
     snapName = xenrt.randomGuestName()
     self.instance.createSnapshot(snapName, memory=memorySnapshot)
     self._snapshotRevert(snapName, memorySnapshot)
     self.instance.deleteSnapshot(snapName)
     # Revert to base snapshot to prevent snapshot chain getting too long
     self._snapshotRevert("%s-base" % self.instance.name, memorySnapshot=False)
Exemplo n.º 10
0
 def prepare(self, arglist=None):
     _TCXSA.prepare(self, arglist)
     self.name = xenrt.randomGuestName()
     
     self.downloadKernel()
     
     if isinstance(self.host, xenrt.lib.xenserver.ClearwaterHost):
         self.host.execdom0("echo '%s' > /root/minios.cfg" % self.getCfg())
         return
     
     # hack the DLVM script so that it uses mini-os for its kernel
     if isinstance(self.host, xenrt.lib.xenserver.TampaHost):
         insert = 'run("cp \/root\/mini-os-xsa.gz %s\/boot\/%s" % (mountpoint, "xenu-linux-2.6.18.8.xs6.1.0.16.450"))'
     elif isinstance(self.host, xenrt.lib.xenserver.BostonHost) and self.host.productVersion == "Sanibel":
         insert = 'run("cp \/root\/mini-os-xsa.gz %s\/boot\/%s" % (mountpoint, "xenu-linux-2.6.18.8.xs6.0.2.16.450"))'
     elif isinstance(self.host, xenrt.lib.xenserver.BostonHost):
         insert = 'run("cp \/root\/mini-os-xsa.gz %s\/boot\/%s" % (mountpoint, "xenu-linux-2.6.18.8.xs6.0.0.16.450"))'
     elif isinstance(self.host, xenrt.lib.xenserver.MNRHost) and (self.host.productVersion == "Cowley" or self.host.productVersion == "Oxford"):
         insert = 'run("cp \/root\/mini-os-xsa.gz %s\/boot\/%s" % (mountpoint, "xenu-linux-2.6.18.8.xs5.6.100.16.450"))'
     elif isinstance(self.host, xenrt.lib.xenserver.MNRHost):
         insert = 'run("cp \/root\/mini-os-xsa.gz %s\/boot\/%s" % (mountpoint, "xenu-linux-2.6.18.8.xs5.6.0.15.449"))'
     elif isinstance(self.host, xenrt.lib.xenserver.Host) and self.host.productVersion == "George":
         insert = 'run("cp \/root\/mini-os-xsa.gz %s\/boot\/%s" % (mountpoint, "xenu-linux-2.6.18.8.xs5.5.0.13.442"))'
     elif isinstance(self.host, xenrt.lib.xenserver.Host):
         insert = 'run("cp \/root\/mini-os-xsa.gz %s\/boot\/%s" % (mountpoint, "xenu-linux-2.6.18.8.xs5.0.0.10.439"))'
     
     self.host.execdom0("sed -i '/root.tar.bz2/ s/$/; %s/' /opt/xensource/packages/post-install-scripts/debian-etch" % insert)
     self.host.execdom0("cat /opt/xensource/packages/post-install-scripts/debian-etch")
Exemplo n.º 11
0
    def createWindowsVM(self, host, distro="win7-x64", memory=4000, arch="x86-64", disksize=28843545600, srtype="DEFAULT", waitForStart=False):
        """Trigger a windows install without having to wait for it to install completely"""
        if not waitForStart:
            template = xenrt.lib.xenserver.getTemplate(host, distro=distro, arch=arch)
            xenrt.TEC().logverbose("Setup for %s" % (distro))
            guest=host.createGenericEmptyGuest(memory=memory, name=xenrt.randomGuestName())
            device=guest.createDisk(sizebytes=disksize, bootable=True, sruuid=srtype)
            guest.changeCD(distro + ".iso")
            guest.start()
            # Allow some time for the vm to start
            xenrt.sleep(20)
        else:
            device=0
            disksize=disksize/xenrt.MEGA
            guest=host.createGenericWindowsGuest(sr=srtype, distro=distro,disksize=disksize,memory=memory)

        if self.INTELLICACHE:
            cli=host.getCLIInstance()
            if guest.getState() != "DOWN":
                guest.shutdown(force=True)
            vbd=cli.execute("vbd-list", "userdevice=%s vm-uuid=%s --minimal" % 
                            (device, guest.uuid)).strip()
            vdi=cli.execute("vdi-list","vbd-uuids=%s --minimal" % vbd).strip()
            cli.execute("vdi-param-set","allow-caching=true uuid=%s" % vdi)
            guest.start()
Exemplo n.º 12
0
    def run(self, arglist=None):
        sdkzip = xenrt.TEC().getFile("xe-phase-2/sdk.zip", "sdk.zip")
        if not sdkzip:
            raise xenrt.XRTError("Couldn't find xe-phase-2/sdk.zip")
        nfs = xenrt.NFSDirectory()
        xenrt.command("unzip %s -d %s" % (sdkzip, nfs.path()))
        
        self.guest = self.host.guestFactory()(\
                        xenrt.randomGuestName(),
                        host=self.host,
                        password=xenrt.TEC().lookup("ROOT_PASSWORD_SDK"))
        self.guest.importVM(self.host, "%s/sdk" % (nfs.path()))
        self.guest.paramSet("is-a-template", "true")
        nfs.remove()

        nfs = xenrt.NFSDirectory()
        xenrt.getTestTarball("apiperf", extract=True, directory=nfs.path())
        self.host.createISOSR(nfs.getMountURL("apiperf"))
        self.sr = self.host.parseListForUUID("sr-list",
                                             "name-label",
                                             "Remote ISO Library on: %s" %
                                             (nfs.getMountURL("apiperf")))
        for s in self.host.getSRs(type="iso", local=True):
            self.host.getCLIInstance().execute("sr-scan", "uuid=%s" %(s))
        time.sleep(30)
    
        self.runSubcase("test", "pool0", "Pool", "Pool0")
        self.runSubcase("test", "pool1", "Pool", "Pool1")
        self.runSubcase("test", "xendesktop", "XenDesktop", "XenDesktop")
Exemplo n.º 13
0
    def prepare(self, arglist):
        self.vmuuid = None
        self.host = self.getDefaultHost()
        cli = self.host.getCLIInstance()
        self.sruuid = self.host.getLocalSR()
        vdiuuid = cli.execute("vdi-create",
                              "sr-uuid=%s name-label=NullVDI type=user "
                              "virtual-size=4GiB" % (self.sruuid)).strip()
        self.vmuuid = cli.execute("vm-install",
                                  "new-name-label=%s "
                                  "template=\"Other install media\"" %
                                  (xenrt.randomGuestName())).strip()
        device = cli.execute("vm-param-get",
                             "uuid=%s param-name=allowed-VBD-devices" %
                             (self.vmuuid)).split("; ")[0]
        vbd = cli.execute("vbd-create",
                          "vm-uuid=%s device=%s vdi-uuid=%s bootable=true "
                          "type=Disk mode=RW unpluggable=True" %
                          (self.vmuuid, device, vdiuuid))

        rebootscript = """#!/bin/bash
for (( i=0;i<%u;i++ )); do
    time xe vm-reboot uuid=%s --force
done
""" % (self.SAMPLES_PER_DATAPOINT, self.vmuuid)
        fn = xenrt.TEC().tempFile()
        f = file(fn, "w")
        f.write(rebootscript)
        f.close()
        sftp = self.host.sftpClient()
        try:
            sftp.copyTo(fn, "/root/rebooter.sh")
        finally:
            sftp.close()
Exemplo n.º 14
0
    def do_XSVERSIONS(self, value, coord):
        print "DEBUG: XSVERSIONS value=[%s]" % value
        # 1. reinstall pool with $new_value version of xenserver
        # for each h in self.hosts: self.pool.install_host(...)
        for g in self.guests:
            try:
                self.guests[g].shutdown(force=True)
            except:
                pass
            self.guests[g].uninstall()
        self.guests.clear()

        # 2. reinstall guests in the pool
        # self.guests.append( self.pool.install_guest(...) )

        pool = self.tc.getDefaultPool()
        host = self.tc.getDefaultHost()
        cli = host.getCLIInstance()
        defaultSR = pool.master.lookupDefaultSR()

        xenrt.TEC().logverbose("Installing VM for experiment...")
        vm_name="VM-%s" % xenrt.randomGuestName()
        vm_template = "Windows XP SP3 (32-bit)"
        #templates = host.getTemplate("debian")
        #args=[]
        #args.append("new-name-label=%s" % (vm_name))
        #args.append("sr-uuid=%s" % defaultSR)
        #args.append("template-name=%s" % (vm_template))
        #vm_uuid = cli.execute("vm-install",string.join(args),timeout=3600).strip()
        #template = xenrt.lib.xenserver.getTemplate(self, "other")
        g0 = host.guestFactory()(vm_name, vm_template, host=host)
        g0.createGuestFromTemplate(vm_template, defaultSR)
        for i in self.getDimensions()['VMS']:
            g = g0.cloneVM() #name=("%s-%i" % (vm_name,i)))
            self.guests[i] = g
Exemplo n.º 15
0
    def run(self, arglist=None):
        sdkzip = xenrt.TEC().getFile("xe-phase-2/sdk.zip", "sdk.zip")
        if not sdkzip:
            raise xenrt.XRTError("Couldn't find xe-phase-2/sdk.zip")
        nfs = xenrt.NFSDirectory()
        xenrt.command("unzip %s -d %s" % (sdkzip, nfs.path()))

        self.guest = self.host.guestFactory()(\
                        xenrt.randomGuestName(),
                        host=self.host,
                        password=xenrt.TEC().lookup("ROOT_PASSWORD_SDK"))
        self.guest.importVM(self.host, "%s/sdk" % (nfs.path()))
        self.guest.paramSet("is-a-template", "true")
        nfs.remove()

        nfs = xenrt.NFSDirectory()
        xenrt.getTestTarball("apiperf", extract=True, directory=nfs.path())
        self.host.createISOSR(nfs.getMountURL("apiperf"))
        self.sr = self.host.parseListForUUID(
            "sr-list", "name-label",
            "Remote ISO Library on: %s" % (nfs.getMountURL("apiperf")))
        for s in self.host.getSRs(type="iso", local=True):
            self.host.getCLIInstance().execute("sr-scan", "uuid=%s" % (s))
        time.sleep(30)

        self.runSubcase("test", "pool0", "Pool", "Pool0")
        self.runSubcase("test", "pool1", "Pool", "Pool1")
        self.runSubcase("test", "xendesktop", "XenDesktop", "XenDesktop")
Exemplo n.º 16
0
 def create(self):
     apiargs = {
         "operation": "xenapi.subject.create",
         "parameters": [{
             "subject_identifier": xenrt.randomGuestName()
         }]
     }
     self.handle = self._apicall(apiargs)
Exemplo n.º 17
0
    def _multiSnapDelete(self, memorySnapshot=False):
        snapNames = [xenrt.randomGuestName() for x in range(self.snapCount)]
        for s in snapNames:
            self.instance.createSnapshot(s, memory=memorySnapshot)
        for s in snapNames:
            self.instance.deleteSnapshot(s)

        # Revert to base snapshot to prevent snapshot chain getting too long
        self._snapshotRevert("%s-base" % self.instance.name, memorySnapshot=False)
Exemplo n.º 18
0
    def cloneDelete(self):
        templateName = xenrt.randomGuestName()
        self.cloud.createTemplateFromInstance(self.instance, templateName)

        instance2 = self.cloud.createInstanceFromTemplate(templateName)
        instance2.destroy()
        templateid = [x.id for x in self.cloud.cloudApi.listTemplates(templatefilter="all", name=templateName) if x.name==templateName][0]

        self.cloud.cloudApi.deleteTemplate(id=templateid)
Exemplo n.º 19
0
 def prepare(self, arglist=None):
     # Obtain the pool object to retrieve its hosts.
     self.pool = self.getDefaultPool()
     if self.pool is None:
         self.host = self.getDefaultHost()
     else:
         self.host = self.pool.master
     self.vmname = xenrt.randomGuestName()
     self.command = ''
Exemplo n.º 20
0
 def createVPXOnHost(cls, host, vpxName=None, vpxHttpLocation=None):
     """Import a Netscaler VPX onto the specified host"""
     if not vpxName:
         vpxName = xenrt.randomGuestName()
     if not vpxHttpLocation:
         vpxHttpLocation = os.path.join(xenrt.TEC().lookup('EXPORT_DISTFILES_HTTP'), 'tallahassee/NSVPX-XEN-10.0-72.5_nc.xva')
     xenrt.TEC().logverbose('Importing VPX [%s] from: %s to host: %s' % (vpxName, vpxHttpLocation, host.getName()))
     xenrt.productLib(hostname=host.getName()).guest.createVMFromFile(host=host, guestname=vpxName, filename=vpxHttpLocation)
     return cls.setupNetScalerVpx(vpxName)
Exemplo n.º 21
0
 def prepare(self, arglist=None):
     # Obtain the pool object to retrieve its hosts.
     self.pool = self.getDefaultPool()
     if self.pool is None:
         self.host = self.getDefaultHost()
     else:
         self.host = self.pool.master
     self.vmname = xenrt.randomGuestName()
     self.command = ''
Exemplo n.º 22
0
 def createTestGuest(self, host):
     guest = host.templateVM.cloneVM(name=xenrt.randomGuestName())
     guest.setHost(host)
     host.execdom0('xe vif-create vm-uuid=%s network-uuid=%s device=1 mac=%s' % (guest.getUUID(), self.ipv6_net, xenrt.randomMAC()))
     guest.start()
     self.getLogsFrom(guest)
     guest.NICs = guest.getVIFs()
     self.guests.append(guest)
     return guest
Exemplo n.º 23
0
    def _multiSnapDelete(self, memorySnapshot=False):
        snapNames = [xenrt.randomGuestName() for x in range(self.snapCount)]
        for s in snapNames:
            self.instance.createSnapshot(s, memory=memorySnapshot)
        for s in snapNames:
            self.instance.deleteSnapshot(s)

        # Revert to base snapshot to prevent snapshot chain getting too long
        self._snapshotRevert("%s-base" % self.instance.name,
                             memorySnapshot=False)
Exemplo n.º 24
0
 def copy(self):
     xenrt.TEC().logverbose("Attempting to copy snapshot.")
     cli = self.host.getCLIInstance()
     command = ["vm-copy"]
     command.append("uuid=%s" % (self.snappoint))
     command.append("new-name-label=%s" % (xenrt.randomGuestName()))
     try: cli.execute(string.join(command))
     except xenrt.XRTFailure, e:
         xenrt.TEC().warning("Copy failed.")
         if not re.search("VM_IS_SNAPSHOT", e.data):
             raise xenrt.XRTFailure("Copy failed with unexpected error (%s)" % (str(e)))
Exemplo n.º 25
0
    def prepare(self, arglist):
        host = self.getDefaultHost()
        self.name = xenrt.randomGuestName()
        xenVersion = host.getInventoryItem('XEN_VERSION')
        xenrt.TEC().logverbose("Found XEN version: %s" % xenVersion)
        xenMapFile = host.execdom0("""find /boot/xen-%s* | grep '\.map' | grep -v '\-d'""" % xenVersion).strip()
        xenMapLine = host.execdom0('grep " nmi$" %s' % xenMapFile)
        xenrt.TEC().logverbose("Found NMI line from map file: %s" % (xenMapLine))
        self.nmiAddr = '0x' + xenMapLine.split()[0]

        TCXSA24.prepare(self, arglist)
Exemplo n.º 26
0
 def create(self):
     self.name = xenrt.randomGuestName()
     apiargs = {
         "operation":
         "xenapi.user.create",
         "parameters": [{
             "short_name": self.name[:4],
             "fullname": self.name,
             "other-config": {}
         }]
     }
     self.handle = self._apicall(apiargs)
Exemplo n.º 27
0
 def prepare(self, arglist):
     self.host = self.getDefaultHost()
     self.testmac = xenrt.randomMAC()
     self.testguest = self.host.guestFactory()(xenrt.randomGuestName())
     self.testguest.host = self.host
     self.testguest.createGuestFromTemplate("Other install media",
                                             self.host.getLocalSR())
     self.testguest.enablePXE()
     self.testguest.createVIF(mac=self.testmac,
                              bridge=self.host.getPrimaryBridge())
     sftp = self.host.sftpClient()
     sftp.copyFrom("/usr/lib/syslinux/xentest/%s.c32" % (self.TEST),
                   "%s/%s.c32" % (xenrt.TEC().getWorkdir(), self.TEST))
Exemplo n.º 28
0
 def createVPXOnHost(cls, host, vpxName=None, vpxHttpLocation=None):
     """Import a Netscaler VPX onto the specified host"""
     if not vpxName:
         vpxName = xenrt.randomGuestName()
     if not vpxHttpLocation:
         vpxHttpLocation = os.path.join(
             xenrt.TEC().lookup('EXPORT_DISTFILES_HTTP'),
             'tallahassee/NSVPX-XEN-10.0-72.5_nc.xva')
     xenrt.TEC().logverbose('Importing VPX [%s] from: %s to host: %s' %
                            (vpxName, vpxHttpLocation, host.getName()))
     xenrt.productLib(hostname=host.getName()).guest.createVMFromFile(
         host=host, guestname=vpxName, filename=vpxHttpLocation)
     return cls.setupNetScalerVpx(vpxName)
Exemplo n.º 29
0
 def copy(self):
     xenrt.TEC().logverbose("Attempting to copy snapshot.")
     cli = self.host.getCLIInstance()
     command = ["vm-copy"]
     command.append("uuid=%s" % (self.snappoint))
     command.append("new-name-label=%s" % (xenrt.randomGuestName()))
     try:
         cli.execute(string.join(command))
     except xenrt.XRTFailure, e:
         xenrt.TEC().warning("Copy failed.")
         if not re.search("VM_IS_SNAPSHOT", e.data):
             raise xenrt.XRTFailure(
                 "Copy failed with unexpected error (%s)" % (str(e)))
Exemplo n.º 30
0
 def installGuest(self):
     if self.DISTRO:
         vifs = [("0", self.host.getPrimaryBridge(), xenrt.randomMAC(),
                  None)]
         g = xenrt.lib.xenserver.guest.createVM(self.host,
                                                xenrt.randomGuestName(),
                                                self.DISTRO,
                                                vifs=vifs)
     else:
         g = self.host.createGenericLinuxGuest()
     self.uninstallOnCleanup(g)
     if g.windows:
         g.installDrivers()
     return g
Exemplo n.º 31
0
    def prepare(self, arglist):
        host = self.getDefaultHost()
        self.name = xenrt.randomGuestName()
        xenVersion = host.getInventoryItem('XEN_VERSION')
        xenrt.TEC().logverbose("Found XEN version: %s" % xenVersion)
        xenMapFile = host.execdom0(
            """find /boot/xen-%s* | grep '\.map' | grep -v '\-d'""" %
            xenVersion).strip()
        xenMapLine = host.execdom0('grep " nmi$" %s' % xenMapFile)
        xenrt.TEC().logverbose("Found NMI line from map file: %s" %
                               (xenMapLine))
        self.nmiAddr = '0x' + xenMapLine.split()[0]

        TCXSA24.prepare(self, arglist)
Exemplo n.º 32
0
    def prepare(self, arglist=None):
        # Parse generic args
        self.parseArgs(arglist)

        # Parse args relating to this test
        for arg in arglist:
            l = string.split(arg, "=", 1)
            if l[0] == "numothervms":
                self.numothervms = int(l[1])
            elif l[0] == "numiters":
                self.numiters = int(l[1])
            elif l[0] == "measureresponsiveness":
                self.measureResponsiveness = True
            elif l[0] == "installfromscratch":
                self.installFromScratch = True

        self.initialiseHostList()
        self.configureAllHosts()

        if self.goldimagesruuid is None:
            # Normally we use a very fast NFS server (NetApp machine, e.g. telti)
            # to put the VM on, but in this case we use local storage:
            self.goldimagesruuid = self.host.execdom0(
                """xe sr-list name-label=Local\ storage  --minimal""").strip()

        if not self.installFromScratch:
            xenrt.TEC().logverbose("Importing VM")
            self.goldvm = self.importGoldVM(self.goldimagesruuid,
                                            self.desktopimage,
                                            self.desktopvmname,
                                            self.desktopvmnetwork)
        else:
            xenrt.TEC().logverbose("Creating VM from scratch")

            # Create and install the VM
            self.goldvm = xenrt.lib.xenserver.guest.createVM(
                self.host,
                xenrt.randomGuestName(),
                "ws08-x86",
                vcpus=4,
                memory=16384,  # MB
                arch="x86-64",
                sr=self.goldimagesruuid,
                vifs=[("0", self.host.getPrimaryBridge(), xenrt.randomMAC(),
                       None)],
                disks=[("0", 1, False)])

            # Shut the VM down, so its start-time is ready to be measured
            xenrt.TEC().logverbose("Shutting VM down...")
            self.goldvm.shutdown()
Exemplo n.º 33
0
    def cloneDelete(self):
        templateName = xenrt.randomGuestName()
        self.cloud.createTemplateFromInstance(self.instance, templateName)

        instance2 = self.cloud.createInstanceFromTemplate(templateName)
        instance2.destroy()
        templateid = [
            x.id
            for x in self.cloud.cloudApi.listTemplates(templatefilter="all",
                                                       name=templateName)
            if x.name == templateName
        ][0]

        self.cloud.cloudApi.deleteTemplate(id=templateid)
Exemplo n.º 34
0
    def run(self, arglist=None):
        host = self.getDefaultHost()
        cli = host.getCLIInstance()

        # create a vm
        vm_name = xenrt.randomGuestName()
        vm_template = "\"Demo Linux VM\""
        vm = host.guestFactory()(vm_name, vm_template)
        self.uninstallOnCleanup(vm)
        vm.host = host
        self._guestsToUninstall.append(vm)
        args = []
        args.append("new-name-label=%s" % (vm_name))
        args.append("sr-uuid=%s" % host.getLocalSR())
        args.append("template-name=%s" % (vm_template))
        vm_uuid = cli.execute(
            "vm-install", string.join(args), timeout=3600).strip()

        # there's always at least 1 vm (dom0)
        vm_uuids = host.minimalList("vm-list")

        # >0 gpu hw required for this license test
        gpu_group_uuids = host.minimalList("gpu-group-list")

        if len(gpu_group_uuids) < 1:
            raise xenrt.XRTFailure(
                "This host does not contain a GPU group list as expected")
        for vm_uuid in vm_uuids:
            # assign a VGPU to this VM and check this works
            vgpu_uuid = cli.execute(
                "vgpu-create",
                "gpu-group-uuid=%s vm-uuid=%s" % (
                    gpu_group_uuids[0], vm_uuid)).strip()

            # assign another VGPU to this VM and check this fails
            for gpu_group_uuid in gpu_group_uuids:
                try:
                    data = cli.execute(
                        "vgpu-create",
                        "gpu-group-uuid=%s vm-uuid=%s" % (
                            gpu_group_uuid, vm_uuid))
                    raise xenrt.XRTFailure(
                        "Tying more than one GPU to a VM did not fail")
                except xenrt.XRTFailure, e:
                    xenrt.TEC().logverbose(
                        "vgpu-create failed as expected: %s" % str(e))
                    pass
            # clean up vgpu list
            cli.execute("vgpu-destroy", "uuid=%s" % vgpu_uuid)
Exemplo n.º 35
0
    def prepare(self, arglist=None):
        self.host = self.getDefaultHost()
        self.guests = []
        self.hosts = [self.host]

        # Create the initial VM
        guest = xenrt.lib.xenserver.guest.createVM(
            self.host,
            xenrt.randomGuestName(),
            self.DISTRO,
            arch="x86-32",
            memory=self.MEMORY,
            vifs=[("0", self.host.getPrimaryBridge(), xenrt.randomMAC(), None)
                  ],
            disks=[("0", 1, False)],
            postinstall=self.POSTINSTALL)

        self.guests.append(guest)
        guest.preCloneTailor()
        # XRT-4854 disable crond on the VM
        if not guest.windows:
            try:
                guest.execguest("/sbin/chkconfig crond off")
            except:
                pass
        guest.shutdown()

        # Do a clone loop
        if self.TESTMODE:
            max = 3
        else:
            max = int(self.host.lookup("MAX_CONCURRENT_VMS"))
        count = 0
        while count < (max - 1):
            try:
                if count > 0 and count % 20 == 0:
                    # CA-19617 Perform a vm-copy every 20 clones
                    g = guest.copyVM()
                    guest = g
                else:
                    g = guest.cloneVM()
                self.guests.append(g)
                g.start()
                g.shutdown()
            except xenrt.XRTFailure, e:
                xenrt.TEC().comment("Failed to start VM %u: %s" %
                                    (count + 1, e))
                break
            count += 1
Exemplo n.º 36
0
    def prepare(self, arglist=None):
        self.host = self.getDefaultHost()
        self.guests = []
        self.hosts = [self.host]

        # Create the initial VM
        guest = xenrt.lib.xenserver.guest.createVM(self.host,
                                                   xenrt.randomGuestName(),
                                                   self.DISTRO,
                                                   arch="x86-32",
                                                   memory=self.MEMORY,
                                                   vifs=[("0",
                                                        self.host.getPrimaryBridge(),
                                                        xenrt.randomMAC(),
                                                        None)],
                                                   disks=[("0",1,False)],
                                                   postinstall=self.POSTINSTALL)

        self.guests.append(guest)
        guest.preCloneTailor()
        # XRT-4854 disable crond on the VM
        if not guest.windows:
            try:
                guest.execguest("/sbin/chkconfig crond off")
            except:
                pass
        guest.shutdown()

        # Do a clone loop
        if self.TESTMODE:
            max = 3
        else:
            max = int(self.host.lookup("MAX_CONCURRENT_VMS"))
        count = 0
        while count < (max - 1):
            try:
                if count > 0 and count % 20 == 0:
                    # CA-19617 Perform a vm-copy every 20 clones
                    g = guest.copyVM()
                    guest = g
                else:
                    g = guest.cloneVM()
                self.guests.append(g)
                g.start()
                g.shutdown()
            except xenrt.XRTFailure, e:
                xenrt.TEC().comment("Failed to start VM %u: %s" % (count+1,e))
                break
            count += 1
Exemplo n.º 37
0
 def run(self):
     try:
         self.starttime = xenrt.timenow()
         self.guest = xenrt.lib.xenserver.guest.createVM(\
             self.host,
             xenrt.randomGuestName(),
             self.distro,
             memory=self.memory,
             vcpus=self.vcpus,
             vifs=xenrt.lib.xenserver.Guest.DEFAULT)
         #self.guest.installDrivers()
     except Exception, e:
         xenrt.TEC().logverbose("Exception while performing a VM install")
         traceback.print_exc(file=sys.stderr)
         self.exception = e
Exemplo n.º 38
0
 def installSerial(self, index):
     starttime = xenrt.timenow()
     guest = xenrt.lib.xenserver.guest.createVM(\
         self.host,
         xenrt.randomGuestName(),
         self.DISTROS[index],
         memory=self.MEMORY[index],
         vcpus=self.VCPUS[index],
         vifs=xenrt.lib.xenserver.Guest.DEFAULT)
     #guest.installDrivers()
     self.starttimes["SERIAL%u" % (index)] = starttime
     self.endtimes["SERIAL%u" % (index)] = \
         guest.xmlrpcFileMTime("c:\\alldone.txt")
     # Uninstall now to conserve disk space
     guest.shutdown()
     guest.uninstall()
Exemplo n.º 39
0
    def sendPacket(self, iface, b64):
        """Sends the specified packet (L2)
        
        @iface (string): the device id of the interface to send the packet e.g. eth0
        @b64 (string): base 64 encoded contents of the packet to send"""

        tmp = "/tmp/" + xenrt.randomGuestName()
        self.guest.execguest("echo '%s' | base64 -d > %s" % (b64, tmp))

        scr = """#!/usr/bin/python
from scapy.all import *
from scapy.utils import rdpcap
sendp(rdpcap('%s'), iface='%s')
""" % (tmp, iface)

        self.executeScript(scr)
Exemplo n.º 40
0
    def prepare(self, arglist):

        # Get a host to install on
        self.host = self.getDefaultHost()

        # Install the VM
        self.guest = xenrt.lib.xenserver.guest.createVM(\
            self.host,
            xenrt.randomGuestName(),
            vcpus=self.VCPUS,
            memory=self.MEMORY,
            distro=self.DISTRO,
            vifs=[("0",
                   self.host.getPrimaryBridge(),
                   xenrt.util.randomMAC(),
                   None)])
        self.uninstallOnCleanup(self.guest)
Exemplo n.º 41
0
 def run(self, arglist):
     cloud = self.getDefaultToolstack()
     assert isinstance(cloud, xenrt.lib.cloud.CloudStack)
     for distro in arglist:
         # Don't install the tools - we want up to date drivers
         instance = cloud.createInstance(distro=distro, installTools=False)
         templateName = xenrt.randomGuestName()
         cloud.createTemplateFromInstance(instance, templateName)
         d = xenrt.TempDirectory()
         hypervisor = cloud.instanceHypervisorType(instance, nativeCloudType=True)
         templateFormat = cloud._templateFormats[hypervisor].lower()
         cloud.downloadTemplate(templateName, "%s/%s.%s" % (d.path(), distro, templateFormat))
         xenrt.util.command("bzip2 %s/%s.%s" % (d.path(), distro, templateFormat))
         m = xenrt.MountNFS(xenrt.TEC().lookup("EXPORT_CCP_TEMPLATES_NFS"))
         xenrt.sudo("mkdir -p %s/%s" % (m.getMount(), hypervisor))
         xenrt.sudo("cp %s/%s.%s.bz2 %s/%s/" % (d.path(), distro, templateFormat, m.getMount(), hypervisor))
         d.remove()
Exemplo n.º 42
0
    def prepare(self, arglist):

        # Get a host to install on
        self.host = self.getDefaultHost()

        # Install the VM
        self.guest = xenrt.lib.xenserver.guest.createVM(\
            self.host,
            xenrt.randomGuestName(),
            vcpus=self.VCPUS,
            memory=self.MEMORY,
            distro=self.DISTRO,
            vifs=[("0",
                   self.host.getPrimaryBridge(),
                   xenrt.util.randomMAC(),
                   None)])
        self.uninstallOnCleanup(self.guest)
Exemplo n.º 43
0
    def prepare(self, arglist=None):
        self.hosts = []
        for i in range(self.HOSTS):
            self.hosts.append(self.getHost("RESOURCE_HOST_%u" % (i)))
        self.guests = []
        self.originals = []

        # Create the initial VMs
        for host in self.hosts:
            guest = xenrt.lib.xenserver.guest.createVM(host,
                                                       xenrt.randomGuestName(),
                                                       self.DISTRO,
                                                       arch="x86-32",
                                                       memory=128,
                                                       vifs=[("0",
                                                              host.getPrimaryBridge(),
                                                              xenrt.randomMAC(),
                                                              None)],
                                                       disks=[("0",1,False)])

            self.guests.append(guest)
            self.originals.append(guest)
            guest.preCloneTailor()
            guest.shutdown()

        # Do a clone loop
        if self.TESTMODE:
            max = 3
        else:
            max = int(self.hosts[0].lookup("MAX_CONCURRENT_VMS"))
            if max > self.HOSTVMCAP:
                max = self.HOSTVMCAP
        for guest in self.originals:
            count = 0
            while count < (max - 1):
                try:
                    g = guest.cloneVM()
                    self.guests.append(g)
                    g.start()
                    g.shutdown()
                except xenrt.XRTFailure, e:
                    xenrt.TEC().comment("Failed to start VM %u: %s" %
                                        (count+1,e))
                    break
                count += 1
Exemplo n.º 44
0
 def createTemplate(self):
     xenrt.TEC().logverbose("Turning snapshot into template...")
     name = xenrt.randomGuestName()
     cli = self.host.getCLIInstance()
     command = ["snapshot-clone"]
     command.append("snapshot-uuid=%s" % (self.snappoint))
     command.append("new-name-label=%s" % (name))
     try:
         self.template = cli.execute(string.join(command), strip=True)
     except xenrt.XRTFailure, e:
         if re.search("Unknown command", str(e)):
             xenrt.TEC().warning("The snapshot-clone command doesn't appear to exist.")
             command = ["snapshot-create-template"]
             command.append("snapshot-uuid=%s" % (self.snappoint))
             command.append("new-name-label=%s" % (name))
             self.template = cli.execute(string.join(command), strip=True)
         else:
             raise e
Exemplo n.º 45
0
    def prepare(self, arglist=None):
        # Parse generic args
        self.parseArgs(arglist)

        # Parse args relating to this test
        for arg in arglist:
            l = string.split(arg, "=", 1)
            if l[0] == "numothervms":
                self.numothervms = int(l[1])
            elif l[0] == "numiters":
                self.numiters = int(l[1])
            elif l[0] == "measureresponsiveness":
                self.measureResponsiveness = True
            elif l[0] == "installfromscratch":
                self.installFromScratch = True

        self.initialiseHostList()
        self.configureAllHosts()

        if self.goldimagesruuid is None:
            # Normally we use a very fast NFS server (NetApp machine, e.g. telti)
            # to put the VM on, but in this case we use local storage:
            self.goldimagesruuid = self.host.execdom0("""xe sr-list name-label=Local\ storage  --minimal""").strip()

        if not self.installFromScratch:
            xenrt.TEC().logverbose("Importing VM")
            self.goldvm = self.importGoldVM(self.goldimagesruuid, self.desktopimage, self.desktopvmname, self.desktopvmnetwork)
        else:
            xenrt.TEC().logverbose("Creating VM from scratch")

            # Create and install the VM
            self.goldvm = xenrt.lib.xenserver.guest.createVM(self.host,
                xenrt.randomGuestName(),
                "ws08-x86",
                vcpus=4,
                memory=16384, # MB
                arch="x86-64",
                sr=self.goldimagesruuid,
                vifs=[("0", self.host.getPrimaryBridge(), xenrt.randomMAC(), None)],
                disks=[("0",1,False)])

            # Shut the VM down, so its start-time is ready to be measured
            xenrt.TEC().logverbose("Shutting VM down...")
            self.goldvm.shutdown()
Exemplo n.º 46
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)))
Exemplo n.º 47
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)))
Exemplo n.º 48
0
    def prepare(self, arglist=None):
        self.hosts = []
        for i in range(self.HOSTS):
            self.hosts.append(self.getHost("RESOURCE_HOST_%u" % (i)))
        self.guests = []
        self.originals = []

        # Create the initial VMs
        for host in self.hosts:
            guest = xenrt.lib.xenserver.guest.createVM(
                host,
                xenrt.randomGuestName(),
                self.DISTRO,
                arch="x86-32",
                memory=128,
                vifs=[("0", host.getPrimaryBridge(), xenrt.randomMAC(), None)],
                disks=[("0", 1, False)])

            self.guests.append(guest)
            self.originals.append(guest)
            guest.preCloneTailor()
            guest.shutdown()

        # Do a clone loop
        if self.TESTMODE:
            max = 3
        else:
            max = int(self.hosts[0].lookup("MAX_CONCURRENT_VMS"))
            if max > self.HOSTVMCAP:
                max = self.HOSTVMCAP
        for guest in self.originals:
            count = 0
            while count < (max - 1):
                try:
                    g = guest.cloneVM()
                    self.guests.append(g)
                    g.start()
                    g.shutdown()
                except xenrt.XRTFailure, e:
                    xenrt.TEC().comment("Failed to start VM %u: %s" %
                                        (count + 1, e))
                    break
                count += 1
Exemplo n.º 49
0
 def createTemplate(self):
     xenrt.TEC().logverbose("Turning snapshot into template...")
     name = xenrt.randomGuestName()
     cli = self.host.getCLIInstance()
     command = ["snapshot-clone"]
     command.append("snapshot-uuid=%s" % (self.snappoint))
     command.append("new-name-label=%s" % (name))
     try:
         self.template = cli.execute(string.join(command), strip=True)
     except xenrt.XRTFailure, e:
         if re.search("Unknown command", str(e)):
             xenrt.TEC().warning(
                 "The snapshot-clone command doesn't appear to exist.")
             command = ["snapshot-create-template"]
             command.append("snapshot-uuid=%s" % (self.snappoint))
             command.append("new-name-label=%s" % (name))
             self.template = cli.execute(string.join(command), strip=True)
         else:
             raise e
Exemplo n.º 50
0
    def createWindowsVM(self,
                        host,
                        distro="win7-x64",
                        memory=4000,
                        arch="x86-64",
                        disksize=28843545600,
                        srtype="DEFAULT",
                        waitForStart=False):
        """Trigger a windows install without having to wait for it to install completely"""
        if not waitForStart:
            template = xenrt.lib.xenserver.getTemplate(host,
                                                       distro=distro,
                                                       arch=arch)
            xenrt.TEC().logverbose("Setup for %s" % (distro))
            guest = host.createGenericEmptyGuest(memory=memory,
                                                 name=xenrt.randomGuestName())
            device = guest.createDisk(sizebytes=disksize,
                                      bootable=True,
                                      sruuid=srtype)
            guest.changeCD(distro + ".iso")
            guest.start()
            # Allow some time for the vm to start
            xenrt.sleep(20)
        else:
            device = 0
            disksize = disksize / xenrt.MEGA
            guest = host.createGenericWindowsGuest(sr=srtype,
                                                   distro=distro,
                                                   disksize=disksize,
                                                   memory=memory)

        if self.INTELLICACHE:
            cli = host.getCLIInstance()
            if guest.getState() != "DOWN":
                guest.shutdown(force=True)
            vbd = cli.execute(
                "vbd-list", "userdevice=%s vm-uuid=%s --minimal" %
                (device, guest.uuid)).strip()
            vdi = cli.execute("vdi-list",
                              "vbd-uuids=%s --minimal" % vbd).strip()
            cli.execute("vdi-param-set", "allow-caching=true uuid=%s" % vdi)
            guest.start()
Exemplo n.º 51
0
 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)
Exemplo n.º 52
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()
Exemplo n.º 53
0
   def prepare(self, arglist):
 
       postInstall = []
       self.host = self.getDefaultHost()
       if self.PVDRIVER:
           postInstall = ["installDrivers"]
       
       self.vm = xenrt.lib.xenserver.guest.createVM(self.host,
                                                   xenrt.randomGuestName(),
                                                   "win7-x86",
                                                   arch="x86-32",
                                                   memory=2048,
                                                   vifs=[("0",
                                                       self.host.getPrimaryBridge(),
                                                       xenrt.randomMAC(),
                                                       None)],
                                                   disks=[("0",1,False)],
                                                   postinstall=postInstall,
                                                   use_ipv6=True)
       self.getLogsFrom(self.vm)
       self.uninstallOnCleanup(self.vm)
Exemplo n.º 54
0
    def installOS(self):

        disks = []
        if self.ROOTDISK:
            disks = [("0", self.ROOTDISK, False)] 

        self.guestName = xenrt.randomGuestName(self.distro, self.arch)
        self.guest = xenrt.lib.xenserver.guest.createVM(self.host,
                    self.guestName,
                    self.distro,
                    vcpus = self.vcpus,
                    corespersocket = self.cps,
                    memory = self.memory,
                    arch = self.arch,
                    vifs = xenrt.lib.xenserver.Guest.DEFAULT,
                    template = self.template,
                    notools = self.distro.startswith("solaris"),
                    disks=disks)
        
        self.getLogsFrom(self.guest)
        self.guest.check()

        # Check the in-guest memory matches what we expect
        self.checkGuestMemory(self.memory)
Exemplo n.º 55
0
 def p2v(self):
     self.guest = self.targethost.p2v(xenrt.randomGuestName(), self.DISTRO, self.p2vhost)
     self.uninstallOnCleanup(self.guest)
Exemplo n.º 56
0
    def run(self, arglist=None):

        kit = "sdk"

        if arglist and len(arglist) > 0:
            machine = arglist[0]
        else:
            raise xenrt.XRTError("No machine specified for installation")

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

        # Optional arguments
        vcpus = None
        memory = None
        uninstall = True
        guestname = xenrt.randomGuestName()
        for arg in arglist[1:]:
            l = string.split(arg, "=", 1)
            if l[0] == "vcpus":
                vcpus = int(l[1])
            elif l[0] == "memory":
                memory = int(l[1])
            elif l[0] == "nouninstall":
                uninstall = False
            elif l[0] == "kit":
                kit = l[1]
            elif l[0] == "guest":
                guestname = l[1]

        g = host.guestFactory()(\
            guestname, "NO_TEMPLATE",
            password=xenrt.TEC().lookup("ROOT_PASSWORD_SDK"))
        g.host = host
        self.guest = g
        if vcpus != None:
            g.setVCPUs(vcpus)
        if memory != None:
            g.setMemory(memory)

        # Perform the import
        sdkzip = None
        sdkiso = xenrt.TEC().lookup("SDK_CD_IMAGE", None)
        if not sdkiso:
            sdkzip = xenrt.TEC().getFile("xe-phase-2/%s.zip" % (kit), "%s.zip" % (kit))
        if not sdkiso and not sdkzip:
            sdkiso = xenrt.TEC().getFile("xe-phase-2/%s.iso" % (kit), "%s.iso" % (kit))
        if not sdkiso and not sdkzip:
            raise xenrt.XRTError("No SDK ISO/ZIP file given")
        try:
            if sdkiso:
                mount = xenrt.MountISO(sdkiso)
                mountpoint = mount.getMount()
            if sdkzip:
                # XXX Make this a tempDir once we've moved them out of /tmp
                tmp = xenrt.NFSDirectory()
                mountpoint = tmp.path()
                xenrt.command("unzip %s -d %s" % (sdkzip, mountpoint))
            g.importVM(host, "%s/%s" % (mountpoint, kit))
            br = host.getPrimaryBridge()
            if not br:
                raise xenrt.XRTError("Host has no bridge")
            g.vifs = [("eth0", br, xenrt.randomMAC(), None)]
            for v in g.vifs:
                eth, bridge, mac, ip = v
                g.createVIF(eth, bridge, mac)
        finally:
            try:
                if sdkiso:
                    mount.unmount()
                if sdkzip:
                    tmp.remove()
            except:
                pass
        g.memset(g.memory)
        g.cpuset(g.vcpus)

        xenrt.TEC().registry.guestPut(guestname, g)

        # Make sure we can boot it
        g.makeNonInteractive()
        g.tailored = True
        g.start()
        time.sleep(120)
        g.shutdown()

        # Uninstall
        if uninstall:
            g.uninstall()
Exemplo n.º 57
0
    def run(self, arglist=[]):
        """Do testing tasks in run"""

        # Read/initialize variables.
        args = xenrt.util.strlistToDict(arglist)
        iterations = args.get("iterations") or "0"
        logperiteration = args.get("logperiteration") or "1000"
        timeout = args.get("timeout") or "180"
        timeout = int(timeout)
        seed = args.get("seed") or "%x" % random.randint(0, 0xffffffff)

        modifier = xenrt.TEC().lookup("timeout", None)
        if modifier and modifier > 0:
            timeout = int(modifier)
            log("Using timeout from given submit command.")

        modifier = xenrt.TEC().lookup("seed", None)
        if modifier and modifier != "":
            seed = modifier
            log("Using seed from given submit command.")

        log("Create an empty guest with Windows 7 template")
        name = xenrt.randomGuestName()
        template = xenrt.lib.xenserver.getTemplate(self.host, "win7sp1")
        guest = self.host.guestFactory()(name, template, self.host)
        guest.setVCPUs(2)
        guest.setMemory(2048)
        guest.createGuestFromTemplate(template, None)

        log("Assign VGPU to the guest.")
        # Get a VGPU type
        vgputypes = self.host.minimalList("vgpu-type-list")
        vgputype = None
        for type in vgputypes:
            if self.host.genParamGet("vgpu-type", type, "model-name") != "passthrough":
                vgputype = type
                break
        if not vgputype:
            raise xenrt.XRTError("Cannot find relavant VGPU type.")
        log("VGPU type: %s" + vgputype)

        # Get a GPU Group.
        groups = self.host.minimalList("gpu-group-list")
        group = None
        for g in groups:
            if vgputype in self.host.genParamGet("gpu-group", g, "enabled-VGPU-types"):
                group = g
                break
        if not group:
            raise xenrt.XRTError("Cannot find a proper GPU group.")

        # Assign VGPU to the guest.
        cli = self.host.getCLIInstance()
        cli.execute("vgpu-create gpu-group-uuid=%s vgpu-type-uuid=%s vm-uuid=%s" % (group, vgputype, guest.getUUID()))

        log("Prepare Fuzzer")
        #Fetch File
        url = xenrt.TEC().lookup("EXPORT_DISTFILES_HTTP", "") + "/demufuzzer/demufuzzer-v1"
        remotepath = xenrt.TEC().getFile(url)
        try:
            xenrt.checkFileExists(remotepath)
        except:
            raise xenrt.XRTError("Failed to find demu fuzzer.")

        localpath = "/tmp/demufuzzer"
        sh = self.host.sftpClient()
        try:
            sh.copyTo(remotepath, localpath)
        finally:
            sh.close()
        # Replace HVM Loader with DEMU fuzzer.
        ret = self.host.execdom0("mv /usr/lib/xen/boot/hvmloader /usr/lib/xen/boot/hvmloader_orig")
        ret = self.host.execdom0("mv /tmp/demufuzzer /usr/lib/xen/boot/hvmloader")

        log("Setting up test variables.")
        log("iterations: %s" % iterations)
        log("log per iterations: %s" % logperiteration)
        log("Timeout: %d mins" % timeout)
        self.host.xenstoreWrite("demufuzzer/iterations", iterations) # 0 (infinity) is default.
        self.host.xenstoreWrite("demufuzzer/logperiteration", logperiteration) # 1000 is default.
        #self.host.xenstoreWrite("demufuzzer/logtoqemu", "1") # 1 is default.

        log("Start fuzzer!")
        self.startFuzzing(guest, seed)

        # capture DMESG
        self.host.execdom0("xl dmesg -c > /tmp/dmesg")
        self.host.addExtraLogFile("/tmp/dmesg")

        log("Wait for given time (%d mins) or until find a new issue" % timeout)
        targettime = xenrt.util.timenow() + timeout * 60
        while (xenrt.util.timenow() < targettime):
            self.host.execdom0("xl dmesg -c >> /tmp/dmesg")
            if not self.isDEMUAlive():
                log("DEMU is crashed.")
                try:
                    self.host.checkHealth()
                except xenrt.XRTException as e:
                    log("%s: %s happend." % (e, e.data))
                    raise xenrt.XRTFailure("Host is unhealty.")
                
                # If it is not a host crash, it is not security issue. Restarting.
                self.stopFuzzing(guest)
                self.startFuzzing(guest)
            else:
                xenrt.sleep(30)

        log("DEMU fuzzer ran for %d mins without Dom0 crash." % timeout)