示例#1
0
文件: stubs.py 项目: mdegerne/nova-2
def stub_out_migration_methods(stubs):
    fakesr = fake.create_sr()

    def fake_move_disks(self, instance, disk_info):
        vdi_ref = fake.create_vdi(instance['name'], fakesr)
        vdi_rec = fake.get_record('VDI', vdi_ref)
        vdi_rec['other_config']['nova_disk_type'] = 'root'
        return {'uuid': vdi_rec['uuid'], 'ref': vdi_ref}

    def fake_get_vdi(session, vm_ref):
        vdi_ref_parent = fake.create_vdi('derp-parent', fakesr)
        vdi_rec_parent = fake.get_record('VDI', vdi_ref_parent)
        vdi_ref = fake.create_vdi('derp', fakesr,
                sm_config={'vhd-parent': vdi_rec_parent['uuid']})
        vdi_rec = session.call_xenapi("VDI.get_record", vdi_ref)
        return vdi_ref, vdi_rec

    def fake_sr(session, *args):
        return fakesr

    def fake_get_sr_path(*args):
        return "fake"

    def fake_destroy(*args, **kwargs):
        pass

    def fake_generate_ephemeral(*args):
        pass

    stubs.Set(vmops.VMOps, '_destroy', fake_destroy)
    stubs.Set(vm_utils, 'move_disks', fake_move_disks)
    stubs.Set(vm_utils, 'scan_default_sr', fake_sr)
    stubs.Set(vm_utils, 'get_vdi_for_vm_safely', fake_get_vdi)
    stubs.Set(vm_utils, 'get_sr_path', fake_get_sr_path)
    stubs.Set(vm_utils, 'generate_ephemeral', fake_generate_ephemeral)
示例#2
0
def stub_out_migration_methods(stubs):
    fakesr = fake.create_sr()

    def fake_move_disks(self, instance, disk_info):
        vdi_ref = fake.create_vdi(instance['name'], fakesr)
        vdi_rec = fake.get_record('VDI', vdi_ref)
        vdi_rec['other_config']['nova_disk_type'] = 'root'
        return {'uuid': vdi_rec['uuid'], 'ref': vdi_ref}

    def fake_get_vdi(session, vm_ref):
        vdi_ref_parent = fake.create_vdi('derp-parent', fakesr)
        vdi_rec_parent = fake.get_record('VDI', vdi_ref_parent)
        vdi_ref = fake.create_vdi(
            'derp', fakesr, sm_config={'vhd-parent': vdi_rec_parent['uuid']})
        vdi_rec = session.call_xenapi("VDI.get_record", vdi_ref)
        return vdi_ref, vdi_rec

    def fake_sr(session, *args):
        return fakesr

    def fake_get_sr_path(*args):
        return "fake"

    def fake_destroy(*args, **kwargs):
        pass

    def fake_generate_ephemeral(*args):
        pass

    stubs.Set(vmops.VMOps, '_destroy', fake_destroy)
    stubs.Set(vm_utils, 'move_disks', fake_move_disks)
    stubs.Set(vm_utils, 'scan_default_sr', fake_sr)
    stubs.Set(vm_utils, 'get_vdi_for_vm_safely', fake_get_vdi)
    stubs.Set(vm_utils, 'get_sr_path', fake_get_sr_path)
    stubs.Set(vm_utils, 'generate_ephemeral', fake_generate_ephemeral)
示例#3
0
文件: stubs.py 项目: mygoda/openstack
def stub_out_migration_methods(stubs):
    fakesr = fake.create_sr()

    def fake_move_disks(self, instance, disk_info):
        vdi_ref = fake.create_vdi(instance["name"], fakesr)
        vdi_rec = fake.get_record("VDI", vdi_ref)
        vdi_rec["other_config"]["nova_disk_type"] = "root"
        return {"uuid": vdi_rec["uuid"], "ref": vdi_ref}

    def fake_get_vdi(session, vm_ref):
        vdi_ref_parent = fake.create_vdi("derp-parent", fakesr)
        vdi_rec_parent = fake.get_record("VDI", vdi_ref_parent)
        vdi_ref = fake.create_vdi("derp", fakesr, sm_config={"vhd-parent": vdi_rec_parent["uuid"]})
        vdi_rec = session.call_xenapi("VDI.get_record", vdi_ref)
        return vdi_ref, vdi_rec

    def fake_sr(session, *args):
        return fakesr

    def fake_get_sr_path(*args):
        return "fake"

    def fake_destroy(*args, **kwargs):
        pass

    def fake_generate_ephemeral(*args):
        pass

    stubs.Set(vmops.VMOps, "_destroy", fake_destroy)
    stubs.Set(vm_utils, "move_disks", fake_move_disks)
    stubs.Set(vm_utils, "scan_default_sr", fake_sr)
    stubs.Set(vm_utils, "get_vdi_for_vm_safely", fake_get_vdi)
    stubs.Set(vm_utils, "get_sr_path", fake_get_sr_path)
    stubs.Set(vm_utils, "generate_ephemeral", fake_generate_ephemeral)