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 PerformanceTracker: PRIORITIES = ( 1, {'vpc': True, 'db': True, 'app': True}, 2, {'vpc': 'monitoring', 'db': 'monitoring', 'app': 'monitoring'}, ) 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 run_agent(self): self.ai.run()
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()
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 __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)
'vpc': True, 'db': True, 'app': 'started' }, effects={ 'vpc': True, 'db': True, 'app': 'stopped' }) actions.add_action(name='DestroyApp', pre_conditions={ 'vpc': True, 'db': True, 'app': 'not_health' }, effects={ 'vpc': True, 'db': True, 'app': False }) init_state = {'vpc': False, 'app': False, 'db': False} init_goal = {'vpc': True, 'db': True, 'app': True} ai_cloud_builder = Agent(name='CloudBuilder', actions=actions, initial_state=init_state, goal=init_goal) result = ai_cloud_builder.run() pprint.pprint(result, indent=2, width=80)
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='StartApp', pre_conditions={'vpc': True, 'db': True, 'app': 'stopped'}, effects={'vpc': True, 'db': True, 'app': 'started'} ) actions.add_action( name='StopApp', pre_conditions={'vpc': True, 'db': True, 'app': 'started'}, effects={'vpc': True, 'db': True, 'app': 'stopped'} ) actions.add_action( name='DestroyApp', pre_conditions={'vpc': True, 'db': True, 'app': 'not_health'}, effects={'vpc': True, 'db': True, 'app': False} ) init_state = {'vpc': False, 'app': False, 'db': False} init_goal = {'vpc': True, 'db': True, 'app': True} ai_cloud_builder = Agent(name='CloudBuilder', actions=actions, initial_state=init_state, goal=init_goal) result = ai_cloud_builder.run() pprint.pprint(result, indent=2, width=80)
class CloudBuild: PRIORITIES = [ {'vpc': True, 'db': True, 'app': True}, {'vpc': 'monitoring', 'db': 'monitoring', 'app': 'monitoring'}, ] 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 run_agent(self): self.ai.run()