Esempio n. 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)
Esempio n. 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)
Esempio n. 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'])
Esempio n. 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'])
Esempio n. 5
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())
Esempio n. 6
0
 def test_invalid_cache(self):
     with open(self.cache_file, 'w') as fd:
         fd.write('[{}')
     self.assertIsNotNone(cache.list_vms())
Esempio n. 7
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())
Esempio n. 8
0
 def test_update_empty_cache(self):
     response = loads(get_vm_response)
     cache.update_cache(response)
     self.assertEqual(response, cache.list_vms())