Example #1
0
    def run(self, **kwargs):

        self.context.prompt.render_warning_message(CLI_DEPRECATION_WARNING)

        repo_id = kwargs[OPTION_REPO_ID.keyword]
        node_id = load_consumer_id(self.context)
        dist_id = constants.HTTP_DISTRIBUTOR
        strategy = kwargs[STRATEGY_OPTION.keyword]
        binding_config = {constants.STRATEGY_KEYWORD: strategy}

        if not node_activated(self.context, node_id):
            msg = NOT_ACTIVATED_ERROR
            self.context.prompt.render_failure_message(msg)
            return os.EX_USAGE

        if not repository_enabled(self.context, repo_id):
            msg = BIND_FAILED_NOT_ENABLED
            self.context.prompt.render_failure_message(msg)
            return os.EX_USAGE

        if strategy not in constants.STRATEGIES:
            msg = STRATEGY_NOT_SUPPORTED % dict(n=strategy,
                                                s=constants.STRATEGIES)
            self.context.prompt.render_failure_message(msg)
            return os.EX_DATAERR

        self.context.server.bind.bind(node_id,
                                      repo_id,
                                      dist_id,
                                      notify_agent=False,
                                      binding_config=binding_config)
        self.context.prompt.render_success_message(BIND_SUCCEEDED)
        warning = BIND_WARNING % dict(r=repo_id)
        self.context.prompt.render_warning_message(warning)
Example #2
0
    def run(self, **kwargs):

        repo_id = kwargs[OPTION_REPO_ID.keyword]
        node_id = kwargs[NODE_ID_OPTION.keyword]
        dist_id = constants.HTTP_DISTRIBUTOR
        strategy = kwargs[STRATEGY_OPTION.keyword]
        binding_config = {constants.STRATEGY_KEYWORD: strategy}

        if not node_activated(self.context, node_id):
            msg = NOT_ACTIVATED_ERROR % dict(t=CONSUMER, id=node_id)
            self.context.prompt.render_failure_message(msg)
            return os.EX_USAGE

        if not repository_enabled(self.context, repo_id):
            msg = FAILED_NOT_ENABLED
            self.context.prompt.render_failure_message(msg)
            return os.EX_USAGE

        if strategy not in constants.STRATEGIES:
            msg = STRATEGY_NOT_SUPPORTED % dict(n=strategy, s=constants.STRATEGIES)
            self.context.prompt.render_failure_message(msg)
            return os.EX_DATAERR

        self.context.server.bind.bind(
            node_id,
            repo_id,
            dist_id,
            notify_agent=False,
            binding_config=binding_config)
        self.context.prompt.render_success_message(BIND_SUCCEEDED)
        warning = BIND_WARNING % dict(r=repo_id)
        self.context.prompt.render_warning_message(warning)
Example #3
0
    def run(self, **kwargs):

        convert_boolean_arguments([AUTO_PUBLISH_OPTION.keyword], kwargs)

        repo_id = kwargs[OPTION_REPO_ID.keyword]
        auto_publish = kwargs[AUTO_PUBLISH_OPTION.keyword]
        binding = self.context.server.repo_distributor

        if repository_enabled(self.context, repo_id):
            msg = ALREADY_ENABLED
            self.context.prompt.render_success_message(msg)
            return

        try:
            binding.create(
                repo_id,
                constants.HTTP_DISTRIBUTOR,
                {},
                auto_publish,
                constants.HTTP_DISTRIBUTOR)
            self.context.prompt.render_success_message(REPO_ENABLED)
            self.context.prompt.render_warning_message(ENABLE_WARNING % dict(r=repo_id))
            if auto_publish:
                self.context.prompt.render_warning_message(AUTO_PUBLISH_WARNING)
        except NotFoundException, e:
            for _id, _type in missing_resources(e):
                if _type == 'repository':
                    msg = RESOURCE_MISSING_ERROR % dict(t=REPOSITORY, id=_id)
                    self.context.prompt.render_failure_message(msg)
                else:
                    raise
            return os.EX_DATAERR
Example #4
0
    def run(self, **kwargs):

        convert_boolean_arguments([AUTO_PUBLISH_OPTION.keyword], kwargs)

        repo_id = kwargs[OPTION_REPO_ID.keyword]
        auto_publish = kwargs[AUTO_PUBLISH_OPTION.keyword]
        binding = self.context.server.repo_distributor

        if repository_enabled(self.context, repo_id):
            msg = ALREADY_ENABLED
            self.context.prompt.render_success_message(msg)
            return

        try:
            binding.create(repo_id, constants.HTTP_DISTRIBUTOR, {},
                           auto_publish, constants.HTTP_DISTRIBUTOR)
            self.context.prompt.render_success_message(REPO_ENABLED)
            self.context.prompt.render_warning_message(ENABLE_WARNING %
                                                       dict(r=repo_id))
            if auto_publish:
                self.context.prompt.render_warning_message(
                    AUTO_PUBLISH_WARNING)
        except NotFoundException, e:
            for _id, _type in missing_resources(e):
                if _type == 'repository':
                    msg = RESOURCE_MISSING_ERROR % dict(t=REPOSITORY, id=_id)
                    self.context.prompt.render_failure_message(msg)
                else:
                    raise
            return os.EX_DATAERR
Example #5
0
    def run(self, **kwargs):
        repo_id = kwargs[OPTION_REPO_ID.keyword]

        if not repository_enabled(self.context, repo_id):
            msg = FAILED_NOT_ENABLED
            self.context.prompt.render_failure_message(msg)
            return

        try:
            http = self.context.server.repo_actions.publish(repo_id, constants.HTTP_DISTRIBUTOR, {})
            task = http.response_body
            self.poll([task], kwargs)
        except NotFoundException, e:
            for _id, _type in missing_resources(e):
                if _type == 'repo_id':
                    msg = RESOURCE_MISSING_ERROR % dict(t=REPOSITORY, id=_id)
                    self.context.prompt.render_failure_message(msg)
                else:
                    raise
            return os.EX_DATAERR
Example #6
0
    def run(self, **kwargs):
        repo_id = kwargs[OPTION_REPO_ID.keyword]

        if not repository_enabled(self.context, repo_id):
            msg = FAILED_NOT_ENABLED
            self.context.prompt.render_success_message(msg)
            return

        try:
            http = self.context.server.repo_actions.publish(
                repo_id, constants.HTTP_DISTRIBUTOR, {})
            task = http.response_body
            self.poll([task], kwargs)
        except NotFoundException, e:
            for _id, _type in missing_resources(e):
                if _type == 'repo_id':
                    msg = RESOURCE_MISSING_ERROR % dict(t=REPOSITORY, id=_id)
                    self.context.prompt.render_failure_message(msg)
                else:
                    raise
            return os.EX_DATAERR