def test_make_ironic_bootstrap_task(self):
        cid = 123

        result = tasks_templates.make_ironic_bootstrap_task([1, 2, 3], cid=cid)

        extra_conf_files = "/usr/share/ironic-fa-bootstrap-configs/"
        ssh_keys = "/var/lib/fuel/keys/{0}/ironic/ironic.pub".format(cid)

        self.assertEqual(
            result, {
                'id': None,
                'type': 'shell',
                'uids': [1, 2, 3],
                'parameters': {
                    'cmd':
                    ("BOOTSTRAP_FUEL_PKGS='openssh-server ntp fuel-agent' "
                     "EXTRA_CONF_FILES='{extra_conf_files}' "
                     "DESTDIR='/var/www/nailgun/bootstrap/ironic/{cid}' "
                     "BOOTSTRAP_SSH_KEYS='{bootstrap_ssh_keys}' "
                     'fuel-bootstrap-image ').format(
                         cid=cid,
                         extra_conf_files=extra_conf_files,
                         bootstrap_ssh_keys=ssh_keys),
                    'timeout':
                    settings.PROVISIONING_IMAGES_BUILD_TIMEOUT,
                    'retries':
                    1,
                    'interval':
                    1,
                    'cwd':
                    '/'
                }
            })
Example #2
0
    def test_make_ironic_bootstrap_task(self):
        cid = 123

        result = tasks_templates.make_ironic_bootstrap_task(
            [1, 2, 3],
            cid=cid)

        extra_conf_files = "/usr/share/ironic-fa-bootstrap-configs/"
        ssh_keys = "/var/lib/fuel/keys/{0}/ironic/ironic.pub".format(cid)

        self.assertEqual(result, {
            'type': 'shell',
            'uids': [1, 2, 3],
            'parameters': {
                'cmd': (
                    "BOOTSTRAP_FUEL_PKGS='openssh-server ntp fuel-agent' "
                    "EXTRA_CONF_FILES='{extra_conf_files}' "
                    "DESTDIR='/var/www/nailgun/bootstrap/ironic/{cid}' "
                    "BOOTSTRAP_SSH_KEYS='{bootstrap_ssh_keys}' "
                    'fuel-bootstrap-image ').format(
                        cid=cid,
                        extra_conf_files=extra_conf_files,
                        bootstrap_ssh_keys=ssh_keys),
                'timeout': settings.PROVISIONING_IMAGES_BUILD_TIMEOUT,
                'retries': 1,
                'interval': 1,
                'cwd': '/'}})
    def serialize_pre_provision_tasks(cls, cluster):
        tasks = super(ProvisioningSerializer80, cls).serialize_pre_provision_tasks(cluster)

        attrs = objects.Attributes.merged_attrs_values(cluster.attributes)

        if attrs["ironic"]["enabled"]:
            tasks.append(tasks_templates.generate_ironic_bootstrap_keys_task([consts.MASTER_ROLE], cluster.id))

            tasks.append(tasks_templates.make_ironic_bootstrap_task([consts.MASTER_ROLE], cluster.id))

        PriorityStrategy().one_by_one(tasks)
        return tasks
    def serialize_pre_provision_tasks(cls, cluster):
        tasks = super(ProvisioningSerializer80,
                      cls).serialize_pre_provision_tasks(cluster)

        attrs = objects.Attributes.merged_attrs_values(cluster.attributes)

        if attrs['ironic']['enabled']:
            tasks.append(
                tasks_templates.generate_ironic_bootstrap_keys_task(
                    [consts.MASTER_NODE_UID], cluster.id))

            tasks.append(
                tasks_templates.make_ironic_bootstrap_task(
                    [consts.MASTER_NODE_UID], cluster.id))

        PriorityStrategy().one_by_one(tasks)
        return tasks
    def test_make_ironic_bootstrap_task(self):
        cid = 123
        bootstrap_path = "/var/www/nailgun/bootstrap/ironic/{cid}/".format(
            cid=cid)

        result = tasks_templates.make_ironic_bootstrap_task([1, 2, 3], cid=cid)

        extra_conf_files = "/usr/share/ironic-fa-bootstrap-configs/"
        ssh_keys = "/var/lib/fuel/keys/{0}/ironic/ironic.pub".format(cid)
        log_file = "/var/log/fuel-ironic-bootstrap-image-build.log"
        ironic_bootstrap_pkgs = ' '.join("--package '{0}'".format(pkg)
                                         for pkg in IRONIC_BOOTSTRAP_PKGS)

        self.assertEqual(
            result, {
                'id': None,
                'type': 'shell',
                'uids': [1, 2, 3],
                'parameters': {
                    'cmd': ("test -e {bootstrap_path}vmlinuz || "
                            "(fuel-bootstrap build {ironic_bootstrap_pkgs} "
                            "--root-ssh-authorized-file {bootstrap_ssh_keys} "
                            "--output-dir {bootstrap_path} "
                            "--extra-dir {extra_conf_files} --no-compress "
                            '--no-default-extra-dirs --no-default-packages '
                            '--log-file {log_file})').format(
                                cid=cid,
                                extra_conf_files=extra_conf_files,
                                bootstrap_ssh_keys=ssh_keys,
                                ironic_bootstrap_pkgs=ironic_bootstrap_pkgs,
                                bootstrap_path=bootstrap_path,
                                log_file=log_file),
                    'timeout':
                    settings.PROVISIONING_IMAGES_BUILD_TIMEOUT,
                    'retries':
                    1,
                    'interval':
                    1,
                    'cwd':
                    '/'
                }
            })
    def test_make_ironic_bootstrap_task(self):
        cid = 123
        bootstrap_path = "/var/www/nailgun/bootstrap/ironic/{cid}/".format(
            cid=cid)

        result = tasks_templates.make_ironic_bootstrap_task(
            [1, 2, 3],
            cid=cid)

        extra_conf_files = "/usr/share/ironic-fa-bootstrap-configs/"
        ssh_keys = "/var/lib/fuel/keys/{0}/ironic/ironic.pub".format(cid)
        log_file = "/var/log/fuel-ironic-bootstrap-image-build.log"
        ironic_bootstrap_pkgs = ' '.join(
            "--package '{0}'".format(pkg) for pkg in IRONIC_BOOTSTRAP_PKGS)

        self.assertEqual(result, {
            'id': None,
            'type': 'shell',
            'uids': [1, 2, 3],
            'parameters': {
                'cmd': (
                    "test -e {bootstrap_path}vmlinuz || "
                    "(fuel-bootstrap build {ironic_bootstrap_pkgs} "
                    "--root-ssh-authorized-file {bootstrap_ssh_keys} "
                    "--output-dir {bootstrap_path} "
                    "--extra-dir {extra_conf_files} --no-compress "
                    '--no-default-extra-dirs --no-default-packages '
                    '--log-file {log_file})').format(
                        cid=cid,
                        extra_conf_files=extra_conf_files,
                        bootstrap_ssh_keys=ssh_keys,
                        ironic_bootstrap_pkgs=ironic_bootstrap_pkgs,
                        bootstrap_path=bootstrap_path,
                        log_file=log_file),
                'timeout': settings.PROVISIONING_IMAGES_BUILD_TIMEOUT,
                'retries': 1,
                'interval': 1,
                'cwd': '/'}})