Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
AlfinST committed Sep 16, 2021
1 parent a43a5a0 commit ad7b7c5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 7 additions & 5 deletions src/ychaos/cli/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ def _register_machine_target_hooks(self) -> None:
Returns:
None
"""
assert isinstance(self.executor, MachineTargetExecutor)
assert isinstance(self.executor, (MachineTargetExecutor, SelfTargetExecutor))
target_type = self.executor.__target_type__

class OnTargetExecutorStart(YChaosCLITargetExecutorHook):
def __call__(self):
self.console.log(
f"Starting attack. executor={MachineTargetExecutor.__target_type__}"
f"Starting attack. executor={target_type}"
)

class OnTargetUnreachableHook(YChaosCLITargetExecutorHook):
Expand Down Expand Up @@ -78,14 +79,15 @@ def __call__(self):
def build_executor(self):
if self.testplan.attack.target_type == TargetType.MACHINE:
self.executor = MachineTargetExecutor(testplan=self.testplan)
self._register_machine_target_hooks()

elif self.testplan.attack.target_type == TargetType.SELF:
self.executor = SelfTargetExecutor(testplan=self.testplan)
self._register_machine_target_hooks()
#do i register teh machine target hooks?

else:
raise NotImplementedError()

self._register_machine_target_hooks()

def run(self):
self.executor.execute()

Expand Down
10 changes: 4 additions & 6 deletions src/ychaos/core/executor/SelfTargetExecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
from typing import Any
from types import SimpleNamespace

from .MachineTargetExecutor import YChaosAnsibleResultCallback
from ...app_logger import AppLogger
from .BaseExecutor import BaseExecutor
# from MachineTargetExecutor import YChaosAnsibleResultCallback
from ...utils.dependency import DependencyUtils
from ...testplan.schema import TestPlan
from ...utils.hooks import EventHook
Expand Down Expand Up @@ -138,7 +136,7 @@ def prepare(self):
action=dict(
module="pip",
chdir="{{result_pwd.stdout}}",
name='"ychaos[agents]"',
name="ychaos[agents]",
virtualenv="ychaos_env",
),
failed_when=[
Expand Down Expand Up @@ -172,15 +170,15 @@ def prepare(self):
),
dict(
name="Run YChaos Agent",
ignore_errors="no",
ignore_errors="yes",
action=dict(
module="command",
args=dict(cmd=" ".join(
[
"source '{{result_pip.virtualenv}}/bin/activate'",
"&&",
"ychaos --log-file {{result_create_workspace.path}}/ychaos.log",
"agent attack --testplan {{result_testplan_file.dest}} --attack-report-yaml {{result_create_workspace.path}}/attack_report.yaml",
"ychaos --log-file '{{result_create_workspace.path}}/ychaos.log'",
"agent attack --testplan '{{result_testplan_file.dest}}' --attack-report-yaml '{{result_create_workspace.path}}/attack_report.yaml'",
]
),
),
Expand Down

0 comments on commit ad7b7c5

Please sign in to comment.