Revision 0f89715b
b/snf-cyclades-app/synnefo/api/management/commands/floating-ip-remove.py | ||
---|---|---|
34 | 34 |
#from optparse import make_option |
35 | 35 |
|
36 | 36 |
from django.db import transaction |
37 |
from django.core.management.base import BaseCommand, CommandError |
|
37 |
from django.core.management.base import CommandError |
|
38 |
from snf_django.management.commands import RemoveCommand |
|
38 | 39 |
from synnefo.management import common |
39 | 40 |
from synnefo.logic import ips |
40 | 41 |
|
41 | 42 |
|
42 |
class Command(BaseCommand):
|
|
43 |
class Command(RemoveCommand):
|
|
43 | 44 |
help = "Release a floating IP" |
44 | 45 |
|
45 | 46 |
@common.convert_api_faults |
... | ... | |
48 | 49 |
if not args: |
49 | 50 |
raise CommandError("Please provide a floating-ip address") |
50 | 51 |
|
52 |
force = options['force'] |
|
53 |
self.confirm_deletion(force, "floating ip(s)", args) |
|
54 |
|
|
51 | 55 |
floating_ip_id = args[0] |
52 | 56 |
|
53 | 57 |
floating_ip = common.get_floating_ip_by_id(floating_ip_id, |
b/snf-cyclades-app/synnefo/api/management/commands/network-remove.py | ||
---|---|---|
28 | 28 |
# policies, either expressed or implied, of GRNET S.A. |
29 | 29 |
# |
30 | 30 |
|
31 |
from django.core.management.base import BaseCommand, CommandError |
|
31 |
from django.core.management.base import CommandError |
|
32 |
from snf_django.management.commands import RemoveCommand |
|
32 | 33 |
from synnefo.logic import networks |
33 | 34 |
from synnefo.management.common import get_network, convert_api_faults |
34 | 35 |
|
35 | 36 |
|
36 |
class Command(BaseCommand):
|
|
37 |
class Command(RemoveCommand):
|
|
37 | 38 |
can_import_settings = True |
38 | 39 |
help = "Remove a network from the Database, and Ganeti" |
39 | 40 |
|
... | ... | |
42 | 43 |
if len(args) < 1: |
43 | 44 |
raise CommandError("Please provide a network ID") |
44 | 45 |
|
46 |
force = options['force'] |
|
47 |
self.confirm_deletion(force, "network(s)", args) |
|
48 |
|
|
45 | 49 |
network = get_network(args[0], for_update=True) |
46 | 50 |
|
47 | 51 |
self.stdout.write('Removing network: %s\n' % network.backend_id) |
b/snf-cyclades-app/synnefo/api/management/commands/port-remove.py | ||
---|---|---|
29 | 29 |
# |
30 | 30 |
|
31 | 31 |
from optparse import make_option |
32 |
from django.core.management.base import BaseCommand, CommandError
|
|
32 |
from django.core.management.base import CommandError |
|
33 | 33 |
from synnefo.logic import servers |
34 | 34 |
from synnefo.management import common |
35 | 35 |
from snf_django.management.utils import parse_bool |
36 |
from snf_django.management.commands import RemoveCommand |
|
36 | 37 |
|
37 | 38 |
|
38 |
class Command(BaseCommand):
|
|
39 |
class Command(RemoveCommand):
|
|
39 | 40 |
can_import_settings = True |
40 | 41 |
help = "Remove a port from the Database and from the VMs attached to" |
41 |
option_list = BaseCommand.option_list + (
|
|
42 |
option_list = RemoveCommand.option_list + (
|
|
42 | 43 |
make_option( |
43 | 44 |
"--wait", |
44 | 45 |
dest="wait", |
... | ... | |
53 | 54 |
if len(args) < 1: |
54 | 55 |
raise CommandError("Please provide a port ID") |
55 | 56 |
|
57 |
force = options['force'] |
|
58 |
self.confirm_deletion(force, "port(s)", args) |
|
59 |
|
|
56 | 60 |
port = common.get_port(args[0], for_update=True) |
57 | 61 |
|
58 | 62 |
servers.delete_port(port) |
b/snf-cyclades-app/synnefo/api/management/commands/server-remove.py | ||
---|---|---|
33 | 33 |
|
34 | 34 |
from optparse import make_option |
35 | 35 |
|
36 |
from django.core.management.base import BaseCommand, CommandError
|
|
36 |
from django.core.management.base import CommandError |
|
37 | 37 |
from synnefo.management.common import (get_vm, convert_api_faults, |
38 | 38 |
wait_server_task) |
39 | 39 |
from synnefo.logic import servers |
40 |
from snf_django.management.commands import RemoveCommand |
|
40 | 41 |
from snf_django.management.utils import parse_bool |
41 | 42 |
|
42 | 43 |
|
43 |
class Command(BaseCommand):
|
|
44 |
class Command(RemoveCommand):
|
|
44 | 45 |
args = "<server ID>" |
45 | 46 |
help = "Remove a server by deleting the instance from the Ganeti backend." |
46 | 47 |
|
47 |
option_list = BaseCommand.option_list + (
|
|
48 |
option_list = RemoveCommand.option_list + (
|
|
48 | 49 |
make_option( |
49 | 50 |
'--wait', |
50 | 51 |
dest='wait', |
... | ... | |
59 | 60 |
if len(args) != 1: |
60 | 61 |
raise CommandError("Please provide a server ID") |
61 | 62 |
|
63 |
force = options['force'] |
|
64 |
self.confirm_deletion(force, "server(s)", args) |
|
65 |
|
|
62 | 66 |
server = get_vm(args[0]) |
63 | 67 |
|
64 | 68 |
self.stdout.write("Trying to remove server '%s' from backend '%s'\n" % |
b/snf-cyclades-app/synnefo/logic/management/commands/pool-remove.py | ||
---|---|---|
31 | 31 |
# interpreted as representing official policies, either expressed |
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 |
from django.core.management.base import BaseCommand, CommandError |
|
34 |
from django.core.management.base import CommandError |
|
35 |
from snf_django.management.commands import RemoveCommand |
|
35 | 36 |
from optparse import make_option |
36 | 37 |
|
37 | 38 |
from synnefo.management.common import pool_table_from_type |
... | ... | |
39 | 40 |
POOL_CHOICES = ['bridge', 'mac-prefix'] |
40 | 41 |
|
41 | 42 |
|
42 |
class Command(BaseCommand):
|
|
43 |
class Command(RemoveCommand):
|
|
43 | 44 |
help = "Remove a pool." |
44 | 45 |
args = "<pool ID>" |
45 | 46 |
output_transaction = True |
46 |
option_list = BaseCommand.option_list + (
|
|
47 |
option_list = RemoveCommand.option_list + (
|
|
47 | 48 |
make_option("--type", dest="type", |
48 | 49 |
choices=POOL_CHOICES, |
49 | 50 |
help="Type of pool" |
... | ... | |
58 | 59 |
|
59 | 60 |
pool_table = pool_table_from_type(type_) |
60 | 61 |
|
62 |
force = options['force'] |
|
63 |
self.confirm_deletion(force, "pool(s)", args) |
|
64 |
|
|
61 | 65 |
try: |
62 | 66 |
pool_id = int(args[0]) |
63 | 67 |
pool = pool_table.objects.get(id=pool_id) |
b/snf-django-lib/snf_django/management/commands/__init__.py | ||
---|---|---|
349 | 349 |
|
350 | 350 |
ids = ', '.join(args) |
351 | 351 |
self.stdout.write("Are you sure you want to delete %s %s?" |
352 |
" [Y/N]\n" % (resource, ids))
|
|
352 |
" [Y/N] " % (resource, ids))
|
|
353 | 353 |
try: |
354 | 354 |
answer = distutils.util.strtobool(raw_input()) |
355 | 355 |
if answer != 1: |
Also available in: Unified diff