def vcenter(vcenter_name): """ vcenter """ try: a = Action(v_server=get_config(vcenter_name, 'ip'), v_user=get_config(vcenter_name, 'user'), v_passwd=get_config(vcenter_name, 'password')) a.v_check_login() return jsonify({'status': 'success'}) except Exception: return jsonify({ 'status': "error connecting to VCenter {name}".format(name=vcenter_name) })
def datacenter(vcenter_name): """ datacenter """ try: a = Action(v_server=get_config(vcenter_name, 'ip'), v_user=get_config(vcenter_name, 'user'), v_passwd=get_config(vcenter_name, 'password')) ret = json.dumps(a.v_get_datacenter()) resp = app.response_class(response=ret, status=200, mimetype="application/json") return resp except Exception: return jsonify({ 'status': 'error extracting datacenter for VCenter {name}'.format( name=vcenter_name) })
def vdportgroup(vcenter_name, vdswitch_name, datacenter_name): """ vdportgroup """ try: oformat = request.args.get('format', default='full', type=str) a = Action(v_server=get_config(vcenter_name, 'ip'), v_user=get_config(vcenter_name, 'user'), v_passwd=get_config(vcenter_name, 'password')) ret = json.dumps(a.v_get_vdportgroup(datacenter_name, vdswitch_name)) resp = app.response_class(response=ret, status=200, mimetype="application/json") return resp except Exception: return jsonify({ 'status': "error extracting vdportgroup for VCenter {vcenter_name} and Datacenter \ {datacenter_name}".format(vcenter_name=vcenter_name, datacenter_name=datacenter_name) })
def cluster(vcenter_name, datacenter_name): """ cluster """ try: oformat = request.args.get('format', default='full', type=str) a = Action(v_server=get_config(vcenter_name, 'ip'), v_user=get_config(vcenter_name, 'user'), v_passwd=get_config(vcenter_name, 'password')) if oformat == 'full': return jsonify(a.v_get_cluster(datacenter_name)) ret = json.dumps( a.v_get_cluster(datacenter_name)[datacenter_name].keys()) resp = app.response_class(response=ret, status=200, mimetype="application/json") return resp except Exception: return jsonify({ 'status': "error extracting datastore for VCenter {vcenter_name} and Datacenter \ {datacenter_name}".format(vcenter_name=vcenter_name, datacenter_name=datacenter_name) })
def handle_message(sender_psid, received_message): resp = {} user = User.query.filter_by(_id=int(sender_psid)).first() print(user.prev_action) if 'text' in received_message: intent = act_man.get_intent(received_message['text']) print(intent) action = act_man.next_action(user, intent) user.prev_action = action db.session.commit() resp = Action.get_response(user) callSendAPI(sender_psid, resp)
import os from actions_toolkit import core from app import log from app.action import Action os.environ[ 'INPUT_WEBHOOK'] = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=01a56312-d0cb-dffx-8f15-8821d8f3a9e2' os.environ['INPUT_COUNT'] = '10' try: hook = core.get_input('webhook', required=True) secret = core.get_input('secret') count = int(core.get_input('count') or 8) action = Action(hook, secret, count) action.run() except Exception as e: log.set_failed(str(e))
from actions_toolkit import core from app.action import Action if __name__ == '__main__': username = core.get_input('gitee-username') password = core.get_input('gitee-password') repo = core.get_input('gitee-repo') branch = core.get_input('branch', required=False) directory = core.get_input('directory', required=False) https = core.get_input('https', required=False) action = Action(username, password, repo, branch, directory, https) try: action.run() core.info('Rebuild Gitee Pages successfully.') except Exception as e: core.set_failed(str(e))
from app.action import Action username = '******' password = '******' repo = 'doocs/advanced-java' branch = 'main' action = Action(username, password, repo, branch) action.run()
from actions_toolkit import core from app.action import Action if __name__ == '__main__': input_hook = core.get_input('webhook') input_secret = core.get_input('secret', required=False) count_str = core.get_input('count') input_count = int(count_str) if count_str else 8 action = Action(input_hook, input_secret, input_count) try: action.run() core.info('V2EX Action Run Successfully.') except Exception as e: core.set_failed(str(e))