You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.7 KiB

#!/usr/bin/env python3
from common import EC2Environment, CREATE
import atexit, argparse, os
REGION = "eu-central-1"
VERSION = "1.4.0"
parser = argparse.ArgumentParser(description='Create a test setup')
parser.add_argument('--instancetype', default='t3.nano', help='EC2 instance type')
parser.add_argument('--version', default=VERSION, help='VpnCloud version to use')
parser.add_argument('--count', '-c', dest="count", type=int, default=2, help='Number of instance to create')
parser.add_argument('--cluster', action="store_true", help='Cluster instances to get reliable throughput')
parser.add_argument('--subnet', help='AWS subnet id to use (empty = create new one)')
parser.add_argument('--keyname', help='Name of AWS keypair to use (empty = create new one)')
parser.add_argument('--keyfile', help='Path of the private key file')
args = parser.parse_args()
privatekey = None
if args.keyname:
with open(args.keyfile, 'r') as fp:
privatekey =
setup = EC2Environment(
region = REGION,
node_count = args.count,
instance_type = args.instancetype,
vpncloud_version = args.version,
cluster_nodes = args.cluster,
subnet = args.subnet or CREATE,
keyname = args.keyname or CREATE,
privatekey = privatekey
if not args.keyname:
assert not os.path.exists(args.keyfile)
with open(args.keyfile, 'x') as fp:
os.chmod(args.keyfile, 0o400)
print("SSH private key written to {}".format(args.keyfile))
atexit.register(lambda : os.remove(args.keyfile))
for node in setup.nodes:
print("\t {}@{}\tprivate: {}".format(setup.username, node.public_ip, node.private_ip))
print("Press ENTER to shut down")