Ejemplo n.º 1
0
 def test_legacy_mapping_from_object_list(self):
     bdm1 = objects.BlockDeviceMapping()
     bdm1 = objects.BlockDeviceMapping._from_db_object(
         None, bdm1, fake_block_device.FakeDbBlockDeviceDict(
             self.new_mapping[0]))
     bdm2 = objects.BlockDeviceMapping()
     bdm2 = objects.BlockDeviceMapping._from_db_object(
         None, bdm2, fake_block_device.FakeDbBlockDeviceDict(
             self.new_mapping[1]))
     bdmlist = objects.BlockDeviceMappingList()
     bdmlist.objects = [bdm1, bdm2]
     block_device.legacy_mapping(bdmlist)
Ejemplo n.º 2
0
 def block_device_mapping_get_all_by_instance(self, context, instance,
                                              legacy):
     bdms = self.db.block_device_mapping_get_all_by_instance(
         context, instance['uuid'])
     if legacy:
         bdms = block_device.legacy_mapping(bdms)
     return jsonutils.to_primitive(bdms)
Ejemplo n.º 3
0
    def _handle_cell_delete(self, context, instance, method_name):
        if not instance.cell_name:
            delete_type = method_name == 'soft_delete' and 'soft' or 'hard'
            self.cells_rpcapi.instance_delete_everywhere(context,
                    instance, delete_type)
            bdms = block_device.legacy_mapping(
                self.db.block_device_mapping_get_all_by_instance(
                    context, instance.uuid))
            # NOTE(danms): If we try to delete an instance with no cell,
            # there isn't anything to salvage, so we can hard-delete here.
            super(ComputeCellsAPI, self)._local_delete(context, instance, bdms,
                                                       method_name,
                                                       self._do_delete)
            return

        method = getattr(super(ComputeCellsAPI, self), method_name)
        method(context, instance)
Ejemplo n.º 4
0
    def test_legacy_mapping_source_image(self):
        got_legacy = block_device.legacy_mapping(self.new_mapping)

        for legacy, expected in zip(got_legacy, self.legacy_mapping):
            self.assertThat(expected, matchers.IsSubDictOf(legacy))
Ejemplo n.º 5
0
 def block_device_mapping_get_all_by_instance(self, context, instance, legacy):
     bdms = self.db.block_device_mapping_get_all_by_instance(context, instance["uuid"])
     if legacy:
         bdms = block_device.legacy_mapping(bdms)
     return jsonutils.to_primitive(bdms)