Ejemplo n.º 1
0
    def test__build_pxe_config(self):
        instance_uuid = 'instance_uuid_123'
        CONF.set_default('pxe_append_params', 'test_param', group='pxe')

        template = 'ironic/tests/drivers/pxe_config.template'
        pxe_config_template = open(template, 'r').read()

        self.mox.StubOutWithMock(utils, 'random_alnum')

        utils.random_alnum(32).AndReturn('0123456789ABCDEFGHIJKLMNOPQRSTUV')

        image_info = {'deploy_kernel': ['deploy_kernel',
                                       CONF.pxe.tftp_root + '/' +
                                        instance_uuid + '/deploy_kernel'],
                     'deploy_ramdisk': ['deploy_ramdisk',
                                         CONF.pxe.tftp_root + '/' +
                                        instance_uuid + '/deploy_ramdisk'],
                     'kernel': ['kernel_id',
                                CONF.pxe.tftp_root + '/' + instance_uuid +
                                '/kernel'],
                     'ramdisk': ['ramdisk_id',
                                 CONF.pxe.tftp_root + '/' + instance_uuid +
                                 '/ramdisk']
        }

        self.mox.ReplayAll()

        pxe_config = pxe._build_pxe_config(self.node, image_info)

        self.assertEqual(pxe_config, pxe_config_template)
Ejemplo n.º 2
0
    def test__build_pxe_config(self):
        instance_uuid = 'instance_uuid_123'
        CONF.set_default('pxe_append_params', 'test_param', group='pxe')
        CONF.set_default('api_url', 'http://192.168.122.184:6385')

        template = 'ironic/tests/drivers/pxe_config.template'
        pxe_config_template = open(template, 'r').read()

        fake_key = '0123456789ABCDEFGHIJKLMNOPQRSTUV'
        with mock.patch.object(utils, 'random_alnum') as random_alnum_mock:
            random_alnum_mock.return_value = fake_key

            image_info = {'deploy_kernel': ['deploy_kernel',
                                            CONF.pxe.tftp_root + '/' +
                                            instance_uuid + '/deploy_kernel'],
                          'deploy_ramdisk': ['deploy_ramdisk',
                                            CONF.pxe.tftp_root + '/' +
                                            instance_uuid + '/deploy_ramdisk'],
                          'kernel': ['kernel_id',
                                     CONF.pxe.tftp_root + '/' + instance_uuid +
                                     '/kernel'],
                          'ramdisk': ['ramdisk_id',
                                     CONF.pxe.tftp_root + '/' + instance_uuid +
                                     '/ramdisk']
                      }
            pxe_config = pxe._build_pxe_config(self.node, image_info)

            random_alnum_mock.assert_called_once_with(32)
            self.assertEqual(pxe_config, pxe_config_template)

        # test that deploy_key saved
        db_node = self.dbapi.get_node(self.node['uuid'])
        db_key = db_node['driver_info'].get('pxe_deploy_key')
        self.assertEqual(db_key, fake_key)
Ejemplo n.º 3
0
    def test__build_pxe_config(self, random_alnum_mock):
        self.config(pxe_append_params="test_param", group="pxe")
        # NOTE: right '/' should be removed from url string
        self.config(api_url="http://192.168.122.184:6385/", group="conductor")

        template = "ironic/tests/drivers/pxe_config.template"
        pxe_config_template = open(template, "r").read()

        fake_key = "0123456789ABCDEFGHIJKLMNOPQRSTUV"
        random_alnum_mock.return_value = fake_key

        image_info = {
            "deploy_kernel": ("deploy_kernel", os.path.join(CONF.pxe.tftp_root, self.node.uuid, "deploy_kernel")),
            "deploy_ramdisk": ("deploy_ramdisk", os.path.join(CONF.pxe.tftp_root, self.node.uuid, "deploy_ramdisk")),
            "kernel": ("kernel_id", os.path.join(CONF.pxe.tftp_root, self.node.uuid, "kernel")),
            "ramdisk": ("ramdisk_id", os.path.join(CONF.pxe.tftp_root, self.node.uuid, "ramdisk")),
        }
        pxe_config = pxe._build_pxe_config(self.node, image_info, self.context)

        random_alnum_mock.assert_called_once_with(32)
        self.assertEqual(pxe_config_template, pxe_config)

        # test that deploy_key saved
        db_node = self.dbapi.get_node_by_uuid(self.node.uuid)
        db_key = db_node["driver_info"].get("pxe_deploy_key")
        self.assertEqual(fake_key, db_key)
Ejemplo n.º 4
0
    def test__build_pxe_config(self):
        self.config(pxe_append_params='test_param', group='pxe')
        # NOTE: right '/' should be removed from url string
        self.config(api_url='http://192.168.122.184:6385/', group='conductor')

        template = 'ironic/tests/drivers/pxe_config.template'
        pxe_config_template = open(template, 'r').read()

        fake_key = '0123456789ABCDEFGHIJKLMNOPQRSTUV'
        with mock.patch.object(utils, 'random_alnum') as random_alnum_mock:
            random_alnum_mock.return_value = fake_key

            image_info = {
                'deploy_kernel': [
                    'deploy_kernel',
                    os.path.join(CONF.pxe.tftp_root, self.node.uuid,
                                 'deploy_kernel')
                ],
                'deploy_ramdisk': [
                    'deploy_ramdisk',
                    os.path.join(CONF.pxe.tftp_root, self.node.uuid,
                                 'deploy_ramdisk')
                ],
                'kernel': [
                    'kernel_id',
                    os.path.join(CONF.pxe.tftp_root, self.node.uuid, 'kernel')
                ],
                'ramdisk': [
                    'ramdisk_id',
                    os.path.join(CONF.pxe.tftp_root, self.node.uuid, 'ramdisk')
                ]
            }
            pxe_config = pxe._build_pxe_config(self.node, image_info,
                                               self.context)

            random_alnum_mock.assert_called_once_with(32)
            self.assertEqual(pxe_config_template, pxe_config)

        # test that deploy_key saved
        db_node = self.dbapi.get_node_by_uuid(self.node['uuid'])
        db_key = db_node['driver_info'].get('pxe_deploy_key')
        self.assertEqual(fake_key, db_key)
Ejemplo n.º 5
0
    def test__build_pxe_config(self):
        self.config(pxe_append_params='test_param', group='pxe')
        # NOTE: right '/' should be removed from url string
        self.config(api_url='http://192.168.122.184:6385/', group='conductor')

        template = 'ironic/tests/drivers/pxe_config.template'
        pxe_config_template = open(template, 'r').read()

        fake_key = '0123456789ABCDEFGHIJKLMNOPQRSTUV'
        with mock.patch.object(utils, 'random_alnum') as random_alnum_mock:
            random_alnum_mock.return_value = fake_key

            image_info = {'deploy_kernel': ['deploy_kernel',
                                            os.path.join(CONF.pxe.tftp_root,
                                                         self.node.uuid,
                                                         'deploy_kernel')],
                          'deploy_ramdisk': ['deploy_ramdisk',
                                            os.path.join(CONF.pxe.tftp_root,
                                                         self.node.uuid,
                                                         'deploy_ramdisk')],
                          'kernel': ['kernel_id',
                                     os.path.join(CONF.pxe.tftp_root,
                                                  self.node.uuid,
                                                  'kernel')],
                          'ramdisk': ['ramdisk_id',
                                     os.path.join(CONF.pxe.tftp_root,
                                                  self.node.uuid,
                                                  'ramdisk')]
                      }
            pxe_config = pxe._build_pxe_config(self.node,
                                               image_info,
                                               self.context)

            random_alnum_mock.assert_called_once_with(32)
            self.assertEqual(pxe_config_template, pxe_config)

        # test that deploy_key saved
        db_node = self.dbapi.get_node_by_uuid(self.node.uuid)
        db_key = db_node['driver_info'].get('pxe_deploy_key')
        self.assertEqual(fake_key, db_key)