From cd5ce7e16f64cd212a2ac15a2b529ed25d489799 Mon Sep 17 00:00:00 2001 From: Ari Brown Date: Wed, 22 Jan 2025 10:09:36 -0500 Subject: [PATCH] some updates, cant remember what for --- TODO.md | 6 +++++- minerva/command.py | 8 +------- minerva/machine.py | 7 ++++++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/TODO.md b/TODO.md index 242df33..a126cc0 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,8 @@ * start docker containers via method on Machine() * control and automate logfiles * add logfile for `docker events` - +* build web frontend + * identify containers that error out + * oomkill is common with docker because you're not allowed to suddenly reach + for swap space (???) + * removing this functionality is difficult and OS-dependent diff --git a/minerva/command.py b/minerva/command.py index 135c79e..250dfcd 100644 --- a/minerva/command.py +++ b/minerva/command.py @@ -19,7 +19,7 @@ class Command: self.machine = machine self.command = command self.disown = disown - self.watch = True#watch + self.watch = watch self.logset = logset self.thread = None @@ -36,8 +36,6 @@ class Command: # https://github.com/paramiko/paramiko/issues/593#issuecomment-145377328 # def execute(self): - print(f"running: {self.command}") - print("\t", self.logset) stdin, stdout, stderr = self.machine.ssh.client.exec_command(self.command) # this is the same for all three inputs @@ -88,20 +86,16 @@ class Command: break for c in readq: if c.recv_ready(): - print(f"\t{len(c.in_buffer)} in stdout") flush_data(channel.recv(len(c.in_buffer)), out, (self.watch and sys.stdout.buffer)) got_chunk = True - print(f"\t{len(c.in_buffer)} left in stdout") if c.recv_stderr_ready(): - print(f"\t{len(c.in_stderr_buffer)} in stderr") flush_data(channel.recv_stderr(len(c.in_stderr_buffer)), err, (self.watch and sys.stderr.buffer)) got_chunk = True - print(f"\t{len(c.in_stderr_buffer)} left in stderr") # for c """ diff --git a/minerva/machine.py b/minerva/machine.py index b6058f2..ce53f65 100644 --- a/minerva/machine.py +++ b/minerva/machine.py @@ -22,6 +22,10 @@ class Machine(minerva.Remote): public = True, disk_size = 8): + + if not key_pair or not key_pair[1]: + key_pair = (pier.key_pair_name, pier.key_path) + super().__init__(None, username, key_pair[1], name) self.pier = pier @@ -50,7 +54,7 @@ class Machine(minerva.Remote): res = self.pier.ec2.run_instances( ImageId = self.ami, InstanceType = self.instance_type, - KeyName = self.key_pair[0] or self.pier.key_pair_name, + KeyName = self.key_pair[0], MinCount = 1, MaxCount = 1, TagSpecifications = [{'ResourceType': 'instance', @@ -127,6 +131,7 @@ class Machine(minerva.Remote): self.public_ip = self.description['PublicIpAddress'] print(f"\t{self.name} ({self.info['InstanceId']}\t- {self.instance_type}) => {self.public_ip} ({self.private_ip})") + print(repr(self.key_pair)) self.ip = self.public_ip or self.private_ip self.ssh = Connection(self.ip,