def setUpLvmCMD(self): self.lv_act = Actions() self.lv_act.add(name='ExpandLV', pre_conditions={ 'lv_need_expansion': True, 'vg_need_expansion': False, }, effects={ 'lv_need_expansion': False, }, shell='echo expand_lv', cost=1.0) self.lv_act.add(name='ExpandVG', pre_conditions={ 'vg_need_expansion': True, 'pv_need_expansion': False, }, effects={ 'vg_need_expansion': False, }, shell='echo expand_vg') self.lv_act.add( name='ExpandPV', pre_conditions={ 'pv_need_expansion': True, }, effects={ 'pv_need_expansion': False, }, shell='echo purge_old_files', cost=1.5, )
def __init__(self): # ACTIONS self.actions = Actions() # update app self.actions.add_action(name='UpdateApp', pre_conditions={ 'vpc': True, 'db': True, 'app': 'version_out_of_date' }, effects={ 'vpc': True, 'db': True, 'app': True }) # rollback change self.actions.add_action(name='RollbackApp', pre_conditions={ 'vpc': True, 'db': True, 'app': 'need_rollback' }, effects={ 'vpc': True, 'db': True, 'app': True }) # init_state = {'vpc': False, 'app': False, 'db': False} init_goal = {'vpc': True, 'db': True, 'app': True} self.ai = Agent(name='CloudBuilder', actions=self.actions, goal=init_goal)
class DeploymentAgent: PRIORITIES = [ {'vpc': True, 'db': True, 'app': True}, {'vpc': 'monitoring', 'db': 'monitoring', 'app': 'monitoring'}, ] def __init__(self): # ACTIONS self.actions = Actions() # update app self.actions.add_action( name='UpdateApp', pre_conditions={'vpc': True, 'db': True, 'app': 'version_out_of_date'}, effects={'vpc': True, 'db': True, 'app': True} ) # rollback change self.actions.add_action( name='RollbackApp', pre_conditions={'vpc': True, 'db': True, 'app': 'need_rollback'}, effects={'vpc': True, 'db': True, 'app': True} ) # init_state = {'vpc': False, 'app': False, 'db': False} init_goal = {'vpc': True, 'db': True, 'app': True} self.ai = Agent(name='CloudBuilder', actions=self.actions, goal=init_goal) def run_agent(self): self.ai.run()
class DeploymentAgent: PRIORITIES = [ { 'vpc': True, 'db': True, 'app': True }, { 'vpc': 'monitoring', 'db': 'monitoring', 'app': 'monitoring' }, ] def __init__(self): # ACTIONS self.actions = Actions() # update app self.actions.add_action(name='UpdateApp', pre_conditions={ 'vpc': True, 'db': True, 'app': 'version_out_of_date' }, effects={ 'vpc': True, 'db': True, 'app': True }) # rollback change self.actions.add_action(name='RollbackApp', pre_conditions={ 'vpc': True, 'db': True, 'app': 'need_rollback' }, effects={ 'vpc': True, 'db': True, 'app': True }) # init_state = {'vpc': False, 'app': False, 'db': False} init_goal = {'vpc': True, 'db': True, 'app': True} self.ai = Agent(name='CloudBuilder', actions=self.actions, goal=init_goal) def run_agent(self): self.ai.run()
def setUp(self): self.print = PrettyPrinter(indent=4) self.goal = { "tmp_dir_state": "exist", "tmp_dir_content": "token_found", } self.actions = Actions() self.sensors = Sensors() self.sensors.add( name='SenseTmpDirState', shell= 'if [ -d "/tmp/goap_tmp" ]; then echo -n "exist"; else echo -n "not_exist"; fi', binding='tmp_dir_state') self.sensors.add( name='SenseTmpDirContent', shell= '[ -f /tmp/goap_tmp/.token ] && echo -n "token_found" || echo -n "token_not_found"', binding='tmp_dir_content') self.actions.add(name='CreateTmpDir', pre_conditions={ 'tmp_dir_state': 'not_exist', 'tmp_dir_content': 'token_not_found' }, effects={ 'tmp_dir_state': 'exist', 'tmp_dir_content': 'token_not_found' }, shell='mkdir -p /tmp/goap_tmp') self.actions.add(name='CreateToken', pre_conditions={ 'tmp_dir_state': 'exist', 'tmp_dir_content': 'token_not_found' }, effects={ 'tmp_dir_state': 'exist', 'tmp_dir_content': 'token_found' }, shell='touch /tmp/goap_tmp/.token') world_state_matrix = { "tmp_dir_state": 'Unknown', "tmp_dir_content": 'Unknown', } self.automaton = Automaton(name='directory_watcher', actions=self.actions, sensors=self.sensors, world_state=world_state_matrix)
def setUpDirHandlerCMD(self): self.dir_handler_cmd = Actions() self.dir_handler_cmd.add(name='CreateTmpDir', pre_conditions={ 'tmp_dir_state': False, 'tmp_dir_content': False }, effects={ 'tmp_dir_state': True, 'tmp_dir_content': False }, shell='mkdir -p /tmp/goap_tmp') self.dir_handler_cmd.add(name='CreateToken', pre_conditions={ 'tmp_dir_state': True, 'tmp_dir_content': False }, effects={ 'tmp_dir_state': True, 'tmp_dir_content': True }, shell='touch /tmp/goap_tmp/.token')
def setup_actions(): actions = Actions() actions.add(name='CloneGitRepo', pre_conditions={}, effects={}, shell='mkdir -p /tmp/goap_tmp') actions.add(name='BuildProject', pre_conditions={}, effects={}, shell='touch /tmp/goap_tmp/.token') actions.add(name='NotifyBuild', pre_conditions={}, effects={}, shell='touch /tmp/goap_tmp/.token') return actions
def test_graph_isomorphic(self): from Goap.Planner import Node from Goap.Planner import Edge acts = Actions() acts.add(name='CreateTmpDir', pre_conditions={ 'tmp_dir_state': False, 'tmp_dir_content': False }, effects={ 'tmp_dir_state': True, 'tmp_dir_content': False }, shell='mkdir -p /tmp/goap_tmp') acts.add(name='CreateToken', pre_conditions={ 'tmp_dir_state': True, 'tmp_dir_content': False }, effects={ 'tmp_dir_state': True, 'tmp_dir_content': True }, shell='touch /tmp/goap_tmp/.token') node1 = Node(attributes={ 'tmp_dir_state': False, 'tmp_dir_content': False }) node2 = Node(attributes={ 'tmp_dir_state': True, 'tmp_dir_content': False }) node3 = Node(attributes={ 'tmp_dir_state': True, 'tmp_dir_content': True }) edge1 = Edge(name='CreateTmpDir', predecessor=node1, successor=node2, obj=acts.get('CreateTmpDir')) edge2 = Edge(name='CreateToken', predecessor=node2, successor=node3, obj=acts.get('CreateToken')) g1 = nx.DiGraph(nodes=[node1, node2, node3], edges=[edge1, edge2]) g2 = self.planner.graph.directed assert nx.is_isomorphic(g1, g2) is True
def __init__(self): # ACTIONS self.actions = Actions() # update app self.actions.add_action( name='UpdateApp', pre_conditions={'vpc': True, 'db': True, 'app': 'version_out_of_date'}, effects={'vpc': True, 'db': True, 'app': True} ) # rollback change self.actions.add_action( name='RollbackApp', pre_conditions={'vpc': True, 'db': True, 'app': 'need_rollback'}, effects={'vpc': True, 'db': True, 'app': True} ) # init_state = {'vpc': False, 'app': False, 'db': False} init_goal = {'vpc': True, 'db': True, 'app': True} self.ai = Agent(name='CloudBuilder', actions=self.actions, goal=init_goal)
def setupPlanner(): acts = Actions() acts.add( name='ExpandLV', pre_conditions={ 'lv_need_expansion': True, 'vg_need_expansion': False, }, effects={ 'lv_need_expansion': False, }, shell='echo expand_lv', cost=1.5 ) acts.add( name='ExpandVG', pre_conditions={ 'vg_need_expansion': True, 'pv_need_expansion': False, }, effects={ 'vg_need_expansion': False, }, shell='echo expand_vg', cost=1.0, ) acts.add( name='ExpandPV', pre_conditions={ 'pv_need_expansion': True, }, effects={ 'pv_need_expansion': False, }, shell='echo expand_pv', cost=0.5, ) return Planner(actions=acts)
def __init__(self): # ACTIONS actions = Actions() # increase app capacity actions.add_action( name='IncreaseAppCapacity', pre_conditions={'vpc': True, 'db': True, 'app': 'out_of_capacity'}, effects={'vpc': True, 'db': True, 'app': True} ) # increase db capacity actions.add_action( name='IncreaseAppCapacity', pre_conditions={'vpc': True, 'db': 'out_of_capacity', 'app': True}, effects={'vpc': True, 'db': True, 'app': True} ) # init_state = {'vpc': False, 'app': False, 'db': False} init_goal = {'vpc': True, 'db': True, 'app': True} self.ai = Agent(name='CloudBuilder', actions=self.actions, goal=init_goal)
def setup_actions(): actions = Actions() actions.add(name='CreateTmpDir', pre_conditions={ 'tmp_dir_state': 'not_exist', 'tmp_dir_content': 'token_not_found' }, effects={ 'tmp_dir_state': 'exist', 'tmp_dir_content': 'token_not_found' }, shell='mkdir -p /tmp/goap_tmp') actions.add(name='CreateToken', pre_conditions={ 'tmp_dir_state': 'exist', 'tmp_dir_content': 'token_not_found' }, effects={ 'tmp_dir_state': 'exist', 'tmp_dir_content': 'token_found' }, shell='touch /tmp/goap_tmp/.token') return actions
from pprint import PrettyPrinter pp = PrettyPrinter(indent=4) priorities = AutomatonPriorities([ {'vpc_state': 'available', 'db_state': 'available', 'app_state': 'running'} ]) world_state_matrix = { "vpc_state": 'Unknown', "db_state": 'Unknown', "app_state": 'Unknown', } goal = { "vpc_state": "available", "db_state": "available", "app_state": "running", } aws_actions = Actions() aws_actions.add( name='CreateVPC', pre_conditions={'vpc_state': 'unavailable', 'db_state': 'unavailable', 'app_state': 'unavailable'}, effects={'vpc_state': 'available', 'db_state': 'unavailable', 'app_state': 'unavailable'}, shell='echo "vpc created"' ) aws_actions.add( name='CreateDB', pre_conditions={'vpc_state': 'available', 'db_state': 'unavailable', 'app_state': 'unavailable'}, effects={'vpc_state': 'available', 'db_state': 'available', 'app_state': 'unavailable'}, shell='echo "db created"' ) aws_actions.add( name='CreateApp', pre_conditions={'vpc_state': 'available', 'db_state': 'available', 'app_state': 'unavailable'},
import networkx as nx from Goap.Action import Actions # settings DEBUG = False # ACTIONS actions = Actions() actions.add_action( name='CreateVPC', pre_conditions={'vpc': False, 'app': False, 'db': False}, effects={'vpc': True, 'app': False, 'db': False} ) actions.add_action( name='CreateDB', pre_conditions={'vpc': True, 'db': False, 'app': False}, effects={'vpc': True, 'db': True, 'app': False} ) actions.add_action( name='CreateApp', pre_conditions={'vpc': True, 'db': True, 'app': False}, effects={'vpc': True, 'db': True, 'app': True} ) # initial STATE initial_state = ({'vpc': False}, {'db': False}, {'app': False}) # goal goal = ({'vpc': True}, {'db': True}, {'app': True}) # GRAPH / World
from Goap.Action import Actions from Goap.Agent import Agent import pprint # ACTIONS actions = Actions() # VPC/Network set actions.add_action( name='CreateVPC', pre_conditions={'vpc': False, 'db': False, 'app': False}, effects={'vpc': True, 'db': False, 'app': False} ) # DB set actions.add_action( name='CreateDB', pre_conditions={'vpc': True, 'db': False, 'app': False}, effects={'vpc': True, 'db': True, 'app': False} ) actions.add_action( name='StartDB', pre_conditions={'vpc': True, 'db': 'stopped', 'app': False}, effects={'vpc': True, 'db': 'started', 'app': False} ) actions.add_action( name='StopDB', pre_conditions={'vpc': True, 'db': 'started', 'app': False}, effects={'vpc': True, 'db': 'stopped', 'app': False} ) actions.add_action( name='DestroyDB', pre_conditions={'vpc': True, 'db': 'not_health', 'app': False},
class ActionTest(unittest.TestCase): def setUp(self): # ACTIONS self.actions = Actions() def test_add_action_success(self): self.actions.add(name='CreateVPC', pre_conditions={ 'vpc': False, 'db': False, 'app': False }, effects={ 'vpc': True, 'db': False, 'app': False }, shell='awscli vpc create') self.actions.add(name='CreateDB', pre_conditions={ 'vpc': True, 'db': False, 'app': False }, effects={ 'vpc': True, 'db': True, 'app': False }, shell='awscli vpc create') assert "CreateVPC" == str(self.actions.get(name='CreateVPC')) assert "CreateDB" == str(self.actions.get(name='CreateDB')) def test_remove_action_success(self): self.actions.add(name='CreateVPC', pre_conditions={ 'vpc': False, 'db': False, 'app': False }, effects={ 'vpc': True, 'db': False, 'app': False }, shell='awscli vpc create') self.actions.add(name='CreateDB', pre_conditions={ 'vpc': True, 'db': False, 'app': False }, effects={ 'vpc': True, 'db': True, 'app': False }, shell='awscli vpc create') self.actions.remove(name='CreateVPC') assert "CreateDB" == str(self.actions.get(name='CreateDB')) def test_remove_action_error(self): self.actions.add(name='CreateVPC', pre_conditions={ 'vpc': False, 'db': False, 'app': False }, effects={ 'vpc': True, 'db': False, 'app': False }, shell='awscli vpc create') self.actions.add(name='CreateDB', pre_conditions={ 'vpc': True, 'db': False, 'app': False }, effects={ 'vpc': True, 'db': True, 'app': False }, shell='awscli vpc create') self.actions.remove(name='CreateAPP') assert 'None' == str(self.actions.get(name='CreateAPP'))
actions_result = self.fsm.start( init_state=self.world_facts, end_state=self.STD_STATES['obliterate']) print('[INFO] Plan executed: {}'.format(actions_result)) print('Sleeping 7 sec from {}'.format(datetime.now())) sleep(7) if __name__ == '__main__': from Goap.Action import Actions # import pprint # ACTIONS actions = Actions() # VPC/Network set actions.add_action(name='CreateVPC', pre_conditions={ 'vpc': False, 'db': False, 'app': False }, effects={ 'vpc': True, 'db': False, 'app': False }) actions.add_action(name='DestroyVPC', pre_conditions={ 'vpc': True,
class PlannerTest(unittest.TestCase): @staticmethod def __reset_environment(): if path.isdir('/tmp/goap_tmp'): subprocess.call(['rm', '-rf', '/tmp/goap_tmp']) def __print(self): self.print.pprint('Nodes: {}, Edges: {}'.format( self.planner.graph.nodes, self.planner.graph.edges)) def setUp(self): self.print = PrettyPrinter(indent=4) self.setUpDirHandlerCMD() self.setUpLvmCMD() self.init_ws = WorldState({ "tmp_dir_state": False, "tmp_dir_content": False, }) self.gs = WorldState({ "tmp_dir_state": True, "tmp_dir_content": True, }) self.planner = Planner(actions=self.dir_handler_cmd) def setUpDirHandlerCMD(self): self.dir_handler_cmd = Actions() self.dir_handler_cmd.add(name='CreateTmpDir', pre_conditions={ 'tmp_dir_state': False, 'tmp_dir_content': False }, effects={ 'tmp_dir_state': True, 'tmp_dir_content': False }, shell='mkdir -p /tmp/goap_tmp') self.dir_handler_cmd.add(name='CreateToken', pre_conditions={ 'tmp_dir_state': True, 'tmp_dir_content': False }, effects={ 'tmp_dir_state': True, 'tmp_dir_content': True }, shell='touch /tmp/goap_tmp/.token') def setUpLvmCMD(self): self.lv_act = Actions() self.lv_act.add(name='ExpandLV', pre_conditions={ 'lv_need_expansion': True, 'vg_need_expansion': False, }, effects={ 'lv_need_expansion': False, }, shell='echo expand_lv', cost=1.0) self.lv_act.add(name='ExpandVG', pre_conditions={ 'vg_need_expansion': True, 'pv_need_expansion': False, }, effects={ 'vg_need_expansion': False, }, shell='echo expand_vg') self.lv_act.add( name='ExpandPV', pre_conditions={ 'pv_need_expansion': True, }, effects={ 'pv_need_expansion': False, }, shell='echo purge_old_files', cost=1.5, ) def test_set_goal(self): self.planner.goal = self.gs assert self.gs == self.planner.goal def test_graph_isomorphic(self): from Goap.Planner import Node from Goap.Planner import Edge acts = Actions() acts.add(name='CreateTmpDir', pre_conditions={ 'tmp_dir_state': False, 'tmp_dir_content': False }, effects={ 'tmp_dir_state': True, 'tmp_dir_content': False }, shell='mkdir -p /tmp/goap_tmp') acts.add(name='CreateToken', pre_conditions={ 'tmp_dir_state': True, 'tmp_dir_content': False }, effects={ 'tmp_dir_state': True, 'tmp_dir_content': True }, shell='touch /tmp/goap_tmp/.token') node1 = Node(attributes={ 'tmp_dir_state': False, 'tmp_dir_content': False }) node2 = Node(attributes={ 'tmp_dir_state': True, 'tmp_dir_content': False }) node3 = Node(attributes={ 'tmp_dir_state': True, 'tmp_dir_content': True }) edge1 = Edge(name='CreateTmpDir', predecessor=node1, successor=node2, obj=acts.get('CreateTmpDir')) edge2 = Edge(name='CreateToken', predecessor=node2, successor=node3, obj=acts.get('CreateToken')) g1 = nx.DiGraph(nodes=[node1, node2, node3], edges=[edge1, edge2]) g2 = self.planner.graph.directed assert nx.is_isomorphic(g1, g2) is True def test_plan(self): create_tmp_dir = self.planner.actions.get('CreateTmpDir') create_token = self.planner.actions.get('CreateToken') plan = self.planner.plan(state=self.init_ws, goal=self.gs) action_plan = [action[2]['object'] for action in plan] assert action_plan == [create_tmp_dir, create_token]
def __init__(self): # ACTIONS actions = Actions() # VPC/Network set actions.add_action( name='CreateVPC', pre_conditions={'vpc': False, 'db': False, 'app': False}, effects={'vpc': True, 'db': False, 'app': False} ) actions.add_action( name='DestroyVPC', pre_conditions={'vpc': True, 'db': False, 'app': False}, effects={'vpc': False, 'db': False, 'app': False} ) # DB set actions.add_action( name='CreateDB', pre_conditions={'vpc': True, 'db': False, 'app': False}, effects={'vpc': True, 'db': True, 'app': False} ) actions.add_action( name='DestroyDB', pre_conditions={'vpc': True, 'db': True, 'app': False}, effects={'vpc': True, 'db': False, 'app': False} ) # APP set actions.add_action( name='CreateApp', pre_conditions={'vpc': True, 'db': True, 'app': False}, effects={'vpc': True, 'db': True, 'app': True} ) actions.add_action( name='StopApp', pre_conditions={'vpc': True, 'db': True, 'app': 'unhealthy'}, effects={'vpc': True, 'db': True, 'app': 'stopped'} ) actions.add_action( name='TerminateStoppedApps', pre_conditions={'vpc': True, 'db': True, 'app': 'stopped'}, effects={'vpc': True, 'db': True, 'app': False} ) # inconsistent app actions.add_action( name='DestroyInconsistentApp', pre_conditions={'vpc': True, 'db': True, 'app': 'inconsistent'}, effects={'vpc': True, 'db': True, 'app': False} ) # out of capacity actions.add_action( name='IncreaseAppCapacity', pre_conditions={'vpc': True, 'db': True, 'app': 'out_of_capacity'}, effects={'vpc': True, 'db': True, 'app': True} ) actions.add_action( name='TerminateStoppedApps', pre_conditions={'vpc': True, 'db': True, 'app': 'stopped'}, effects={'vpc': True, 'db': True, 'app': False} ) # init_state = {'vpc': False, 'app': False, 'db': False} init_goal = {'vpc': True, 'db': True, 'app': True} self.ai = Agent(name='CloudBuilder', actions=self.actions, goal=init_goal)
def setUp(self): # ACTIONS self.actions = Actions()
for state in self._transitions: self._current_state = state result.append(self._current_state.do()) self.stop() return result if __name__ == '__main__': import random # import pprint from time import sleep from datetime import datetime # ACTIONS actions = Actions() # monitor state actions.add( name='CheckModules', pre_conditions={'vpc_checked': False, 'db_check': False, 'app_checked': False}, effects={'vpc_checked': True, 'db_check': True, 'app_checked': True} ) # VPC/Network set actions.add( name='CreateVPC', pre_conditions={'vpc': False, 'db': False, 'app': False}, effects={'vpc': True, 'db': False, 'app': False} ) # DB set actions.add( name='CreateDB',
class AutomatonTest(unittest.TestCase): @staticmethod def __reset_environment(): if path.isdir('/tmp/goap_tmp'): subprocess.call(['rm', '-rf', '/tmp/goap_tmp']) def __print(self): self.print.pprint( 'Acknowledge world: {}, Action Plan: {}, Result: {}'.format( self.automaton.world_state, self.automaton.action_plan, self.automaton.actions_response)) def setUp(self): self.print = PrettyPrinter(indent=4) self.goal = { "tmp_dir_state": "exist", "tmp_dir_content": "token_found", } self.actions = Actions() self.sensors = Sensors() self.sensors.add( name='SenseTmpDirState', shell= 'if [ -d "/tmp/goap_tmp" ]; then echo -n "exist"; else echo -n "not_exist"; fi', binding='tmp_dir_state') self.sensors.add( name='SenseTmpDirContent', shell= '[ -f /tmp/goap_tmp/.token ] && echo -n "token_found" || echo -n "token_not_found"', binding='tmp_dir_content') self.actions.add(name='CreateTmpDir', pre_conditions={ 'tmp_dir_state': 'not_exist', 'tmp_dir_content': 'token_not_found' }, effects={ 'tmp_dir_state': 'exist', 'tmp_dir_content': 'token_not_found' }, shell='mkdir -p /tmp/goap_tmp') self.actions.add(name='CreateToken', pre_conditions={ 'tmp_dir_state': 'exist', 'tmp_dir_content': 'token_not_found' }, effects={ 'tmp_dir_state': 'exist', 'tmp_dir_content': 'token_found' }, shell='touch /tmp/goap_tmp/.token') world_state_matrix = { "tmp_dir_state": 'Unknown', "tmp_dir_content": 'Unknown', } self.automaton = Automaton(name='directory_watcher', actions=self.actions, sensors=self.sensors, world_state=world_state_matrix) def test_sensing(self): self.__reset_environment() self.automaton.input_goal(self.goal) self.automaton.sense() assert self.automaton.world_state == { 'tmp_dir_state': 'not_exist', 'tmp_dir_content': 'token_not_found' } def test_planning(self): create_tmp_dir = self.actions.get('CreateTmpDir') create_token = self.actions.get('CreateToken') self.__reset_environment() self.automaton.input_goal(self.goal) self.automaton.sense() self.automaton.plan() action_plan = [ action[2]['object'] for action in self.automaton.action_plan ] assert action_plan == [create_tmp_dir, create_token] def test_acting(self): self.__reset_environment() self.automaton.input_goal(self.goal) self.automaton.sense() self.automaton.plan() self.automaton.act() assert path.isdir('/tmp/goap_tmp') and path.isfile( '/tmp/goap_tmp/.token')
print('[ERROR]: Unknown state\n[ERROR]: Nothing to be done, need manual interaction\n{}') self.world_state = self.STD_STATES['inconsistent'] actions_result = self.fsm.start(init_state=self.world_state, end_state=self.STD_STATES['obliterate']) print('[INFO] Plan executed: {}'.format(actions_result)) print('Sleeping 7 sec from {}'.format(datetime.now())) sleep(7) if __name__ == '__main__': from Goap.Action import Actions # import pprint # ACTIONS actions = Actions() # VPC/Network set actions.add( name='CreateVPC', pre_conditions={'vpc': False, 'db': False, 'app': False}, effects={'vpc': True, 'db': False, 'app': False} ) actions.add( name='DestroyVPC', pre_conditions={'vpc': True, 'db': False, 'app': False}, effects={'vpc': False, 'db': False, 'app': False} ) # DB set actions.add( name='CreateDB', pre_conditions={'vpc': True, 'db': False, 'app': False},
for state in self._transitions: self._current_state = state result.append(self._current_state.do()) self.stop() return result if __name__ == '__main__': from Goap import Planner import random # import pprint from time import sleep from datetime import datetime # ACTIONS actions = Actions() # monitor state actions.add_action(name='CheckModules', pre_conditions={ 'vpc_checked': False, 'db_check': False, 'app_checked': False }, effects={ 'vpc_checked': True, 'db_check': True, 'app_checked': True }) # VPC/Network set actions.add_action(name='CreateVPC', pre_conditions={
priorities = AutomatonPriorities([{ 'vpc_state': 'available', 'db_state': 'available', 'app_state': 'running' }]) world_state_matrix = { "vpc_state": 'Unknown', "db_state": 'Unknown', "app_state": 'Unknown', } goal = { "vpc_state": "available", "db_state": "available", "app_state": "running", } aws_actions = Actions() aws_actions.add(name='CreateVPC', pre_conditions={ 'vpc_state': 'unavailable', 'db_state': 'unavailable', 'app_state': 'unavailable' }, effects={ 'vpc_state': 'available', 'db_state': 'unavailable', 'app_state': 'unavailable' }, shell='echo "vpc created"') aws_actions.add(name='CreateDB', pre_conditions={ 'vpc_state': 'available',