Esempio n. 1
0
 def test_build_agent_options_root_device_hints(self):
     self.config(api_url='api-url', group='conductor')
     self.node.properties['root_device'] = {'model': 'fake_model'}
     options = agent.build_agent_options(self.node)
     self.assertEqual('api-url', options['ipa-api-url'])
     self.assertEqual('fake_agent', options['ipa-driver-name'])
     self.assertEqual('model=fake_model', options['root_device'])
Esempio n. 2
0
 def test_build_agent_options_root_device_hints(self):
     self.config(api_url='api-url', group='conductor')
     self.node.properties['root_device'] = {'model': 'fake_model'}
     options = agent.build_agent_options(self.node)
     self.assertEqual('api-url', options['ipa-api-url'])
     self.assertEqual('fake_agent', options['ipa-driver-name'])
     self.assertEqual('model=fake_model', options['root_device'])
Esempio n. 3
0
    def test_build_agent_options_keystone(self, get_url_mock):

        self.config(api_url=None, group='conductor')
        get_url_mock.return_value = 'api-url'
        options = agent.build_agent_options(self.node)
        self.assertEqual('api-url', options['ipa-api-url'])
        self.assertEqual('fake_agent', options['ipa-driver-name'])
Esempio n. 4
0
    def deploy(self, task):
        """Start deployment of the task's node.

        Fetches the instance image, prepares the options for the deployment
        ramdisk, sets the node to boot from virtual media cdrom, and reboots
        the given node.

        :param task: a TaskManager instance containing the node to act on.
        :returns: deploy state DEPLOYWAIT.
        :raises: InstanceDeployFailure, if image size if greater than root
            partition.
        :raises: ImageCreationFailed, if it failed while creating the floppy
            image.
        :raises: IloOperationError, if some operation on iLO fails.
        """
        node = task.node

        iscsi_deploy.cache_instance_image(task.context, node)
        iscsi_deploy.check_image_size(task)

        deploy_ramdisk_opts = iscsi_deploy.build_deploy_ramdisk_options(node)
        agent_opts = agent.build_agent_options(node)
        deploy_ramdisk_opts.update(agent_opts)
        deploy_nic_mac = deploy_utils.get_single_nic_with_vif_port_id(task)
        deploy_ramdisk_opts['BOOTIF'] = deploy_nic_mac
        deploy_iso = node.driver_info['ilo_deploy_iso']

        _reboot_into(task, deploy_iso, deploy_ramdisk_opts)

        return states.DEPLOYWAIT
Esempio n. 5
0
    def deploy(self, task):
        """Start deployment of the task's node.

        Fetches the instance image, prepares the options for the deployment
        ramdisk, sets the node to boot from virtual media cdrom, and reboots
        the given node.

        :param task: a TaskManager instance containing the node to act on.
        :returns: deploy state DEPLOYWAIT.
        :raises: InstanceDeployFailure, if image size if greater than root
            partition.
        :raises: ImageCreationFailed, if it failed while creating the floppy
            image.
        :raises: IloOperationError, if some operation on iLO fails.
        """
        node = task.node

        iscsi_deploy.cache_instance_image(task.context, node)
        iscsi_deploy.check_image_size(task)

        deploy_ramdisk_opts = iscsi_deploy.build_deploy_ramdisk_options(node)
        agent_opts = agent.build_agent_options(node)
        deploy_ramdisk_opts.update(agent_opts)
        deploy_nic_mac = deploy_utils.get_single_nic_with_vif_port_id(task)
        deploy_ramdisk_opts['BOOTIF'] = deploy_nic_mac
        deploy_iso = node.driver_info['ilo_deploy_iso']

        _reboot_into(task, deploy_iso, deploy_ramdisk_opts)

        return states.DEPLOYWAIT
Esempio n. 6
0
    def test_build_agent_options_keystone(self, get_url_mock):

        self.config(api_url=None, group='conductor')
        get_url_mock.return_value = 'api-url'
        options = agent.build_agent_options(self.node)
        self.assertEqual('api-url', options['ipa-api-url'])
        self.assertEqual('fake_agent', options['ipa-driver-name'])
Esempio n. 7
0
def _build_pxe_config_options(node, pxe_info, ctx):
    """Build the PXE config options for a node

    This method builds the PXE boot options for a node,
    given all the required parameters.

    The options should then be passed to pxe_utils.create_pxe_config to
    create the actual config files.

    :param node: a single Node.
    :param pxe_info: a dict of values to set on the configuration file
    :param ctx: security context
    :returns: A dictionary of pxe options to be used in the pxe bootfile
        template.
    """
    is_whole_disk_image = node.driver_internal_info.get('is_whole_disk_image')
    if is_whole_disk_image:
        # These are dummy values to satisfy elilo.
        # image and initrd fields in elilo config cannot be blank.
        kernel = 'no_kernel'
        ramdisk = 'no_ramdisk'

    if CONF.pxe.ipxe_enabled:
        deploy_kernel = '/'.join([CONF.deploy.http_url, node.uuid,
                                  'deploy_kernel'])
        deploy_ramdisk = '/'.join([CONF.deploy.http_url, node.uuid,
                                   'deploy_ramdisk'])
        if not is_whole_disk_image:
            kernel = '/'.join([CONF.deploy.http_url, node.uuid,
                              'kernel'])
            ramdisk = '/'.join([CONF.deploy.http_url, node.uuid,
                               'ramdisk'])
    else:
        deploy_kernel = pxe_info['deploy_kernel'][1]
        deploy_ramdisk = pxe_info['deploy_ramdisk'][1]
        if not is_whole_disk_image:
            kernel = pxe_info['kernel'][1]
            ramdisk = pxe_info['ramdisk'][1]

    pxe_options = {
        'deployment_aki_path': deploy_kernel,
        'deployment_ari_path': deploy_ramdisk,
        'pxe_append_params': CONF.pxe.pxe_append_params,
        'tftp_server': CONF.pxe.tftp_server,
        'aki_path': kernel,
        'ari_path': ramdisk
    }

    deploy_ramdisk_options = iscsi_deploy.build_deploy_ramdisk_options(node)
    pxe_options.update(deploy_ramdisk_options)

    # NOTE(lucasagomes): We are going to extend the normal PXE config
    # to also contain the agent options so it could be used for both the
    # DIB ramdisk and the IPA ramdisk
    agent_opts = agent.build_agent_options(node)
    pxe_options.update(agent_opts)

    return pxe_options
Esempio n. 8
0
def _prepare_agent_vmedia_boot(task):
    """Ejects virtual media devices and prepares for vmedia boot."""
    # Eject all virtual media devices, as we are going to use them
    # during deploy.
    ilo_common.eject_vmedia_devices(task)

    deploy_ramdisk_opts = agent.build_agent_options(task.node)
    deploy_iso = task.node.driver_info['ilo_deploy_iso']
    _reboot_into(task, deploy_iso, deploy_ramdisk_opts)
Esempio n. 9
0
def _prepare_agent_vmedia_boot(task):
    """Ejects virtual media devices and prepares for vmedia boot."""
    # Eject all virtual media devices, as we are going to use them
    # during deploy.
    ilo_common.eject_vmedia_devices(task)

    deploy_ramdisk_opts = agent.build_agent_options(task.node)
    deploy_iso = task.node.driver_info['ilo_deploy_iso']
    _reboot_into(task, deploy_iso, deploy_ramdisk_opts)
Esempio n. 10
0
def _build_pxe_config_options(node, pxe_info, ctx):
    """Build the PXE config options for a node

    This method builds the PXE boot options for a node,
    given all the required parameters.

    The options should then be passed to pxe_utils.create_pxe_config to
    create the actual config files.

    :param node: a single Node.
    :param pxe_info: a dict of values to set on the configuration file
    :param ctx: security context
    :returns: A dictionary of pxe options to be used in the pxe bootfile
        template.
    """
    is_whole_disk_image = node.driver_internal_info.get('is_whole_disk_image')
    if is_whole_disk_image:
        # These are dummy values to satisfy elilo.
        # image and initrd fields in elilo config cannot be blank.
        kernel = 'no_kernel'
        ramdisk = 'no_ramdisk'

    if CONF.pxe.ipxe_enabled:
        deploy_kernel = '/'.join(
            [CONF.pxe.http_url, node.uuid, 'deploy_kernel'])
        deploy_ramdisk = '/'.join(
            [CONF.pxe.http_url, node.uuid, 'deploy_ramdisk'])
        if not is_whole_disk_image:
            kernel = '/'.join([CONF.pxe.http_url, node.uuid, 'kernel'])
            ramdisk = '/'.join([CONF.pxe.http_url, node.uuid, 'ramdisk'])
    else:
        deploy_kernel = pxe_info['deploy_kernel'][1]
        deploy_ramdisk = pxe_info['deploy_ramdisk'][1]
        if not is_whole_disk_image:
            kernel = pxe_info['kernel'][1]
            ramdisk = pxe_info['ramdisk'][1]

    pxe_options = {
        'deployment_aki_path': deploy_kernel,
        'deployment_ari_path': deploy_ramdisk,
        'pxe_append_params': CONF.pxe.pxe_append_params,
        'tftp_server': CONF.pxe.tftp_server,
        'aki_path': kernel,
        'ari_path': ramdisk
    }

    deploy_ramdisk_options = iscsi_deploy.build_deploy_ramdisk_options(node)
    pxe_options.update(deploy_ramdisk_options)

    # NOTE(lucasagomes): We are going to extend the normal PXE config
    # to also contain the agent options so it could be used for both the
    # DIB ramdisk and the IPA ramdisk
    agent_opts = agent.build_agent_options(node)
    pxe_options.update(agent_opts)

    return pxe_options
Esempio n. 11
0
    def deploy(self, task):
        """Perform a deployment to a node.

        Prepares the options for the agent ramdisk and sets the node to boot
        from virtual media cdrom.

        :param task: a TaskManager instance.
        :returns: states.DEPLOYWAIT
        :raises: ImageCreationFailed, if it failed while creating the floppy
            image.
        :raises: IRMCOperationError, if some operation on iRMC fails.
        """
        deploy_ramdisk_opts = agent.build_agent_options(task.node)
        _reboot_into_deploy_iso(task, deploy_ramdisk_opts)

        return states.DEPLOYWAIT
Esempio n. 12
0
    def deploy(self, task):
        """Start deployment of the task's node.

        Fetches the instance image, prepares the options for the deployment
        ramdisk, sets the node to boot from virtual media cdrom, and reboots
        the given node.

        :param task: a TaskManager instance containing the node to act on.
        :returns: deploy state DEPLOYWAIT.
        :raises: InstanceDeployFailure, if image size if greater than root
            partition.
        :raises: ImageCreationFailed, if it failed while creating the floppy
            image.
        :raises: IloOperationError, if some operation on iLO fails.
        """
        node = task.node

        # Clear ilo_boot_iso if it's a glance image to force recreate
        # another one again (or use existing one in glance).
        # This is mainly for rebuild scenario.
        if service_utils.is_glance_image(
                node.instance_info.get('image_source')):
            instance_info = node.instance_info
            instance_info.pop('ilo_boot_iso', None)
            node.instance_info = instance_info
            node.save()

        # Eject all virtual media devices, as we are going to use them
        # during deploy.
        ilo_common.eject_vmedia_devices(task)

        iscsi_deploy.cache_instance_image(task.context, node)
        iscsi_deploy.check_image_size(task)

        deploy_ramdisk_opts = iscsi_deploy.build_deploy_ramdisk_options(node)
        agent_opts = agent.build_agent_options(node)
        deploy_ramdisk_opts.update(agent_opts)
        deploy_nic_mac = deploy_utils.get_single_nic_with_vif_port_id(task)
        deploy_ramdisk_opts['BOOTIF'] = deploy_nic_mac
        deploy_iso = node.driver_info['ilo_deploy_iso']

        _reboot_into(task, deploy_iso, deploy_ramdisk_opts)

        return states.DEPLOYWAIT
Esempio n. 13
0
    def deploy(self, task):
        """Start deployment of the task's node.

        Fetches the instance image, prepares the options for the deployment
        ramdisk, sets the node to boot from virtual media cdrom, and reboots
        the given node.

        :param task: a TaskManager instance containing the node to act on.
        :returns: deploy state DEPLOYWAIT.
        :raises: InstanceDeployFailure, if image size if greater than root
            partition.
        :raises: ImageCreationFailed, if it failed while creating the floppy
            image.
        :raises: IloOperationError, if some operation on iLO fails.
        """
        node = task.node

        # Clear ilo_boot_iso if it's a glance image to force recreate
        # another one again (or use existing one in glance).
        # This is mainly for rebuild scenario.
        if service_utils.is_glance_image(
                node.instance_info.get('image_source')):
            instance_info = node.instance_info
            instance_info.pop('ilo_boot_iso', None)
            node.instance_info = instance_info
            node.save()

        # Eject all virtual media devices, as we are going to use them
        # during deploy.
        ilo_common.eject_vmedia_devices(task)

        iscsi_deploy.cache_instance_image(task.context, node)
        iscsi_deploy.check_image_size(task)

        deploy_ramdisk_opts = iscsi_deploy.build_deploy_ramdisk_options(node)
        agent_opts = agent.build_agent_options(node)
        deploy_ramdisk_opts.update(agent_opts)
        deploy_nic_mac = deploy_utils.get_single_nic_with_vif_port_id(task)
        deploy_ramdisk_opts['BOOTIF'] = deploy_nic_mac
        deploy_iso = node.driver_info['ilo_deploy_iso']

        _reboot_into(task, deploy_iso, deploy_ramdisk_opts)

        return states.DEPLOYWAIT
Esempio n. 14
0
    def prepare(self, task):
        """Prepare the deployment environment for this task's node.

        Generates the TFTP configuration for PXE-booting both the deployment
        and user images, fetches the TFTP image from Glance and add it to the
        local cache.

        :param task: a TaskManager instance containing the node to act on.
        """
        node = task.node
        if node.provision_state == states.ACTIVE:
            task.driver.boot.prepare_instance(task)
        else:
            deploy_opts = build_deploy_ramdisk_options(node)

            # NOTE(lucasagomes): We are going to extend the normal PXE config
            # to also contain the agent options so it could be used for
            # both the DIB ramdisk and the IPA ramdisk
            agent_opts = agent.build_agent_options(node)
            deploy_opts.update(agent_opts)

            task.driver.boot.prepare_ramdisk(task, deploy_opts)
Esempio n. 15
0
 def test_build_agent_options_conf(self):
     self.config(api_url='api-url', group='conductor')
     options = agent.build_agent_options(self.node)
     self.assertEqual('api-url', options['ipa-api-url'])
     self.assertEqual('fake_agent', options['ipa-driver-name'])
     self.assertEqual(0, options['coreos.configdrive'])
 def test_build_agent_options_conf(self):
     self.config(api_url='api-url', group='conductor')
     options = agent.build_agent_options()
     self.assertEqual('api-url', options['ipa-api-url'])
Esempio n. 17
0
def _prepare_agent_vmedia_boot(task):
    """prepare for vmedia boot."""

    deploy_ramdisk_opts = agent.build_agent_options(task.node)
    deploy_iso = task.node.driver_info['ilo_deploy_iso']
    _reboot_into(task, deploy_iso, deploy_ramdisk_opts)
Esempio n. 18
0
 def test_build_agent_options_conf(self):
     self.config(api_url='api-url', group='conductor')
     options = agent.build_agent_options(self.node)
     self.assertEqual('api-url', options['ipa-api-url'])
     self.assertEqual('fake_agent', options['ipa-driver-name'])
     self.assertEqual(0, options['coreos.configdrive'])
Esempio n. 19
0
 def test_build_agent_options_conf(self):
     self.config(api_url='api-url', group='conductor')
     options = agent.build_agent_options()
     self.assertEqual('api-url', options['ipa-api-url'])
Esempio n. 20
0
def _prepare_agent_vmedia_boot(task):
    """prepare for vmedia boot."""

    deploy_ramdisk_opts = agent.build_agent_options(task.node)
    deploy_iso = task.node.driver_info['ilo_deploy_iso']
    _reboot_into(task, deploy_iso, deploy_ramdisk_opts)