本文整理汇总了Python中pulp_node.extension.missing_resources函数的典型用法代码示例。如果您正苦于以下问题:Python missing_resources函数的具体用法?Python missing_resources怎么用?Python missing_resources使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了missing_resources函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
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: run
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
示例3: run
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
示例4: missing_resources
def missing_resources(self, prompt, exception):
unhandled = []
for _id, _type in missing_resources(exception):
if _type == 'consumer_id':
msg = RESOURCE_MISSING_ERROR % dict(t=NODE, id=_id)
prompt.render_failure_message(msg)
continue
if _type == 'repo_id':
msg = RESOURCE_MISSING_ERROR % dict(t=REPOSITORY, id=_id)
prompt.render_failure_message(msg)
continue
unhandled.append((_id, _type))
return unhandled
示例5: run
def run(self, **kwargs):
consumer_id = load_consumer_id(self.context)
delta = {'notes': ACTIVATED_NOTE}
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
示例6: run
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
示例7: run
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