Beispiel #1
0
def loadSQLite(mxa_id, table_name=None, db_path=None):
    global ID, NAME, TCP_IP, TELNET_PORT, LOCATION, JFW_PORT, MXA_PORT, STATUS
    if table_name:
        config = sql.getSQLite(
            'SELECT * FROM ' + str(table_name) + ' WHERE id=' + str(mxa_id),
            db_path)
    else:
        config = sql.getSQLite(
            'SELECT * FROM ' + MXA_TABLE_NAME + ' WHERE id=' + str(mxa_id),
            db_path)
    if config:
        if config[0]['id'] is not None: ID = config[0]['id']
        if config[0]['name'] is not None: NAME = config[0]['name']
        if config[0]['ip'] is not None: TCP_IP = config[0]['ip']
        if config[0]['port'] is not None: TELNET_PORT = config[0]['port']
        if config[0]['location'] is not None: LOCATION = config[0]['location']
        if config[0]['jfw_port'] is not None: JFW_PORT = config[0]['jfw_port']
        if config[0]['mxa_port'] is not None: MXA_PORT = config[0]['mxa_port']
        if config[0]['status'] is not None: STATUS = config[0]['status']
        return config[0]
    return {
        "error":
        "Loading table [" + MXA_TABLE_NAME + "] with ID [" + str(mxa_id) +
        "] Failed"
    }
Beispiel #2
0
 def reset(self, db_path=None):
     if not self.MY_DAEMON:
         utility.info("##################### " + Fore.YELLOW + "Reset MXA" +
                      Style.RESET_ALL + " ######################")
     mxaList = sql.getSQLite(
         'SELECT * FROM rf_matrix_db WHERE output_device = "' +
         self.MY_NAME + '"',
         db_path=db_path)
     for mxa in mxaList:
         if mxa['jfw_id'] and mxa['jfw_port']:
             jfw.loadSQLite(str(mxa['jfw_id']), db_path=db_path)
             jfw.connectJFW('SAR' + str(mxa['jfw_port']) + ' 127',
                            daemon=True)
             if not self.MY_DAEMON:
                 utility.info("Reseting JFW [" + str(jfw.ID) + "]...")
         else:
             rf_matrix_box = sql.getSQLite(
                 'SELECT * FROM rf_matrix WHERE id=' +
                 str(mxa['rf_matrix_id']),
                 db_path=db_path)[0]
             rf_matrix.loadSQLite(str(rf_matrix_box['id']), db_path=db_path)
             if 'QRB' in rf_matrix_box['name']:
                 if not self.MY_DAEMON:
                     utility.info("Reseting QRB [" + rf_matrix_box['name'] +
                                  "]...")
                 rf_matrix.resetQRBAtten(portB=mxa['port'], daemon=True)
             elif 'RFM' in rf_matrix_box['name']:
                 jfw.connectJFW('SAR' + str(self.MY_JFW_PORT) + ' 127',
                                daemon=True)
Beispiel #3
0
 def loadSQLite(self, jfw_id, table_name=None, db_path=None):
     try:
         if table_name:
             config = sql.getSQLite(
                 'SELECT * FROM ' + str(table_name) + ' WHERE id=' +
                 str(jfw_id), db_path)[0]
         else:
             config = sql.getSQLite(
                 'SELECT * FROM ' + self.MY_JFW_TABLE_NAME + ' WHERE id=' +
                 str(jfw_id), db_path)[0]
     except Exception as e:
         utility.warn("JFW loadSQLite failed: " + str(e), track=False)
         config = {"error": str(e)}
     return self.__loadConfig(json=config)
Beispiel #4
0
def loadSQLite(rid, table_name=None, db_path=None):
    global ID, NAME, TCP_IP, TCP_PORT, BUFFER_SIZE, STATUS
    if table_name:
        config = sql.getSQLite(
            'SELECT * FROM ' + str(table_name) + ' WHERE id=' + str(rid),
            db_path)
    else:
        config = sql.getSQLite(
            'SELECT * FROM ' + RF_MATRIX_TABLE_NAME + ' WHERE id=' + str(rid),
            db_path)
    if config:
        if config[0]['id'] is not None: ID = config[0]['id']
        if config[0]['name'] is not None: NAME = config[0]['name']
        if config[0]['ip'] is not None: TCP_IP = config[0]['ip']
        if config[0]['port'] is not None: TCP_PORT = config[0]['port']
        if config[0]['status'] is not None: STATUS = config[0]['status']
        return config[0]
    return {
        "error":
        "Loading table [" + RF_MATRIX_TABLE_NAME + "] with ID [" + str(rid) +
        "] Failed"
    }
Beispiel #5
0
def resetMXA(name=None, db_path=None, daemon=False):
    if name:
        mxaList = sql.getSQLite(
            'SELECT * FROM rf_matrix_db WHERE output_device = "' + name + '"',
            db_path=db_path)
    else:
        mxaList = sql.getSQLite(
            'SELECT * FROM rf_matrix_db WHERE output_device = "' + NAME + '"',
            db_path=db_path)
    for mxa in mxaList:
        if mxa['jfw_id'] and mxa['jfw_port']:
            jfw.loadSQLite(str(mxa['jfw_id']), db_path=db_path)
            jfw.connectJFW('SAR' + str(mxa['jfw_port']) + ' 127')
        else:
            rf_matrix_box = sql.getSQLite('SELECT * FROM rf_matrix WHERE id=' +
                                          str(mxa['rf_matrix_id']),
                                          db_path=db_path)[0]
            rf_matrix.loadSQLite(str(rf_matrix_box['id']), db_path=db_path)
            if 'QRB' in rf_matrix_box['name']:
                rf_matrix.resetQRBAtten(portB=mxa['port'], daemon=daemon)
            elif 'RFM' in rf_matrix_box['name']:
                jfw.connectJFW('SAR' + str(JFW_PORT) + ' 127')
    return mxaList