Statistics
| Branch: | Revision:

root / graphs / management / commands / rgconf.py @ 04733cdb

History | View | Annotate | Download (1.2 kB)

1
# -*- coding: utf-8 -*- vim:encoding=utf-8:
2
# vim: tabstop=4:shiftwidth=4:softtabstop=4:expandtab
3

    
4
from django.core.management.base import BaseCommand, CommandError
5
from django.conf import settings
6
from core.models import *
7
from datetime import datetime, timedelta
8
import sys
9
import os
10
from __genrgconfig__ import *
11
from __dbfuncs__ import *
12

    
13
class Command(BaseCommand):
14

    
15
    def handle(self, *args, **options):
16
        luns = Lun.objects.all()
17
        types = settings.LUN_GRAPH_TYPES
18
        for lun in luns:
19
            for type in types:
20
                self.dbupdate(lun, type)
21
            print 'Node: %s ...done' % lun.pk
22

    
23
    def dbupdate(self, device, type):
24
        # Ok. A couple of hacks here. Instead of a if then elif then elif.... for each type
25
        # we get first from the settings dictionnary the confdir and then the function used 
26
        # for this type from the globals() dictionary
27
        try:
28
#            dir = getattr(settings,'RG_%s_CONFDIR' % type.upper())
29
#            self.checkdir(dir)
30
            
31
            func = globals()['%s_genconfig' % type]
32
            func(device)
33
            print "Done with device"
34
        except AttributeError as e:
35
            print "%s is not going to be configured because %s" % (type, e)
36
            return
37