Example #1
0
 def host_call_plugin_swap(self, _1, _2, plugin, method, _5):
     sr_ref = fake.get_all('SR')[0]
     vdi_ref = fake.create_vdi('', False, sr_ref, False)
     vdi_rec = fake.get_record('VDI', vdi_ref)
     if plugin == "glance" and method == "download_vhd":
         swap_vdi_ref = fake.create_vdi('', False, sr_ref, False)
         swap_vdi_rec = fake.get_record('VDI', swap_vdi_ref)
         ret_str = json.dumps(
                 [dict(vdi_type='os', vdi_uuid=vdi_rec['uuid']),
                 dict(vdi_type='swap', vdi_uuid=swap_vdi_rec['uuid'])])
     else:
         ret_str = vdi_rec['uuid']
     return '<string>%s</string>' % ret_str
Example #2
0
 def host_call_plugin_swap(self, _1, _2, plugin, method, _5):
     sr_ref = fake.get_all('SR')[0]
     vdi_ref = fake.create_vdi('', False, sr_ref, False)
     vdi_rec = fake.get_record('VDI', vdi_ref)
     if plugin == "glance" and method == "download_vhd":
         swap_vdi_ref = fake.create_vdi('', False, sr_ref, False)
         swap_vdi_rec = fake.get_record('VDI', swap_vdi_ref)
         ret_str = json.dumps(
                 [dict(vdi_type='os', vdi_uuid=vdi_rec['uuid']),
                 dict(vdi_type='swap', vdi_uuid=swap_vdi_rec['uuid'])])
     else:
         ret_str = vdi_rec['uuid']
     return '<string>%s</string>' % ret_str
Example #3
0
    def test_get_instance_vdis_for_sr(self):
        vm_ref = fake.create_vm("foo", "Running")
        sr_ref = fake.create_sr()

        vdi_1 = fake.create_vdi("vdiname1", sr_ref)
        vdi_2 = fake.create_vdi("vdiname2", sr_ref)

        for vdi_ref in [vdi_1, vdi_2]:
            fake.create_vbd(vm_ref, vdi_ref)

        stubs.stubout_session(self.stubs, fake.SessionBase)
        driver = xenapi_conn.XenAPIDriver(False)

        result = list(vm_utils.get_instance_vdis_for_sr(driver._session, vm_ref, sr_ref))

        self.assertEquals([vdi_1, vdi_2], result)
Example #4
0
    def fake_fetch_image(cls, session, instance_id, image, user, project,
                         type):
        # Stubout wait_for_task
        def fake_wait_for_task(self, task, id):
            class FakeEvent:

                def send(self, value):
                    self.rv = value

                def wait(self):
                    return self.rv

            done = FakeEvent()
            self._poll_task(id, task, done)
            rv = done.wait()
            return rv

        def fake_loop(self):
            pass

        stubs.Set(xenapi_conn.XenAPISession, 'wait_for_task',
                  fake_wait_for_task)

        stubs.Set(xenapi_conn.XenAPISession, '_stop_loop', fake_loop)

        from nova.virt.xenapi.fake import create_vdi
        name_label = "instance-%s" % instance_id
        #TODO: create fake SR record
        sr_ref = "fakesr"
        vdi_ref = create_vdi(name_label=name_label, read_only=False,
                             sr_ref=sr_ref, sharable=False)
        vdi_rec = session.get_xenapi().VDI.get_record(vdi_ref)
        vdi_uuid = vdi_rec['uuid']
        return vdi_uuid
Example #5
0
    def fake_fetch_image(cls, session, instance_id, image, user, project,
                         type):
        # Stubout wait_for_task
        def fake_wait_for_task(self, id, task):
            class FakeEvent:

                def send(self, value):
                    self.rv = value

                def wait(self):
                    return self.rv

            done = FakeEvent()
            self._poll_task(id, task, done)
            rv = done.wait()
            return rv

        def fake_loop(self):
            pass

        stubs.Set(xenapi_conn.XenAPISession, 'wait_for_task',
                  fake_wait_for_task)

        stubs.Set(xenapi_conn.XenAPISession, '_stop_loop', fake_loop)

        from nova.virt.xenapi.fake import create_vdi
        name_label = "instance-%s" % instance_id
        #TODO: create fake SR record
        sr_ref = "fakesr"
        vdi_ref = create_vdi(name_label=name_label, read_only=False,
                             sr_ref=sr_ref, sharable=False)
        vdi_rec = session.get_xenapi().VDI.get_record(vdi_ref)
        vdi_uuid = vdi_rec['uuid']
        return vdi_uuid
Example #6
0
    def test_get_instance_vdis_for_sr(self):
        vm_ref = fake.create_vm("foo", "Running")
        sr_ref = fake.create_sr()

        vdi_1 = fake.create_vdi('vdiname1', sr_ref)
        vdi_2 = fake.create_vdi('vdiname2', sr_ref)

        for vdi_ref in [vdi_1, vdi_2]:
            fake.create_vbd(vm_ref, vdi_ref)

        stubs.stubout_session(self.stubs, fake.SessionBase)
        driver = xenapi_conn.XenAPIDriver(False)

        result = list(vm_utils.get_instance_vdis_for_sr(
            driver._session, vm_ref, sr_ref))

        self.assertEquals([vdi_1, vdi_2], result)
Example #7
0
    def VM_snapshot(self, session_ref, vm_ref, label):
        status = "Running"
        template_vm_ref = fake.create_vm(label, status, is_a_template=True, is_control_domain=False)

        sr_ref = "fakesr"
        template_vdi_ref = fake.create_vdi(label, read_only=True, sr_ref=sr_ref, sharable=False)

        template_vbd_ref = fake.create_vbd(template_vm_ref, template_vdi_ref)
        return template_vm_ref
Example #8
0
File: stubs.py Project: termie/nova
 def fake_get_vdi(cls, session, vm_ref):
     vdi_ref = fake.create_vdi(name_label='derp',
                               read_only=False,
                               sr_ref='herp',
                               sharable=False)
     vdi_rec = session.get_xenapi().VDI.get_record(vdi_ref)
     return vdi_ref, {
         'uuid': vdi_rec['uuid'],
     }
Example #9
0
File: stubs.py Project: kiall/nova
    def VM_snapshot(self, session_ref, vm_ref, label):
        status = "Running"
        template_vm_ref = fake.create_vm(label, status, is_a_template=True,
            is_control_domain=False)

        sr_ref = "fakesr"
        template_vdi_ref = fake.create_vdi(label, sr_ref, read_only=True)

        template_vbd_ref = fake.create_vbd(template_vm_ref, template_vdi_ref)
        return template_vm_ref
Example #10
0
    def fake_wait_for_vhd_coalesce(session, instance_id, sr_ref, vdi_ref, original_parent_uuid):
        from nova.virt.xenapi.fake import create_vdi

        name_label = "instance-%s" % instance_id
        # TODO: create fake SR record
        sr_ref = "fakesr"
        vdi_ref = create_vdi(name_label=name_label, read_only=False, sr_ref=sr_ref, sharable=False)
        vdi_rec = session.get_xenapi().VDI.get_record(vdi_ref)
        vdi_uuid = vdi_rec["uuid"]
        return vdi_uuid
Example #11
0
 def fake_fetch_image(cls, session, instance_id, image, user, project,
                      type):
     from nova.virt.xenapi.fake import create_vdi
     name_label = "instance-%s" % instance_id
     #TODO: create fake SR record
     sr_ref = "fakesr"
     vdi_ref = create_vdi(name_label=name_label, read_only=False,
                          sr_ref=sr_ref, sharable=False)
     vdi_rec = session.get_xenapi().VDI.get_record(vdi_ref)
     vdi_uuid = vdi_rec['uuid']
     return [dict(vdi_type='os', vdi_uuid=vdi_uuid)]
Example #12
0
 def fake_wait_for_vhd_coalesce(session, instance_id, sr_ref, vdi_ref,
                           original_parent_uuid):
     from nova.virt.xenapi.fake import create_vdi
     name_label = "instance-%s" % instance_id
     #TODO: create fake SR record
     sr_ref = "fakesr"
     vdi_ref = create_vdi(name_label=name_label, read_only=False,
                          sr_ref=sr_ref, sharable=False)
     vdi_rec = session.get_xenapi().VDI.get_record(vdi_ref)
     vdi_uuid = vdi_rec['uuid']
     return vdi_uuid
Example #13
0
 def fake_fetch_image(cls, context, session, instance, image, user,
                      project, type):
     from nova.virt.xenapi.fake import create_vdi
     name_label = "instance-%s" % instance.id
     #TODO: create fake SR record
     sr_ref = "fakesr"
     vdi_ref = create_vdi(name_label=name_label, read_only=False,
                          sr_ref=sr_ref, sharable=False)
     vdi_rec = session.get_xenapi().VDI.get_record(vdi_ref)
     vdi_uuid = vdi_rec['uuid']
     return [dict(vdi_type='os', vdi_uuid=vdi_uuid)]
Example #14
0
File: stubs.py Project: termie/nova
 def host_call_plugin(self, _1, _2, plugin, method, _5):
     # If the call is for 'copy_kernel_vdi' return None.
     if method == 'copy_kernel_vdi':
         return
     sr_ref = fake.get_all('SR')[0]
     vdi_ref = fake.create_vdi('', False, sr_ref, False)
     vdi_rec = fake.get_record('VDI', vdi_ref)
     if plugin == "glance" and method == "download_vhd":
         ret_str = json.dumps(
             [dict(vdi_type='os', vdi_uuid=vdi_rec['uuid'])])
     else:
         ret_str = vdi_rec['uuid']
     return '<string>%s</string>' % ret_str
Example #15
0
 def host_call_plugin(self, _1, _2, plugin, method, _5):
     # If the call is for 'copy_kernel_vdi' return None.
     if method == 'copy_kernel_vdi':
         return
     sr_ref = fake.get_all('SR')[0]
     vdi_ref = fake.create_vdi('', False, sr_ref, False)
     vdi_rec = fake.get_record('VDI', vdi_ref)
     if plugin == "glance" and method == "download_vhd":
         ret_str = json.dumps([dict(vdi_type='os',
                 vdi_uuid=vdi_rec['uuid'])])
     else:
         ret_str = vdi_rec['uuid']
     return '<string>%s</string>' % ret_str
Example #16
0
 def host_call_plugin(self, _1, _2, _3, _4, _5):
     sr_ref = fake.get_all('SR')[0]
     vdi_ref = fake.create_vdi('', False, sr_ref, False)
     vdi_rec = fake.get_record('VDI', vdi_ref)
     return '<string>%s</string>' % vdi_rec['uuid']
Example #17
0
 def fake_get_vdi(cls, session, vm_ref):
     vdi_ref = fake.create_vdi('derp', 'herp')
     vdi_rec = session.call_xenapi("VDI.get_record", vdi_ref)
     return vdi_ref, {'uuid': vdi_rec['uuid'], }
Example #18
0
 def host_call_plugin(self, _1, _2, _3, _4, _5):
     sr_ref = fake.get_all('SR')[0]
     vdi_ref = fake.create_vdi('', False, sr_ref, False)
     vdi_rec = fake.get_record('VDI', vdi_ref)
     return '<string>%s</string>' % vdi_rec['uuid']
Example #19
0
def _make_fake_vdi():
    sr_ref = fake.get_all('SR')[0]
    vdi_ref = fake.create_vdi('', sr_ref)
    vdi_rec = fake.get_record('VDI', vdi_ref)
    return vdi_rec['uuid']
Example #20
0
 def VDI_snapshot(self, session_ref, vm_ref, _1):
     sr_ref = "fakesr"
     return fake.create_vdi('fakelabel', sr_ref, read_only=True)
Example #21
0
 def fake_get_vdi(cls, session, vm_ref):
     vdi_ref = fake.create_vdi(name_label='derp', read_only=False,
                          sr_ref='herp', sharable=False)
     vdi_rec = session.call_xenapi("VDI.get_record", vdi_ref)
     return vdi_ref, {'uuid': vdi_rec['uuid'], }
Example #22
0
 def VDI_snapshot(self, session_ref, vm_ref, _1):
     sr_ref = "fakesr"
     return fake.create_vdi('fakelabel', sr_ref, read_only=True)
Example #23
0
File: stubs.py Project: kiall/nova
 def fake_get_vdi(session, vm_ref):
     vdi_ref = fake.create_vdi('derp', 'herp')
     vdi_rec = session.call_xenapi("VDI.get_record", vdi_ref)
     return vdi_ref, {'uuid': vdi_rec['uuid'], }
Example #24
0
 def fake_move_disks(self, instance, disk_info):
     vdi_ref = fake.create_vdi('new', 'fake')
     return fake.get_record('VDI', vdi_ref)['uuid']
Example #25
0
 def host_call_plugin(self, _1, _2, _3, _4, _5):
     sr_ref = fake.get_all("SR")[0]
     vdi_ref = fake.create_vdi("", False, sr_ref, False)
     vdi_rec = fake.get_record("VDI", vdi_ref)
     return "<string>%s</string>" % vdi_rec["uuid"]
Example #26
0
File: stubs.py Project: kiall/nova
 def fake_move_disks(self, instance, disk_info):
     vdi_ref = fake.create_vdi(instance['name'], 'fake')
     vdi_rec = fake.get_record('VDI', vdi_ref)
     vdi_rec['other_config']['nova_disk_type'] = 'root'
     return {'uuid': vdi_rec['uuid'], 'ref': vdi_ref}
Example #27
0
 def fake_move_disks(self, instance, disk_info):
     vdi_ref = fake.create_vdi(instance["name"], "fake")
     vdi_rec = fake.get_record("VDI", vdi_ref)
     vdi_rec["other_config"]["nova_disk_type"] = "root"
     return {"uuid": vdi_rec["uuid"], "ref": vdi_ref}
Example #28
0
def _make_fake_vdi():
    sr_ref = fake.get_all('SR')[0]
    vdi_ref = fake.create_vdi('', False, sr_ref, False)
    vdi_rec = fake.get_record('VDI', vdi_ref)
    return vdi_rec['uuid']
Example #29
0
def _make_fake_vdi():
    sr_ref = fake.get_all("SR")[0]
    vdi_ref = fake.create_vdi("", sr_ref)
    vdi_rec = fake.get_record("VDI", vdi_ref)
    return vdi_rec["uuid"]
Example #30
0
 def fake_get_vdi(cls, session, vm_ref):
     vdi_ref = fake.create_vdi(name_label="derp", read_only=False, sr_ref="herp", sharable=False)
     vdi_rec = session.get_xenapi().VDI.get_record(vdi_ref)
     return vdi_ref, {"uuid": vdi_rec["uuid"]}
Example #31
0
 def fake_get_vdi(session, vm_ref):
     vdi_ref = fake.create_vdi("derp", "herp")
     vdi_rec = session.call_xenapi("VDI.get_record", vdi_ref)
     return vdi_ref, {"uuid": vdi_rec["uuid"]}