Ejemplo n.º 1
0
 def test_reboot(self, host):
     host.reboot(verify=True)
     wait_for(TestEXTSR.sr.all_pbds_attached, "Wait for PDB attached")
     vm = TestEXTSR.vm
     vm.start()
     vm.wait_for_os_booted()
     vm.shutdown(verify=True)
Ejemplo n.º 2
0
def test(host):
    print("Check for updates")
    if not host.has_updates():
        pytest.skip("No updates available for the host. Skipping.")

    host.install_updates()
    host.restart_toolstack()
    wait_for(host.is_enabled, "Wait for host enabled")
    host.reboot(verify=True)
    print("Check for updates again")
    assert not host.has_updates()
Ejemplo n.º 3
0
def setup_host(hostname_or_ip):
    print(">>> Connect host %s" % hostname_or_ip)
    h = Host(hostname_or_ip)
    h.initialize()
    assert h.is_master(), "we connect only to master hosts during initial setup"
    # XO connection
    h_data = host_data(hostname_or_ip)
    skip_xo_config = h_data.get('skip_xo_config', False)
    if not skip_xo_config:
        h.xo_server_add(h_data['user'], h_data['password'])
    else:
        h.xo_get_server_id(store=True)
    wait_for(h.xo_server_connected, timeout_secs=10)
    return h, skip_xo_config
Ejemplo n.º 4
0
def test_basic_vm_crosspool_migrate(hosts, vm_ref):
    host1 = hosts[0]
    host2 = hosts[1]
    assert host1.pool.uuid != host2.pool.uuid

    vm = host1.import_vm_url(vm_ref)
    vm.start()
    vm.wait_for_os_booted()
    vm.migrate(host2)
    wait_for_not(vm.exists_on_previous_pool, "Wait for VM not on old pool anymore")
    wait_for(vm.exists, "Wait for VM on new pool")
    vm.wait_for_os_booted()
    vm.shutdown(verify=True)
    vm.destroy(verify=True)
Ejemplo n.º 5
0
def test_checkpoint(running_linux_vm):
    vm = running_linux_vm
    print("Start a 'sleep' process on VM through SSH")
    vm.ssh(['sleep 100000'], background=True)
    snapshot = vm.checkpoint()
    filepath = '/tmp/%s' % snapshot.uuid
    vm.ssh_touch_file(filepath)
    snapshot.revert()
    vm.resume()
    vm.wait_for_linux_vm_running_and_ssh_up(wait_for_ip=False)
    print("Check file does not exist anymore")
    vm.ssh(['test ! -f ' + filepath])
    print("Check 'sleep' process is still running")
    output = vm.ssh(['ps -edf | grep -v grep | grep "sleep 100000"'])
    print("Kill 'sleep' process")
    pid = output.split()[0]
    output = vm.ssh(['kill ' + pid])
    wait_for(lambda: vm.ssh(['! ps -edf | grep -s grep | grep "sleep 100000"'], check=False, simple_output=False).returncode != 0,
             "Wait for process %s not running anymore" % pid,
             timeout_secs=10)
    snapshot.destroy(verify=True)
Ejemplo n.º 6
0
def running_linux_vm(imported_vm):
    vm = imported_vm

    # may be already running if we skipped the import to use an existing VM
    if not vm.is_running():
        print("> ", end='')
        vm.start()
    wait_for(vm.is_running, '> Wait for VM running')
    wait_for(vm.try_get_and_store_ip, "> Wait for VM IP")
    wait_for(vm.is_ssh_up, "> Wait for VM SSH up")
    return vm
Ejemplo n.º 7
0
 def test_create_sr(self, host, sr_disk):
     TestEXTSR.sr = host.sr_create('ext', "EXT-local-SR",
                                   {'device': '/dev/' + sr_disk})
     wait_for(TestEXTSR.sr.exists, "Wait for SR to exist")
Ejemplo n.º 8
0
 def test_create_sr(self, host_with_xfsprogs, sr_disk):
     host = host_with_xfsprogs
     TestXFSSR.sr = host.sr_create('xfs', "XFS-local-SR",
                                   {'device': '/dev/' + sr_disk})
     wait_for(TestXFSSR.sr.exists, "Wait for SR to exist")