def setUp(self):
        super(XenAPIMigrateInstance, self).setUp()
        self.stubs = stubout.StubOutForTesting()
        FLAGS.target_host = '127.0.0.1'
        FLAGS.xenapi_connection_url = 'test_url'
        FLAGS.xenapi_connection_password = '******'
        db_fakes.stub_out_db_instance_api(self.stubs)
        stubs.stub_out_get_target(self.stubs)
        xenapi_fake.reset()
        xenapi_fake.create_network('fake', FLAGS.flat_network_bridge)
        self.manager = manager.AuthManager()
        self.user = self.manager.create_user('fake',
                                             'fake',
                                             'fake',
                                             admin=True)
        self.project = self.manager.create_project('fake', 'fake', 'fake')
        self.context = context.RequestContext('fake', 'fake', False)
        self.values = {
            'id': 1,
            'project_id': self.project.id,
            'user_id': self.user.id,
            'image_id': 1,
            'kernel_id': None,
            'ramdisk_id': None,
            'local_gb': 5,
            'instance_type_id': '3',  # m1.large
            'mac_address': 'aa:bb:cc:dd:ee:ff',
            'os_type': 'linux'
        }

        fake_utils.stub_out_utils_execute(self.stubs)
        stubs.stub_out_migration_methods(self.stubs)
        stubs.stubout_get_this_vm_uuid(self.stubs)
        glance_stubs.stubout_glance_client(self.stubs, glance_stubs.FakeGlance)
Exemple #2
0
    def setUp(self):
        super(XenAPIMigrateInstance, self).setUp()
        self.stubs = stubout.StubOutForTesting()
        FLAGS.target_host = '127.0.0.1'
        FLAGS.xenapi_connection_url = 'test_url'
        FLAGS.xenapi_connection_password = '******'
        db_fakes.stub_out_db_instance_api(self.stubs)
        stubs.stub_out_get_target(self.stubs)
        xenapi_fake.reset()
        xenapi_fake.create_network('fake', FLAGS.flat_network_bridge)
        self.user_id = 'fake'
        self.project_id = 'fake'
        self.context = context.RequestContext(self.user_id, self.project_id)
        self.values = {'id': 1,
                  'project_id': self.project_id,
                  'user_id': self.user_id,
                  'image_ref': 1,
                  'kernel_id': None,
                  'ramdisk_id': None,
                  'local_gb': 5,
                  'instance_type_id': '3',  # m1.large
                  'os_type': 'linux',
                  'architecture': 'x86-64'}

        fake_utils.stub_out_utils_execute(self.stubs)
        stubs.stub_out_migration_methods(self.stubs)
        stubs.stubout_get_this_vm_uuid(self.stubs)
        glance_stubs.stubout_glance_client(self.stubs)
Exemple #3
0
    def setUp(self):
        super(XenAPIMigrateInstance, self).setUp()
        self.stubs = stubout.StubOutForTesting()
        FLAGS.target_host = '127.0.0.1'
        FLAGS.xenapi_connection_url = 'test_url'
        FLAGS.xenapi_connection_password = '******'
        db_fakes.stub_out_db_instance_api(self.stubs)
        stubs.stub_out_get_target(self.stubs)
        xenapi_fake.reset()
        self.manager = manager.AuthManager()
        self.user = self.manager.create_user('fake', 'fake', 'fake',
                                             admin=True)
        self.project = self.manager.create_project('fake', 'fake', 'fake')
        self.values = {'name': 1, 'id': 1,
                  'project_id': self.project.id,
                  'user_id': self.user.id,
                  'image_id': 1,
                  'kernel_id': None,
                  'ramdisk_id': None,
                  'instance_type': 'm1.large',
                  'mac_address': 'aa:bb:cc:dd:ee:ff',
                  'os_type': 'linux'}

        stubs.stub_out_migration_methods(self.stubs)
        glance_stubs.stubout_glance_client(self.stubs,
                                           glance_stubs.FakeGlance)
Exemple #4
0
    def setUp(self):
        super(XenAPIMigrateInstance, self).setUp()
        self.stubs = stubout.StubOutForTesting()
        FLAGS.target_host = '127.0.0.1'
        FLAGS.xenapi_connection_url = 'test_url'
        FLAGS.xenapi_connection_password = '******'
        db_fakes.stub_out_db_instance_api(self.stubs)
        stubs.stub_out_get_target(self.stubs)
        xenapi_fake.reset()
        self.manager = manager.AuthManager()
        self.user = self.manager.create_user('fake',
                                             'fake',
                                             'fake',
                                             admin=True)
        self.project = self.manager.create_project('fake', 'fake', 'fake')
        self.values = {
            'name': 1,
            'id': 1,
            'project_id': self.project.id,
            'user_id': self.user.id,
            'image_id': 1,
            'kernel_id': None,
            'ramdisk_id': None,
            'instance_type': 'm1.large',
            'mac_address': 'aa:bb:cc:dd:ee:ff',
            'os_type': 'linux'
        }

        stubs.stub_out_migration_methods(self.stubs)
        glance_stubs.stubout_glance_client(self.stubs, glance_stubs.FakeGlance)
Exemple #5
0
    def setUp(self):
        super(XenAPIMigrateInstance, self).setUp()
        self.stubs = stubout.StubOutForTesting()
        FLAGS.target_host = "127.0.0.1"
        FLAGS.xenapi_connection_url = "test_url"
        FLAGS.xenapi_connection_password = "******"
        db_fakes.stub_out_db_instance_api(self.stubs)
        stubs.stub_out_get_target(self.stubs)
        xenapi_fake.reset()
        xenapi_fake.create_network("fake", FLAGS.flat_network_bridge)
        self.manager = manager.AuthManager()
        self.user = self.manager.create_user("fake", "fake", "fake", admin=True)
        self.project = self.manager.create_project("fake", "fake", "fake")
        self.context = context.RequestContext("fake", "fake", False)
        self.values = {
            "id": 1,
            "project_id": self.project.id,
            "user_id": self.user.id,
            "image_id": 1,
            "kernel_id": None,
            "ramdisk_id": None,
            "local_gb": 5,
            "instance_type_id": "3",  # m1.large
            "mac_address": "aa:bb:cc:dd:ee:ff",
            "os_type": "linux",
        }

        fake_utils.stub_out_utils_execute(self.stubs)
        stubs.stub_out_migration_methods(self.stubs)
        stubs.stubout_get_this_vm_uuid(self.stubs)
        glance_stubs.stubout_glance_client(self.stubs, glance_stubs.FakeGlance)
Exemple #6
0
 def setUp(self):
     super(XenAPIVMTestCase, self).setUp()
     self.network = utils.import_object(FLAGS.network_manager)
     self.stubs = stubout.StubOutForTesting()
     self.flags(xenapi_connection_url='test_url',
                xenapi_connection_password='******',
                instance_name_template='%d')
     xenapi_fake.reset()
     xenapi_fake.create_local_srs()
     xenapi_fake.create_local_pifs()
     db_fakes.stub_out_db_instance_api(self.stubs)
     xenapi_fake.create_network('fake', FLAGS.flat_network_bridge)
     stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
     stubs.stubout_get_this_vm_uuid(self.stubs)
     stubs.stubout_stream_disk(self.stubs)
     stubs.stubout_is_vdi_pv(self.stubs)
     self.stubs.Set(vmops.VMOps, 'reset_network', reset_network)
     self.stubs.Set(vmops.VMOps, '_find_rescue_vbd_ref',
                    _find_rescue_vbd_ref)
     stubs.stub_out_vm_methods(self.stubs)
     glance_stubs.stubout_glance_client(self.stubs)
     fake_utils.stub_out_utils_execute(self.stubs)
     self.user_id = 'fake'
     self.project_id = 'fake'
     self.context = context.RequestContext(self.user_id, self.project_id)
     self.conn = xenapi_conn.get_connection(False)
Exemple #7
0
    def test_spawn_netinject_file(self):
        FLAGS.xenapi_image_service = 'glance'
        db_fakes.stub_out_db_instance_api(self.stubs, injected=True)

        self._tee_executed = False

        def _tee_handler(cmd, **kwargs):
            input = kwargs.get('process_input', None)
            self.assertNotEqual(input, None)
            config = [line.strip() for line in input.split("\n")]
            # Find the start of eth0 configuration and check it
            index = config.index('auto eth0')
            self.assertEquals(config[index + 1:index + 8], [
                'iface eth0 inet static',
                'address 192.168.0.100',
                'netmask 255.255.255.0',
                'broadcast 192.168.0.255',
                'gateway 192.168.0.1',
                'dns-nameservers 192.168.0.1',
                ''])
            self._tee_executed = True
            return '', ''

        fake_utils.fake_execute_set_repliers([
            # Capture the sudo tee .../etc/network/interfaces command
            (r'(sudo\s+)?tee.*interfaces', _tee_handler),
        ])
        FLAGS.xenapi_image_service = 'glance'
        self._test_spawn(glance_stubs.FakeGlance.IMAGE_MACHINE,
                         glance_stubs.FakeGlance.IMAGE_KERNEL,
                         glance_stubs.FakeGlance.IMAGE_RAMDISK,
                         check_injection=True)
        self.assertTrue(self._tee_executed)
Exemple #8
0
 def setUp(self):
     super(XenAPIVMTestCase, self).setUp()
     self.manager = manager.AuthManager()
     self.user = self.manager.create_user("fake", "fake", "fake", admin=True)
     self.project = self.manager.create_project("fake", "fake", "fake")
     self.network = utils.import_object(FLAGS.network_manager)
     self.stubs = stubout.StubOutForTesting()
     self.flags(
         xenapi_connection_url="test_url", xenapi_connection_password="******", instance_name_template="%d"
     )
     xenapi_fake.reset()
     xenapi_fake.create_local_srs()
     xenapi_fake.create_local_pifs()
     db_fakes.stub_out_db_instance_api(self.stubs)
     xenapi_fake.create_network("fake", FLAGS.flat_network_bridge)
     stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
     stubs.stubout_get_this_vm_uuid(self.stubs)
     stubs.stubout_stream_disk(self.stubs)
     stubs.stubout_is_vdi_pv(self.stubs)
     self.stubs.Set(VMOps, "reset_network", reset_network)
     stubs.stub_out_vm_methods(self.stubs)
     glance_stubs.stubout_glance_client(self.stubs, glance_stubs.FakeGlance)
     fake_utils.stub_out_utils_execute(self.stubs)
     self.context = context.RequestContext("fake", "fake", False)
     self.conn = xenapi_conn.get_connection(False)
    def setUp(self):
        super(XenAPIMigrateInstance, self).setUp()
        self.stubs = stubout.StubOutForTesting()
        FLAGS.target_host = '127.0.0.1'
        FLAGS.xenapi_connection_url = 'test_url'
        FLAGS.xenapi_connection_password = '******'
        db_fakes.stub_out_db_instance_api(self.stubs)
        stubs.stub_out_get_target(self.stubs)
        xenapi_fake.reset()
        xenapi_fake.create_network('fake', FLAGS.flat_network_bridge)
        self.manager = manager.AuthManager()
        self.user = self.manager.create_user('fake', 'fake', 'fake',
                                             admin=True)
        self.project = self.manager.create_project('fake', 'fake', 'fake')
        self.context = context.RequestContext('fake', 'fake', False)
        self.values = {'id': 1,
                  'project_id': self.project.id,
                  'user_id': self.user.id,
                  'image_id': 1,
                  'kernel_id': None,
                  'ramdisk_id': None,
                  'local_gb': 5,
                  'instance_type_id': '3',  # m1.large
                  'mac_address': 'aa:bb:cc:dd:ee:ff',
                  'os_type': 'linux'}

        fake_utils.stub_out_utils_execute(self.stubs)
        stubs.stub_out_migration_methods(self.stubs)
        stubs.stubout_get_this_vm_uuid(self.stubs)
        glance_stubs.stubout_glance_client(self.stubs,
                                           glance_stubs.FakeGlance)
Exemple #10
0
 def setUp(self):
     super(XenAPIVMTestCase, self).setUp()
     self.network = utils.import_object(FLAGS.network_manager)
     self.stubs = stubout.StubOutForTesting()
     self.flags(xenapi_connection_url='test_url',
                xenapi_connection_password='******',
                instance_name_template='%d')
     xenapi_fake.reset()
     xenapi_fake.create_local_srs()
     xenapi_fake.create_local_pifs()
     db_fakes.stub_out_db_instance_api(self.stubs)
     xenapi_fake.create_network('fake', FLAGS.flat_network_bridge)
     stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
     stubs.stubout_get_this_vm_uuid(self.stubs)
     stubs.stubout_stream_disk(self.stubs)
     stubs.stubout_is_vdi_pv(self.stubs)
     self.stubs.Set(vmops.VMOps, 'reset_network', reset_network)
     self.stubs.Set(vmops.VMOps, '_find_rescue_vbd_ref',
             _find_rescue_vbd_ref)
     stubs.stub_out_vm_methods(self.stubs)
     glance_stubs.stubout_glance_client(self.stubs)
     fake_utils.stub_out_utils_execute(self.stubs)
     self.user_id = 'fake'
     self.project_id = 'fake'
     self.context = context.RequestContext(self.user_id, self.project_id)
     self.conn = xenapi_conn.get_connection(False)
    def setUp(self):
        super(XenAPIMigrateInstance, self).setUp()
        self.stubs = stubout.StubOutForTesting()
        self.flags(target_host="127.0.0.1", xenapi_connection_url="test_url", xenapi_connection_password="******")
        db_fakes.stub_out_db_instance_api(self.stubs)
        stubs.stub_out_get_target(self.stubs)
        xenapi_fake.reset()
        xenapi_fake.create_network("fake", FLAGS.flat_network_bridge)
        self.user_id = "fake"
        self.project_id = "fake"
        self.context = context.RequestContext(self.user_id, self.project_id)
        self.values = {
            "id": 1,
            "project_id": self.project_id,
            "user_id": self.user_id,
            "image_ref": 1,
            "kernel_id": None,
            "ramdisk_id": None,
            "local_gb": 5,
            "instance_type_id": "3",  # m1.large
            "os_type": "linux",
            "architecture": "x86-64",
        }

        fake_utils.stub_out_utils_execute(self.stubs)
        stubs.stub_out_migration_methods(self.stubs)
        stubs.stubout_get_this_vm_uuid(self.stubs)
        glance_stubs.stubout_glance_client(self.stubs)
    def test_spawn_netinject_xenstore(self):
        FLAGS.xenapi_image_service = 'glance'
        db_fakes.stub_out_db_instance_api(self.stubs, injected=True)

        self._tee_executed = False

        def _mount_handler(cmd, *ignore_args, **ignore_kwargs):
            # When mounting, create real files under the mountpoint to simulate
            # files in the mounted filesystem

            # mount point will be the last item of the command list
            self._tmpdir = cmd[len(cmd) - 1]
            LOG.debug(
                _('Creating files in %s to simulate guest agent' %
                  self._tmpdir))
            os.makedirs(os.path.join(self._tmpdir, 'usr', 'sbin'))
            # Touch the file using open
            open(
                os.path.join(self._tmpdir, 'usr', 'sbin',
                             'xe-update-networking'), 'w').close()
            return '', ''

        def _umount_handler(cmd, *ignore_args, **ignore_kwargs):
            # Umount would normall make files in the m,ounted filesystem
            # disappear, so do that here
            LOG.debug(
                _('Removing simulated guest agent files in %s' % self._tmpdir))
            os.remove(
                os.path.join(self._tmpdir, 'usr', 'sbin',
                             'xe-update-networking'))
            os.rmdir(os.path.join(self._tmpdir, 'usr', 'sbin'))
            os.rmdir(os.path.join(self._tmpdir, 'usr'))
            return '', ''

        def _tee_handler(cmd, *ignore_args, **ignore_kwargs):
            self._tee_executed = True
            return '', ''

        fake_utils.fake_execute_set_repliers([
            (r'(sudo\s+)?mount', _mount_handler),
            (r'(sudo\s+)?umount', _umount_handler),
            (r'(sudo\s+)?tee.*interfaces', _tee_handler)
        ])
        self._test_spawn(1, 2, 3, check_injection=True)

        # tee must not run in this case, where an injection-capable
        # guest agent is detected
        self.assertFalse(self._tee_executed)
Exemple #13
0
 def setUp(self):
     super(XenAPIVolumeTestCase, self).setUp()
     self.stubs = stubout.StubOutForTesting()
     FLAGS.target_host = '127.0.0.1'
     FLAGS.xenapi_connection_url = 'test_url'
     FLAGS.xenapi_connection_password = '******'
     db_fakes.stub_out_db_instance_api(self.stubs)
     stubs.stub_out_get_target(self.stubs)
     xenapi_fake.reset()
     self.values = {'name': 1, 'id': 1,
               'project_id': 'fake',
               'user_id': 'fake',
               'image_id': 1,
               'kernel_id': 2,
               'ramdisk_id': 3,
               'instance_type': 'm1.large',
               'mac_address': 'aa:bb:cc:dd:ee:ff',
               }
Exemple #14
0
    def test_spawn_netinject_xenstore(self):
        FLAGS.xenapi_image_service = 'glance'
        db_fakes.stub_out_db_instance_api(self.stubs, injected=True)

        self._tee_executed = False

        def _mount_handler(cmd, *ignore_args, **ignore_kwargs):
            # When mounting, create real files under the mountpoint to simulate
            # files in the mounted filesystem

            # mount point will be the last item of the command list
            self._tmpdir = cmd[len(cmd) - 1]
            LOG.debug(_('Creating files in %s to simulate guest agent' %
                self._tmpdir))
            os.makedirs(os.path.join(self._tmpdir, 'usr', 'sbin'))
            # Touch the file using open
            open(os.path.join(self._tmpdir, 'usr', 'sbin',
                'xe-update-networking'), 'w').close()
            return '', ''

        def _umount_handler(cmd, *ignore_args, **ignore_kwargs):
            # Umount would normall make files in the m,ounted filesystem
            # disappear, so do that here
            LOG.debug(_('Removing simulated guest agent files in %s' %
                self._tmpdir))
            os.remove(os.path.join(self._tmpdir, 'usr', 'sbin',
                'xe-update-networking'))
            os.rmdir(os.path.join(self._tmpdir, 'usr', 'sbin'))
            os.rmdir(os.path.join(self._tmpdir, 'usr'))
            return '', ''

        def _tee_handler(cmd, *ignore_args, **ignore_kwargs):
            self._tee_executed = True
            return '', ''

        fake_utils.fake_execute_set_repliers([
            (r'(sudo\s+)?mount', _mount_handler),
            (r'(sudo\s+)?umount', _umount_handler),
            (r'(sudo\s+)?tee.*interfaces', _tee_handler)])
        self._test_spawn(1, 2, 3, check_injection=True)

        # tee must not run in this case, where an injection-capable
        # guest agent is detected
        self.assertFalse(self._tee_executed)
Exemple #15
0
 def setUp(self):
     super(XenAPIVolumeTestCase, self).setUp()
     self.stubs = stubout.StubOutForTesting()
     self.context = context.RequestContext('fake', 'fake', False)
     FLAGS.target_host = '127.0.0.1'
     FLAGS.xenapi_connection_url = 'test_url'
     FLAGS.xenapi_connection_password = '******'
     db_fakes.stub_out_db_instance_api(self.stubs)
     stubs.stub_out_get_target(self.stubs)
     xenapi_fake.reset()
     self.values = {'id': 1,
               'project_id': 'fake',
               'user_id': 'fake',
               'image_ref': 1,
               'kernel_id': 2,
               'ramdisk_id': 3,
               'instance_type_id': '3',  # m1.large
               'os_type': 'linux',
               'architecture': 'x86-64'}
Exemple #16
0
    def test_spawn_netinject_file(self):
        FLAGS.xenapi_image_service = "glance"
        db_fakes.stub_out_db_instance_api(self.stubs, injected=True)

        self._tee_executed = False

        def _tee_handler(cmd, **kwargs):
            input = kwargs.get("process_input", None)
            self.assertNotEqual(input, None)
            config = [line.strip() for line in input.split("\n")]
            # Find the start of eth0 configuration and check it
            index = config.index("auto eth0")
            self.assertEquals(
                config[index + 1 : index + 8],
                [
                    "iface eth0 inet static",
                    "address 10.0.0.3",
                    "netmask 255.255.255.0",
                    "broadcast 10.0.0.255",
                    "gateway 10.0.0.1",
                    "dns-nameservers 10.0.0.2",
                    "",
                ],
            )
            self._tee_executed = True
            return "", ""

        fake_utils.fake_execute_set_repliers(
            [
                # Capture the sudo tee .../etc/network/interfaces command
                (r"(sudo\s+)?tee.*interfaces", _tee_handler)
            ]
        )
        FLAGS.xenapi_image_service = "glance"
        self._test_spawn(
            glance_stubs.FakeGlance.IMAGE_MACHINE,
            glance_stubs.FakeGlance.IMAGE_KERNEL,
            glance_stubs.FakeGlance.IMAGE_RAMDISK,
            check_injection=True,
        )
        self.assertTrue(self._tee_executed)
Exemple #17
0
 def setUp(self):
     super(XenAPIVolumeTestCase, self).setUp()
     self.stubs = stubout.StubOutForTesting()
     FLAGS.target_host = '127.0.0.1'
     FLAGS.xenapi_connection_url = 'test_url'
     FLAGS.xenapi_connection_password = '******'
     db_fakes.stub_out_db_instance_api(self.stubs)
     stubs.stub_out_get_target(self.stubs)
     xenapi_fake.reset()
     self.values = {
         'name': 1,
         'id': 1,
         'project_id': 'fake',
         'user_id': 'fake',
         'image_id': 1,
         'kernel_id': 2,
         'ramdisk_id': 3,
         'instance_type': 'm1.large',
         'mac_address': 'aa:bb:cc:dd:ee:ff',
         'os_type': 'linux'
     }
Exemple #18
0
 def setUp(self):
     super(XenAPIVolumeTestCase, self).setUp()
     self.stubs = stubout.StubOutForTesting()
     self.context = context.RequestContext("fake", "fake", False)
     FLAGS.target_host = "127.0.0.1"
     FLAGS.xenapi_connection_url = "test_url"
     FLAGS.xenapi_connection_password = "******"
     db_fakes.stub_out_db_instance_api(self.stubs)
     stubs.stub_out_get_target(self.stubs)
     xenapi_fake.reset()
     self.values = {
         "id": 1,
         "project_id": "fake",
         "user_id": "fake",
         "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",
     }
Exemple #19
0
 def setUp(self):
     super(XenAPIVMTestCase, self).setUp()
     self.manager = manager.AuthManager()
     self.user = self.manager.create_user('fake', 'fake', 'fake',
                                          admin=True)
     self.project = self.manager.create_project('fake', 'fake', 'fake')
     self.network = utils.import_object(FLAGS.network_manager)
     self.stubs = stubout.StubOutForTesting()
     FLAGS.xenapi_connection_url = 'test_url'
     FLAGS.xenapi_connection_password = '******'
     xenapi_fake.reset()
     xenapi_fake.create_local_srs()
     db_fakes.stub_out_db_instance_api(self.stubs)
     xenapi_fake.create_network('fake', FLAGS.flat_network_bridge)
     stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
     stubs.stubout_get_this_vm_uuid(self.stubs)
     stubs.stubout_stream_disk(self.stubs)
     self.stubs.Set(VMOps, 'reset_network', reset_network)
     glance_stubs.stubout_glance_client(self.stubs,
                                        glance_stubs.FakeGlance)
     self.conn = xenapi_conn.get_connection(False)
Exemple #20
0
 def setUp(self):
     super(XenAPIVolumeTestCase, self).setUp()
     self.stubs = stubout.StubOutForTesting()
     self.user_id = 'fake'
     self.project_id = 'fake'
     self.context = context.RequestContext(self.user_id, self.project_id)
     FLAGS.target_host = '127.0.0.1'
     FLAGS.xenapi_connection_url = 'test_url'
     FLAGS.xenapi_connection_password = '******'
     db_fakes.stub_out_db_instance_api(self.stubs)
     stubs.stub_out_get_target(self.stubs)
     xenapi_fake.reset()
     self.values = {'id': 1,
               'project_id': self.user_id,
               'user_id': 'fake',
               'image_ref': 1,
               'kernel_id': 2,
               'ramdisk_id': 3,
               'instance_type_id': '3',  # m1.large
               'os_type': 'linux',
               'architecture': 'x86-64'}
Exemple #21
0
    def setUp(self):
        super(XenAPIMigrateInstance, self).setUp()
        self.stubs = stubout.StubOutForTesting()
        self.flags(target_host='127.0.0.1',
                xenapi_connection_url='test_url',
                xenapi_connection_password='******')
        db_fakes.stub_out_db_instance_api(self.stubs)
        stubs.stub_out_get_target(self.stubs)
        xenapi_fake.reset()
        xenapi_fake.create_network('fake', FLAGS.flat_network_bridge)
        self.user_id = 'fake'
        self.project_id = 'fake'
        self.context = context.RequestContext(self.user_id, self.project_id)
        self.instance_values = {'id': 1,
                  'project_id': self.project_id,
                  'user_id': self.user_id,
                  'image_ref': 1,
                  'kernel_id': None,
                  'ramdisk_id': None,
                  'local_gb': 5,
                  'instance_type_id': '3',  # m1.large
                  'os_type': 'linux',
                  'architecture': 'x86-64'}

        migration_values = {
            'source_compute': 'nova-compute',
            'dest_compute': 'nova-compute',
            'dest_host': '10.127.5.114',
            'status': 'post-migrating',
            'instance_uuid': '15f23e6a-cc6e-4d22-b651-d9bdaac316f7',
            'old_instance_type_id': 5,
            'new_instance_type_id': 1
        }
        self.migration = db.migration_create(
            context.get_admin_context(), migration_values)

        fake_utils.stub_out_utils_execute(self.stubs)
        stubs.stub_out_migration_methods(self.stubs)
        stubs.stubout_get_this_vm_uuid(self.stubs)
        glance_stubs.stubout_glance_client(self.stubs)
Exemple #22
0
    def setUp(self):
        super(XenAPIMigrateInstance, self).setUp()
        self.stubs = stubout.StubOutForTesting()
        self.flags(target_host='127.0.0.1',
                xenapi_connection_url='test_url',
                xenapi_connection_password='******')
        db_fakes.stub_out_db_instance_api(self.stubs)
        stubs.stub_out_get_target(self.stubs)
        xenapi_fake.reset()
        xenapi_fake.create_network('fake', FLAGS.flat_network_bridge)
        self.user_id = 'fake'
        self.project_id = 'fake'
        self.context = context.RequestContext(self.user_id, self.project_id)
        self.instance_values = {'id': 1,
                  'project_id': self.project_id,
                  'user_id': self.user_id,
                  'image_ref': 1,
                  'kernel_id': None,
                  'ramdisk_id': None,
                  'local_gb': 5,
                  'instance_type_id': '3',  # m1.large
                  'os_type': 'linux',
                  'architecture': 'x86-64'}

        migration_values = {
            'source_compute': 'nova-compute',
            'dest_compute': 'nova-compute',
            'dest_host': '10.127.5.114',
            'status': 'post-migrating',
            'instance_uuid': '15f23e6a-cc6e-4d22-b651-d9bdaac316f7',
            'old_instance_type_id': 5,
            'new_instance_type_id': 1
        }
        self.migration = db.migration_create(
            context.get_admin_context(), migration_values)

        fake_utils.stub_out_utils_execute(self.stubs)
        stubs.stub_out_migration_methods(self.stubs)
        stubs.stubout_get_this_vm_uuid(self.stubs)
        glance_stubs.stubout_glance_client(self.stubs)
 def setUp(self):
     super(XenAPIVolumeTestCase, self).setUp()
     self.stubs = stubout.StubOutForTesting()
     self.user_id = "fake"
     self.project_id = "fake"
     self.context = context.RequestContext(self.user_id, self.project_id)
     self.flags(target_host="127.0.0.1", xenapi_connection_url="test_url", xenapi_connection_password="******")
     db_fakes.stub_out_db_instance_api(self.stubs)
     stubs.stub_out_get_target(self.stubs)
     xenapi_fake.reset()
     self.values = {
         "id": 1,
         "project_id": self.user_id,
         "user_id": "fake",
         "image_ref": 1,
         "kernel_id": 2,
         "ramdisk_id": 3,
         "local_gb": 20,
         "instance_type_id": "3",  # m1.large
         "os_type": "linux",
         "architecture": "x86-64",
     }
    def test_spawn_netinject_xenstore(self):
        db_fakes.stub_out_db_instance_api(self.stubs, injected=True)

        self._tee_executed = False

        def _mount_handler(cmd, *ignore_args, **ignore_kwargs):
            # When mounting, create real files under the mountpoint to simulate
            # files in the mounted filesystem

            # mount point will be the last item of the command list
            self._tmpdir = cmd[len(cmd) - 1]
            LOG.debug(_("Creating files in %s to simulate guest agent" % self._tmpdir))
            os.makedirs(os.path.join(self._tmpdir, "usr", "sbin"))
            # Touch the file using open
            open(os.path.join(self._tmpdir, "usr", "sbin", "xe-update-networking"), "w").close()
            return "", ""

        def _umount_handler(cmd, *ignore_args, **ignore_kwargs):
            # Umount would normall make files in the m,ounted filesystem
            # disappear, so do that here
            LOG.debug(_("Removing simulated guest agent files in %s" % self._tmpdir))
            os.remove(os.path.join(self._tmpdir, "usr", "sbin", "xe-update-networking"))
            os.rmdir(os.path.join(self._tmpdir, "usr", "sbin"))
            os.rmdir(os.path.join(self._tmpdir, "usr"))
            return "", ""

        def _tee_handler(cmd, *ignore_args, **ignore_kwargs):
            self._tee_executed = True
            return "", ""

        fake_utils.fake_execute_set_repliers(
            [(r"mount", _mount_handler), (r"umount", _umount_handler), (r"tee.*interfaces", _tee_handler)]
        )
        self._test_spawn(1, 2, 3, check_injection=True)

        # tee must not run in this case, where an injection-capable
        # guest agent is detected
        self.assertFalse(self._tee_executed)
Exemple #25
0
 def setUp(self):
     super(XenAPIVMTestCase, self).setUp()
     self.manager = manager.AuthManager()
     self.user = self.manager.create_user('fake',
                                          'fake',
                                          'fake',
                                          admin=True)
     self.project = self.manager.create_project('fake', 'fake', 'fake')
     self.network = utils.import_object(FLAGS.network_manager)
     self.stubs = stubout.StubOutForTesting()
     FLAGS.xenapi_connection_url = 'test_url'
     FLAGS.xenapi_connection_password = '******'
     xenapi_fake.reset()
     xenapi_fake.create_local_srs()
     db_fakes.stub_out_db_instance_api(self.stubs)
     xenapi_fake.create_network('fake', FLAGS.flat_network_bridge)
     stubs.stubout_session(self.stubs, stubs.FakeSessionForVMTests)
     stubs.stubout_get_this_vm_uuid(self.stubs)
     stubs.stubout_stream_disk(self.stubs)
     stubs.stubout_is_vdi_pv(self.stubs)
     self.stubs.Set(VMOps, 'reset_network', reset_network)
     glance_stubs.stubout_glance_client(self.stubs, glance_stubs.FakeGlance)
     self.conn = xenapi_conn.get_connection(False)