Revision db908bb1 snf-cyclades-app/synnefo/api/management/commands/server-create.py
b/snf-cyclades-app/synnefo/api/management/commands/server-create.py | ||
---|---|---|
69 | 69 |
" available flavors."), |
70 | 70 |
make_option("--password", dest="password", |
71 | 71 |
help="Password for the new server"), |
72 |
make_option("--networks", dest="network_ids", |
|
73 |
help="Comma separated list of network IDs to connect"), |
|
74 |
make_option("--ports", dest="port_ids", |
|
75 |
help="Comma separated list of port IDs to connect"), |
|
76 |
make_option("--floating-ips", dest="floating_ip_ids", |
|
77 |
help="Comma separated list of port IDs to connect"), |
|
72 | 78 |
make_option( |
73 | 79 |
'--wait', |
74 | 80 |
dest='wait', |
75 |
default="True",
|
|
81 |
default="False",
|
|
76 | 82 |
choices=["True", "False"], |
77 | 83 |
metavar="True|False", |
78 | 84 |
help="Wait for Ganeti job to complete."), |
... | ... | |
109 | 115 |
else: |
110 | 116 |
backend = None |
111 | 117 |
|
118 |
network_ids = parse_list(options["network_ids"]) |
|
119 |
port_ids = parse_list(options["port_ids"]) |
|
120 |
floating_ip_ids = parse_list(options["floating_ip_ids"]) |
|
121 |
|
|
122 |
networks = map(lambda x: {"uuid": x}, network_ids) |
|
123 |
ports = map(lambda x: {"port": x}, port_ids) |
|
124 |
|
|
112 | 125 |
server = servers.create(user_id, name, password, flavor, image, |
126 |
networks=(ports+networks), |
|
127 |
floating_ips=floating_ip_ids, |
|
113 | 128 |
use_backend=backend) |
114 | 129 |
pprint.pprint_server(server, stdout=self.stdout) |
115 | 130 |
|
116 | 131 |
wait = parse_bool(options["wait"]) |
117 | 132 |
common.wait_server_task(server, wait, self.stdout) |
133 |
|
|
134 |
|
|
135 |
def parse_list(_list): |
|
136 |
if _list is None: |
|
137 |
return [] |
|
138 |
else: |
|
139 |
return _list.split(",") |
Also available in: Unified diff