Revision 87c1dadc

b/snf-tools/snf-admin
52 52

  
53 53
from synnefo.db import models
54 54
from synnefo.invitations.invitations import add_invitation, send_invitation
55
from synnefo.logic.users import _register_user, delete_user
55
from synnefo.logic import backend, users
56 56

  
57 57

  
58 58
def get_user(uid):
......
186 186
            print 'Invalid type'
187 187
            return
188 188
        
189
        user = _register_user(realname, username, email, type)
189
        user = users._register_user(realname, username, email, type)
190 190
        print_item(user)
191 191

  
192 192

  
......
204 204
    def main(self, user_id):
205 205
        if self.force:
206 206
            user = get_user(user_id)
207
            delete_user(user)
207
            users.delete_user(user)
208 208
        else:
209 209
            print "WARNING: Deleting a user is a very destructive operation."
210 210
            print "Any objects with foreign keys pointing to this user will" \
......
500 500
        print_items(flavors, self.detail)
501 501

  
502 502

  
503
class ShowStats(Command):
504
    group = 'stats'
505
    name = None
506
    description = 'show statistics'
507

  
508
    def main(self):
509
        stats = {}
510
        stats['Users'] = models.SynnefoUser.objects.count()
511
        stats['Images'] = models.Image.objects.exclude(state='DELETED').count()
512
        stats['Flavors'] = models.Flavor.objects.count()
513
        stats['VMs'] = models.VirtualMachine.objects.filter(deleted=False).count()
514
        stats['Networks'] = models.Network.objects.exclude(state='DELETED').count()
515
        stats['Invitations'] = models.Invitations.objects.count()
516
        
517
        stats['Ganeti Instances'] = len(backend.get_ganeti_instances())
518
        stats['Ganeti Nodes'] = len(backend.get_ganeti_nodes())
519
        stats['Ganeti Jobs'] = len(backend.get_ganeti_jobs())
520
        
521
        print_dict(stats)
522

  
523

  
503 524
def print_usage(exe, groups, group=None, shortcut=False):
504 525
    nop = Command(exe, [])
505 526
    nop.parser.print_help()

Also available in: Unified diff