def __init__(self): prpcrypt_key = prpcrypt(current_app.config['PRPCRYPTO_KEY']) api_info = ApiMg.query.filter_by(app_name='zabbixapi').all() for each_info in api_info: # 连接用户 self.__user = each_info.to_json()['api_user'] # 连接密码 self.__password = prpcrypt_key.decrypt(each_info.to_json()['api_paas']) # 连接url self.__url = each_info.to_json()["api_url"] print '初始化完成'
def __init__(self): """获取saltapi连接所需的账户密码及url""" prpcrypt_key = prpcrypt( current_app.config.get('PRPCRYPTO_KEY')) # 调用crypto 解密 api_info = ApiMg.query.filter_by(app_name="saltstackapi").all() for each_info in api_info: # 连接用户 self.__user = each_info.to_json()['api_user'] # 连接密码 self.__password = prpcrypt_key.decrypt( each_info.to_json()['api_paas']) # 连接url self.__url = each_info.to_json()["api_url"] # 连接ID self.__token_id = self.get_saltapi_token()
def __init__(self,app_name): ''' @note 获取saltapi连接所需的账户密码及url @app_name代表saltapi所应用的场景,例如有两套satl环境时 ''' prpcrypt_key = prpcrypt(current_app.config.get('PRPCRYPTO_KEY')) # 调用crypto 解密 api_info = ApiMg.query.filter_by(app_name=app_name).all() for each_info in api_info: # 连接用户 self.__user = each_info.to_json()['api_user'] # 连接密码 self.__password = prpcrypt_key.decrypt(each_info.to_json()['api_paas']) # 连接url self.__salt_url = each_info.to_json()["api_url"] # 连接ID self.__token_id = self.get_saltapi_token(app_name)
def __init__(self, app_name): ''' @note 获取saltapi连接所需的账户密码及url @app_name代表saltapi所应用的场景,例如有两套satl环境时 ''' prpcrypt_key = prpcrypt( current_app.config.get('PRPCRYPTO_KEY')) # 调用crypto 解密 api_info = ApiMg.query.filter_by(app_name=app_name).all() for each_info in api_info: # 连接用户 self.__user = each_info.to_json()['api_user'] # 连接密码 self.__password = prpcrypt_key.decrypt( each_info.to_json()['api_paas']) # 连接url self.__salt_url = each_info.to_json()["api_url"] # 连接ID self.__token_id = self.get_saltapi_token(app_name)
def api_manager(): """对接第三方API管理函数""" form = ApiForm() if form.validate_on_submit(): apiinfo = ApiMg(app_name=form.app_name.data, api_user=form.api_user.data, api_paas=form.api_paas.data, api_url=form.api_url.data) try: # 加密api密码 prpcrypt_key = prpcrypt(current_app.config.get('PRPCRYPTO_KEY')) apiinfo.api_paas = prpcrypt_key.encrypt(form.api_paas.data) db.session.add(apiinfo) db.session.commit() flash('添加Api信息成功', 'success') except Exception, e: db.session.rollback() print e flash('添加Api信息错误 %s' % e, 'danger')
def api_manager(): ''' @note: 对接第三方API管理函数 ''' form = ApiForm() #i#f form.validate_on_submit(): if form.validate_on_submit(): apiinfo = ApiMg(app_name=form.app_name.data, api_user=form.api_user.data, api_paas=form.api_paas.data, api_url=form.api_url.data) try: # 加密api密码 prpcrypt_key = prpcrypt(current_app.config.get('PRPCRYPTO_KEY')) apiinfo.api_paas = prpcrypt_key.encrypt(form.api_paas.data) db.session.add(apiinfo) db.session.commit() flash('添加Api信息成功','success') except Exception,e: db.session.rollback() print e flash('添加Api信息错误','danger')