Commit ba6cb8ee authored by Dionysis Grigoropoulos's avatar Dionysis Grigoropoulos Committed by Christos Stavrakakis
Browse files

cyclades: Update some snf-manage commands

* Update network-remove, server-remove, floating-ip-remove, port-remove
to extend RemoveCommand class added in commit
ec15e2ab68f90dcc7310863c9293708055fbfb7d
parent 17eb2798
......@@ -34,12 +34,13 @@
#from optparse import make_option
from django.db import transaction
from django.core.management.base import BaseCommand, CommandError
from django.core.management.base import CommandError
from snf_django.management.commands import RemoveCommand
from synnefo.management import common
from synnefo.logic import ips
class Command(BaseCommand):
class Command(RemoveCommand):
help = "Release a floating IP"
@common.convert_api_faults
......@@ -48,6 +49,9 @@ class Command(BaseCommand):
if not args:
raise CommandError("Please provide a floating-ip address")
force = options['force']
self.confirm_deletion(force, "floating ip(s)", args)
floating_ip_id = args[0]
floating_ip = common.get_floating_ip_by_id(floating_ip_id,
......
......@@ -28,12 +28,13 @@
# policies, either expressed or implied, of GRNET S.A.
#
from django.core.management.base import BaseCommand, CommandError
from django.core.management.base import CommandError
from snf_django.management.commands import RemoveCommand
from synnefo.logic import networks
from synnefo.management.common import get_network, convert_api_faults
class Command(BaseCommand):
class Command(RemoveCommand):
can_import_settings = True
help = "Remove a network from the Database, and Ganeti"
......@@ -42,6 +43,9 @@ class Command(BaseCommand):
if len(args) < 1:
raise CommandError("Please provide a network ID")
force = options['force']
self.confirm_deletion(force, "network(s)", args)
network = get_network(args[0], for_update=True)
self.stdout.write('Removing network: %s\n' % network.backend_id)
......
......@@ -29,16 +29,17 @@
#
from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
from django.core.management.base import CommandError
from synnefo.logic import servers
from synnefo.management import common
from snf_django.management.utils import parse_bool
from snf_django.management.commands import RemoveCommand
class Command(BaseCommand):
class Command(RemoveCommand):
can_import_settings = True
help = "Remove a port from the Database and from the VMs attached to"
option_list = BaseCommand.option_list + (
option_list = RemoveCommand.option_list + (
make_option(
"--wait",
dest="wait",
......@@ -53,6 +54,9 @@ class Command(BaseCommand):
if len(args) < 1:
raise CommandError("Please provide a port ID")
force = options['force']
self.confirm_deletion(force, "port(s)", args)
port = common.get_port(args[0], for_update=True)
servers.delete_port(port)
......
......@@ -33,18 +33,19 @@
from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
from django.core.management.base import CommandError
from synnefo.management.common import (get_vm, convert_api_faults,
wait_server_task)
from synnefo.logic import servers
from snf_django.management.commands import RemoveCommand
from snf_django.management.utils import parse_bool
class Command(BaseCommand):
class Command(RemoveCommand):
args = "<server ID>"
help = "Remove a server by deleting the instance from the Ganeti backend."
option_list = BaseCommand.option_list + (
option_list = RemoveCommand.option_list + (
make_option(
'--wait',
dest='wait',
......@@ -59,6 +60,9 @@ class Command(BaseCommand):
if len(args) != 1:
raise CommandError("Please provide a server ID")
force = options['force']
self.confirm_deletion(force, "server(s)", args)
server = get_vm(args[0])
self.stdout.write("Trying to remove server '%s' from backend '%s'\n" %
......
......@@ -31,7 +31,8 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from django.core.management.base import BaseCommand, CommandError
from django.core.management.base import CommandError
from snf_django.management.commands import RemoveCommand
from optparse import make_option
from synnefo.management.common import pool_table_from_type
......@@ -39,11 +40,11 @@ from synnefo.management.common import pool_table_from_type
POOL_CHOICES = ['bridge', 'mac-prefix']
class Command(BaseCommand):
class Command(RemoveCommand):
help = "Remove a pool."
args = "<pool ID>"
output_transaction = True
option_list = BaseCommand.option_list + (
option_list = RemoveCommand.option_list + (
make_option("--type", dest="type",
choices=POOL_CHOICES,
help="Type of pool"
......@@ -58,6 +59,9 @@ class Command(BaseCommand):
pool_table = pool_table_from_type(type_)
force = options['force']
self.confirm_deletion(force, "pool(s)", args)
try:
pool_id = int(args[0])
pool = pool_table.objects.get(id=pool_id)
......
......@@ -349,7 +349,7 @@ class RemoveCommand(BaseCommand):
ids = ', '.join(args)
self.stdout.write("Are you sure you want to delete %s %s?"
" [Y/N]\n" % (resource, ids))
" [Y/N] " % (resource, ids))
try:
answer = distutils.util.strtobool(raw_input())
if answer != 1:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment