forked from bellwether/minerva
sped up instance creation
This commit is contained in:
parent
bfb5dda6d9
commit
c8a29cfcd3
2 changed files with 9 additions and 7 deletions
|
|
@ -75,8 +75,6 @@ class Machine:
|
|||
self.thread.join()
|
||||
|
||||
def wait(self, n):
|
||||
time.sleep(n) # give time for AWS to register that the instance has been created
|
||||
|
||||
i = 0
|
||||
# Time for the server to show as "running"
|
||||
# and time for the server to finish getting daemons running
|
||||
|
|
@ -88,6 +86,9 @@ class Machine:
|
|||
reason = f"{self.info['InstanceId']} took too long to start ({i} attempts)"
|
||||
raise Exception(reason)
|
||||
|
||||
# Final wait, now that the server is up and running -- need
|
||||
# some time for daemons to start
|
||||
time.sleep(25)
|
||||
self.ready = True
|
||||
|
||||
# alternatively, could maybe implement this with SSM so that we can access
|
||||
|
|
@ -96,15 +97,16 @@ class Machine:
|
|||
if self.ssh:
|
||||
return True
|
||||
|
||||
if not self.public:
|
||||
raise Exception("Can only log into server that has a public IP")
|
||||
|
||||
# Machine must be running first, so we need to wait for the countdown to finish
|
||||
self.join()
|
||||
|
||||
# Final wait, now that the server is up and running -- need some time for daemons to start
|
||||
time.sleep(25)
|
||||
|
||||
resp = self.pier.ec2.describe_instances(InstanceIds=[self.info['InstanceId']])
|
||||
self.description = resp['Reservations'][0]['Instances'][0]
|
||||
self.public_ip = self.description['PublicIpAddress']
|
||||
|
||||
print(f"\t{self.name} ({self.info['InstanceId']}) => {self.public_ip} ({self.private_ip})")
|
||||
|
||||
self.ssh = Connection(self.public_ip,
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ class Pier:
|
|||
self.make_key_pair()
|
||||
|
||||
def make_key_pair(self):
|
||||
print("making keypair")
|
||||
self.key_pair_name = f"Minerva-{random.random()}"
|
||||
print(f"making keypair ({self.key_pair_name})")
|
||||
self.key = self.ec2.create_key_pair(KeyName=self.key_pair_name)
|
||||
|
||||
self.key_path = "/tmp/key"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue