in source/code/configuration/task_configuration.py [0:0]
def configuration_item_to_task(self, item):
"""
Processes a configuration item into an internally used task specification. The method verifies the attributes from the
configuration and sets defaults for missing items.
:param item: Task configuration item
:return: Task item
"""
action_name = self.validate_action(item.get(configuration.CONFIG_ACTION_NAME))
conf_item = self.get_parameters(item)
process_this_account = TaskConfiguration.as_boolean(conf_item.get(configuration.CONFIG_THIS_ACCOUNT, True))
account = self.this_account if process_this_account else None
task_name = conf_item[configuration.CONFIG_TASK_NAME]
try:
result = {
handlers.TASK_NAME: task_name, handlers.TASK_ACTION: action_name,
handlers.TASK_REGIONS: self.validate_regions(regions=conf_item.get(configuration.CONFIG_REGIONS, []),
action_name=action_name),
handlers.TASK_THIS_ACCOUNT: process_this_account,
handlers.TASK_INTERVAL: self.verify_interval(
interval=conf_item.get(configuration.CONFIG_INTERVAL, None),
item=item,
action_name=action_name,
task_name=task_name),
handlers.TASK_EVENTS: TaskConfiguration.validate_events(
conf_item.get(configuration.CONFIG_EVENTS, {}), action_name),
handlers.TASK_EVENT_SCOPES: TaskConfiguration.validate_event_scopes(
conf_item.get(configuration.CONFIG_EVENT_SCOPES, {}), action_name),
handlers.TASK_TIMEZONE: self.verified_timezone(
tz_name=conf_item.get(configuration.CONFIG_TIMEZONE, DEFAULT_TIMEZONE)),
handlers.TASK_SELECT_SIZE: TaskConfiguration.validate_lambda_size(
conf_item.get(configuration.CONFIG_TASK_SELECT_SIZE,
actions.ACTION_SIZE_STANDARD)),
handlers.TASK_SELECT_ECS_MEMORY: conf_item.get(configuration.CONFIG_ECS_SELECT_MEMORY, None),
handlers.TASK_EXECUTE_SIZE: TaskConfiguration.validate_lambda_size(
conf_item.get(configuration.CONFIG_TASK_EXECUTE_SIZE,
actions.ACTION_SIZE_STANDARD)),
handlers.TASK_EXECUTE_ECS_MEMORY: conf_item.get(
configuration.CONFIG_ECS_EXECUTE_MEMORY, None),
handlers.TASK_COMPLETION_SIZE: TaskConfiguration.validate_lambda_size(
conf_item.get(configuration.CONFIG_TASK_COMPLETION_SIZE, actions.ACTION_SIZE_STANDARD)),
handlers.TASK_COMPLETION_ECS_MEMORY: conf_item.get(
configuration.CONFIG_ECS_SELECT_MEMORY, None),
handlers.TASK_TIMEOUT: self.verify_timeout(
action_name=action_name,
timeout=conf_item.get(configuration.CONFIG_TASK_TIMEOUT)),
handlers.TASK_TAG_FILTER: TaskConfiguration.validate_tagfilter(
tag_filter=conf_item.get(configuration.CONFIG_TAG_FILTER),
action_name=action_name),
handlers.TASK_EVENT_SOURCE_TAG_FILTER: TaskConfiguration.validate_tagfilter(
tag_filter=conf_item.get(configuration.CONFIG_EVENT_SOURCE_TAG_FILTER),
action_name=action_name),
handlers.TASK_DRYRUN: TaskConfiguration.as_boolean(
val=conf_item.get(configuration.CONFIG_DRYRUN, False)),
handlers.TASK_DEBUG: TaskConfiguration.as_boolean(
val=conf_item.get(configuration.CONFIG_DEBUG, False)),
handlers.TASK_NOTIFICATIONS: TaskConfiguration.as_boolean(
val=conf_item.get(configuration.CONFIG_TASK_NOTIFICATIONS, False)),
handlers.TASK_ENABLED: TaskConfiguration.as_boolean(
val=conf_item.get(configuration.CONFIG_ENABLED, True)),
handlers.TASK_INTERNAL: TaskConfiguration.as_boolean(
val=conf_item.get(configuration.CONFIG_INTERNAL, False)),
handlers.TASK_METRICS: TaskConfiguration.as_boolean(
val=conf_item.get(configuration.CONFIG_TASK_METRICS, False)),
handlers.TASK_ACCOUNTS: self.verify_accounts(
account, conf_item.get(configuration.CONFIG_ACCOUNTS, []), action_name, task_name),
handlers.TASK_ROLE: self.verify_task_role_name(
role_name=conf_item.get(configuration.CONFIG_TASK_CROSS_ACCOUNT_ROLE_NAME, ""),
action_name=action_name),
handlers.TASK_DESCRIPTION: conf_item.get(configuration.CONFIG_DESCRIPTION),
handlers.TASK_PARAMETERS: self.verify_task_parameters(
task_parameters=conf_item.get(configuration.CONFIG_PARAMETERS, {}),
task_settings=conf_item,
action_name=action_name),
handlers.TASK_SERVICE: actions.get_action_properties(action_name).get(actions.ACTION_SERVICE, ""),
handlers.TASK_RESOURCE_TYPE: actions.get_action_properties(action_name).get(actions.ACTION_RESOURCES, "")
}
return result
except ValueError as ex:
raise_value_error(ERR_ERR_IN_CONFIG_ITEM, safe_json(conf_item, indent=3), str(ex))