コード例 #1
0
    def test_host(self, ns, endpoint=None, **kwargs):
        failure_text = {
            "auth":
            "The manager was unable to login to %s on your behalf",
            "agent":
            "The manager was unable to invoke the agent on %s",
            "resolve":
            "Unable to resolve fqdn for %s",
            "reverse_resolve":
            "The agent on %s was unable to resolve the manager's IP address",
            "ping":
            "The manager was unable to ping %s",
            "reverse_ping":
            "The agent on %s was unable to ping the manager's IP address",
            "hostname_valid":
            "The system hostname on %s either does not resolve, or resolves to a loopback address",
            "fqdn_resolves":
            "The self-reported fqdn on %s does not resolve on the manager",
            "fqdn_matches":
            "The self-reported fqdn on %s does not resolve to the same address as the hostname supplied via CLI",
            "yum_valid_repos":
            "The yum configuration on %s contains invalid repository entries",
            "yum_can_update":
            "Unable to verify that %s is able to access any yum mirrors for vendor packages",
            "openssl":
            "Unable to verify that OpenSSL is working as expected for %s",
        }

        command = self.api.endpoints["test_host"].create(**kwargs)
        self.output.command(command)

        # Actually the command above may just return if the user used nowait so we need to make sure that the command has really
        # completed and if not wait for it to complete.
        command = CommandMonitor(self.api, command).wait_complete()

        if command["cancelled"]:
            raise BadUserInput(
                "\nTest host connection command cancelled for %s" %
                kwargs["address"])
        elif command["errored"]:
            raise BadUserInput(
                "\nTest host connection command errored for %s" %
                kwargs["address"])

        job = self.api.endpoints["job"].get_decoded(command["jobs"][0])
        step_result = job["step_results"].values()[0]

        failures = []
        for failkey in [
                result["name"] for result in step_result["status"]
                if not result["value"]
        ]:
            failures.append(failure_text[failkey] % step_result["address"])

        if failures:
            message = "Failed sanity checks (use --force to add anyway): "
            raise BadUserInput("\n".join([message] + failures))
コード例 #2
0
    def _resolve_osts(self, ns):
        if ns.osts is None:
            raise BadUserInput("At least one OST must be supplied.")

        osts = []
        for ost_spec in ns.osts:
            ost_vn = self._resolve_volume_node(ost_spec)
            osts.append({"conf_params": {}, "volume_id": ost_vn.volume_id})
        return osts
コード例 #3
0
    def _resolve_mdts(self, ns):
        if ns.mdts is None:
            raise BadUserInput("At least one MDT must be supplied.")

        mdts = []
        for mdt_spec in ns.mdts:
            mdt_vn = self._resolve_volume_node(mdt_spec)
            mdts.append({"conf_params": {}, "volume_id": mdt_vn.volume_id})
        return mdts
コード例 #4
0
    def _resolve_mgt(self, ns):
        if ns.mgt is None:
            raise BadUserInput("No MGT supplied.")

        if len(ns.mgt) > 1:
            raise BadUserInput("Only 1 MGT per filesystem is allowed.")

        mgt = {}
        try:
            mgt_vn = self._resolve_volume_node(ns.mgt[0])
            mgt['volume_id'] = mgt_vn.volume_id
        except (InvalidVolumeNode, NotFound):
            mgs = self.api.endpoints['host'].show(ns.mgt[0])
            kwargs = {'host_id': mgs['id'], 'kind': 'mgt'}
            try:
                mgt['id'] = self.api.endpoints['target'].list(**kwargs)[0]['id']
            except IndexError:
                raise BadUserInput("Invalid mgt spec: %s" % ns.mgt[0])
        return mgt
コード例 #5
0
    def add(self, ns):
        kwargs = {'address': ns.subject}

        if not ns.server_profile:
            raise BadUserInput("No server_profile supplied.")

        kwargs['server_profile'] = self.api.endpoints['server_profile'].show(ns.server_profile[0])['resource_uri']

        if not ns.force:
            self.test_host(ns, **kwargs)
        self.output(self.api_endpoint.create(**kwargs))