Revision 0723a85c

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)
b/snf-cyclades-app/synnefo/api/management/commands/port-remove.py
28 28
# policies, either expressed or implied, of GRNET S.A.
29 29
#
30 30

  
31
from optparse import make_option
31 32
from django.core.management.base import BaseCommand, CommandError
32 33
from synnefo.logic import ports
33 34
from synnefo.api.util import get_port
34
from synnefo.management.common  import convert_api_faults
35
from synnefo.management import common
36
from snf_django.management.utils import parse_bool
37

  
35 38

  
36 39
class Command(BaseCommand):
37 40
    can_import_settings = True
38 41
    help = "Remove a port from the Database and from the VMs attached to"
42
    option_list = BaseCommand.option_list + (
43
        make_option(
44
            "--wait",
45
            dest="wait",
46
            default="True",
47
            choices=["True", "False"],
48
            metavar="True|False",
49
            help="Wait for Ganeti jobs to complete."),
50
    )
39 51

  
40
    @convert_api_faults
52
    @common.convert_api_faults
41 53
    def handle(self, *args, **options):
42 54
        if len(args) < 1:
43 55
            raise CommandError("Please provide a port ID")
......
46 58

  
47 59
        ports.delete(port)
48 60

  
49
        self.stdout.write("Successfully removed port\n")
61
        wait = parse_bool(options["wait"])
62
        common.wait_server_task(port.machine, wait, stdout=self.stdout)

Also available in: Unified diff