Beispiel #1
0
    def test_activate_and_deactivate_bootloader(self):
        self._create_node()
        instance_type = {
            'extra_specs': {
                'baremetal:deploy_kernel_id': 'eeee',
                'baremetal:deploy_ramdisk_id': 'ffff',
                }
            }
        self.instance['uuid'] = 'fake-uuid'

        self.mox.StubOutWithMock(self.driver.virtapi, 'instance_type_get')
        self.mox.StubOutWithMock(utils, 'write_to_file')
        self.mox.StubOutWithMock(utils, 'create_link_without_raise')
        self.mox.StubOutWithMock(utils, 'unlink_without_raise')
        self.mox.StubOutWithMock(utils, 'rmtree_without_raise')

        self.driver.virtapi.instance_type_get(
            self.context, self.instance['instance_type_id']).AndReturn(
                instance_type)

        # create the config file
        utils.write_to_file(mox.StrContains('fake-uuid'),
                               mox.StrContains(CONF.baremetal.tftp_root))
        # unlink and link the 2 interfaces
        for i in range(2):
            utils.unlink_without_raise(mox.Or(
                    mox.StrContains('fake-uuid'),
                    mox.StrContains(CONF.baremetal.tftp_root)))
            utils.create_link_without_raise(
                    mox.StrContains('fake-uuid'),
                    mox.StrContains(CONF.baremetal.tftp_root))
        # unlink all 2 interfaces, 4 images, and the config file
        for i in range(7):
            utils.unlink_without_raise(mox.Or(
                    mox.StrContains('fake-uuid'),
                    mox.StrContains(CONF.baremetal.tftp_root)))
        utils.rmtree_without_raise(mox.StrContains('fake-uuid'))

        self.mox.ReplayAll()

        # activate and deactivate the bootloader
        # and check the deployment task_state in the database
        row = db.bm_node_get(self.context, 1)
        self.assertTrue(row['deploy_key'] is None)

        self.driver.activate_bootloader(self.context, self.node,
                                            self.instance)
        row = db.bm_node_get(self.context, 1)
        self.assertTrue(row['deploy_key'] is not None)

        self.driver.deactivate_bootloader(self.context, self.node,
                                            self.instance)
        row = db.bm_node_get(self.context, 1)
        self.assertTrue(row['deploy_key'] is None)

        self.mox.VerifyAll()
Beispiel #2
0
    def test_activate_and_deactivate_bootloader(self):
        self._create_node()
        instance_type = {
            'extra_specs': {
                'baremetal:deploy_kernel_id': 'eeee',
                'baremetal:deploy_ramdisk_id': 'ffff',
                }
            }
        self.instance['uuid'] = 'fake-uuid'

        self.mox.StubOutWithMock(self.driver.virtapi, 'instance_type_get')
        self.mox.StubOutWithMock(utils, 'write_to_file')
        self.mox.StubOutWithMock(utils, 'create_link_without_raise')
        self.mox.StubOutWithMock(utils, 'unlink_without_raise')
        self.mox.StubOutWithMock(utils, 'rmtree_without_raise')

        self.driver.virtapi.instance_type_get(
            self.context, self.instance['instance_type_id']).AndReturn(
                instance_type)

        # create the config file
        utils.write_to_file(mox.StrContains('fake-uuid'),
                               mox.StrContains(CONF.baremetal.tftp_root))
        # unlink and link the 2 interfaces
        for i in range(2):
            utils.unlink_without_raise(mox.Or(
                    mox.StrContains('fake-uuid'),
                    mox.StrContains(CONF.baremetal.tftp_root)))
            utils.create_link_without_raise(
                    mox.StrContains('fake-uuid'),
                    mox.StrContains(CONF.baremetal.tftp_root))
        # unlink all 2 interfaces, 4 images, and the config file
        for i in range(7):
            utils.unlink_without_raise(mox.Or(
                    mox.StrContains('fake-uuid'),
                    mox.StrContains(CONF.baremetal.tftp_root)))
        utils.rmtree_without_raise(mox.StrContains('fake-uuid'))

        self.mox.ReplayAll()

        # activate and deactivate the bootloader
        # and check the deployment task_state in the database
        row = db.bm_node_get(self.context, 1)
        self.assertTrue(row['deploy_key'] is None)

        self.driver.activate_bootloader(self.context, self.node,
                                            self.instance)
        row = db.bm_node_get(self.context, 1)
        self.assertTrue(row['deploy_key'] is not None)

        self.driver.deactivate_bootloader(self.context, self.node,
                                            self.instance)
        row = db.bm_node_get(self.context, 1)
        self.assertTrue(row['deploy_key'] is None)

        self.mox.VerifyAll()
Beispiel #3
0
    def test_activate_bootloader_passes_details(self):
        self._create_node()
        macs = [nic['address'] for nic in self.nic_info]
        macs.sort()
        image_info = {
                'deploy_kernel': [None, 'aaaa'],
                'deploy_ramdisk': [None, 'bbbb'],
                'kernel': [None, 'cccc'],
                'ramdisk': [None, 'dddd'],
            }
        self.instance['uuid'] = 'fake-uuid'
        iqn = "iqn-%s" % self.instance['uuid']
        pxe_config = 'this is a fake pxe config'
        pxe_path = pxe.get_pxe_config_file_path(self.instance)
        pxe.get_image_file_path(self.instance)

        self.mox.StubOutWithMock(self.driver.virtapi, 'instance_type_get')
        self.mox.StubOutWithMock(pxe, 'get_tftp_image_info')
        self.mox.StubOutWithMock(pxe, 'get_partition_sizes')
        self.mox.StubOutWithMock(utils, 'random_alnum')
        self.mox.StubOutWithMock(pxe, 'build_pxe_config')
        self.mox.StubOutWithMock(utils, 'write_to_file')
        self.mox.StubOutWithMock(utils, 'create_link_without_raise')

        self.driver.virtapi.instance_type_get(
            self.context, self.instance['instance_type_id']).AndReturn({})
        pxe.get_tftp_image_info(self.instance, {}).AndReturn(image_info)
        pxe.get_partition_sizes(self.instance).AndReturn((0, 0))
        utils.random_alnum(32).AndReturn('alnum')
        pxe.build_pxe_config(
                self.node['id'], 'alnum', iqn,
                'aaaa', 'bbbb', 'cccc', 'dddd').AndReturn(pxe_config)
        utils.write_to_file(pxe_path, pxe_config)
        for mac in macs:
            utils.create_link_without_raise(
                    pxe_path, pxe.get_pxe_mac_path(mac))

        self.mox.ReplayAll()

        self.driver.activate_bootloader(self.context, self.node, self.instance)

        self.mox.VerifyAll()
Beispiel #4
0
    def test_activate_bootloader_passes_details(self):
        self._create_node()
        macs = [nic['address'] for nic in self.nic_info]
        macs.sort()
        image_info = {
                'deploy_kernel': [None, 'aaaa'],
                'deploy_ramdisk': [None, 'bbbb'],
                'kernel': [None, 'cccc'],
                'ramdisk': [None, 'dddd'],
            }
        self.instance['uuid'] = 'fake-uuid'
        iqn = "iqn-%s" % self.instance['uuid']
        pxe_config = 'this is a fake pxe config'
        pxe_path = pxe.get_pxe_config_file_path(self.instance)
        pxe.get_image_file_path(self.instance)

        self.mox.StubOutWithMock(self.driver.virtapi, 'instance_type_get')
        self.mox.StubOutWithMock(pxe, 'get_tftp_image_info')
        self.mox.StubOutWithMock(pxe, 'get_partition_sizes')
        self.mox.StubOutWithMock(utils, 'random_alnum')
        self.mox.StubOutWithMock(pxe, 'build_pxe_config')
        self.mox.StubOutWithMock(utils, 'write_to_file')
        self.mox.StubOutWithMock(utils, 'create_link_without_raise')

        self.driver.virtapi.instance_type_get(
            self.context, self.instance['instance_type_id']).AndReturn({})
        pxe.get_tftp_image_info(self.instance, {}).AndReturn(image_info)
        pxe.get_partition_sizes(self.instance).AndReturn((0, 0))
        utils.random_alnum(32).AndReturn('alnum')
        pxe.build_pxe_config(
                self.node['id'], 'alnum', iqn,
                'aaaa', 'bbbb', 'cccc', 'dddd').AndReturn(pxe_config)
        utils.write_to_file(pxe_path, pxe_config)
        for mac in macs:
            utils.create_link_without_raise(
                    pxe_path, pxe.get_pxe_mac_path(mac))

        self.mox.ReplayAll()

        self.driver.activate_bootloader(self.context, self.node, self.instance)

        self.mox.VerifyAll()