From de958088b4c179f7d200f19000647766079de6e9 Mon Sep 17 00:00:00 2001 From: itsikkes Date: Mon, 1 Aug 2016 16:52:27 +0300 Subject: [PATCH] depth commandline option is not overwritten when getting config from the island --- chaos_monkey/config.py | 4 ++++ chaos_monkey/control.py | 9 +++++---- chaos_monkey/monkey.py | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/chaos_monkey/config.py b/chaos_monkey/config.py index 721b3d9a2..9c58c42f2 100644 --- a/chaos_monkey/config.py +++ b/chaos_monkey/config.py @@ -51,6 +51,8 @@ class Configuration(object): continue if key in ["name", "id", "current_server"]: continue + if self._depth_from_commandline and key=="depth": + continue try: default_value = getattr(Configuration, key) except AttributeError: @@ -83,6 +85,8 @@ class Configuration(object): return result + _depth_from_commandline = False + ########################### # logging config ########################### diff --git a/chaos_monkey/control.py b/chaos_monkey/control.py index d23164239..f8f3e3ee0 100644 --- a/chaos_monkey/control.py +++ b/chaos_monkey/control.py @@ -22,7 +22,7 @@ class ControlClient(object): proxies = {} @staticmethod - def wakeup(parent=None, default_tunnel=None): + def wakeup(parent=None, default_tunnel=None, has_internet_access=None): LOG.debug("Trying to wake up with C&C servers list: %r" % WormConfiguration.command_servers) if parent or default_tunnel: LOG.debug("parent: %s, default_tunnel: %s" % (parent, default_tunnel)) @@ -30,7 +30,8 @@ class ControlClient(object): if not parent: parent = GUID - internet_access = check_internet_access(WormConfiguration.internet_services) + if has_internet_access is None: + has_internet_access = check_internet_access(WormConfiguration.internet_services) for server in WormConfiguration.command_servers: try: @@ -40,7 +41,7 @@ class ControlClient(object): 'hostname': hostname, 'ip_addresses': local_ips(), 'description': " ".join(platform.uname()), - 'internet_access': internet_access, + 'internet_access': has_internet_access, 'config': WormConfiguration.as_dict(), 'parent': parent} @@ -71,7 +72,7 @@ class ControlClient(object): proxy_address, proxy_port = proxy_find LOG.info("Found tunnel at %s:%s" % (proxy_address, proxy_port)) ControlClient.proxies['https'] = 'https://%s:%s' % (proxy_address, proxy_port) - ControlClient.wakeup(parent=parent) + ControlClient.wakeup(parent=parent, has_internet_access=has_internet_access) else: LOG.info("No tunnel found") diff --git a/chaos_monkey/monkey.py b/chaos_monkey/monkey.py index 482211b81..c7c3824a4 100644 --- a/chaos_monkey/monkey.py +++ b/chaos_monkey/monkey.py @@ -52,6 +52,7 @@ class ChaosMonkey(object): self._default_server = opts.server if opts.depth: WormConfiguration.depth = int(opts.depth) + WormConfiguration._depth_from_commandline = True self._keep_running = True self._network = NetworkScanner() self._dropper_path = sys.argv[0]