c7testvm: Allow using a specific name instead of generating one
parent
e6136b01ef
commit
5dfd71b2fd
|
@ -149,6 +149,7 @@ def wait_for_host(host, port, timeout=300):
|
|||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--name')
|
||||
parser.add_argument('--ram', type=int, default=1024)
|
||||
parser.add_argument('--vcpus', type=int, default=2)
|
||||
parser.add_argument('--cpu', default='host')
|
||||
|
@ -166,6 +167,9 @@ def parse_args():
|
|||
def main():
|
||||
args = parse_args()
|
||||
|
||||
if args.name:
|
||||
name = args.name
|
||||
else:
|
||||
name = 'C7-{}'.format(binascii.hexlify(os.urandom(3)).decode())
|
||||
hostname = '{}.local'.format(name.lower())
|
||||
|
||||
|
@ -212,7 +216,10 @@ def main():
|
|||
p = subprocess.Popen(cmd, env=env)
|
||||
httpd.handle_request()
|
||||
httpd.server_close()
|
||||
try:
|
||||
p.wait()
|
||||
except KeyboardInterrupt:
|
||||
raise SystemExit(1)
|
||||
print('Waiting for host to come up...')
|
||||
if wait_for_host(hostname, 22):
|
||||
os.execlp('ssh', 'ssh', '-oStrictHostKeyChecking=no',
|
||||
|
|
Loading…
Reference in New Issue