Example #1
0
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)" % parsed_args)

        nodes_config = oooutils.parse_env_file(parsed_args.env_file)

        if parsed_args.validate_only:
            return baremetal.validate_nodes(self.app.client_manager,
                                            nodes_json=nodes_config)

        if parsed_args.no_deploy_image:
            deploy_kernel = None
            deploy_ramdisk = None
        else:
            deploy_kernel = 'bm-deploy-kernel'
            deploy_ramdisk = 'bm-deploy-ramdisk'

        nodes = baremetal.register_or_update(
            self.app.client_manager,
            nodes_json=nodes_config,
            kernel_name=deploy_kernel,
            ramdisk_name=deploy_ramdisk,
            instance_boot_option=parsed_args.instance_boot_option)

        nodes_uuids = [node['uuid'] for node in nodes]

        if parsed_args.introspect:
            baremetal.introspect(self.app.client_manager,
                                 node_uuids=nodes_uuids,
                                 run_validations=parsed_args.run_validations)

        if parsed_args.provide:
            baremetal.provide(
                self.app.client_manager,
                node_uuids=nodes_uuids,
            )
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)" % parsed_args)

        nodes_config = oooutils.parse_env_file(parsed_args.env_file)
        parsed_args.env_file.close()

        if parsed_args.validate_only:
            return baremetal.validate_nodes(self.app.client_manager,
                                            nodes_json=nodes_config)

        # Look for *specific* deploy images and update the node data if
        # one is found.
        if not parsed_args.no_deploy_image:
            oooutils.update_nodes_deploy_data(nodes_config,
                                              http_boot=parsed_args.http_boot)
        nodes = baremetal.register_or_update(
            self.app.client_manager,
            nodes_json=nodes_config,
            instance_boot_option=parsed_args.instance_boot_option)

        nodes_uuids = [node['uuid'] for node in nodes]

        if parsed_args.introspect:
            baremetal.introspect(self.app.client_manager,
                                 node_uuids=nodes_uuids,
                                 run_validations=parsed_args.run_validations,
                                 concurrency=parsed_args.concurrency)

        if parsed_args.provide:
            baremetal.provide(
                self.app.client_manager,
                node_uuids=nodes_uuids,
            )
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)" % parsed_args)

        nodes_config = oooutils.parse_env_file(parsed_args.env_file)

        queue_name = str(uuid.uuid4())

        if parsed_args.no_deploy_image:
            deploy_kernel = None
            deploy_ramdisk = None
        else:
            deploy_kernel = 'bm-deploy-kernel'
            deploy_ramdisk = 'bm-deploy-ramdisk'

        nodes = baremetal.register_or_update(
            self.app.client_manager,
            nodes_json=nodes_config,
            queue_name=queue_name,
            kernel_name=deploy_kernel,
            ramdisk_name=deploy_ramdisk,
            instance_boot_option=parsed_args.instance_boot_option
        )

        nodes_uuids = [node['uuid'] for node in nodes]

        if parsed_args.introspect:
            baremetal.introspect(self.app.client_manager,
                                 node_uuids=nodes_uuids,
                                 queue_name=queue_name)

        if parsed_args.provide:
            baremetal.provide(self.app.client_manager,
                              node_uuids=nodes_uuids,
                              queue_name=queue_name)
    def take_action(self, parsed_args):

        self.log.debug("take_action(%s)" % parsed_args)

        if parsed_args.json or parsed_args.file_in.name.endswith('.json'):
            nodes_config = json.load(parsed_args.file_in)
        elif parsed_args.csv or parsed_args.file_in.name.endswith('.csv'):
            nodes_config = _csv_to_nodes_dict(parsed_args.file_in)
        elif parsed_args.file_in.name.endswith('.yaml'):
            nodes_config = yaml.safe_load(parsed_args.file_in)
        else:
            raise exceptions.InvalidConfiguration(
                _("Invalid file extension for %s, must be json, yaml or csv") %
                parsed_args.file_in.name)

        if 'nodes' in nodes_config:
            nodes_config = nodes_config['nodes']

        client = self.app.client_manager.baremetal
        if parsed_args.initial_state == "enroll":
            api_version = client.http_client.os_ironic_api_version
            if [int(part) for part in api_version.split('.')] < [1, 11]:
                raise exceptions.InvalidConfiguration(
                    _("OS_BAREMETAL_API_VERSION must be >=1.11 for use of "
                      "'enroll' provision state; currently %s") % api_version)

        # NOTE (dprince) move this to tripleo-common?
        for node in nodes_config:
            caps = node.get('capabilities', {})
            if not isinstance(caps, dict):
                caps = utils.capabilities_to_dict(caps)
            caps.setdefault('boot_option', parsed_args.instance_boot_option)
            node['capabilities'] = caps

        queue_name = str(uuid.uuid4())

        if parsed_args.no_deploy_image:
            deploy_kernel = None
            deploy_ramdisk = None
        else:
            deploy_kernel = parsed_args.deploy_kernel
            deploy_ramdisk = parsed_args.deploy_ramdisk

        nodes = baremetal.register_or_update(self.app.client_manager,
                                             nodes_json=nodes_config,
                                             queue_name=queue_name,
                                             kernel_name=deploy_kernel,
                                             ramdisk_name=deploy_ramdisk)

        node_uuids = [node['uuid'] for node in nodes]

        if parsed_args.initial_state == "available":
            baremetal.provide(self.app.client_manager,
                              node_uuids=node_uuids,
                              queue_name=queue_name)
    def take_action(self, parsed_args):

        self.log.debug("take_action(%s)" % parsed_args)

        file_type = None
        if parsed_args.json:
            file_type = 'json'
        elif parsed_args.csv:
            file_type = 'csv'

        nodes_config = utils.parse_env_file(parsed_args.file_in, file_type)

        client = self.app.client_manager.baremetal
        if parsed_args.initial_state == "enroll":
            api_version = client.http_client.os_ironic_api_version
            if [int(part) for part in api_version.split('.')] < [1, 11]:
                raise exceptions.InvalidConfiguration(
                    _("OS_BAREMETAL_API_VERSION must be >=1.11 for use of "
                      "'enroll' provision state; currently %s") % api_version)

        queue_name = str(uuid.uuid4())

        if parsed_args.no_deploy_image:
            deploy_kernel = None
            deploy_ramdisk = None
        else:
            deploy_kernel = parsed_args.deploy_kernel
            deploy_ramdisk = parsed_args.deploy_ramdisk

        nodes = baremetal.register_or_update(
            self.app.client_manager,
            nodes_json=nodes_config,
            queue_name=queue_name,
            kernel_name=deploy_kernel,
            ramdisk_name=deploy_ramdisk,
            instance_boot_option=parsed_args.instance_boot_option
        )

        if parsed_args.initial_state == "available":
            # NOTE(dtantsur): newly enrolled nodes state is reported as
            # "enroll" from the workflow even though it's actually "manageable"
            # because the node list is built before "manage" action is run.
            node_uuids = [node['uuid'] for node in nodes
                          if node['provision_state'] in {'manageable',
                                                         'enroll'}]
            baremetal.provide(self.app.client_manager, node_uuids=node_uuids,
                              queue_name=queue_name)
Example #6
0
    def test_register_or_update_success(self):

        self.websocket.wait_for_messages.return_value = self.message_success

        self.assertEqual(
            baremetal.register_or_update(self.app.client_manager,
                                         nodes_json=[],
                                         kernel_name="kernel",
                                         ramdisk_name="ramdisk"), [])

        self.workflow.executions.create.assert_called_once_with(
            'tripleo.baremetal.v1.register_or_update',
            workflow_input={
                'kernel_name': 'kernel',
                'nodes_json': [],
                'ramdisk_name': 'ramdisk'
            })
Example #7
0
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)" % parsed_args)

        nodes_config = oooutils.parse_env_file(parsed_args.env_file)
        parsed_args.env_file.close()

        if parsed_args.validate_only:
            return baremetal.validate_nodes(self.app.client_manager,
                                            nodes_json=nodes_config)

        # Look for *specific* deploy images and update the node data if
        # one is found.
        if not parsed_args.no_deploy_image:
            oooutils.update_nodes_deploy_data(nodes_config,
                                              http_boot=parsed_args.http_boot)
        nodes = baremetal.register_or_update(
            self.app.client_manager,
            nodes_json=nodes_config,
            instance_boot_option=parsed_args.instance_boot_option
        )

        nodes_uuids = [node.uuid for node in nodes]

        if parsed_args.introspect:
            extra_vars = {
                "node_uuids": nodes_uuids,
                "run_validations": parsed_args.run_validations,
                "concurrency": parsed_args.concurrency,
            }

            with oooutils.TempDirs() as tmp:
                oooutils.run_ansible_playbook(
                    playbook='cli-baremetal-introspect.yaml',
                    inventory='localhost,',
                    workdir=tmp,
                    playbook_dir=constants.ANSIBLE_TRIPLEO_PLAYBOOKS,
                    verbosity=oooutils.playbook_verbosity(self=self),
                    extra_vars=extra_vars
                )

        if parsed_args.provide:
            baremetal.provide(
                verbosity=oooutils.playbook_verbosity(self=self),
                node_uuids=nodes_uuids
            )
Example #8
0
    def take_action(self, parsed_args):

        self.log.debug("take_action(%s)" % parsed_args)

        file_type = None
        if parsed_args.json:
            file_type = 'json'
        elif parsed_args.csv:
            file_type = 'csv'

        nodes_config = utils.parse_env_file(parsed_args.file_in, file_type)

        client = self.app.client_manager.baremetal
        if parsed_args.initial_state == "enroll":
            api_version = client.http_client.os_ironic_api_version
            if [int(part) for part in api_version.split('.')] < [1, 11]:
                raise exceptions.InvalidConfiguration(
                    _("OS_BAREMETAL_API_VERSION must be >=1.11 for use of "
                      "'enroll' provision state; currently %s") % api_version)

        queue_name = str(uuid.uuid4())

        if parsed_args.no_deploy_image:
            deploy_kernel = None
            deploy_ramdisk = None
        else:
            deploy_kernel = parsed_args.deploy_kernel
            deploy_ramdisk = parsed_args.deploy_ramdisk

        nodes = baremetal.register_or_update(
            self.app.client_manager,
            nodes_json=nodes_config,
            queue_name=queue_name,
            kernel_name=deploy_kernel,
            ramdisk_name=deploy_ramdisk,
            instance_boot_option=parsed_args.instance_boot_option)

        node_uuids = [node['uuid'] for node in nodes]

        if parsed_args.initial_state == "available":
            baremetal.provide(self.app.client_manager,
                              node_uuids=node_uuids,
                              queue_name=queue_name)
    def test_register_or_update_success(self):

        self.websocket.wait_for_message.return_value = {
            "status": "SUCCESS",
            "registered_nodes": [],
        }

        self.assertEqual(
            baremetal.register_or_update(self.app.client_manager,
                                         nodes_json=[],
                                         queue_name="QUEUE_NAME",
                                         kernel_name="kernel",
                                         ramdisk_name="ramdisk"), [])

        self.workflow.executions.create.assert_called_once_with(
            'tripleo.baremetal.v1.register_or_update',
            workflow_input={
                'kernel_name': 'kernel',
                'queue_name': 'QUEUE_NAME',
                'nodes_json': [],
                'ramdisk_name': 'ramdisk'
            })
    def take_action(self, parsed_args):
        self.log.debug("take_action(%s)" % parsed_args)

        nodes_config = oooutils.parse_env_file(parsed_args.env_file)

        if parsed_args.validate_only:
            return baremetal.validate_nodes(self.app.client_manager,
                                            nodes_json=nodes_config)

        if parsed_args.no_deploy_image:
            deploy_kernel = None
            deploy_ramdisk = None
        else:
            deploy_kernel = oooutils.deploy_kernel()[0]
            deploy_ramdisk = oooutils.deploy_ramdisk()[0]

        # Look for *specific* deploy images and update the node data if
        # one is found.
        oooutils.update_nodes_deploy_data(self.app.client_manager.image,
                                          nodes_config)
        nodes = baremetal.register_or_update(
            self.app.client_manager,
            nodes_json=nodes_config,
            kernel_name=deploy_kernel,
            ramdisk_name=deploy_ramdisk,
            instance_boot_option=parsed_args.instance_boot_option)

        nodes_uuids = [node['uuid'] for node in nodes]

        if parsed_args.introspect:
            baremetal.introspect(self.app.client_manager,
                                 node_uuids=nodes_uuids,
                                 run_validations=parsed_args.run_validations)

        if parsed_args.provide:
            baremetal.provide(
                self.app.client_manager,
                node_uuids=nodes_uuids,
            )
    def test_register_or_update_success(self):

        self.websocket.wait_for_message.return_value = {
            "status": "SUCCESS",
            "registered_nodes": [],
        }

        self.assertEqual(baremetal.register_or_update(
            self.app.client_manager,
            nodes_json=[],
            queue_name="QUEUE_NAME",
            kernel_name="kernel",
            ramdisk_name="ramdisk"
        ), [])

        self.workflow.executions.create.assert_called_once_with(
            'tripleo.baremetal.v1.register_or_update',
            workflow_input={
                'kernel_name': 'kernel',
                'queue_name': 'QUEUE_NAME',
                'nodes_json': [],
                'ramdisk_name': 'ramdisk'
            })
Example #12
0
 def test_register_or_update_success(self):
     self.assertEqual(
         baremetal.register_or_update(self.app.client_manager,
                                      nodes_json=[],
                                      instance_boot_option='local'),
         [mock.ANY])