def testRestartVm(self):
        name = "staticvm"
        args = self.create_vm(name, wait=True)

        self.click(self.wait_css('#vm-{}-reboot'.format(name), cond=clickable))
        wait(lambda: "reboot: Power down" in self.machine.execute("sudo cat {0}".format(args.get('logfile'))), delay=3)
        self.wait_css('#vm-{}-state'.format(name), cond=text_in, text_='running')
Exemplo n.º 2
0
    def testRestartVm(self):
        name = "staticvm"
        args = self.create_vm(name, wait=True)

        self.click(self.wait_css('#vm-{}-reboot'.format(name), cond=clickable))
        wait(lambda: "reboot: Power down" in self.machine.execute("sudo cat {0}".format(args.get('logfile'))), delay=3)
        self.wait_css('#vm-{}-state'.format(name), cond=text_in, text_='running')
    def testSendNMI(self):
        name = "staticvm"
        args = self.create_vm(name, wait=True)

        self.click(self.wait_css('#vm-{}-off-caret'.format(name), cond=clickable))
        self.click(self.wait_css('#vm-{}-sendNMI'.format(name), cond=clickable))
        wait(lambda: "NMI received" in self.machine.execute("sudo cat {0}".format(args.get('logfile'))), delay=3)
        self.wait_css('#vm-{}-state'.format(name), cond=text_in, text_='running')
Exemplo n.º 4
0
    def testSendNMI(self):
        name = "staticvm"
        args = self.create_vm(name, wait=True)

        self.click(self.wait_css('#vm-{}-off-caret'.format(name), cond=clickable))
        self.click(self.wait_css('#vm-{}-sendNMI'.format(name), cond=clickable))
        wait(lambda: "NMI received" in self.machine.execute("sudo cat {0}".format(args.get('logfile'))), delay=3)
        self.wait_css('#vm-{}-state'.format(name), cond=text_in, text_='running')
    def testForceRestartVm(self):
        name = "staticvm"
        args = self.create_vm(name, wait=True)

        self.click(self.wait_css('#vm-{}-reboot-caret'.format(name), cond=clickable))
        self.click(self.wait_css('#vm-{}-forceReboot'.format(name), cond=clickable))
        wait(lambda: re.search("login:.*Initializing cgroup",
                               self.machine.execute("sudo cat {0}".format(args.get('logfile')))), delay=3)
        self.wait_css('#vm-{}-state'.format(name), cond=text_in, text_='running')
Exemplo n.º 6
0
    def testForceRestartVm(self):
        name = "staticvm"
        args = self.create_vm(name, wait=True)

        self.click(self.wait_css('#vm-{}-reboot-caret'.format(name), cond=clickable))
        self.click(self.wait_css('#vm-{}-forceReboot'.format(name), cond=clickable))
        wait(lambda: re.search("login:.*Initializing cgroup",
                               self.machine.execute("sudo cat {0}".format(args.get('logfile')))), delay=3)
        self.wait_css('#vm-{}-state'.format(name), cond=text_in, text_='running')
    def testShutdownVm(self):
        name = "staticvm"
        args = self.create_vm(name, wait=True)

        self.click(self.wait_css('#vm-{}-off'.format(name), cond=clickable))
        self.wait_css('#vm-{}-state'.format(name), cond=text_in, text_='shut off')
        wait(lambda: "reboot: Power down" in self.machine.execute("sudo cat {0}".format(args.get('logfile'))), delay=3)
        self.wait_css('#vm-{}-run'.format(name))
        self.click(self.wait_css('#vm-{}-consoles'.format(name), cond=clickable))
        self.wait_text("Please start the virtual machine to access its console.", element="div")
Exemplo n.º 8
0
    def testShutdownVm(self):
        name = "staticvm"
        args = self.create_vm(name, wait=True)

        self.click(self.wait_css('#vm-{}-off'.format(name), cond=clickable))
        self.wait_css('#vm-{}-state'.format(name), cond=text_in, text_='shut off')
        wait(lambda: "reboot: Power down" in self.machine.execute("sudo cat {0}".format(args.get('logfile'))), delay=3)
        self.wait_css('#vm-{}-run'.format(name))
        self.click(self.wait_css('#vm-{}-consoles'.format(name), cond=clickable))
        self.wait_text("Please start the virtual machine to access its console.", element="div")
Exemplo n.º 9
0
 def force_reboot_operation():
     self.click(
         self.wait_css('#vm-{}-reboot-caret'.format(name),
                       cond=clickable))
     self.click(
         self.wait_css('#vm-{}-forceReboot'.format(name),
                       cond=clickable))
     wait(lambda: re.search(
         "login:.*Initializing cgroup",
         self.machine.execute("sudo cat {0}".format(args.get('logfile'))
                              )))
Exemplo n.º 10
0
    def testInlineConsole(self):
        name = "staticvm"
        args = self.create_vm(name, graphics='vnc')

        self.click(self.wait_css('#vm-{}-consoles'.format(name), cond=clickable))
        # HACK: cond=text_in does not work with <select> in Edge
        s = Select(self.wait_id('console-type-select'))
        wait(lambda: s.first_selected_option.text == 'Graphics Console (VNC)')
        self.wait_css('.toolbar-pf-results canvas')

        # Test ctrl+alt+del
        self.wait_vm_complete_start(args)
        self.click(self.wait_css('#console-send-shortcut', cond=clickable))
        self.click(self.wait_css('#console-send-shortcut + ul li:nth-of-type(1) > a', cond=clickable))
        wait(lambda: "reboot: machine restart" in self.machine.execute(
            "sudo cat {0}".format(args.get('logfile'))), delay=3)
Exemplo n.º 11
0
    def vcpuConfigureAndCheck(self, vmstate, maxnum, count, sockets, cores, threads):
        # create a vm on host
        name = "staticvm"
        args = self.create_vm(name, state=vmstate)

        # open vcpu configure window
        self.click(self.wait_css('#vm-{}-vcpus-count'.format(name), cond=clickable))
        self.wait_xpath("//input[@id='machines-vcpu-count-field' and @value='1']")
        self.wait_xpath("//input[@id='machines-vcpu-max-field' and @value='1']")

        # set vcpu params
        self.send_keys(self.wait_css('#machines-vcpu-max-field'), maxnum, ctrla=True)
        self.send_keys(self.wait_css('#machines-vcpu-count-field'), count, ctrla=True)
        Select(self.wait_id('socketsSelect')).select_by_visible_text(sockets)
        Select(self.wait_id('coresSelect')).select_by_visible_text(cores)
        Select(self.wait_id('threadsSelect')).select_by_visible_text(threads)
        if vmstate == 'running':
            cond = visible
        else:
            cond = invisible
        self.wait_css('#machines-vcpu-modal-dialog span.idle-message', cond=cond)

        # apply settings
        self.click(self.wait_css('#machines-vcpu-modal-dialog-apply', cond=clickable))
        self.wait_css('#machines-vcpu-modal-dialog', cond=invisible)
        if vmstate == 'running':
            tmpcount = '1'
        else:
            tmpcount = count
        self.wait_css('#vm-{}-vcpus-count'.format(name), cond=text_in, text_=tmpcount)

        # if configure vcpu while vm is running, needs to shut down vm to let configuration take effect.
        if vmstate == 'running':
            # shut down may not work if the VM is not completely started
            self.wait_vm_complete_start(args)
            self.click(self.wait_css('#vm-{}-off'.format(name), cond=clickable))
            self.wait_css('#vm-{}-state'.format(name), cond=text_in, text_='shut off')
            self.wait_css('#vm-{}-vcpus-count'.format(name), cond=text_in, text_=count)

        # run vm to see if the configurations are persisted
        self.click(self.wait_css('#vm-{}-run'.format(name), cond=clickable))
        self.wait_css('#vm-{}-state'.format(name), cond=text_in, text_='running')
        self.wait_css('#vm-{}-vcpus-count'.format(name), cond=text_in, text_=count)
        self.click(self.wait_css('#vm-{}-vcpus-count'.format(name), cond=clickable))
        self.wait_xpath("//input[@id='machines-vcpu-count-field' and @value={}]".format(count))
        self.wait_xpath("//input[@id='machines-vcpu-max-field' and @value={}]".format(maxnum))
        # HACK: cond=text_in does not work with <select> in Edge
        socketsSelect = Select(self.wait_id('socketsSelect'))
        coresSelect = Select(self.wait_id('coresSelect'))
        threadsSelect = Select(self.wait_id('threadsSelect'))
        wait(lambda: socketsSelect.first_selected_option.text == sockets)
        wait(lambda: coresSelect.first_selected_option.text == cores)
        wait(lambda: threadsSelect.first_selected_option.text == threads)

        # check cpu topology in dumpxml
        cmd = "sudo virsh dumpxml {} | tee /tmp/staticvm.xml | " \
            "xmllint --xpath '/domain/cpu/topology[@sockets=\'{}\'][@cores=\'{}\'][@threads=\'{}\']' -" \
            .format(name, sockets, cores, threads)
        self.machine.execute(cmd)
    def operationsForVm(self, vm_args):
        name = vm_args.get('name')
        log_file = vm_args.get('logfile')

        if log_file and name and 'vnc' in vm_args.get('graphics'):
            self.wait_vm_complete_start(vm_args)
            self.click(
                self.wait_css('#vm-{}-reboot'.format(name), cond=clickable))
            wait(lambda: self.machine.execute(
                "sudo cat {} | grep 'Sent SIGTERM to all processes' | wc -l".
                format(log_file)).strip() == '1',
                 delay=3)

            self.wait_vm_complete_start(vm_args)
            self.machine.execute('sudo sh -c "echo > {}"'.format(log_file))
            self.click(
                self.wait_css('#vm-{}-reboot-caret'.format(name),
                              cond=clickable))
            self.click(
                self.wait_css('#vm-{}-forceReboot'.format(name),
                              cond=clickable))
            wait(lambda: "Initializing cgroup subsys cpuset" in self.machine.
                 execute("sudo cat {}".format(log_file)),
                 delay=3)

            self.wait_vm_complete_start(vm_args)
            self.click(
                self.wait_css('#vm-{}-off-caret'.format(name), cond=clickable))
            self.click(
                self.wait_css('#vm-{}-sendNMI'.format(name), cond=clickable))
            wait(lambda: "NMI received" in self.machine.execute(
                "sudo cat {}".format(log_file)),
                 delay=3)

            self.click(self.wait_css('#vm-{}-off'.format(name),
                                     cond=clickable))
            self.wait_css('#vm-{}-off'.format(name), cond=invisible)
            self.wait_css('#vm-{}-run'.format(name))

            self.machine.execute('sudo sh -c "echo > {}"'.format(log_file))
            self.click(self.wait_css('#vm-{}-run'.format(name),
                                     cond=clickable))
            self.wait_css('#vm-{}-run'.format(name), cond=invisible)
            self.wait_css('#vm-{}-off'.format(name))

            self.click(
                self.wait_css('#vm-{}-off-caret'.format(name), cond=clickable))
            self.click(
                self.wait_css('#vm-{}-forceOff'.format(name), cond=clickable))
            self.wait_css('#vm-{}-off'.format(name), cond=invisible)
            self.wait_css('#vm-{}-run'.format(name))
    def operationsForVm(self, vm_args):
        name = vm_args.get('name')
        log_file = vm_args.get('logfile')

        if log_file and name and 'vnc' in vm_args.get('graphics'):
            self.wait_vm_complete_start(vm_args)
            self.click(self.wait_css('#vm-{}-reboot'.format(name), cond=clickable))
            wait(lambda: self.machine.execute("sudo cat {} | grep 'Sent SIGTERM to all processes' | wc -l".format(log_file)).strip() == '1',
                 delay=3)

            self.wait_vm_complete_start(vm_args)
            self.machine.execute('sudo sh -c "echo > {}"'.format(log_file))
            self.click(self.wait_css('#vm-{}-reboot-caret'.format(name), cond=clickable))
            self.click(self.wait_css('#vm-{}-forceReboot'.format(name), cond=clickable))
            wait(lambda: "Initializing cgroup subsys cpuset" in self.machine.execute("sudo cat {}".format(log_file)),
                 delay=3)

            self.wait_vm_complete_start(vm_args)
            self.click(self.wait_css('#vm-{}-off-caret'.format(name), cond=clickable))
            self.click(self.wait_css('#vm-{}-sendNMI'.format(name), cond=clickable))
            wait(lambda: "NMI received" in self.machine.execute("sudo cat {}".format(log_file)),
                 delay=3)

            self.click(self.wait_css('#vm-{}-off'.format(name), cond=clickable))
            self.wait_css('#vm-{}-off'.format(name), cond=invisible)
            self.wait_css('#vm-{}-run'.format(name))

            self.machine.execute('sudo sh -c "echo > {}"'.format(log_file))
            self.click(self.wait_css('#vm-{}-run'.format(name), cond=clickable))
            self.wait_css('#vm-{}-run'.format(name), cond=invisible)
            self.wait_css('#vm-{}-off'.format(name))

            self.click(self.wait_css('#vm-{}-off-caret'.format(name), cond=clickable))
            self.click(self.wait_css('#vm-{}-forceOff'.format(name), cond=clickable))
            self.wait_css('#vm-{}-off'.format(name), cond=invisible)
            self.wait_css('#vm-{}-run'.format(name))