Пример #1
0
 def test_from_legacy_with_pre_result(self):
     test_bdmi = migrate_data.LibvirtLiveMigrateBDMInfo(
         serial='123',
         bus='scsi',
         dev='/dev/sda',
         type='disk',
         format='qcow2',
         boot_index=1,
         connection_info='myinfo')
     obj = migrate_data.LibvirtLiveMigrateData(
         is_volume_backed=False,
         filename='foo',
         image_type='rbd',
         block_migration=False,
         disk_over_commit=False,
         disk_available_mb=123,
         is_shared_instance_path=False,
         is_shared_block_storage=False,
         instance_relative_path='foo/bar',
         graphics_listen_addrs={'vnc': '127.0.0.1'},
         serial_listen_addr='127.0.0.1',
         bdms=[test_bdmi])
     obj2 = migrate_data.LibvirtLiveMigrateData()
     obj2.from_legacy_dict(obj.to_legacy_dict())
     self.assertEqual(obj.to_legacy_dict(), obj2.to_legacy_dict())
Пример #2
0
 def test_vif_migrate_data(self):
     source_vif = network_model.VIF(
         id=uuids.port_id,
         network=network_model.Network(id=uuids.network_id),
         type=network_model.VIF_TYPE_OVS,
         vnic_type=network_model.VNIC_TYPE_NORMAL,
         active=True,
         profile={'migrating_to': 'dest-host'})
     vif_details_dict = {'port_filter': True}
     profile_dict = {'trusted': False}
     vif_data = objects.VIFMigrateData(
         port_id=uuids.port_id,
         vnic_type=network_model.VNIC_TYPE_NORMAL,
         vif_type=network_model.VIF_TYPE_BRIDGE,
         vif_details=vif_details_dict,
         profile=profile_dict,
         host='dest-host',
         source_vif=source_vif)
     # Make sure the vif_details and profile fields are converted and
     # stored properly.
     self.assertEqual(jsonutils.dumps(vif_details_dict),
                      vif_data.vif_details_json)
     self.assertEqual(jsonutils.dumps(profile_dict), vif_data.profile_json)
     self.assertDictEqual(vif_details_dict, vif_data.vif_details)
     self.assertDictEqual(profile_dict, vif_data.profile)
     obj = migrate_data.LibvirtLiveMigrateData(
         file_backed_memory_discard=False)
     obj.vifs = [vif_data]
     manifest = ovo_base.obj_tree_get_versions(obj.obj_name())
     primitive = obj.obj_to_primitive(target_version='1.8',
                                      version_manifest=manifest)
     self.assertIn('file_backed_memory_discard',
                   primitive['nova_object.data'])
     self.assertNotIn('vifs', primitive['nova_object.data'])
    def test_obj_make_compatible(self):
        obj = migrate_data.LibvirtLiveMigrateData(
            src_supports_native_luks=True,
            old_vol_attachment_ids={uuids.volume: uuids.attachment},
            supported_perf_events=[],
            serial_listen_addr='127.0.0.1',
            target_connect_addr='127.0.0.1',
            dst_wants_file_backed_memory=False,
            file_backed_memory_discard=False)

        data = lambda x: x['nova_object.data']

        primitive = data(obj.obj_to_primitive())
        self.assertIn('file_backed_memory_discard', primitive)
        primitive = data(obj.obj_to_primitive(target_version='1.0'))
        self.assertNotIn('target_connect_addr', primitive)
        self.assertNotIn('supported_perf_events', primitive)
        self.assertNotIn('old_vol_attachment_ids', primitive)
        self.assertNotIn('src_supports_native_luks', primitive)
        self.assertNotIn('dst_wants_file_backed_memory', primitive)
        primitive = data(obj.obj_to_primitive(target_version='1.1'))
        self.assertNotIn('serial_listen_ports', primitive)
        primitive = data(obj.obj_to_primitive(target_version='1.2'))
        self.assertNotIn('supported_perf_events', primitive)
        primitive = data(obj.obj_to_primitive(target_version='1.3'))
        self.assertNotIn('old_vol_attachment_ids', primitive)
        primitive = data(obj.obj_to_primitive(target_version='1.4'))
        self.assertNotIn('src_supports_native_luks', primitive)
        primitive = data(obj.obj_to_primitive(target_version='1.6'))
        self.assertNotIn('dst_wants_file_backed_memory', primitive)
        primitive = data(obj.obj_to_primitive(target_version='1.7'))
        self.assertNotIn('file_backed_memory_discard', primitive)
Пример #4
0
 def test_from_legacy_dict(self):
     obj = migrate_data.LibvirtLiveMigrateData(
         is_volume_backed=False,
         filename='foo',
         image_type='rbd',
         block_migration=False,
         disk_over_commit=False,
         disk_available_mb=123,
         is_shared_instance_path=False,
         is_shared_block_storage=False,
         instance_relative_path='foo/bar')
     legacy = obj.to_legacy_dict()
     legacy['ignore_this_thing'] = True
     obj2 = migrate_data.LibvirtLiveMigrateData()
     obj2.from_legacy_dict(legacy)
     self.assertEqual(obj.filename, obj2.filename)
Пример #5
0
 def test_obj_make_compatible(self):
     obj = migrate_data.LibvirtLiveMigrateData(
         old_vol_attachment_ids={uuids.volume: uuids.attachment})
     primitive = obj.obj_to_primitive(target_version='1.0')
     self.assertNotIn('old_vol_attachment_ids', primitive)
     primitive = obj.obj_to_primitive(target_version='1.3')
     self.assertNotIn('old_vol_attachment_ids', primitive)
Пример #6
0
    def test_obj_make_compatible(self):
        obj = migrate_data.LibvirtLiveMigrateData(
            src_supports_native_luks=True,
            old_vol_attachment_ids={uuids.volume: uuids.attachment},
            supported_perf_events=[],
            serial_listen_addr='127.0.0.1',
            target_connect_addr='127.0.0.1',
            dst_wants_file_backed_memory=False,
            file_backed_memory_discard=False,
            src_supports_numa_live_migration=True,
            dst_supports_numa_live_migration=True,
            dst_numa_info=migrate_data.LibvirtLiveMigrateNUMAInfo())
        manifest = ovo_base.obj_tree_get_versions(obj.obj_name())

        data = lambda x: x['nova_object.data']

        primitive = data(obj.obj_to_primitive())
        self.assertIn('file_backed_memory_discard', primitive)
        primitive = data(
            obj.obj_to_primitive(target_version='1.0',
                                 version_manifest=manifest))
        self.assertNotIn('target_connect_addr', primitive)
        self.assertNotIn('supported_perf_events', primitive)
        self.assertNotIn('old_vol_attachment_ids', primitive)
        self.assertNotIn('src_supports_native_luks', primitive)
        self.assertNotIn('dst_wants_file_backed_memory', primitive)
        primitive = data(
            obj.obj_to_primitive(target_version='1.1',
                                 version_manifest=manifest))
        self.assertNotIn('serial_listen_ports', primitive)
        primitive = data(
            obj.obj_to_primitive(target_version='1.2',
                                 version_manifest=manifest))
        self.assertNotIn('supported_perf_events', primitive)
        primitive = data(
            obj.obj_to_primitive(target_version='1.3',
                                 version_manifest=manifest))
        self.assertNotIn('old_vol_attachment_ids', primitive)
        primitive = data(
            obj.obj_to_primitive(target_version='1.4',
                                 version_manifest=manifest))
        self.assertNotIn('src_supports_native_luks', primitive)
        primitive = data(
            obj.obj_to_primitive(target_version='1.6',
                                 version_manifest=manifest))
        self.assertNotIn('dst_wants_file_backed_memory', primitive)
        primitive = data(
            obj.obj_to_primitive(target_version='1.7',
                                 version_manifest=manifest))
        self.assertNotIn('file_backed_memory_discard', primitive)
        primitive = data(
            obj.obj_to_primitive(target_version='1.9',
                                 version_manifest=manifest))
        self.assertNotIn('dst_numa_info', primitive)
        self.assertNotIn('src_supports_numa_live_migration', primitive)
        self.assertNotIn('dst_supports_numa_live_migration', primitive)
Пример #7
0
    def test_obj_make_compatible(self):
        props = {
            'serial_listen_addr': '127.0.0.1',
            'serial_listen_ports': [1000, 10001, 10002, 10003],
        }

        obj = migrate_data.LibvirtLiveMigrateData(**props)
        primitive = obj.obj_to_primitive()
        self.assertIn('serial_listen_ports', primitive['nova_object.data'])
        obj.obj_make_compatible(primitive['nova_object.data'], '1.1')
        self.assertNotIn('serial_listen_ports', primitive['nova_object.data'])
Пример #8
0
    def check_can_live_migrate_destination(self, context, instance,
                                           src_compute_info, dst_compute_info,
                                           block_migration=False,
                                           disk_over_commit=False):
        data = migrate_data.LibvirtLiveMigrateData()
        data.filename = 'fake'
        data.image_type = CONF.libvirt.images_type
        data.graphics_listen_addr_vnc = CONF.vnc.server_listen
        data.graphics_listen_addr_spice = CONF.spice.server_listen
        data.serial_listen_addr = None
        data.block_migration = block_migration
        data.disk_over_commit = disk_over_commit or False  # called with None
        data.disk_available_mb = 100000
        data.is_shared_block_storage = True
        data.is_shared_instance_path = True

        return data
Пример #9
0
 def test_to_legacy_dict_with_pre_result(self):
     test_bdmi = migrate_data.LibvirtLiveMigrateBDMInfo(
         serial='123',
         bus='scsi',
         dev='/dev/sda',
         type='disk',
         format='qcow2',
         boot_index=1,
         connection_info='myinfo')
     obj = migrate_data.LibvirtLiveMigrateData(
         is_volume_backed=False,
         filename='foo',
         image_type='rbd',
         block_migration=False,
         disk_over_commit=False,
         disk_available_mb=123,
         is_shared_instance_path=False,
         is_shared_block_storage=False,
         instance_relative_path='foo/bar',
         graphics_listen_addr_vnc='127.0.0.1',
         serial_listen_addr='127.0.0.1',
         bdms=[test_bdmi])
     legacy = obj.to_legacy_dict(pre_migration_result=True)
     self.assertIn('pre_live_migration_result', legacy)
     expected = {
         'graphics_listen_addrs': {
             'vnc': '127.0.0.1',
             'spice': None
         },
         'target_connect_addr': None,
         'serial_listen_addr': '127.0.0.1',
         'volume': {
             '123': {
                 'connection_info': 'myinfo',
                 'disk_info': {
                     'bus': 'scsi',
                     'dev': '/dev/sda',
                     'type': 'disk',
                     'format': 'qcow2',
                     'boot_index': '1',
                 }
             }
         }
     }
     self.assertEqual(expected, legacy['pre_live_migration_result'])
Пример #10
0
    def check_can_live_migrate_destination(self, context, instance,
                                           src_compute_info, dst_compute_info,
                                           block_migration=False,
                                           disk_over_commit=False):
        data = migrate_data.LibvirtLiveMigrateData()
        data.filename = 'fake'
        data.image_type = CONF.libvirt.images_type
        data.graphics_listen_addr_vnc = CONF.vnc.server_listen
        data.graphics_listen_addr_spice = CONF.spice.server_listen
        data.serial_listen_addr = None
        # Notes(eliqiao): block_migration and disk_over_commit are not
        # nullable, so just don't set them if they are None
        if block_migration is not None:
            data.block_migration = block_migration
        if disk_over_commit is not None:
            data.disk_over_commit = disk_over_commit
        data.disk_available_mb = 100000
        data.is_shared_block_storage = True
        data.is_shared_instance_path = True

        return data
Пример #11
0
 def test_obj_make_compatible(self):
     obj = migrate_data.LibvirtLiveMigrateData(
         src_supports_native_luks=True,
         old_vol_attachment_ids={uuids.volume: uuids.attachment},
         supported_perf_events=[],
         serial_listen_addr='127.0.0.1',
         target_connect_addr='127.0.0.1')
     primitive = obj.obj_to_primitive(target_version='1.0')
     self.assertNotIn('target_connect_addr', primitive)
     self.assertNotIn('serial_listen_addr=', primitive)
     self.assertNotIn('supported_perf_events', primitive)
     self.assertNotIn('old_vol_attachment_ids', primitive)
     self.assertNotIn('src_supports_native_luks', primitive)
     primitive = obj.obj_to_primitive(target_version='1.1')
     self.assertNotIn('serial_listen_addr=', primitive)
     primitive = obj.obj_to_primitive(target_version='1.2')
     self.assertNotIn('supported_perf_events', primitive)
     primitive = obj.obj_to_primitive(target_version='1.3')
     self.assertNotIn('old_vol_attachment_ids', primitive)
     primitive = obj.obj_to_primitive(target_version='1.4')
     self.assertNotIn('src_supports_native_luks', primitive)
Пример #12
0
 def test_to_legacy_dict(self):
     obj = migrate_data.LibvirtLiveMigrateData(
         is_volume_backed=False,
         filename='foo',
         image_type='rbd',
         block_migration=False,
         disk_over_commit=False,
         disk_available_mb=123,
         is_shared_instance_path=False,
         is_shared_block_storage=False,
         instance_relative_path='foo/bar')
     expected = {
         'is_volume_backed': False,
         'filename': 'foo',
         'image_type': 'rbd',
         'block_migration': False,
         'disk_over_commit': False,
         'disk_available_mb': 123,
         'is_shared_instance_path': False,
         'is_shared_block_storage': False,
         'instance_relative_path': 'foo/bar',
     }
     self.assertEqual(expected, obj.to_legacy_dict())
Пример #13
0
 def test_detect_implementation_libvirt_early(self):
     legacy = migrate_data.LibvirtLiveMigrateData(
         image_type='foo').to_legacy_dict()
     self.assertIsInstance(
         migrate_data.LiveMigrateData.detect_implementation(legacy),
         migrate_data.LibvirtLiveMigrateData)
Пример #14
0
 def test_detect_implementation_libvirt(self):
     legacy = migrate_data.LibvirtLiveMigrateData(
         instance_relative_path='foo').to_legacy_dict()
     self.assertIsInstance(
         migrate_data.LiveMigrateData.detect_implementation(legacy),
         migrate_data.LibvirtLiveMigrateData)