agent: |
ODmnpJrpOYeYwLVgNCe3Ensure that the instance is running
Ensure that the instance is running
There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.
Get the instance state and check if the instance is running. If it is not running, start it.
inputs
outputs
cmd = f'aws ec2 describe-instances --instance-ids {instance_id} --query "Reservations[].Instances[].State.Name" --output text'
op = _exe(None, cmd)
_problem = True
if "running" in op:
_problem = False
_proceed = not _problem
host_is_up = not _problem
if host_is_up:
msg = "Host is up"
msg_type = "SUCCESS"
else:
msg = "Host is not up!"
msg_type = "ERROR"
print(msg)
context.log(msg_type, msg)
context.skip_sub_tasks = host_is_up
task_title = context.task_title
context.job_context[task_title] = {"msg" : msg, "msg_type" : msg_type}
copied
- 1kCWBHxpZilKc9mcoNC5HStart an ec2 instance
1
There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.inputsoutputscmd = f'aws ec2 start-instances --instance-ids {instance_id}' op = _exe(None, cmd) msg = "Instance was down. Restarted the instance" print(msg) task_title = context.task_title msg_type = "SUCCESS" context.job_context[task_title] = {"msg" : msg, "msg_type" : msg_type}copied1- 1.1FS6km40Slgy4DKab5lkmWait until the instance is running
1.1
Wait until the instance is running
There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.It takes a few seconds for the instance to come up. Keep checking the status for a few seconds. After a specified number of iterations, just give up and print an error message.
inputsoutputsimport time op = "" iter = 0 if "running" not in op and iter < 3: cmd = f'aws ec2 describe-instances --instance-ids {instance_id} --query "Reservations[].Instances[].State.Name" --output text' op = _exe(None, cmd) iter = iter + 1 time.sleep(60) cmd = f'aws ec2 describe-instances --instance-ids {instance_id} --query "Reservations[].Instances[].State.Name" --output text' op = _exe(None, cmd) task_title = context.task_title if "running" not in op: msg = f"Giving up. The host doesn't seem to be coming up: {instance_id}" msg_type = "ERROR" print(msg) context.proceed = False else: msg = f"This instance {instance_id} is now running" msg_type = "SUCCESS" print(msg) context.log(msg_type, msg) context.job_context[task_title] = {"msg" : msg, "msg_type" : msg_type}copied1.1 - 1.2vvE6yWNtxdJIwucjupz2Mount the volumes if needed
1.2
There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.inputsoutputsmount /dev/xvdb /datacopied1.2