From 195bf2c3e40bef3f324dc6f4c3427b0247d2673d Mon Sep 17 00:00:00 2001 From: Jan Schumann Date: Thu, 13 Dec 2018 12:55:33 +0100 Subject: [PATCH] add environment and account to model properties --- AutoscalingLifecycle/__init__.py | 25 ++++++++++++++++++------- CHANGELOG.md | 4 ++++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/AutoscalingLifecycle/__init__.py b/AutoscalingLifecycle/__init__.py index 1fba64e..c2fae55 100644 --- a/AutoscalingLifecycle/__init__.py +++ b/AutoscalingLifecycle/__init__.py @@ -11,15 +11,15 @@ from .entity import NodeRepository from .entity import Repositories from .entity import Repository -from .logging import Formatter -from .logging import Logging -from .logging import MessageFormatter +from .exceptions import CommandNotFoundError from .exceptions import ConfigurationError -from .exceptions import TriggerParameterConfigurationError +from .exceptions import EventNotSupportedError from .exceptions import StopIterationAfterTrigger from .exceptions import StopProcessingAfterStateChange -from .exceptions import CommandNotFoundError -from .exceptions import EventNotSupportedError +from .exceptions import TriggerParameterConfigurationError +from .logging import Formatter +from .logging import Logging +from .logging import MessageFormatter def listify(obj): @@ -261,6 +261,10 @@ class Model(object): :type clients: Clients :param repositories: :type repositories: Repositories + :param environment: + :type environment: str + :param account: + :type account: str :param _state: :type _state: str :param event: @@ -272,6 +276,8 @@ class Model(object): formatter = None clients = None repositories = None + environment = None + account = None event = None _node = None @@ -284,11 +290,13 @@ class Model(object): COMMAND = 'command' - def __init__(self, clients: Clients, repositories: Repositories, logging: Logging): + def __init__(self, clients: Clients, repositories: Repositories, logging: Logging, environment: str, account: str): self.logger = logging.get_logger() self.repositories = repositories self.clients = clients self.formatter = logging.get_formatter() + self.environment = environment + self.account = account self.node = None self.state = None @@ -424,6 +432,7 @@ def _send_command(self, comment: str, commands: list, target_nodes = None, comma command_id = self.clients.get('ssm').send_command(target_node_ids, comment, commands, command_timeout) self.repositories.get('command').register(command_id, metadata) + # # convenience methods # @@ -435,6 +444,7 @@ def get_node_repository(self) -> NodeRepository: def get_command_repository(self) -> CommandRepository: return self.repositories.get(self.COMMAND) + # # built-in trigger functions # @@ -619,6 +629,7 @@ def __add_transition(self, sources: list, dest: str, config: dict): after = after ) + # # processing # diff --git a/CHANGELOG.md b/CHANGELOG.md index cdb59bc..4b69b00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ NEW FEATURES: * Snapshots can now be created with a list of tags +IMPROVEMENTS: + +* Add account and environment as model properties + ## 0.61.0 IMPROVEMENTS: