Пример #1
0
def run(argv):
	parser = argparse.ArgumentParser(description='Connect to a running environment')
	parser.add_argument("environment",
	                    metavar="[host:]environment",
	                    help="The environment to connect to")
	args = parser.parse_args(argv)
	env = Environment.findOne({"id": args.environment})

	if env is None:
		print("No environment found: %s", args.environment)
		sys.exit(1)

	if env.state != "running":
		print("%s is not currently running. Please start it first." % env.id)
		sys.exit(1)

	ip_address = env.ip_address
	print("Connecting to %s at %s" % (env.id, ip_address))

	subprocess.check_call(["ssh-add", env.private_key_path])

	ssh_command = rep.SSH_PROXY + ["ssh", "-o", "StrictHostKeyChecking=no", "root@%s" % ip_address]
	subprocess.check_call(ssh_command)

	sys.exit(0)
Пример #2
0
def run(argv):
	envs = Environment.find()
	headers = ["ID", "Docker ID", "State", "IP Address"]
	rows = []
	for env in envs:
		rows.append([env.id, env.docker_id, env.state, env.ip_address])
	print(tabulate(rows, headers))
	sys.exit(0)
Пример #3
0
def run(argv):
	parser = argparse.ArgumentParser(description='Create an environment from an existing image')
	parser.add_argument("--from-image", "-i",
	                    metavar="[host:]image_name",
	                    help="The location of the image",
	                    dest="image")
	args = parser.parse_args(argv)
	environment = Environment.create_from_image_id(args.image)
	print("ENVIRONMENT ID = %s" % environment.id)
	print("DOCKER ID = %s" % environment.docker_id)
	sys.exit(0)
Пример #4
0
def run(argv):
	parser = argparse.ArgumentParser(description='Start a running environment')
	parser.add_argument("environment",
	                    metavar="[host:]environment",
	                    help="The environment to start")
	args = parser.parse_args(argv)
	env = Environment.findOne({"id": args.environment})

	if env.state == "running":
		print("%s is already running." % env.id)
		sys.exit(1)

	print("Starting %s..." % env.id)
	env.start()
	print("Done")

	sys.exit(0)