Exemplo n.º 1
0
def __sync_from_db():
    _obj = cps_object.CPSObject(module=_KEY, qual='target')
    _l = []
    cps.db_get(_obj.get(), _l)
    for i in _l:
        if not __create_acl_entry(i):
            print('Failed to create ACL entry for ', i)
def _get_node_group_objs():
    # Get all cps/node-group objects
    obj = cps_object.CPSObject(qual="target", module="cps/node-group")
    node_grp_objs = []
    cps.db_get(obj.get(), node_grp_objs)

    node_group_objs = []
    for r in node_grp_objs:
        grp = {}
        grp = cps_convert_attr_data(r)
        node_group_objs.append(grp)

    return node_group_objs
Exemplo n.º 3
0
def __get_db_objs():
    #load the DB entry list
    _db_objs = []
    if cps.db_get(
            cps_object.CPSObject(module=_KEY, qual='target').get(),
            _db_objs) != 0:
        print('DB - Can\'t get list of acl config db entries')

    return _db_objs
def _get_connection_objs():
    # Get all cps/connection-object
    obj = cps_object.CPSObject(qual="observed", module="cps/connection-object")
    res = []
    cps.db_get(obj.get(), res)

    conn_objs = {}
    for r in res:
        conn = {}
        conn = cps_convert_attr_data(r)
        conn_objs.update({
            conn['cps/connection-object/name']: {
                "ip": conn['cps/connection-object/addr'],
                "tunnel": conn['cps/connection-object/tunnel'],
                "timestamp": conn['cps/connection-object/timestamp']
            }
        })

    return conn_objs
def _print_connection_objs(qualifier, mod):
    obj = cps_object.CPSObject(qual=qualifier, module=mod)
    res = []
    cps.db_get(obj.get(), res)
    for r in res:
        print r