本文整理匯總了Python中result.Result.pluginError方法的典型用法代碼示例。如果您正苦於以下問題:Python Result.pluginError方法的具體用法?Python Result.pluginError怎麽用?Python Result.pluginError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類result.Result
的用法示例。
在下文中一共展示了Result.pluginError方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: run_filters
# 需要導入模塊: from result import Result [as 別名]
# 或者: from result.Result import pluginError [as 別名]
def run_filters(self, filters, hostIDs, vmID, properties_map):
result = Result()
request_id = str(uuid.uuid1())
log_adapter = \
utils.RequestAdapter(self._logger,
{'method': 'run_filters',
'request_id': request_id})
# run each filter in a process for robustness
log_adapter.info("got request: %s" % str(filters))
avail_f, missing_f = utils.partition(filters,
lambda f: f in self._filters)
# handle missing filters
for f in missing_f:
log_adapter.warning("Filter requested but was not found: %s" % f)
result.pluginError(f, "plugin not found: '%s'" % f)
# Prepare a generator "list" of runners
filterRunners = [
PythonMethodRunner(
self._pluginDir,
self._class_to_module_map[f],
f,
utils.FILTER,
(hostIDs, vmID, properties_map),
request_id)
for f in avail_f
]
for runner in filterRunners:
runner.start()
log_adapter.debug("Waiting for filters to finish")
# TODO add timeout config
if utils.waitOnGroup(filterRunners):
log_adapter.warning("Waiting on filters timed out")
log_adapter.debug("Aggregating results")
filters_results = self.aggregate_filter_results(filterRunners,
request_id)
if filters_results is None:
log_adapter.info('All filters failed, return the full list')
result.error("all filters failed")
filters_results = hostIDs
result.add(filters_results)
log_adapter.info('returning: %s' % str(filters_results))
return result
示例2: run_cost_functions
# 需要導入模塊: from result import Result [as 別名]
# 或者: from result.Result import pluginError [as 別名]
def run_cost_functions(self,
cost_functions,
hostIDs,
vmID,
properties_map):
result = Result()
request_id = str(uuid.uuid1())
log_adapter = \
utils.RequestAdapter(self._logger,
{'method': 'run_cost_functions',
'request_id': request_id})
# run each filter in a process for robustness
log_adapter.info("got request: %s" % str(cost_functions))
# Get the list of known and unknown score functions
available_cost_f, missing_cost_f = \
utils.partition(cost_functions, lambda (n, w): n in self._scores)
# Report the unknown functions
for name, weight in missing_cost_f:
log_adapter.warning("requested but was not found: %s" % name)
result.pluginError(name, "plugin not found: '%s'" % name)
# Prepare a generator "list" with runners and weights
scoreRunners = [
(PythonMethodRunner(
self._pluginDir,
self._class_to_module_map[name],
name,
utils.SCORE,
(hostIDs, vmID, properties_map),
request_id), weight)
for name, weight in available_cost_f
]
for runner, _weight in scoreRunners:
runner.start()
log_adapter.debug("Waiting for scoring to finish")
if utils.waitOnGroup([runner for runner, _weight in scoreRunners]):
log_adapter.warning("Waiting on score functions timed out")
result.error("Waiting on score functions timed out")
log_adapter.debug("Aggregating results")
results = self.aggregate_score_results(scoreRunners, request_id)
result.add(results)
log_adapter.info('returning: %s' % str(results))
return result
示例3: run_load_balancing
# 需要導入模塊: from result import Result [as 別名]
# 或者: from result.Result import pluginError [as 別名]
def run_load_balancing(self, balance, hostIDs, properties_map):
result = Result()
request_id = str(uuid.uuid1())
log_adapter = \
utils.RequestAdapter(self._logger,
{'method': 'run_load_balancing',
'request_id': request_id})
log_adapter.info("got request: %s" % balance)
if balance not in self._balancers:
warn_message = "Load balance requested but was not found: %s"\
% balance
log_adapter.warning(warn_message)
result.pluginError(balance, warn_message)
return result
runner = PythonMethodRunner(self._pluginDir,
self._class_to_module_map[balance],
balance,
utils.BALANCE,
(hostIDs, properties_map),
request_id)
runner.start()
log_adapter.debug('Waiting for balance to finish')
runner.join(30)
log_adapter.info('returning: %s' % str(runner.getResults()))
if runner.getResults() is None:
result.add(['', []])
else:
result.add(runner.getResults())
return result