示例#1
0
文件: commands.py 项目: alanoe/pulp
    def run(self, **kwargs):
        node_id = kwargs[NODE_ID_OPTION.keyword]
        max_bandwidth = kwargs[MAX_BANDWIDTH_OPTION.keyword]
        max_concurrency = kwargs[MAX_CONCURRENCY_OPTION.keyword]
        units = [dict(type_id='node', unit_key=None)]
        options = {
            constants.MAX_DOWNLOAD_BANDWIDTH_KEYWORD: max_bandwidth,
            constants.MAX_DOWNLOAD_CONCURRENCY_KEYWORD: max_concurrency,
        }

        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

        try:
            http = self.context.server.consumer_content.update(node_id, units=units,
                                                               options=options)
            task = http.response_body
            self.poll([task], kwargs)
        except NotFoundException, e:
            for _id, _type in missing_resources(e):
                if _type == 'consumer':
                    msg = RESOURCE_MISSING_ERROR % dict(t=NODE, id=_id)
                    self.context.prompt.render_failure_message(msg)
                else:
                    raise
            return os.EX_DATAERR
示例#2
0
    def run(self, **kwargs):

        self.context.prompt.render_warning_message(CLI_DEPRECATION_WARNING)

        consumer_id = load_consumer_id(self.context)
        delta = {
            'notes': {
                constants.NODE_NOTE_KEY: None,
                constants.STRATEGY_NOTE_KEY: None
            }
        }

        if not node_activated(self.context, consumer_id):
            self.context.prompt.render_success_message(
                NOT_ACTIVATED_NOTHING_DONE)
            return

        try:
            self.context.server.consumer.update(consumer_id, delta)
            self.context.prompt.render_success_message(NODE_DEACTIVATED)
        except NotFoundException, e:
            for _id, _type in missing_resources(e):
                if _type == 'consumer':
                    self.context.prompt.render_failure_message(
                        NOT_REGISTERED_MESSAGE)
                else:
                    raise
            return os.EX_DATAERR
示例#3
0
文件: commands.py 项目: pombreda/pulp
    def run(self, **kwargs):
        node_id = kwargs[NODE_ID_OPTION.keyword]
        max_bandwidth = kwargs[MAX_BANDWIDTH_OPTION.keyword]
        max_concurrency = kwargs[MAX_CONCURRENCY_OPTION.keyword]
        units = [dict(type_id='node', unit_key=None)]
        options = {
            constants.MAX_DOWNLOAD_BANDWIDTH_KEYWORD: max_bandwidth,
            constants.MAX_DOWNLOAD_CONCURRENCY_KEYWORD: max_concurrency,
        }

        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

        try:
            http = self.context.server.consumer_content.update(node_id,
                                                               units=units,
                                                               options=options)
            task = http.response_body
            self.poll([task], kwargs)
        except NotFoundException, e:
            for _id, _type in missing_resources(e):
                if _type == 'consumer':
                    msg = RESOURCE_MISSING_ERROR % dict(t=NODE, id=_id)
                    self.context.prompt.render_failure_message(msg)
                else:
                    raise
            return os.EX_DATAERR
示例#4
0
文件: commands.py 项目: alanoe/pulp
    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)
示例#5
0
文件: commands.py 项目: alanoe/pulp
    def run(self, **kwargs):

        consumer_id = kwargs[OPTION_CONSUMER_ID.keyword]
        strategy = kwargs[STRATEGY_OPTION.keyword]
        delta = {'notes': {constants.NODE_NOTE_KEY: True, constants.STRATEGY_NOTE_KEY: strategy}}

        if node_activated(self.context, consumer_id):
            msg = ALREADY_ACTIVATED_NOTHING_DONE % dict(n=CONSUMER)
            self.context.prompt.render_success_message(msg)
            return

        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

        try:
            self.context.server.consumer.update(consumer_id, delta)
            self.context.prompt.render_success_message(NODE_ACTIVATED)
        except NotFoundException, e:
            for _id, _type in missing_resources(e):
                if _type == 'consumer':
                    msg = RESOURCE_MISSING_ERROR % dict(t=CONSUMER, id=_id)
                    self.context.prompt.render_failure_message(msg)
                else:
                    raise
            return os.EX_DATAERR
示例#6
0
文件: commands.py 项目: pombreda/pulp
    def run(self, **kwargs):

        consumer_id = kwargs[NODE_ID_OPTION.keyword]
        delta = {
            'notes': {
                constants.NODE_NOTE_KEY: None,
                constants.STRATEGY_NOTE_KEY: None
            }
        }

        if not node_activated(self.context, consumer_id):
            msg = NOT_ACTIVATED_NOTHING_DONE % dict(t=CONSUMER)
            self.context.prompt.render_success_message(msg)
            return

        try:
            self.context.server.consumer.update(consumer_id, delta)
            self.context.prompt.render_success_message(NODE_DEACTIVATED)
        except NotFoundException, e:
            for _id, _type in missing_resources(e):
                if _type == 'consumer':
                    msg = RESOURCE_MISSING_ERROR % dict(t=CONSUMER, id=_id)
                    self.context.prompt.render_failure_message(msg)
                else:
                    raise
            return os.EX_DATAERR
示例#7
0
    def run(self, **kwargs):

        self.context.prompt.render_warning_message(CLI_DEPRECATION_WARNING)

        consumer_id = load_consumer_id(self.context)
        strategy = kwargs[STRATEGY_OPTION.keyword]
        delta = {'notes': {constants.NODE_NOTE_KEY: True, constants.STRATEGY_NOTE_KEY: strategy}}

        if node_activated(self.context, consumer_id):
            self.context.prompt.render_success_message(ALREADY_ACTIVATED_NOTHING_DONE)
            return

        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

        try:
            self.context.server.consumer.update(consumer_id, delta)
            self.context.prompt.render_success_message(NODE_ACTIVATED)
        except NotFoundException, e:
            for _id, _type in missing_resources(e):
                if _type == 'consumer':
                    self.context.prompt.render_failure_message(NOT_REGISTERED_MESSAGE)
                else:
                    raise
            return os.EX_DATAERR
示例#8
0
文件: commands.py 项目: kbotc/pulp
    def run(self, **kwargs):

        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 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

        try:
            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)
        except NotFoundException, e:
            unhandled = self.missing_resources(self.context.prompt, e)
            for _id, _type in unhandled:
                if _type == "distributor":
                    msg = BIND_FAILED_NOT_ENABLED
                    self.context.prompt.render_failure_message(msg)
                else:
                    raise
            return os.EX_DATAERR
示例#9
0
文件: commands.py 项目: pombreda/pulp
    def run(self, **kwargs):

        consumer_id = kwargs[OPTION_CONSUMER_ID.keyword]
        strategy = kwargs[STRATEGY_OPTION.keyword]
        delta = {
            'notes': {
                constants.NODE_NOTE_KEY: True,
                constants.STRATEGY_NOTE_KEY: strategy
            }
        }

        if node_activated(self.context, consumer_id):
            msg = ALREADY_ACTIVATED_NOTHING_DONE % dict(n=CONSUMER)
            self.context.prompt.render_success_message(msg)
            return

        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

        try:
            self.context.server.consumer.update(consumer_id, delta)
            self.context.prompt.render_success_message(NODE_ACTIVATED)
        except NotFoundException, e:
            for _id, _type in missing_resources(e):
                if _type == 'consumer':
                    msg = RESOURCE_MISSING_ERROR % dict(t=CONSUMER, id=_id)
                    self.context.prompt.render_failure_message(msg)
                else:
                    raise
            return os.EX_DATAERR
示例#10
0
文件: commands.py 项目: juwu/pulp
    def run(self, **kwargs):
        node_id = kwargs[NODE_ID_OPTION.keyword]
        strategy = kwargs[STRATEGY_OPTION.keyword]
        options = {constants.STRATEGY_KEYWORD: strategy}
        units = [dict(type_id='node', unit_key=None)]

        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 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

        try:
            http = self.context.server.consumer_content.update(node_id, units=units, options=options)
            task = http.response_body
            self.poll([task])
        except NotFoundException, e:
            for _id, _type in missing_resources(e):
                if _type == 'consumer':
                    msg = RESOURCE_MISSING_ERROR % dict(t=NODE, id=_id)
                    self.context.prompt.render_failure_message(msg)
                else:
                    raise
            return os.EX_DATAERR
示例#11
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)
示例#12
0
    def run(self, **kwargs):

        self.context.prompt.render_warning_message(CLI_DEPRECATION_WARNING)

        consumer_id = load_consumer_id(self.context)
        strategy = kwargs[STRATEGY_OPTION.keyword]
        delta = {
            'notes': {
                constants.NODE_NOTE_KEY: True,
                constants.STRATEGY_NOTE_KEY: strategy
            }
        }

        if node_activated(self.context, consumer_id):
            self.context.prompt.render_success_message(
                ALREADY_ACTIVATED_NOTHING_DONE)
            return

        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

        try:
            self.context.server.consumer.update(consumer_id, delta)
            self.context.prompt.render_success_message(NODE_ACTIVATED)
        except NotFoundException, e:
            for _id, _type in missing_resources(e):
                if _type == 'consumer':
                    self.context.prompt.render_failure_message(
                        NOT_REGISTERED_MESSAGE)
                else:
                    raise
            return os.EX_DATAERR
示例#13
0
文件: commands.py 项目: kbotc/pulp
    def run(self, **kwargs):

        consumer_id = load_consumer_id(self.context)
        delta = {"notes": {constants.NODE_NOTE_KEY: None, constants.STRATEGY_NOTE_KEY: None}}

        if not node_activated(self.context, consumer_id):
            self.context.prompt.render_success_message(NOT_ACTIVATED_NOTHING_DONE)
            return

        try:
            self.context.server.consumer.update(consumer_id, delta)
            self.context.prompt.render_success_message(NODE_DEACTIVATED)
        except NotFoundException, e:
            for _id, _type in missing_resources(e):
                if _type == "consumer":
                    self.context.prompt.render_failure_message(NOT_REGISTERED_MESSAGE)
                else:
                    raise
            return os.EX_DATAERR
示例#14
0
文件: commands.py 项目: alanoe/pulp
    def run(self, **kwargs):

        consumer_id = kwargs[NODE_ID_OPTION.keyword]
        delta = {'notes': {constants.NODE_NOTE_KEY: None, constants.STRATEGY_NOTE_KEY: None}}

        if not node_activated(self.context, consumer_id):
            msg = NOT_ACTIVATED_NOTHING_DONE % dict(t=CONSUMER)
            self.context.prompt.render_success_message(msg)
            return

        try:
            self.context.server.consumer.update(consumer_id, delta)
            self.context.prompt.render_success_message(NODE_DEACTIVATED)
        except NotFoundException, e:
            for _id, _type in missing_resources(e):
                if _type == 'consumer':
                    msg = RESOURCE_MISSING_ERROR % dict(t=CONSUMER, id=_id)
                    self.context.prompt.render_failure_message(msg)
                else:
                    raise
            return os.EX_DATAERR
示例#15
0
文件: commands.py 项目: cliffy94/pulp
    def run(self, **kwargs):
        node_id = kwargs[NODE_ID_OPTION.keyword]
        units = [dict(type_id='node', unit_key=None)]

        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

        try:
            http = self.context.server.consumer_content.update(node_id, units=units, options={})
            task = http.response_body
            self.poll([task], kwargs)
        except NotFoundException, e:
            for _id, _type in missing_resources(e):
                if _type == 'consumer':
                    msg = RESOURCE_MISSING_ERROR % dict(t=NODE, id=_id)
                    self.context.prompt.render_failure_message(msg)
                else:
                    raise
            return os.EX_DATAERR
示例#16
0
    def run(self, **kwargs):
        node_id = kwargs[NODE_ID_OPTION.keyword]
        units = [dict(type_id='node', unit_key=None)]

        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

        try:
            http = self.context.server.consumer_content.update(node_id,
                                                               units=units,
                                                               options={})
            task = http.response_body
            self.poll([task], kwargs)
        except NotFoundException, e:
            for _id, _type in missing_resources(e):
                if _type == 'consumer':
                    msg = RESOURCE_MISSING_ERROR % dict(t=NODE, id=_id)
                    self.context.prompt.render_failure_message(msg)
                else:
                    raise
            return os.EX_DATAERR
示例#17
0
文件: commands.py 项目: pombreda/pulp
    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 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

        try:
            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)
        except NotFoundException, e:
            unhandled = self.missing_resources(self.context.prompt, e)
            for _id, _type in unhandled:
                if _type == 'distributor':
                    msg = FAILED_NOT_ENABLED
                    self.context.prompt.render_failure_message(msg)
                else:
                    raise
            return os.EX_DATAERR