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 __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)
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={ 'vpc': False, 'db': False, 'app': False }, effects={ 'vpc': True, 'db': False,
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, 'db': False, 'app': False }, effects={ 'vpc': False, 'db': False, 'app': False
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},
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)