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)
Beispiel #3
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)

        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)
Beispiel #5
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
            )
Beispiel #6
0
    def take_action(self, parsed_args):
        nodes_config = utils.parse_env_file(parsed_args.instackenv)
        parsed_args.instackenv.close()
        result = parameters.generate_fencing_parameters(
            clients=self.app.client_manager,
            nodes_json=nodes_config,
            delay=parsed_args.delay,
            ipmi_level=parsed_args.ipmi_level,
            ipmi_cipher=parsed_args.ipmi_cipher,
            ipmi_lanplus=parsed_args.ipmi_lanplus,
        )

        fencing_parameters = yaml.safe_dump(result, default_flow_style=False)
        if parsed_args.output:
            parsed_args.output.write(fencing_parameters)
            parsed_args.output.close()
        else:
            print(fencing_parameters)
Beispiel #7
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)
Beispiel #8
0
    def take_action(self, parsed_args):
        nodes_config = utils.parse_env_file(parsed_args.instackenv)

        workflow_input = {
            'nodes_json': nodes_config,
            'delay': parsed_args.delay,
            'ipmi_level': parsed_args.ipmi_level,
            'ipmi_cipher': parsed_args.ipmi_cipher,
            'ipmi_lanplus': parsed_args.ipmi_lanplus,
        }

        result = parameters.generate_fencing_parameters(
            self.app.client_manager, **workflow_input)

        fencing_parameters = yaml.safe_dump(result, default_flow_style=False)
        if parsed_args.output:
            parsed_args.output.write(fencing_parameters)
        else:
            print(fencing_parameters)
    def take_action(self, parsed_args):
        nodes_config = utils.parse_env_file(parsed_args.instackenv)

        # We only need to collect OpenStack client authentication data
        # if we have nodes using Ironic's pxe_ssh driver. If there are
        # any, we'll use the fence_ironic fencing agent, which requires
        # the auth data.
        os_auth = None
        for node in nodes_config:
            if node["pm_type"] == "pxe_ssh":
                os_auth = {}
        if os_auth:
            try:
                os_auth["auth_url"] = os.environ["OS_AUTH_URL"]
                os_auth["login"] = os.environ["OS_USERNAME"]
                os_auth["passwd"] = os.environ["OS_PASSWORD"]
                os_auth["tenant_name"] = os.environ["OS_TENANT_NAME"]
            except KeyError:
                # This really shouldn't happen since we're running in
                # tripleoclient
                raise ValueError(
                    _("Unable to find one or more of OS_AUTH_URL, "
                      "OS_USERNAME, OS_PASSWORD or OS_TENANT_NAME in the "
                      "environment."))
        workflow_input = {
            'nodes_json': nodes_config,
            'os_auth': os_auth,
            'fence_action': parsed_args.fence_action,
            'delay': parsed_args.delay,
            'ipmi_level': parsed_args.ipmi_level,
            'ipmi_cipher': parsed_args.ipmi_cipher,
            'ipmi_lanplus': parsed_args.ipmi_lanplus,
            }
        result = base.call_action(
            self.app.client_manager.workflow_engine,
            'tripleo.parameters.generate_fencing',
            **workflow_input)
        fencing_parameters = yaml.safe_dump(result, default_flow_style=False)
        if parsed_args.output:
            parsed_args.output.write(fencing_parameters)
        else:
            print(fencing_parameters)
    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,
            )