Example #1
0
    def _create_instance_in_cell(ctxt, cell, is_deleted=False,
                                 create_request_spec=False):
        with context.target_cell(ctxt, cell) as cctxt:
            inst = objects.Instance(
                context=cctxt,
                uuid=uuidutils.generate_uuid())
            inst.create()

            if is_deleted:
                inst.destroy()

        if create_request_spec:
            # Fake out some fields in the Instance so we don't lazy-load them.
            inst.flavor = objects.Flavor()
            inst.numa_topology = None
            inst.system_metadata = {}
            inst.pci_requests = None
            inst.project_id = 'fake-project'
            inst.user_id = 'fake-user'
            reqspec_obj._create_minimal_request_spec(ctxt, inst)

        return inst
Example #2
0
    def _create_instance_in_cell(ctxt, cell, is_deleted=False,
                                 create_request_spec=False):
        with context.target_cell(ctxt, cell) as cctxt:
            inst = objects.Instance(
                context=cctxt,
                uuid=uuidutils.generate_uuid())
            inst.create()

            if is_deleted:
                inst.destroy()

        if create_request_spec:
            # Fake out some fields in the Instance so we don't lazy-load them.
            inst.flavor = objects.Flavor()
            inst.numa_topology = None
            inst.system_metadata = {}
            inst.pci_requests = None
            inst.project_id = 'fake-project'
            inst.user_id = 'fake-user'
            reqspec_obj._create_minimal_request_spec(ctxt, inst)

        return inst