Commit 069f5e3e authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Choose networks in server-create cmd

parent b89f1e34
......@@ -69,10 +69,16 @@ class Command(BaseCommand):
" available flavors."),
make_option("--password", dest="password",
help="Password for the new server"),
make_option("--networks", dest="network_ids",
help="Comma separated list of network IDs to connect"),
make_option("--ports", dest="port_ids",
help="Comma separated list of port IDs to connect"),
make_option("--floating-ips", dest="floating_ip_ids",
help="Comma separated list of port IDs to connect"),
make_option(
'--wait',
dest='wait',
default="True",
default="False",
choices=["True", "False"],
metavar="True|False",
help="Wait for Ganeti job to complete."),
......@@ -109,9 +115,25 @@ class Command(BaseCommand):
else:
backend = None
network_ids = parse_list(options["network_ids"])
port_ids = parse_list(options["port_ids"])
floating_ip_ids = parse_list(options["floating_ip_ids"])
networks = map(lambda x: {"uuid": x}, network_ids)
ports = map(lambda x: {"port": x}, port_ids)
server = servers.create(user_id, name, password, flavor, image,
networks=(ports+networks),
floating_ips=floating_ip_ids,
use_backend=backend)
pprint.pprint_server(server, stdout=self.stdout)
wait = parse_bool(options["wait"])
common.wait_server_task(server, wait, self.stdout)
def parse_list(_list):
if _list is None:
return []
else:
return _list.split(",")
......@@ -264,11 +264,11 @@ def pprint_server_nics(server, stdout=None, title=None):
nics = []
for nic in server.nics.all():
nics.append((nic.name, nic.index, nic.mac, nic.ipv4_address,
nics.append((nic.id, nic.name, nic.index, nic.mac, nic.ipv4_address,
nic.ipv6_address, nic.network, nic.firewall_profile,
nic.state))
headers = ["Name", "Index", "MAC", "IPv4 Address", "IPv6 Address",
headers = ["ID", "Name", "Index", "MAC", "IPv4 Address", "IPv6 Address",
"Network", "Firewall", "State"]
pprint_table(stdout, nics, headers, separator=" | ",
title=title)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment