本文整理汇总了Python中st2common.models.api.action.RunnerTypeAPI.validate方法的典型用法代码示例。如果您正苦于以下问题:Python RunnerTypeAPI.validate方法的具体用法?Python RunnerTypeAPI.validate怎么用?Python RunnerTypeAPI.validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类st2common.models.api.action.RunnerTypeAPI
的用法示例。
在下文中一共展示了RunnerTypeAPI.validate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register_runner_types
# 需要导入模块: from st2common.models.api.action import RunnerTypeAPI [as 别名]
# 或者: from st2common.models.api.action.RunnerTypeAPI import validate [as 别名]
def register_runner_types():
LOG.debug('Start : register default RunnerTypes.')
for runnertype in RUNNER_TYPES:
try:
runnertype_db = get_runnertype_by_name(runnertype['name'])
update = True
except StackStormDBObjectNotFoundError:
runnertype_db = None
update = False
runnertype_api = RunnerTypeAPI(**runnertype)
runnertype_api.validate()
runner_type_model = RunnerTypeAPI.to_model(runnertype_api)
if runnertype_db:
runner_type_model.id = runnertype_db.id
try:
runnertype_db = RunnerType.add_or_update(runner_type_model)
extra = {'runnertype_db': runnertype_db}
if update:
LOG.audit('RunnerType updated. RunnerType %s', runnertype_db, extra=extra)
else:
LOG.audit('RunnerType created. RunnerType %s', runnertype_db, extra=extra)
except Exception:
LOG.exception('Unable to register runner type %s.', runnertype['name'])
LOG.debug('End : register default RunnerTypes.')
示例2: register_runner_types
# 需要导入模块: from st2common.models.api.action import RunnerTypeAPI [as 别名]
# 或者: from st2common.models.api.action.RunnerTypeAPI import validate [as 别名]
def register_runner_types(experimental=False):
"""
:param experimental: True to also register experimental runners.
:type experimental: ``bool``
"""
LOG.debug('Start : register default RunnerTypes.')
for runner_type in RUNNER_TYPES:
runner_type = copy.deepcopy(runner_type)
# For backward compatibility reasons, we also register runners under the old names
runner_names = [runner_type['name']] + runner_type.get('aliases', [])
for runner_name in runner_names:
runner_type['name'] = runner_name
runner_experimental = runner_type.get('experimental', False)
if runner_experimental and not experimental:
LOG.debug('Skipping experimental runner "%s"' % (runner_name))
continue
# Remove additional, non db-model attributes
non_db_attributes = ['experimental', 'aliases']
for attribute in non_db_attributes:
if attribute in runner_type:
del runner_type[attribute]
try:
runner_type_db = get_runnertype_by_name(runner_name)
update = True
except StackStormDBObjectNotFoundError:
runner_type_db = None
update = False
# Note: We don't want to overwrite "enabled" attribute which is already in the database
# (aka we don't want to re-enable runner which has been disabled by the user)
if runner_type_db and runner_type_db['enabled'] != runner_type['enabled']:
runner_type['enabled'] = runner_type_db['enabled']
runner_type_api = RunnerTypeAPI(**runner_type)
runner_type_api.validate()
runner_type_model = RunnerTypeAPI.to_model(runner_type_api)
if runner_type_db:
runner_type_model.id = runner_type_db.id
try:
runner_type_db = RunnerType.add_or_update(runner_type_model)
extra = {'runner_type_db': runner_type_db}
if update:
LOG.audit('RunnerType updated. RunnerType %s', runner_type_db, extra=extra)
else:
LOG.audit('RunnerType created. RunnerType %s', runner_type_db, extra=extra)
except Exception:
LOG.exception('Unable to register runner type %s.', runner_type['name'])
LOG.debug('End : register default RunnerTypes.')
示例3: register_runner
# 需要导入模块: from st2common.models.api.action import RunnerTypeAPI [as 别名]
# 或者: from st2common.models.api.action.RunnerTypeAPI import validate [as 别名]
def register_runner(runner_type, experimental):
# For backward compatibility reasons, we also register runners under the old names
runner_names = [runner_type['name']] + runner_type.get('aliases', [])
for runner_name in runner_names:
runner_type['name'] = runner_name
runner_experimental = runner_type.get('experimental', False)
if runner_experimental and not experimental:
LOG.debug('Skipping experimental runner "%s"' % (runner_name))
continue
# Remove additional, non db-model attributes
non_db_attributes = ['experimental', 'aliases']
for attribute in non_db_attributes:
if attribute in runner_type:
del runner_type[attribute]
try:
runner_type_db = get_runnertype_by_name(runner_name)
update = True
except StackStormDBObjectNotFoundError:
runner_type_db = None
update = False
# Note: We don't want to overwrite "enabled" attribute which is already in the database
# (aka we don't want to re-enable runner which has been disabled by the user)
if runner_type_db and runner_type_db['enabled'] != runner_type['enabled']:
runner_type['enabled'] = runner_type_db['enabled']
# If package is not provided, assume it's the same as module name for backward
# compatibility reasons
if not runner_type.get('runner_package', None):
runner_type['runner_package'] = runner_type['runner_module']
runner_type_api = RunnerTypeAPI(**runner_type)
runner_type_api.validate()
runner_type_model = RunnerTypeAPI.to_model(runner_type_api)
if runner_type_db:
runner_type_model.id = runner_type_db.id
try:
runner_type_db = RunnerType.add_or_update(runner_type_model)
extra = {'runner_type_db': runner_type_db}
if update:
LOG.audit('RunnerType updated. RunnerType %s', runner_type_db, extra=extra)
else:
LOG.audit('RunnerType created. RunnerType %s', runner_type_db, extra=extra)
except Exception:
LOG.exception('Unable to register runner type %s.', runner_type['name'])
return 0
return 1
示例4: register_runner_types
# 需要导入模块: from st2common.models.api.action import RunnerTypeAPI [as 别名]
# 或者: from st2common.models.api.action.RunnerTypeAPI import validate [as 别名]
def register_runner_types(experimental=False):
"""
:param experimental: True to also register experimental runners.
:type experimental: ``bool``
"""
LOG.debug("Start : register default RunnerTypes.")
for runner_type in RUNNER_TYPES:
runner_type = copy.deepcopy(runner_type)
# For backward compatibility reasons, we also register runners under the old names
runner_names = [runner_type["name"]] + runner_type.get("aliases", [])
for runner_name in runner_names:
runner_type["name"] = runner_name
runner_experimental = runner_type.get("experimental", False)
if runner_experimental and not experimental:
LOG.debug('Skipping experimental runner "%s"' % (runner_name))
continue
# Remove additional, non db-model attributes
non_db_attributes = ["experimental", "aliases"]
for attribute in non_db_attributes:
if attribute in runner_type:
del runner_type[attribute]
try:
runner_type_db = get_runnertype_by_name(runner_name)
update = True
except StackStormDBObjectNotFoundError:
runner_type_db = None
update = False
runner_type_api = RunnerTypeAPI(**runner_type)
runner_type_api.validate()
runner_type_model = RunnerTypeAPI.to_model(runner_type_api)
if runner_type_db:
runner_type_model.id = runner_type_db.id
try:
runner_type_db = RunnerType.add_or_update(runner_type_model)
extra = {"runner_type_db": runner_type_db}
if update:
LOG.audit("RunnerType updated. RunnerType %s", runner_type_db, extra=extra)
else:
LOG.audit("RunnerType created. RunnerType %s", runner_type_db, extra=extra)
except Exception:
LOG.exception("Unable to register runner type %s.", runner_type["name"])
LOG.debug("End : register default RunnerTypes.")