Revision 0723a85c snf-cyclades-app/synnefo/api/management/commands/port-remove.py

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