Example #1
0
def get_user_batch_env(user_id, batch_id):
    dbopr = Dboperator().getInstance(db_config=test_db)
    records = dbopr.getAll(
        "select `key`, `value` from envirnment where creater=%s and (batch_id=%s or batch_id=0) order by batch_id asc",
        param=(user_id, batch_id))
    result = {}
    for item in records:
        result[item["key"]] = item["value"]
    return result
Example #2
0
def getInterByGroup(id=None, alias=None):
    condtions = []
    params = []
    if id:
        condtions.append(" ig.id=%s ")
        params.append(id)
    if alias:
        condtions.append(" ig.alias=%s ")
        params.append(alias)
    dbopr = Dboperator().getInstance(db_config=test_db)
    return dbopr.getAll(
        '''select gim.id parent_id, ibi.* from interface_group_info ig
                        inner join group_interface_mapping gim on ig.id=gim.group_id
                        inner join interface_info ibi on gim.interface_id=ibi.id
                        where %s order by `order` ''' %
        " and ".join(condtions), params)
Example #3
0
def getAllInterfaceInfos():
    dbopr = Dboperator().getInstance(db_config=test_db)
    return dbopr.getAll(''' select * from interface_info where status=1 ''')
Example #4
0
def getInterByBatch(id):
    dbopr = Dboperator().getInstance(db_config=test_db)
    return dbopr.getAll(
        ''' select * from batch_interface_mapping where batch_id=%s order by `order` ''',
        id)
Example #5
0
def get_plugins(batch_id):
    dbopr = Dboperator().getInstance(db_config=test_db)
    records = dbopr.getAll(
        "select pi.* from batch_plugins_mapping bpm inner join plugin_info pi on bpm.plugin_id=pi.id where bpm.batch_id=%s order by pi.`order`;",
        param=(batch_id, ))
    return records