Beispiel #1
0
    def run(self, arglist=None):

        # arg0 = host

        if arglist and len(arglist) > 0:
            hname = arglist[0]
        else:
            raise xenrt.XRTError("No host specified")
        host = xenrt.TEC().registry.hostGet(hname)
        machine = host.machine

        cli = xenrt.lib.xenserver.cli.Session(machine, password="******")

        allowed = True

        try:
            cli.execute("vm-list")
        except xenrt.XRTFailure, e:
            allowed = False
            if e.data.startswith("Authentication failed"):
                xenrt.TEC().comment("Expected Authentication failed error " +
                                    "when executing a CLI command with an " +
                                    "invalid password")
            else:
                self.setResult(xenrt.RESULT_PARTIAL)
                xenrt.TEC().comment("Expected XRTFailure exception with " +
                                    "unexpected data when executing a CLI " +
                                    "command with an invalid password: " +
                                    e.data)
Beispiel #2
0
    def run(self,arglist=None):

        # arg0 = host

        if arglist and len(arglist) > 0:
            hname = arglist[0]
        else:
            raise xenrt.XRTError("No host specified")
        host = xenrt.TEC().registry.hostGet(hname)
        machine = host.machine

        cli = xenrt.lib.xenserver.cli.Session(machine, password="******")

        allowed = True

        try:
            cli.execute("vm-list")
        except xenrt.XRTFailure, e:
            allowed = False
            if e.data.startswith("Authentication failed"):
                xenrt.TEC().comment("Expected Authentication failed error " +
                                    "when executing a CLI command with an " +
                                    "invalid password")
            else:
                self.setResult(xenrt.RESULT_PARTIAL)
                xenrt.TEC().comment("Expected XRTFailure exception with " +
                                    "unexpected data when executing a CLI " +
                                    "command with an invalid password: " +
                                    e.data)
Beispiel #3
0
    def run(self, arglist=None):

        host = self.getDefaultHost()
        self.host = host

        guest = host.createGenericLinuxGuest()
        self.uninstallOnCleanup(guest)

        # Find out how much memory the guest has
        mem = guest.memget()

        # Make an SR that's half the size
        srsize = mem / 2

        # We create the SR by creating a sparse file, making a filesystem on
        # it, then mounting it loopback...
        localBase = xenrt.TEC().lookup("LOCAL_BASE")
        host.execdom0("dd if=/dev/zero of=%s/ssr bs=1k seek=%dk count=1" %
                      (localBase,srsize))
        host.execdom0("mkfs.ext3 -F %s/ssr" % (localBase))
        host.execdom0("mkdir -p %s/suspendsr" % (localBase))
        host.execdom0("mount -o loop %s/ssr %s/suspendsr" % 
                      (localBase, localBase))

        args = []
        args.append("name-label=suspendsrfull")
        args.append("physical-size=%d" % (srsize * 1048576))
        args.append("type=file")
        args.append("device-config-location=\"%s/suspendsr/sr\"" % (localBase))
        cli = host.getCLIInstance()

        try:
            self.newSR = cli.execute("sr-create",string.join(args),strip=True)
        except:
            raise xenrt.XRTError("Unable to create new SR")

        # Store where the current SR is (assume for now we're not in a pool)
        self.originalSR = host.getHostParam("suspend-image-sr-uuid")

        # Now set ours up
        host.setHostParam("suspend-image-sr-uuid", self.newSR)

        # Try suspend
        allowed = False
        try:
            cli.execute("vm-suspend", "uuid=%s" % (guest.getUUID()),
                        timeout=1200)
            allowed = True
        except xenrt.XRTFailure, e:
            if "timed out" in e.reason:
                xenrt.TEC().logverbose("vm-suspend timed out, performing "
                                       "emergency cleanup")
                host.machine.powerctl.cycle()
                host.waitForSSH(600, desc="Host boot after emergency cleanup")
                time.sleep(300)
                raise xenrt.XRTFailure("vm-suspend timed out")
            else:
                pass
Beispiel #4
0
    def run(self, arglist=None):

        # arg0 = host

        if arglist and len(arglist) > 0:
            hname = arglist[0]
        else:
            raise xenrt.XRTError("No host specified")
        host = xenrt.TEC().registry.hostGet(hname)

        # Find an appropriate SR (the XenSource Tools one will do)
        SRs = host.getSRs(type="iso")
        XSTsr = None
        for sr in SRs:
            # Get the name
            name = host.getSRParam(sr, "name-label")
            if name == "XenSource Tools":
                XSTsr = sr
                break
            elif name == "XenServer Tools":
                XSTsr = sr
                break
        if XSTsr == None:
            raise xenrt.XRTError("Unable to find XenSource Tools SR!")

        # Now try the create
        cli = host.getCLIInstance()

        allowed = True
        try:
            args = [
                "sr-uuid=\"%s\"" % (XSTsr),
                "name-label=\"shouldnt_be_created\"", "type=\"user\"",
                "virtual-size=\"1000000\""
            ]
            cli.execute("vdi-create", string.join(args))
        except xenrt.XRTFailure, e:
            allowed = False
            # Check we get the correct error
            if e.data.startswith("The SR backend does not support the " +
                                 "operation (check the SR's allowed " +
                                 "operations)"):
                xenrt.TEC().comment("Expected not supported exception when " +
                                    "attempting to create vdi on read-only " +
                                    "storage repository.")
            else:
                xenrt.TEC().comment("Expected XRTFailure exception when " +
                                    "attempting to create vdi on read-only " +
                                    "storage repository, with unexpected " +
                                    "data: " + e.data)
                self.setResult(xenrt.RESULT_PARTIAL)
Beispiel #5
0
    def run(self,arglist=None):

        # arg0 = host

        if arglist and len(arglist) > 0:
            hname = arglist[0]
        else:
            raise xenrt.XRTError("No host specified")
        host = xenrt.TEC().registry.hostGet(hname)

        # Find an appropriate SR (the XenSource Tools one will do)
        SRs = host.getSRs(type="iso")
        XSTsr = None
        for sr in SRs:
            # Get the name
            name = host.getSRParam(sr,"name-label")
            if name == "XenSource Tools":
                XSTsr = sr
                break
            elif name == "XenServer Tools":
                XSTsr = sr
                break
        if XSTsr == None:
            raise xenrt.XRTError("Unable to find XenSource Tools SR!")

        # Now try the create
        cli = host.getCLIInstance()
        
        allowed = True
        try:
            args = ["sr-uuid=\"%s\"" % (XSTsr), 
                    "name-label=\"shouldnt_be_created\"", "type=\"user\"", 
                    "virtual-size=\"1000000\""]
            cli.execute("vdi-create",string.join(args))
        except xenrt.XRTFailure, e:
            allowed = False
            # Check we get the correct error
            if e.data.startswith("The SR backend does not support the " +
                                 "operation (check the SR's allowed " +
                                 "operations)"):
                xenrt.TEC().comment("Expected not supported exception when " +
                                    "attempting to create vdi on read-only " +
                                    "storage repository.")
            else:
                xenrt.TEC().comment("Expected XRTFailure exception when " +
                                    "attempting to create vdi on read-only " +
                                    "storage repository, with unexpected " +
                                    "data: " + e.data)
                self.setResult(xenrt.RESULT_PARTIAL)
Beispiel #6
0
    def run(self,arglist=None):

        # arg0 = host

        if arglist and len(arglist) > 0:
            hname = arglist[0]
        else:
            raise xenrt.XRTError("No host specified")
        host = xenrt.TEC().registry.hostGet(hname)

        # Build up command
        cmd = "vm-install"
        args = ["new-name-label=invalidTemplateTest", "template=nonexistent_template"]

        cli = host.getCLIInstance()

        allowed = True

        try:        
            uuid = cli.execute(cmd,string.join(args)) 
        except xenrt.XRTFailure, e: 
            allowed = False
            if e.data.startswith("Error: No templates matched"):
                xenrt.TEC().comment("Expected error when attempting to " +
                                    "install a VM from an invalid template")
            else:
                self.setResult(xenrt.RESULT_PARTIAL)
                xenrt.TEC().comment("Expected XRTFailure exception with " +
                                    "unexpected data when attempting to " +
                                    "install a VM from an invalid template: " +
                                    e.data)
Beispiel #7
0
    def run(self, arglist=None):

        # arg0 = host

        if arglist and len(arglist) > 0:
            hname = arglist[0]
        else:
            raise xenrt.XRTError("No host specified")
        host = xenrt.TEC().registry.hostGet(hname)

        # Build up command
        cmd = "vm-install"
        args = [
            "new-name-label=invalidTemplateTest",
            "template=nonexistent_template"
        ]

        cli = host.getCLIInstance()

        allowed = True

        try:
            uuid = cli.execute(cmd, string.join(args))
        except xenrt.XRTFailure, e:
            allowed = False
            if e.data.startswith("Error: No templates matched"):
                xenrt.TEC().comment("Expected error when attempting to " +
                                    "install a VM from an invalid template")
            else:
                self.setResult(xenrt.RESULT_PARTIAL)
                xenrt.TEC().comment("Expected XRTFailure exception with " +
                                    "unexpected data when attempting to " +
                                    "install a VM from an invalid template: " +
                                    e.data)
Beispiel #8
0
 def postRun(self):
     # Restore the original suspend sr
     if self.originalSR:
         self.host.setHostParam("suspend-image-sr-uuid",self.originalSR)
     # Destroy and cleanup the new SR
     if self.newSR:
         cli = self.host.getCLIInstance()
         pbd = self.host.minimalList("pbd-list", args="sr-uuid=%s" % 
                                                      (self.newSR))[0]
         cli.execute("pbd-unplug uuid=%s" % (pbd))
         cli.execute("pbd-destroy uuid=%s" % (pbd))
         cli.execute("sr-forget", "uuid=%s" % (self.newSR))
         localBase = xenrt.TEC().lookup("LOCAL_BASE")
         self.host.execdom0("umount %s/suspendsr" % (localBase))
         self.host.execdom0("rm -f %s/ssr" % (localBase))
         self.host.execdom0("rmdir %s/suspendsr" % (localBase))
Beispiel #9
0
 def postRun(self):
     # Restore the original suspend sr
     if self.originalSR:
         self.host.setHostParam("suspend-image-sr-uuid", self.originalSR)
     # Destroy and cleanup the new SR
     if self.newSR:
         cli = self.host.getCLIInstance()
         pbd = self.host.minimalList("pbd-list",
                                     args="sr-uuid=%s" % (self.newSR))[0]
         cli.execute("pbd-unplug uuid=%s" % (pbd))
         cli.execute("pbd-destroy uuid=%s" % (pbd))
         cli.execute("sr-forget", "uuid=%s" % (self.newSR))
         localBase = xenrt.TEC().lookup("LOCAL_BASE")
         self.host.execdom0("umount %s/suspendsr" % (localBase))
         self.host.execdom0("rm -f %s/ssr" % (localBase))
         self.host.execdom0("rmdir %s/suspendsr" % (localBase))
Beispiel #10
0
    def run(self, arglist=None):

        host = self.getDefaultHost()
        self.host = host

        guest = host.createGenericLinuxGuest()
        self.uninstallOnCleanup(guest)

        # Find out how much memory the guest has
        mem = guest.memget()

        # Make an SR that's half the size
        srsize = mem / 2

        # We create the SR by creating a sparse file, making a filesystem on
        # it, then mounting it loopback...
        localBase = xenrt.TEC().lookup("LOCAL_BASE")
        host.execdom0("dd if=/dev/zero of=%s/ssr bs=1k seek=%dk count=1" %
                      (localBase, srsize))
        host.execdom0("mkfs.ext3 -F %s/ssr" % (localBase))
        host.execdom0("mkdir -p %s/suspendsr" % (localBase))
        host.execdom0("mount -o loop %s/ssr %s/suspendsr" %
                      (localBase, localBase))

        args = []
        args.append("name-label=suspendsrfull")
        args.append("physical-size=%d" % (srsize * 1048576))
        args.append("type=file")
        args.append("device-config-location=\"%s/suspendsr/sr\"" % (localBase))
        cli = host.getCLIInstance()

        try:
            self.newSR = cli.execute("sr-create",
                                     string.join(args),
                                     strip=True)
        except:
            raise xenrt.XRTError("Unable to create new SR")

        # Store where the current SR is (assume for now we're not in a pool)
        self.originalSR = host.getHostParam("suspend-image-sr-uuid")

        # Now set ours up
        host.setHostParam("suspend-image-sr-uuid", self.newSR)

        # Try suspend
        allowed = False
        try:
            cli.execute("vm-suspend",
                        "uuid=%s" % (guest.getUUID()),
                        timeout=1200)
            allowed = True
        except xenrt.XRTFailure, e:
            if "timed out" in e.reason:
                xenrt.TEC().logverbose("vm-suspend timed out, performing "
                                       "emergency cleanup")
                host.machine.powerctl.cycle()
                host.waitForSSH(600, desc="Host boot after emergency cleanup")
                time.sleep(300)
                raise xenrt.XRTFailure("vm-suspend timed out")
            else:
                pass