Revision 0723a85c snf-cyclades-app/synnefo/api/management/commands/port-create.py
b/snf-cyclades-app/synnefo/api/management/commands/port-create.py | ||
---|---|---|
34 | 34 |
from optparse import make_option |
35 | 35 |
|
36 | 36 |
from django.core.management.base import BaseCommand, CommandError |
37 |
from synnefo.management.common import convert_api_faults |
|
38 | 37 |
|
39 | 38 |
from synnefo.api import util |
40 | 39 |
from synnefo.management import common, pprint |
40 |
from snf_django.management.utils import parse_bool |
|
41 | 41 |
from synnefo.logic import ports |
42 | 42 |
|
43 | 43 |
HELP_MSG = """Create a new port. |
... | ... | |
83 | 83 |
default=None, |
84 | 84 |
help="Comma separated list of Security Group IDs to associate" |
85 | 85 |
" with the port."), |
86 |
make_option( |
|
87 |
"--wait", |
|
88 |
dest="wait", |
|
89 |
default="True", |
|
90 |
choices=["True", "False"], |
|
91 |
metavar="True|False", |
|
92 |
help="Wait for Ganeti jobs to complete."), |
|
86 | 93 |
) |
87 | 94 |
|
88 |
@convert_api_faults |
|
95 |
@common.convert_api_faults
|
|
89 | 96 |
def handle(self, *args, **options): |
90 | 97 |
if args: |
91 | 98 |
raise CommandError("Command doesn't accept any arguments") |
... | ... | |
98 | 105 |
floating_ip_id = options["floating_ip_id"] |
99 | 106 |
# assume giving security groups comma separated |
100 | 107 |
security_group_ids = options["security-groups"] |
108 |
wait = parse_bool(options["wait"]) |
|
101 | 109 |
|
102 | 110 |
if not name: |
103 | 111 |
name = "" |
... | ... | |
146 | 154 |
self.stdout.write("Created port '%s' in DB:\n" % new_port) |
147 | 155 |
pprint.pprint_port(new_port, stdout=self.stdout) |
148 | 156 |
pprint.pprint_port_ips(new_port, stdout=self.stdout) |
149 |
# TODO: Display port information, like ip address |
|
150 |
# TODO: Add --wait argument to report progress about the Ganeti job. |
|
157 |
self.stdout.write("\n") |
|
158 |
common.wait_server_task(new_port.machine, wait, stdout=self.stdout) |
Also available in: Unified diff