Commit 24f8fa85 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

Merge branch '0.9-wip'

parents 40465f15 bee7a4bc
......@@ -75,7 +75,10 @@ class Command(BaseCommand):
for server in servers:
id = str(server.id)
flavor = server.flavor.name
image = get_image(server.imageid, server.userid)['name']
try:
image = get_image(server.imageid, server.userid)['name']
except:
image = server.imageid
fields = (id, server.name, server.userid, flavor, image,
server.operstate)
......
......@@ -41,33 +41,11 @@ from optparse import make_option
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from synnefo.db.models import VirtualMachine, Network
from synnefo.db.models import VirtualMachine
from synnefo.logic import reconciliation, backend
from synnefo.util.rapi import GanetiRapiClient
_valid_users = set()
_invalid_users = set()
def user_exists(user):
from astakos.im.models import AstakosUser
if user in _valid_users:
return True
elif user in _invalid_users:
return False
try:
AstakosUser.objects.get(email=user)
except AstakosUser.DoesNotExist:
_invalid_users.add(user)
return False
else:
_valid_users.add(user)
return True
class Command(BaseCommand):
can_import_settings = True
......@@ -84,14 +62,6 @@ class Command(BaseCommand):
dest='detect_unsynced',
default=False, help='Detect unsynced operstate between ' +
'DB and Ganeti'),
make_option('--detect-orphan-servers',
action='store_true',
dest='detect_orphan_servers',
help='Detect VMs with an invalid owner'),
make_option('--detect-orphan-networks',
action='store_true',
dest='detect_orphan_networks',
help='Detect networks with an invalid owner'),
make_option('--detect-all', action='store_true',
dest='detect_all',
default=False, help='Enable all --detect-* arguments'),
......@@ -166,22 +136,6 @@ class Command(BaseCommand):
elif verbosity == 2:
print >> sys.stderr, "The operstate of all servers is in sync."
if options['detect_orphan_servers']:
for server in VirtualMachine.objects.filter(deleted=False):
owner = server.userid
if not user_exists(owner):
msg = "Server %d (%s) has unknown owner %s\n" % (
server.id, server.name, owner)
self.stdout.write(msg)
if options['detect_orphan_networks']:
for network in Network.objects.exclude(state='DELETED'):
owner = network.userid
if owner and not user_exists(owner):
msg = "Network %d (%s) has unknown owner %s\n" % (
network.id, network.name, owner)
self.stdout.write(msg)
#
# Then fix them
#
......
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