""" @author: dhoomakethu """ from __future__ import absolute_import, unicode_literals from apocalypse.chaos.events import random_event_gen from apocalypse.exceptions import UnknownChaosEvent from apocalypse.utils.logger import get_logger from apocalypse.utils.helpers import banner import types exe_logger = get_logger() def events(): return ChaosExecutor.list_events() def unregister(event): ChaosExecutor.unregister(event) class ChaosExecutor(object): """ Chaos executor class responsible for executing chaos events. """ _category_map = {} _chaos_events = {} def __init__(self, chaos_app):
import time import requests import platform import tarfile from io import BytesIO from apocalypse.utils.proc import Proc, MessageNotFound from apocalypse.utils.logger import get_logger from docker.errors import APIError, NotFound from requests.exceptions import ConnectionError from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning) _NOT_SET = object() log = get_logger() IPTABLES_DOCKER_IMAGE = "vimagick/iptables:latest" class DockerClientException(Exception): """ Docker client execption """ pass def which(program): """ Checks if executable exists and is on the path. Thanks http://stackoverflow.com/a/377028/119592 """
""" @author: dhoomakethu """ from __future__ import absolute_import, unicode_literals import re from apocalypse.utils.logger import get_logger from apocalypse.chaos import register, SSH from apocalypse.chaos import ChaosEvent from apocalypse.chaos.executor import ChaosExecutor pid_regexp = re.compile(r"^\d+$") chaos_logger = get_logger() __all__ = ["Terminate", "Stop", "Reboot", "KillProcesses"] @register(ChaosExecutor) class Terminate(ChaosEvent): enabled = True def _terminate(self): """ terminates a vm (stop + rm) """ vm = self._prepare('Terminate') return self.app.terminate_services( services=vm if isinstance(vm, (list, tuple)) else [vm])
""" @author: dhoomakethu """ from __future__ import absolute_import, unicode_literals from apocalypse.actions import ActionBase import random import types from apocalypse.utils.logger import get_logger from apocalypse.utils.helpers import banner action_logger = get_logger() def actions(): return Action.list_actions() def unregister(action): Action.unregister(action) class Action(object): """ Action class responsible for executing chaos actions. """ _actions = {} __metaclass__ = ActionBase def __init__(self, compute_engine): self.ce = compute_engine