コード例 #1
0
ファイル: policyService.py プロジェクト: cmscaltech/siterm
 def __init__(self, config, logger, sitename):
     self.sitename = sitename
     self.logger = logger
     self.config = config
     self.siteDB = contentDB(logger=self.logger, config=self.config)
     self.dbI = getDBConn('PolicyService')
     self.stateMachine = StateMachine(self.logger)
コード例 #2
0
 def __init__(self, config, logger, sitename):
     self.sitename = sitename
     self.logger = logger
     self.config = config
     self.prefixDB = prefixDB(config, sitename)
     self.dbI = getDBConn('LookUpService')
     self.newGraph = None
     self.shared = False
     self.hosts = {}
コード例 #3
0
 def __init__(self, logger, config=None):
     self.dbI = getDBConn()
     self.config = getConfig(["/etc/dtnrm-site-fe.conf"])
     if config:
         self.config = config
     self.logger = logger
     self.policer = polS.PolicyService(self.config, self.logger)
     self.stateM = stateM.StateMachine(self.logger)
     self.siteDB = contentDB(logger=self.logger, config=self.config)
コード例 #4
0
ファイル: cancelalldeltas.py プロジェクト: sdn-sense/siterm
def deleteAll(sitename, deltaUID=None):
    """delete all deltas."""
    dbI = getDBConn('cancelalldeltas')
    dbobj = getVal(dbI, sitename=sitename)
    for delta in dbobj.get('deltas'):
        if deltaUID and delta['uid'] != deltaUID:
            continue
        print('Cancel %s' % delta['uid'])
        STATEMACHINE._stateChangerDelta(dbobj, 'remove', **delta)
コード例 #5
0
ファイル: DeltaModels.py プロジェクト: cmscaltech/siterm
 def __init__(self, logger, config=None):
     self.dbI = getDBConn('REST-DELTA')
     self.config = getConfig()
     if config:
         self.config = config
     self.logger = logger
     self.policer = {}
     for sitename in self.config.get('general', 'sites').split(','):
         policer = polS.PolicyService(config, logger, sitename)
         self.policer[sitename] = policer
     self.stateM = stateM.StateMachine(self.logger)
     self.siteDB = contentDB(logger=self.logger, config=self.config)
コード例 #6
0
ファイル: listalldeltas.py プロジェクト: cmscaltech/siterm
def getdeltaAll(sitename):
    dbI = getDBConn('listalldeltas')
    dbobj = getVal(dbI, sitename=sitename)
    for delta in dbobj.get('deltas'):
        delta['addition'] = evaldict(delta['addition'])
        delta['reduction'] = evaldict(delta['reduction'])
        print '='*80
        print 'Delta UID  :  ', delta['uid']
        print 'Delta RedID:  ', delta['reductionid']
        print 'Delta State:  ', delta['state']
        print 'Delta ModAdd: ', delta['modadd']
        print 'Delta InsDate:', delta['insertdate']
        print 'Delta Update: ', delta['updatedate']
        print 'Delta Model:  ', delta['modelid']
        print 'Delta connID: ', delta['connectionid']
        print 'Delta Deltatype: ', delta['deltat']
        print '-'*20
        print 'Delta times'
        for deltatimes in dbobj.get('states', search=[['deltaid', delta['uid']]]):
            print 'State: %s Date: %s' % (deltatimes['state'], deltatimes['insertdate'])
        if delta['deltat'] not in ['reduction', 'addition']:
            print 'SOMETHING WRONG WITH THIS DELTA. It does not have any type defined. Was not parsed properly'
            continue
        if not isinstance(delta[delta['deltat']], list):
            conns = [delta[delta['deltat']]]
        else:
            conns = delta[delta['deltat']]
        for conn in conns:
            if 'hosts' not in conn.keys():
                print 'SOMETHING WRONG WITH THIS DELTA. It does not have any hosts defined.'
                continue
            for hostname in conn['hosts'].keys():
                print '-'*20
                print 'Host States %s' % hostname
                for hoststate in dbobj.get('hoststates', search=[['deltaid', delta['uid']], ['hostname', hostname]]):
                    print 'Host %s State %s' % (hostname, hoststate['state'])
                    print 'Insertdate %s UpdateDate %s' % (hoststate['insertdate'], hoststate['updatedate'])
                    print '-'*20
                    print 'Host State History'
                    for hstatehistory in dbobj.get('hoststateshistory', search=[['deltaid', delta['uid']], ['hostname', hostname]]):
                        print 'State: %s, Date: %s' % (hstatehistory['state'], hstatehistory['insertdate'])
        print '-'*20
        print 'Connection details'
        for conn in conns:
            for dConn in dbobj.get('delta_connections', search=[['connectionid', conn['connectionID']]]):
                print dConn
コード例 #7
0
ファイル: acceptdelta.py プロジェクト: sdn-sense/siterm
def getdeltainfo(sitename, deltaUID):
    """Get all delta information.

    INPUT: sitename  - str mandatory
           deltaUID  - str mandatory
    """
    dbI = getDBConn('acceptdelta')
    dbobj = getVal(dbI, sitename=sitename)
    for delta in dbobj.get('deltas'):
        if delta['uid'] != deltaUID:
            continue
        delta['addition'] = evaldict(delta['addition'])
        delta['reduction'] = evaldict(delta['reduction'])
        LOGGER.info('=' * 80)
        LOGGER.info('Delta UID  :  %s', delta['uid'])
        LOGGER.info('Delta RedID:  %s', delta['reductionid'])
        LOGGER.info('Delta State:  %s', delta['state'])
        LOGGER.info('Delta ModAdd: %s', delta['modadd'])
        LOGGER.info('Delta InsDate: %s', delta['insertdate'])
        LOGGER.info('Delta Update:  %s', delta['updatedate'])
        LOGGER.info('Delta Model:  %s', delta['modelid'])
        LOGGER.info('Delta connID:  %s', delta['connectionid'])
        LOGGER.info('Delta Deltatype: %s', delta['deltat'])
        LOGGER.info('-' * 20)
        LOGGER.info('Delta times')
        for deltatimes in dbobj.get('states', search=[['deltaid', delta['uid']]]):
            LOGGER.info('State: %s Date: %s', deltatimes['state'], deltatimes['insertdate'])
        if delta['deltat'] in ['reduction', 'addition']:
            for hostname in list(delta[delta['deltat']]['hosts'].keys()):
                LOGGER.info('-' * 20)
                LOGGER.info('Host States %s', hostname)
                for hoststate in dbobj.get('hoststates', search=[['deltaid', delta['uid']], ['hostname', hostname]]):
                    LOGGER.info('Host %s State %s', hostname, hoststate['state'])
                    LOGGER.info('Insertdate %s UpdateDate %s', hoststate['insertdate'], hoststate['updatedate'])
                    LOGGER.info('-' * 20)
                    LOGGER.info('Host State History')
                    for hstatehistory in dbobj.get('hoststateshistory',
                                                   search=[['deltaid', delta['uid']], ['hostname', hostname]]):
                        LOGGER.info('State: %s, Date: %s', hstatehistory['state'], hstatehistory['insertdate'])
        return delta, dbobj
コード例 #8
0
 def __init__(self):
     self.dbI = getDBConn('Prometheus')
コード例 #9
0
ファイル: FEApis.py プロジェクト: cmscaltech/siterm
 def __init__(self):
     self.dbI = getDBConn('REST-Frontend')
     self.initialized = False
     self.config = getConfig()
     self.siteDB = contentDB()
コード例 #10
0
ファイル: FEApis.py プロジェクト: juztas/backup-siterm-fe
 def __init__(self):
     self.dbI = getDBConn()
     self.initialized = False
     self.config = getConfig(["/etc/dtnrm-site-fe.conf"])
     self.siteDB = contentDB()
コード例 #11
0
ファイル: analyzedelta.py プロジェクト: sdn-sense/siterm
def getdeltaAll(sitename, deltaUID):
    dbI = getDBConn('analyzedelta')
    dbobj = getVal(dbI, sitename=sitename)
    policer = polS.PolicyService(CONFIG, LOGGER)
    for delta in dbobj.get('deltas'):
        if delta['uid'] != deltaUID:
            continue
        delta['addition'] = evaldict(delta['addition'])
        delta['reduction'] = evaldict(delta['reduction'])
        print('=' * 80)
        print('Delta UID  :  ', delta['uid'])
        print('Delta RedID:  ', delta['reductionid'])
        print('Delta State:  ', delta['state'])
        print('Delta ModAdd: ', delta['modadd'])
        print('Delta InsDate:', delta['insertdate'])
        print('Delta Update: ', delta['updatedate'])
        print('Delta Model:  ', delta['modelid'])
        print('Delta connID: ', delta['connectionid'])
        print('Delta Deltatype: ', delta['deltat'])
        print('-' * 20)
        import pprint
        pprint.pprint(delta)
        print('Delta times')
        for deltatimes in dbobj.get('states',
                                    search=[['deltaid', delta['uid']]]):
            print('State: %s Date: %s' %
                  (deltatimes['state'], deltatimes['insertdate']))
        if delta['deltat'] in ['reduction', 'addition']:
            for hostname in list(delta[delta['deltat']]['hosts'].keys()):
                print('-' * 20)
                print('Host States %s' % hostname)
                for hoststate in dbobj.get('hoststates',
                                           search=[['deltaid', delta['uid']],
                                                   ['hostname', hostname]]):
                    print('Host %s State %s' % (hostname, hoststate['state']))
                    print('Insertdate %s UpdateDate %s' %
                          (hoststate['insertdate'], hoststate['updatedate']))
                    print('-' * 20)
                    print('Host State History')
                    for hstatehistory in dbobj.get(
                            'hoststateshistory',
                            search=[['deltaid', delta['uid']],
                                    ['hostname', hostname]]):
                        print('State: %s, Date: %s' %
                              (hstatehistory['state'],
                               hstatehistory['insertdate']))
        toDict = ast.literal_eval(str(delta['content']))
        jOut = getAllHosts(sitename, LOGGER)
        for key in ['reduction', 'addition']:
            print(list(toDict.keys()))
            if key in toDict and toDict[key]:
                print('Got Content %s for key %s', toDict[key], key)
                tmpFile = tempfile.NamedTemporaryFile(delete=False, mode="w+")
                try:
                    tmpFile.write(toDict[key])
                except ValueError as ex:
                    print(
                        'Received ValueError. More details %s. Try to write normally with decode',
                        ex)
                    tmpFile.write(decodebase64(toDict["Content"][key]))
                tmpFile.close()
                # outputDict[key] = self.parseDeltaRequest(tmpFile.name, jOut)
                print("For %s this is delta location %s" % (key, tmpFile.name))
            out = policer.parseDeltaRequest(tmpFile.name, jOut)
            if not out:
                out = policer.parseDeltaRequest(tmpFile.name, jOut, sitename)
                print(out)
コード例 #12
0
 def __init__(self, config, logger):
     self.logger = logger
     self.config = config
     self.siteDB = contentDB(logger=self.logger, config=self.config)
     self.dbI = getDBConn()
     self.stateMachine = StateMachine(self.logger)