Example #1
0
 def _test_spawn(
     self,
     image_id,
     kernel_id,
     ramdisk_id,
     instance_type_id="3",
     os_type="linux",
     instance_id=1,
     check_injection=False,
 ):
     stubs.stubout_loopingcall_start(self.stubs)
     values = {
         "id": instance_id,
         "project_id": self.project.id,
         "user_id": self.user.id,
         "image_id": image_id,
         "kernel_id": kernel_id,
         "ramdisk_id": ramdisk_id,
         "instance_type_id": instance_type_id,
         "mac_address": "aa:bb:cc:dd:ee:ff",
         "os_type": os_type,
     }
     instance = db.instance_create(self.context, values)
     self.conn.spawn(instance)
     self.create_vm_record(self.conn, os_type, instance_id)
     self.check_vm_record(self.conn, check_injection)
Example #2
0
    def test_finish_migrate_no_resize_vdi(self):
        instance = db.instance_create(self.context, self.values)

        def fake_vdi_resize(*args, **kwargs):
            raise Exception("This shouldn't be called")

        self.stubs.Set(stubs.FakeSessionForMigrationTests, "VDI_resize_online", fake_vdi_resize)
        stubs.stubout_session(self.stubs, stubs.FakeSessionForMigrationTests)
        stubs.stubout_loopingcall_start(self.stubs)
        conn = xenapi_conn.get_connection(False)
        network_info = [
            (
                {"bridge": "fa0", "id": 0, "injected": False},
                {
                    "broadcast": "192.168.0.255",
                    "dns": ["192.168.0.1"],
                    "gateway": "192.168.0.1",
                    "gateway6": "dead:beef::1",
                    "ip6s": [{"enabled": "1", "ip": "dead:beef::dcad:beff:feef:0", "netmask": "64"}],
                    "ips": [{"enabled": "1", "ip": "192.168.0.100", "netmask": "255.255.255.0"}],
                    "label": "fake",
                    "mac": "DE:AD:BE:EF:00:00",
                    "rxtx_cap": 3,
                },
            )
        ]

        # Resize instance would be determined by the compute call
        conn.finish_migration(
            self.context, instance, dict(base_copy="hurr", cow="durr"), network_info, resize_instance=False
        )
Example #3
0
 def _create_instance(self, instance_id=1, spawn=True):
     """Creates and spawns a test instance."""
     stubs.stubout_loopingcall_start(self.stubs)
     values = {
         "id": instance_id,
         "project_id": self.project_id,
         "user_id": self.user_id,
         "image_ref": 1,
         "kernel_id": 2,
         "ramdisk_id": 3,
         "local_gb": 20,
         "instance_type_id": "3",  # m1.large
         "os_type": "linux",
         "architecture": "x86-64",
     }
     instance = db.instance_create(self.context, values)
     network_info = [
         (
             {"bridge": "fa0", "id": 0, "injected": False},
             {
                 "broadcast": "192.168.0.255",
                 "dns": ["192.168.0.1"],
                 "gateway": "192.168.0.1",
                 "gateway6": "dead:beef::1",
                 "ip6s": [{"enabled": "1", "ip": "dead:beef::dcad:beff:feef:0", "netmask": "64"}],
                 "ips": [{"enabled": "1", "ip": "192.168.0.100", "netmask": "255.255.255.0"}],
                 "label": "fake",
                 "mac": "DE:AD:BE:EF:00:00",
                 "rxtx_cap": 3,
             },
         )
     ]
     if spawn:
         self.conn.spawn(self.context, instance, network_info)
     return instance
Example #4
0
    def test_finish_migrate_no_local_storage(self):
        tiny_type_id = \
                instance_types.get_instance_type_by_name('m1.tiny')['id']
        self.instance_values.update({'instance_type_id': tiny_type_id,
                                     'local_gb': 0})
        instance = db.instance_create(self.context, self.instance_values)

        def fake_vdi_resize(*args, **kwargs):
            raise Exception("This shouldn't be called")

        self.stubs.Set(stubs.FakeSessionForMigrationTests,
                "VDI_resize_online", fake_vdi_resize)
        stubs.stubout_session(self.stubs, stubs.FakeSessionForMigrationTests)
        stubs.stubout_loopingcall_start(self.stubs)
        conn = xenapi_conn.get_connection(False)
        network_info = [({'bridge': 'fa0', 'id': 0, 'injected': False},
                          {'broadcast': '192.168.0.255',
                           'dns': ['192.168.0.1'],
                           'gateway': '192.168.0.1',
                           'gateway6': 'dead:beef::1',
                           'ip6s': [{'enabled': '1',
                                     'ip': 'dead:beef::dcad:beff:feef:0',
                                           'netmask': '64'}],
                           'ips': [{'enabled': '1',
                                    'ip': '192.168.0.100',
                                    'netmask': '255.255.255.0'}],
                           'label': 'fake',
                           'mac': 'DE:AD:BE:EF:00:00',
                           'rxtx_cap': 3})]
        conn.finish_migration(self.context, self.migration, instance,
                              dict(base_copy='hurr', cow='durr'),
                              network_info, resize_instance=True)
Example #5
0
 def _test_spawn(self, image_ref, kernel_id, ramdisk_id,
                 instance_type_id="3", os_type="linux",
                 architecture="x86-64", instance_id=1,
                 check_injection=False):
     stubs.stubout_loopingcall_start(self.stubs)
     values = {'id': instance_id,
               'project_id': self.project.id,
               'user_id': self.user.id,
               'image_ref': image_ref,
               'kernel_id': kernel_id,
               'ramdisk_id': ramdisk_id,
               'instance_type_id': instance_type_id,
               'os_type': os_type,
               'architecture': architecture}
     instance = db.instance_create(self.context, values)
     network_info = [({'bridge': 'fa0', 'id': 0, 'injected': True},
                       {'broadcast': '192.168.0.255',
                        'dns': ['192.168.0.1'],
                        'gateway': '192.168.0.1',
                        'gateway6': 'dead:beef::1',
                        'ip6s': [{'enabled': '1',
                                  'ip': 'dead:beef::dcad:beff:feef:0',
                                        'netmask': '64'}],
                        'ips': [{'enabled': '1',
                                 'ip': '192.168.0.100',
                                 'netmask': '255.255.255.0'}],
                        'label': 'fake',
                        'mac': 'DE:AD:BE:EF:00:00',
                        'rxtx_cap': 3})]
     self.conn.spawn(instance, network_info)
     self.create_vm_record(self.conn, os_type, instance_id)
     self.check_vm_record(self.conn, check_injection)
     self.assertTrue(instance.os_type)
     self.assertTrue(instance.architecture)
Example #6
0
 def _create_instance(self, instance_id=1, spawn=True):
     """Creates and spawns a test instance."""
     stubs.stubout_loopingcall_start(self.stubs)
     values = {
         'id': instance_id,
         'project_id': self.project_id,
         'user_id': self.user_id,
         'image_ref': 1,
         'kernel_id': 2,
         'ramdisk_id': 3,
         'instance_type_id': '3',  # m1.large
         'os_type': 'linux',
         'architecture': 'x86-64'}
     instance = db.instance_create(self.context, values)
     network_info = [({'bridge': 'fa0', 'id': 0, 'injected': False},
                       {'broadcast': '192.168.0.255',
                        'dns': ['192.168.0.1'],
                        'gateway': '192.168.0.1',
                        'gateway6': 'dead:beef::1',
                        'ip6s': [{'enabled': '1',
                                  'ip': 'dead:beef::dcad:beff:feef:0',
                                        'netmask': '64'}],
                        'ips': [{'enabled': '1',
                                 'ip': '192.168.0.100',
                                 'netmask': '255.255.255.0'}],
                        'label': 'fake',
                        'mac': 'DE:AD:BE:EF:00:00',
                        'rxtx_cap': 3})]
     if spawn:
         self.conn.spawn(instance, network_info)
     return instance
Example #7
0
    def test_finish_migrate_no_local_storage(self):
        tiny_type_id = \
                instance_types.get_instance_type_by_name('m1.tiny')['id']
        self.instance_values.update({'instance_type_id': tiny_type_id,
                                     'local_gb': 0})
        instance = db.instance_create(self.context, self.instance_values)

        def fake_vdi_resize(*args, **kwargs):
            raise Exception("This shouldn't be called")

        self.stubs.Set(stubs.FakeSessionForMigrationTests,
                "VDI_resize_online", fake_vdi_resize)
        stubs.stubout_session(self.stubs, stubs.FakeSessionForMigrationTests)
        stubs.stubout_loopingcall_start(self.stubs)
        conn = xenapi_conn.get_connection(False)
        network_info = [({'bridge': 'fa0', 'id': 0, 'injected': False},
                          {'broadcast': '192.168.0.255',
                           'dns': ['192.168.0.1'],
                           'gateway': '192.168.0.1',
                           'gateway6': 'dead:beef::1',
                           'ip6s': [{'enabled': '1',
                                     'ip': 'dead:beef::dcad:beff:feef:0',
                                           'netmask': '64'}],
                           'ips': [{'enabled': '1',
                                    'ip': '192.168.0.100',
                                    'netmask': '255.255.255.0'}],
                           'label': 'fake',
                           'mac': 'DE:AD:BE:EF:00:00',
                           'rxtx_cap': 3})]
        image_meta = {'id': instance.image_ref, 'disk_format': 'vhd'}
        conn.finish_migration(self.context, self.migration, instance,
                              dict(base_copy='hurr', cow='durr'),
                              network_info, image_meta, resize_instance=True)
Example #8
0
    def test_finish_migrate_no_resize_vdi(self):
        instance = db.instance_create(self.context, self.values)

        def fake_vdi_resize(*args, **kwargs):
            raise Exception("This shouldn't be called")

        self.stubs.Set(stubs.FakeSessionForMigrationTests,
                "VDI_resize_online", fake_vdi_resize)
        stubs.stubout_session(self.stubs, stubs.FakeSessionForMigrationTests)
        stubs.stubout_loopingcall_start(self.stubs)
        conn = xenapi_conn.get_connection(False)
        network_info = [({'bridge': 'fa0', 'id': 0, 'injected': False},
                          {'broadcast': '192.168.0.255',
                           'dns': ['192.168.0.1'],
                           'gateway': '192.168.0.1',
                           'gateway6': 'dead:beef::1',
                           'ip6s': [{'enabled': '1',
                                     'ip': 'dead:beef::dcad:beff:feef:0',
                                           'netmask': '64'}],
                           'ips': [{'enabled': '1',
                                    'ip': '192.168.0.100',
                                    'netmask': '255.255.255.0'}],
                           'label': 'fake',
                           'mac': 'DE:AD:BE:EF:00:00',
                           'rxtx_cap': 3})]

        # Resize instance would be determined by the compute call
        conn.finish_migration(instance, dict(base_copy='hurr', cow='durr'),
                           network_info, resize_instance=False)
Example #9
0
    def _test_spawn(
        self,
        image_ref,
        kernel_id,
        ramdisk_id,
        instance_type_id="3",
        os_type="linux",
        hostname="test",
        architecture="x86-64",
        instance_id=1,
        check_injection=False,
        create_record=True,
        empty_dns=False,
    ):
        stubs.stubout_loopingcall_start(self.stubs)
        if create_record:
            values = {
                "id": instance_id,
                "project_id": self.project_id,
                "user_id": self.user_id,
                "image_ref": image_ref,
                "kernel_id": kernel_id,
                "ramdisk_id": ramdisk_id,
                "local_gb": 20,
                "instance_type_id": instance_type_id,
                "os_type": os_type,
                "hostname": hostname,
                "architecture": architecture,
            }
            instance = db.instance_create(self.context, values)
        else:
            instance = db.instance_get(self.context, instance_id)
        network_info = [
            (
                {"bridge": "fa0", "id": 0, "injected": True},
                {
                    "broadcast": "192.168.0.255",
                    "dns": ["192.168.0.1"],
                    "gateway": "192.168.0.1",
                    "gateway6": "dead:beef::1",
                    "ip6s": [{"enabled": "1", "ip": "dead:beef::dcad:beff:feef:0", "netmask": "64"}],
                    "ips": [{"enabled": "1", "ip": "192.168.0.100", "netmask": "255.255.255.0"}],
                    "label": "fake",
                    "mac": "DE:AD:BE:EF:00:00",
                    "rxtx_cap": 3,
                },
            )
        ]
        if empty_dns:
            network_info[0][1]["dns"] = []

        self.conn.spawn(self.context, instance, network_info)
        self.create_vm_record(self.conn, os_type, instance_id)
        self.check_vm_record(self.conn, check_injection)
        self.assertTrue(instance.os_type)
        self.assertTrue(instance.architecture)
Example #10
0
    def test_finish_migrate(self):
        instance = db.instance_create(self.context, self.values)
        self.called = False
        self.fake_vm_start_called = False

        def fake_vm_start(*args, **kwargs):
            self.fake_vm_start_called = True

        def fake_vdi_resize(*args, **kwargs):
            self.called = True

        self.stubs.Set(stubs.FakeSessionForMigrationTests, "VDI_resize_online",
                       fake_vdi_resize)
        self.stubs.Set(vmops.VMOps, '_start', fake_vm_start)

        stubs.stubout_session(self.stubs, stubs.FakeSessionForMigrationTests)
        stubs.stubout_loopingcall_start(self.stubs)
        conn = xenapi_conn.get_connection(False)
        network_info = [({
            'bridge': 'fa0',
            'id': 0,
            'injected': False
        }, {
            'broadcast':
            '192.168.0.255',
            'dns': ['192.168.0.1'],
            'gateway':
            '192.168.0.1',
            'gateway6':
            'dead:beef::1',
            'ip6s': [{
                'enabled': '1',
                'ip': 'dead:beef::dcad:beff:feef:0',
                'netmask': '64'
            }],
            'ips': [{
                'enabled': '1',
                'ip': '192.168.0.100',
                'netmask': '255.255.255.0'
            }],
            'label':
            'fake',
            'mac':
            'DE:AD:BE:EF:00:00',
            'rxtx_cap':
            3
        })]
        conn.finish_migration(self.context,
                              instance,
                              dict(base_copy='hurr', cow='durr'),
                              network_info,
                              resize_instance=True)
        self.assertEqual(self.called, True)
        self.assertEqual(self.fake_vm_start_called, True)
Example #11
0
    def test_resize_xenserver_6(self):
        instance = db.instance_create(self.context, self.values)
        called = {'resize': False}

        def fake_vdi_resize(*args, **kwargs):
            called['resize'] = True

        self.stubs.Set(stubs.FakeSessionForMigrationTests, "VDI_resize",
                       fake_vdi_resize)
        stubs.stubout_session(self.stubs,
                              stubs.FakeSessionForMigrationTests,
                              product_version=(6, 0, 0))
        stubs.stubout_loopingcall_start(self.stubs)
        conn = xenapi_conn.get_connection(False)
        conn._vmops.resize_instance(instance, '')
        self.assertEqual(called['resize'], True)
Example #12
0
 def _create_instance(self):
     """Creates and spawns a test instance."""
     stubs.stubout_loopingcall_start(self.stubs)
     values = {
         'id': 1,
         'project_id': self.project.id,
         'user_id': self.user.id,
         'image_id': 1,
         'kernel_id': 2,
         'ramdisk_id': 3,
         'instance_type_id': '3',  # m1.large
         'mac_address': 'aa:bb:cc:dd:ee:ff',
         'os_type': 'linux'}
     instance = db.instance_create(self.context, values)
     self.conn.spawn(instance)
     return instance
Example #13
0
    def test_resize_xenserver_6(self):
        instance = db.instance_create(self.context, self.instance_values)
        called = {'resize': False}

        def fake_vdi_resize(*args, **kwargs):
            called['resize'] = True

        self.stubs.Set(stubs.FakeSessionForMigrationTests,
                       "VDI_resize", fake_vdi_resize)
        stubs.stubout_session(self.stubs,
                              stubs.FakeSessionForMigrationTests,
                              product_version=(6, 0, 0))
        stubs.stubout_loopingcall_start(self.stubs)
        conn = xenapi_conn.get_connection(False)
        conn._vmops._resize_instance(instance, '')
        self.assertEqual(called['resize'], True)
Example #14
0
    def test_revert_migrate(self):
        instance = db.instance_create(self.context, self.instance_values)
        self.called = False
        self.fake_vm_start_called = False
        self.fake_finish_revert_migration_called = False

        def fake_vm_start(*args, **kwargs):
            self.fake_vm_start_called = True

        def fake_vdi_resize(*args, **kwargs):
            self.called = True

        def fake_finish_revert_migration(*args, **kwargs):
            self.fake_finish_revert_migration_called = True

        self.stubs.Set(stubs.FakeSessionForMigrationTests,
                "VDI_resize_online", fake_vdi_resize)
        self.stubs.Set(vmops.VMOps, '_start', fake_vm_start)
        self.stubs.Set(vmops.VMOps, 'finish_revert_migration',
                       fake_finish_revert_migration)

        stubs.stubout_session(self.stubs, stubs.FakeSessionForMigrationTests)
        stubs.stubout_loopingcall_start(self.stubs)
        conn = xenapi_conn.get_connection(False)
        network_info = [({'bridge': 'fa0', 'id': 0, 'injected': False},
                          {'broadcast': '192.168.0.255',
                           'dns': ['192.168.0.1'],
                           'gateway': '192.168.0.1',
                           'gateway_v6': 'dead:beef::1',
                           'ip6s': [{'enabled': '1',
                                     'ip': 'dead:beef::dcad:beff:feef:0',
                                           'netmask': '64'}],
                           'ips': [{'enabled': '1',
                                    'ip': '192.168.0.100',
                                    'netmask': '255.255.255.0'}],
                           'label': 'fake',
                           'mac': 'DE:AD:BE:EF:00:00',
                           'rxtx_cap': 3})]
        image_meta = {'id': instance.image_ref, 'disk_format': 'vhd'}
        conn.finish_migration(self.context, self.migration, instance,
                              dict(base_copy='hurr', cow='durr'),
                              network_info, image_meta, resize_instance=True)
        self.assertEqual(self.called, True)
        self.assertEqual(self.fake_vm_start_called, True)

        conn.finish_revert_migration(instance)
        self.assertEqual(self.fake_finish_revert_migration_called, True)
Example #15
0
 def _test_spawn(self, image_id, kernel_id, ramdisk_id,
                 instance_type_id="3", os_type="linux",
                 instance_id=1, check_injection=False):
     stubs.stubout_loopingcall_start(self.stubs)
     values = {'id': instance_id,
               'project_id': self.project.id,
               'user_id': self.user.id,
               'image_id': image_id,
               'kernel_id': kernel_id,
               'ramdisk_id': ramdisk_id,
               'instance_type_id': instance_type_id,
               'mac_address': 'aa:bb:cc:dd:ee:ff',
               'os_type': os_type}
     instance = db.instance_create(self.context, values)
     self.conn.spawn(instance)
     self.create_vm_record(self.conn, os_type, instance_id)
     self.check_vm_record(self.conn, check_injection)
Example #16
0
    def test_revert_migrate(self):
        instance = db.instance_create(self.context, self.values)
        self.called = False
        self.fake_vm_start_called = False
        self.fake_revert_migration_called = False

        def fake_vm_start(*args, **kwargs):
            self.fake_vm_start_called = True

        def fake_vdi_resize(*args, **kwargs):
            self.called = True

        def fake_revert_migration(*args, **kwargs):
            self.fake_revert_migration_called = True

        self.stubs.Set(stubs.FakeSessionForMigrationTests, "VDI_resize_online", fake_vdi_resize)
        self.stubs.Set(vmops.VMOps, "_start", fake_vm_start)
        self.stubs.Set(vmops.VMOps, "revert_migration", fake_revert_migration)

        stubs.stubout_session(self.stubs, stubs.FakeSessionForMigrationTests)
        stubs.stubout_loopingcall_start(self.stubs)
        conn = xenapi_conn.get_connection(False)
        network_info = [
            (
                {"bridge": "fa0", "id": 0, "injected": False},
                {
                    "broadcast": "192.168.0.255",
                    "dns": ["192.168.0.1"],
                    "gateway": "192.168.0.1",
                    "gateway6": "dead:beef::1",
                    "ip6s": [{"enabled": "1", "ip": "dead:beef::dcad:beff:feef:0", "netmask": "64"}],
                    "ips": [{"enabled": "1", "ip": "192.168.0.100", "netmask": "255.255.255.0"}],
                    "label": "fake",
                    "mac": "DE:AD:BE:EF:00:00",
                    "rxtx_cap": 3,
                },
            )
        ]
        conn.finish_migration(
            self.context, instance, dict(base_copy="hurr", cow="durr"), network_info, resize_instance=True
        )
        self.assertEqual(self.called, True)
        self.assertEqual(self.fake_vm_start_called, True)

        conn.revert_migration(instance)
        self.assertEqual(self.fake_revert_migration_called, True)
Example #17
0
 def _create_instance(self):
     """Creates and spawns a test instance."""
     stubs.stubout_loopingcall_start(self.stubs)
     values = {
         'id': 1,
         'project_id': self.project.id,
         'user_id': self.user.id,
         'image_id': 1,
         'kernel_id': 2,
         'ramdisk_id': 3,
         'instance_type_id': '3',  # m1.large
         'mac_address': 'aa:bb:cc:dd:ee:ff',
         'os_type': 'linux'
     }
     instance = db.instance_create(self.context, values)
     self.conn.spawn(instance)
     return instance
Example #18
0
 def _create_instance(self):
     """Creates and spawns a test instance."""
     stubs.stubout_loopingcall_start(self.stubs)
     values = {
         "id": 1,
         "project_id": self.project.id,
         "user_id": self.user.id,
         "image_id": 1,
         "kernel_id": 2,
         "ramdisk_id": 3,
         "instance_type_id": "3",  # m1.large
         "mac_address": "aa:bb:cc:dd:ee:ff",
         "os_type": "linux",
     }
     instance = db.instance_create(self.context, values)
     self.conn.spawn(instance)
     return instance
Example #19
0
    def _test_spawn(self, image_ref, kernel_id, ramdisk_id,
                    instance_type_id="3", os_type="linux",
                    hostname="test", architecture="x86-64", instance_id=1,
                    check_injection=False,
                    create_record=True, empty_dns=False):
        stubs.stubout_loopingcall_start(self.stubs)
        if create_record:
            instance_values = {'id': instance_id,
                      'project_id': self.project_id,
                      'user_id': self.user_id,
                      'image_ref': image_ref,
                      'kernel_id': kernel_id,
                      'ramdisk_id': ramdisk_id,
                      'local_gb': 20,
                      'instance_type_id': instance_type_id,
                      'os_type': os_type,
                      'hostname': hostname,
                      'architecture': architecture}
            instance = db.instance_create(self.context, instance_values)
        else:
            instance = db.instance_get(self.context, instance_id)
        network_info = [({'bridge': 'fa0', 'id': 0, 'injected': True},
                          {'broadcast': '192.168.0.255',
                           'dns': ['192.168.0.1'],
                           'gateway': '192.168.0.1',
                           'gateway_v6': 'dead:beef::1',
                           'ip6s': [{'enabled': '1',
                                     'ip': 'dead:beef::dcad:beff:feef:0',
                                           'netmask': '64'}],
                           'ips': [{'enabled': '1',
                                    'ip': '192.168.0.100',
                                    'netmask': '255.255.255.0'}],
                           'label': 'fake',
                           'mac': 'DE:AD:BE:EF:00:00',
                           'rxtx_cap': 3})]
        if empty_dns:
            network_info[0][1]['dns'] = []

        image_meta = {'id': glance_stubs.FakeGlance.IMAGE_VHD,
                      'disk_format': 'vhd'}
        self.conn.spawn(self.context, instance, image_meta, network_info)
        self.create_vm_record(self.conn, os_type, instance_id)
        self.check_vm_record(self.conn, check_injection)
        self.assertTrue(instance.os_type)
        self.assertTrue(instance.architecture)
Example #20
0
    def _test_spawn(self, image_ref, kernel_id, ramdisk_id,
                    instance_type_id="3", os_type="linux",
                    hostname="test", architecture="x86-64", instance_id=1,
                    check_injection=False,
                    create_record=True, empty_dns=False):
        stubs.stubout_loopingcall_start(self.stubs)
        if create_record:
            instance_values = {'id': instance_id,
                      'project_id': self.project_id,
                      'user_id': self.user_id,
                      'image_ref': image_ref,
                      'kernel_id': kernel_id,
                      'ramdisk_id': ramdisk_id,
                      'local_gb': 20,
                      'instance_type_id': instance_type_id,
                      'os_type': os_type,
                      'hostname': hostname,
                      'architecture': architecture}
            instance = db.instance_create(self.context, instance_values)
        else:
            instance = db.instance_get(self.context, instance_id)
        network_info = [({'bridge': 'fa0', 'id': 0, 'injected': True},
                          {'broadcast': '192.168.0.255',
                           'dns': ['192.168.0.1'],
                           'gateway': '192.168.0.1',
                           'gateway6': 'dead:beef::1',
                           'ip6s': [{'enabled': '1',
                                     'ip': 'dead:beef::dcad:beff:feef:0',
                                           'netmask': '64'}],
                           'ips': [{'enabled': '1',
                                    'ip': '192.168.0.100',
                                    'netmask': '255.255.255.0'}],
                           'label': 'fake',
                           'mac': 'DE:AD:BE:EF:00:00',
                           'rxtx_cap': 3})]
        if empty_dns:
            network_info[0][1]['dns'] = []

        image_meta = {'id': glance_stubs.FakeGlance.IMAGE_VHD,
                      'disk_format': 'vhd'}
        self.conn.spawn(self.context, instance, image_meta, network_info)
        self.create_vm_record(self.conn, os_type, instance_id)
        self.check_vm_record(self.conn, check_injection)
        self.assertTrue(instance.os_type)
        self.assertTrue(instance.architecture)
Example #21
0
 def test_finish_resize(self):
     instance = db.instance_create(self.context, self.values)
     stubs.stubout_session(self.stubs, stubs.FakeSessionForMigrationTests)
     stubs.stubout_loopingcall_start(self.stubs)
     conn = xenapi_conn.get_connection(False)
     network_info = [({'bridge': 'fa0', 'id': 0, 'injected': False},
                       {'broadcast': '192.168.0.255',
                        'dns': ['192.168.0.1'],
                        'gateway': '192.168.0.1',
                        'gateway6': 'dead:beef::1',
                        'ip6s': [{'enabled': '1',
                                  'ip': 'dead:beef::dcad:beff:feef:0',
                                        'netmask': '64'}],
                        'ips': [{'enabled': '1',
                                 'ip': '192.168.0.100',
                                 'netmask': '255.255.255.0'}],
                        'label': 'fake',
                        'mac': 'DE:AD:BE:EF:00:00',
                        'rxtx_cap': 3})]
     conn.finish_resize(instance, dict(base_copy='hurr', cow='durr'),
                                                        network_info)
Example #22
0
 def _test_spawn(self,
                 image_id,
                 kernel_id,
                 ramdisk_id,
                 instance_type_id="3",
                 os_type="linux",
                 instance_id=1,
                 check_injection=False):
     stubs.stubout_loopingcall_start(self.stubs)
     values = {
         'id': instance_id,
         'project_id': self.project.id,
         'user_id': self.user.id,
         'image_id': image_id,
         'kernel_id': kernel_id,
         'ramdisk_id': ramdisk_id,
         'instance_type_id': instance_type_id,
         'mac_address': 'aa:bb:cc:dd:ee:ff',
         'os_type': os_type
     }
     instance = db.instance_create(self.context, values)
     self.conn.spawn(instance)
     self.create_vm_record(self.conn, os_type, instance_id)
     self.check_vm_record(self.conn, check_injection)
Example #23
0
 def test_finish_resize(self):
     instance = db.instance_create(self.context, self.values)
     stubs.stubout_session(self.stubs, stubs.FakeSessionForMigrationTests)
     stubs.stubout_loopingcall_start(self.stubs)
     conn = xenapi_conn.get_connection(False)
     conn.finish_resize(instance, dict(base_copy='hurr', cow='durr'))
Example #24
0
 def test_finish_resize(self):
     instance = db.instance_create(self.context, self.values)
     stubs.stubout_session(self.stubs, stubs.FakeSessionForMigrationTests)
     stubs.stubout_loopingcall_start(self.stubs)
     conn = xenapi_conn.get_connection(False)
     conn.finish_resize(instance, dict(base_copy="hurr", cow="durr"))