示例#1
0
def connect_local_cbapi():
    from cb.utils import Config
    from cb.utils.db import db_session_context
    from cb.db.core_models import User

    cfg = Config()
    cfg.load('/etc/cb/cb.conf')
    db_session_context = db_session_context(cfg)
    db_session = db_session_context.get()

    user = db_session.query(User).filter(User.global_admin == True).first()
    api_token = user.auth_token
    db_session_context.finish()

    port = cfg.NginxWebApiHttpPort
    return cbapi.CbApi('https://{0:s}:{1:d}/'.format('127.0.0.1', port), token=api_token, ssl_verify=False)
示例#2
0
def connect_local_cbapi():
    from cb.utils import Config
    from cb.utils.db import db_session_context
    from cb.db.core_models import User

    cfg = Config()
    cfg.load('/etc/cb/cb.conf')
    db_session_context = db_session_context(cfg)
    db_session = db_session_context.get()

    user = db_session.query(User).filter(User.global_admin == True).first()
    api_token = user.auth_token
    db_session_context.finish()

    port = cfg.NginxWebApiHttpPort
    return cbapi.CbApi('https://{0:s}:{1:d}/'.format('127.0.0.1', port),
                       token=api_token,
                       ssl_verify=False)