Esempio n. 1
0
    def test_build_pxe_config(self):
        args = {
                'deployment_id': 'aaa',
                'deployment_key': 'bbb',
                'deployment_iscsi_iqn': 'ccc',
                'deployment_aki_path': 'ddd',
                'deployment_ari_path': 'eee',
                'aki_path': 'fff',
                'ari_path': 'ggg',
                'network_info': self.test_network_info,
            }
        config = pxe.build_pxe_config(**args)
        self.assertThat(config, matchers.StartsWith('default deploy'))

        # deploy bits are in the deploy section
        start = config.index('label deploy')
        end = config.index('label boot')
        self.assertThat(config[start:end], matchers.MatchesAll(
            matchers.Contains('kernel ddd'),
            matchers.Contains('initrd=eee'),
            matchers.Contains('deployment_id=aaa'),
            matchers.Contains('deployment_key=bbb'),
            matchers.Contains('iscsi_target_iqn=ccc'),
            matchers.Not(matchers.Contains('kernel fff')),
            ))

        # boot bits are in the boot section
        start = config.index('label boot')
        self.assertThat(config[start:], matchers.MatchesAll(
            matchers.Contains('kernel fff'),
            matchers.Contains('initrd=ggg'),
            matchers.Not(matchers.Contains('kernel ddd')),
            ))
Esempio n. 2
0
    def test_build_pxe_config(self):
        args = {
                'deployment_id': 'aaa',
                'deployment_key': 'bbb',
                'deployment_iscsi_iqn': 'ccc',
                'deployment_aki_path': 'ddd',
                'deployment_ari_path': 'eee',
                'aki_path': 'fff',
                'ari_path': 'ggg',
                'network_info': self.test_network_info,
            }
        config = pxe.build_pxe_config(**args)
        self.assertThat(config, matchers.StartsWith('default deploy'))

        # deploy bits are in the deploy section
        start = config.index('label deploy')
        end = config.index('label boot')
        self.assertThat(config[start:end], matchers.MatchesAll(
            matchers.Contains('kernel ddd'),
            matchers.Contains('initrd=eee'),
            matchers.Contains('deployment_id=aaa'),
            matchers.Contains('deployment_key=bbb'),
            matchers.Contains('iscsi_target_iqn=ccc'),
            matchers.Not(matchers.Contains('kernel fff')),
            ))

        # boot bits are in the boot section
        start = config.index('label boot')
        self.assertThat(config[start:], matchers.MatchesAll(
            matchers.Contains('kernel fff'),
            matchers.Contains('initrd=ggg'),
            matchers.Not(matchers.Contains('kernel ddd')),
            ))
Esempio n. 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)
        image_path = pxe.get_image_file_path(self.instance)

        self.mox.StubOutWithMock(flavor_obj.Flavor, 'get_by_id')
        self.mox.StubOutWithMock(pxe, 'get_tftp_image_info')
        self.mox.StubOutWithMock(pxe, 'get_partition_sizes')
        self.mox.StubOutWithMock(bm_utils, 'random_alnum')
        self.mox.StubOutWithMock(pxe, 'build_pxe_config')
        self.mox.StubOutWithMock(bm_utils, 'write_to_file')
        self.mox.StubOutWithMock(bm_utils, 'create_link_without_raise')

        flavor_obj.Flavor.get_by_id(
            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, 0))
        bm_utils.random_alnum(32).AndReturn('alnum')
        pxe.build_pxe_config(self.node['id'], 'alnum', iqn, 'aaaa', 'bbbb',
                             'cccc', 'dddd',
                             self.test_network_info).AndReturn(pxe_config)
        bm_utils.write_to_file(pxe_path, pxe_config)
        for mac in macs:
            bm_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,
                                        network_info=self.test_network_info)

        self.mox.VerifyAll()
Esempio n. 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(flavor_obj.Flavor, 'get_by_id')
        self.mox.StubOutWithMock(pxe, 'get_tftp_image_info')
        self.mox.StubOutWithMock(pxe, 'get_partition_sizes')
        self.mox.StubOutWithMock(bm_utils, 'random_alnum')
        self.mox.StubOutWithMock(pxe, 'build_pxe_config')
        self.mox.StubOutWithMock(bm_utils, 'write_to_file')
        self.mox.StubOutWithMock(bm_utils, 'create_link_without_raise')

        flavor_obj.Flavor.get_by_id(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, 0))
        bm_utils.random_alnum(32).AndReturn('alnum')
        pxe.build_pxe_config(
                self.node['id'], 'alnum', iqn,
                'aaaa', 'bbbb', 'cccc', 'dddd',
                self.test_network_info).AndReturn(pxe_config)
        bm_utils.write_to_file(pxe_path, pxe_config)
        for mac in macs:
            bm_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,
                                        network_info=self.test_network_info)

        self.mox.VerifyAll()
Esempio n. 5
0
    def test_activate_bootloader(self):
        self._create_node()
        macs = [nic['address'] for nic in self.nic_info]
        macs.append(self.node_info['prov_mac_address'])
        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)
        image_path = pxe.get_image_file_path(self.instance)

        self.mox.StubOutWithMock(pxe, 'get_tftp_image_info')
        self.mox.StubOutWithMock(pxe, 'get_partition_sizes')
        self.mox.StubOutWithMock(bm_utils, 'random_alnum')
        self.mox.StubOutWithMock(db, 'bm_deployment_create')
        self.mox.StubOutWithMock(pxe, 'build_pxe_config')
        self.mox.StubOutWithMock(bm_utils, 'write_to_file')
        self.mox.StubOutWithMock(bm_utils, 'create_link_without_raise')

        pxe.get_tftp_image_info(self.instance).AndReturn(image_info)
        pxe.get_partition_sizes(self.instance).AndReturn((0, 0))
        bm_utils.random_alnum(32).AndReturn('alnum')
        db.bm_deployment_create(
                self.context, 'alnum', image_path, pxe_path, 0, 0).\
                        AndReturn(1234)
        pxe.build_pxe_config(
                1234, 'alnum', iqn, 'aaaa', 'bbbb', 'cccc', 'dddd').\
                        AndReturn(pxe_config)
        bm_utils.write_to_file(pxe_path, pxe_config)
        for mac in macs:
            bm_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()
Esempio n. 6
0
    def test_activate_bootloader(self):
        self._create_node()
        macs = [nic['address'] for nic in self.nic_info]
        macs.append(self.node_info['prov_mac_address'])
        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)
        image_path = pxe.get_image_file_path(self.instance)

        self.mox.StubOutWithMock(pxe, 'get_tftp_image_info')
        self.mox.StubOutWithMock(pxe, 'get_partition_sizes')
        self.mox.StubOutWithMock(bm_utils, 'random_alnum')
        self.mox.StubOutWithMock(db, 'bm_deployment_create')
        self.mox.StubOutWithMock(pxe, 'build_pxe_config')
        self.mox.StubOutWithMock(bm_utils, 'write_to_file')
        self.mox.StubOutWithMock(bm_utils, 'create_link_without_raise')

        pxe.get_tftp_image_info(self.instance).AndReturn(image_info)
        pxe.get_partition_sizes(self.instance).AndReturn((0, 0))
        bm_utils.random_alnum(32).AndReturn('alnum')
        db.bm_deployment_create(
                self.context, 'alnum', image_path, pxe_path, 0, 0).\
                        AndReturn(1234)
        pxe.build_pxe_config(
                1234, 'alnum', iqn, 'aaaa', 'bbbb', 'cccc', 'dddd').\
                        AndReturn(pxe_config)
        bm_utils.write_to_file(pxe_path, pxe_config)
        for mac in macs:
            bm_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()
Esempio n. 7
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)
        image_path = 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(bm_utils, "random_alnum")
        self.mox.StubOutWithMock(pxe, "build_pxe_config")
        self.mox.StubOutWithMock(bm_utils, "write_to_file")
        self.mox.StubOutWithMock(bm_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))
        bm_utils.random_alnum(32).AndReturn("alnum")
        pxe.build_pxe_config(
            self.node["id"], "alnum", iqn, "aaaa", "bbbb", "cccc", "dddd", self.test_network_info
        ).AndReturn(pxe_config)
        bm_utils.write_to_file(pxe_path, pxe_config)
        for mac in macs:
            bm_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, network_info=self.test_network_info)

        self.mox.VerifyAll()
Esempio n. 8
0
    def test_build_pxe_config(self):
        args = {
            "deployment_id": "aaa",
            "deployment_key": "bbb",
            "deployment_iscsi_iqn": "ccc",
            "deployment_aki_path": "ddd",
            "deployment_ari_path": "eee",
            "aki_path": "fff",
            "ari_path": "ggg",
            "network_info": self.test_network_info,
        }
        config = pxe.build_pxe_config(**args)
        self.assertThat(config, matchers.StartsWith("default deploy"))

        # deploy bits are in the deploy section
        start = config.index("label deploy")
        end = config.index("label boot")
        self.assertThat(
            config[start:end],
            matchers.MatchesAll(
                matchers.Contains("kernel ddd"),
                matchers.Contains("initrd=eee"),
                matchers.Contains("deployment_id=aaa"),
                matchers.Contains("deployment_key=bbb"),
                matchers.Contains("iscsi_target_iqn=ccc"),
                matchers.Not(matchers.Contains("kernel fff")),
            ),
        )

        # boot bits are in the boot section
        start = config.index("label boot")
        self.assertThat(
            config[start:],
            matchers.MatchesAll(
                matchers.Contains("kernel fff"),
                matchers.Contains("initrd=ggg"),
                matchers.Not(matchers.Contains("kernel ddd")),
            ),
        )