Beispiel #1
0
def list_vms(sync, name, rem):
    if sync or cache.need_update():
        rs = hvclient.get_vm(name)
        vms = hvclient.parse_result(rs)
        if rem:
            cache.remove_cache()
        cache.update_cache(vms)
    cache_vms = cache.list_vms()
    printer.print_list_vms(cache_vms, name)
Beispiel #2
0
def list_vms(sync, name, rem):
    if sync or cache.need_update():
        rs = hvclient.get_vm(name)
        vms = hvclient.parse_result(rs)
        if rem:
            cache.remove_cache()
        cache.update_cache(vms)
    cache_vms = cache.list_vms()
    printer.print_list_vms(cache_vms, name)
Beispiel #3
0
def snap_ls(by_name, ident):
    name = cache.get_name(by_name, ident)
    rs = hvclient.get_vm(name)
    vms = hvclient.parse_result(rs)
    cache.update_cache(vms)
    cache_vms = cache.list_vms()
    printer.print_list_vms(cache_vms, name)
    rs_snaps = hvclient.list_vm_snaps(name)
    snaps = hvclient.parse_result(rs_snaps)
    printer.print_vm_snaps(snaps, name, vms['ParentSnapshotName'])
Beispiel #4
0
def snap_ls(by_name, ident):
    name = cache.get_name(by_name, ident)
    rs = hvclient.get_vm(name)
    vms = hvclient.parse_result(rs)
    cache.update_cache(vms)
    cache_vms = cache.list_vms()
    printer.print_list_vms(cache_vms, name)
    rs_snaps = hvclient.list_vm_snaps(name)
    snaps = hvclient.parse_result(rs_snaps)
    printer.print_vm_snaps(snaps, name, vms['ParentSnapshotName'])
Beispiel #5
0
def connect(by_name, ident):
    name = cache.get_name(by_name, ident)
    vm_cache = cache.get_vm_by_name(name)

    vm_name = vm_cache['Name']
    vm_index = vm_cache['index']
    vm_id = vm_cache['Id']

    rs = hvclient.get_vm(vm_name)
    vm = hvclient.parse_result(rs)
    cache.update_cache(vm)

    if vm['State'] not in [2, 9]:
        rs = hvclient.start_vm(vm_name)
        hvclient.parse_result(rs)
        sleep(5)

    hvclient.connect(vm_id, vm_name, vm_index)
Beispiel #6
0
def connect(by_name, ident):
    name = cache.get_name(by_name, ident)
    vm_cache = cache.get_vm_by_name(name)

    vm_name = vm_cache['Name']
    vm_index = vm_cache['index']
    vm_id = vm_cache['Id']

    rs = hvclient.get_vm(vm_name)
    vm = hvclient.parse_result(rs)
    cache.update_cache(vm)

    if vm['State'] not in [2, 9]:
        rs = hvclient.start_vm(vm_name)
        hvclient.parse_result(rs)
        sleep(5)

    hvclient.connect(vm_id, vm_name, vm_index)
Beispiel #7
0
 def test_remove_cache(self):
     self.fill_cache()
     cache.remove_cache()
     response = loads(get_vm_response)
     cache.update_cache(response)
     self.assertEqual(response, cache.list_vms())
Beispiel #8
0
 def test_update_cache(self):
     self.fill_cache()
     response = loads(get_vm_response)
     cache.update_cache(response)
     self.assertEqual(loads(updated_cache), cache.list_vms())
Beispiel #9
0
 def test_update_empty_cache(self):
     response = loads(get_vm_response)
     cache.update_cache(response)
     self.assertEqual(response, cache.list_vms())