def GetSlivers(data, config, plc): # added by caglar # band-aid for short period as old API returns networks instead of interfaces global KEY_NAME KEY_NAME = "interfaces" ################# logger.verbose("net: GetSlivers called.") if not 'interfaces' in data: # added by caglar # band-aid for short period as old API returns networks instead of interfaces # logger.log_missing_data('net.GetSlivers','interfaces') # return if not 'networks' in data: logger.log_missing_data('net.GetSlivers','interfaces') return else: KEY_NAME = "networks" ################## plnet.InitInterfaces(logger, plc, data) if 'OVERRIDES' in dir(config): if config.OVERRIDES.get('net_max_rate') == '-1': logger.log("net: Slice and node BW Limits disabled.") if len(bwlimit.tc("class show dev %s" % dev_default)): logger.verbose("net: *** DISABLING NODE BW LIMITS ***") bwlimit.stop() else: InitNodeLimit(data) InitI2(plc, data) else: InitNodeLimit(data) InitI2(plc, data) InitNAT(plc, data)
def run(): """ When run as a thread, wait for event, lock db, deep copy it, release it, run bwmon.GetSlivers(), then go back to waiting. """ logger.verbose("bwmon: Thread started") while True: lock.wait() logger.verbose("bwmon: Event received. Running.") database.db_lock.acquire() nmdbcopy = copy.deepcopy(database.db) database.db_lock.release() try: if getDefaults(nmdbcopy) and len(bwlimit.tc("class show dev %s" % dev_default)) > 0: # class show to check if net:InitNodeLimit:bwlimit.init has run. sync(nmdbcopy) else: logger.log("bwmon: BW limits DISABLED.") except: logger.log_exc("bwmon failed") lock.clear()