コード例 #1
0
def user_entering_idvm(message):
    if opstack.normalize_server_id(message.text) is not None:
        srv_id = opstack.normalize_server_id(message.text)
        state.set_id_vm(message.from_user.id, srv_id)
        answer = opstack.bot_diagnostic(state.get_id_vm(message.from_user.id))
        send_large_msg(message.chat.id, "".join(answer))
        state.set_state(message.from_user.id, config.States.S_start.value)
        logger.info("response diag server")
コード例 #2
0
def user_entering_idvm(message):
    if opstack.normalize_server_id(message.text) is not None:
        srv_id = opstack.normalize_server_id(message.text)
        state.set_id_vm(message.from_user.id, srv_id)
        rez = opstack.bot_reboot_srv(state.get_id_vm(message.from_user.id))
        send_large_msg(message.chat.id, rez)
        state.set_state(message.from_user.id, config.States.S_start.value)
        logger.info("response reboot vm")
コード例 #3
0
def user_entering_idvm(message):
    # send messages in normalazer
    if opstack.normalize_server_id(message.text) is not None:
        # get normalized param
        srv_id = opstack.normalize_server_id(message.text)
        # set state id VM for show command
        state.set_id_vm(message.from_user.id, srv_id)
        # send request in openstack
        rez = opstack.bot_ops_url(state.get_id_vm(message.from_user.id))
        # send answer in function for division into parts
        send_large_msg(message.chat.id, rez)
        # reset user state in start position
        state.set_state(message.from_user.id, config.States.S_start.value)
        # send log about request
        logger.info("response console")
コード例 #4
0
def user_entering_action(message):
    if opstack.normalize_server_id(message.text) is not None:
        srv_id = opstack.normalize_server_id(message.text)
        state.set_id_vm(message.from_user.id, srv_id)
        keyboard = types.InlineKeyboardMarkup(row_width=3)
        callback_button1 = types.InlineKeyboardButton(text="show", callback_data=f"show {message.from_user.id}")
        callback_button2 = types.InlineKeyboardButton(text="console", callback_data=f"console {message.from_user.id}")
        callback_button3 = types.InlineKeyboardButton(text="start", callback_data=f"start {message.from_user.id}")
        callback_button4 = types.InlineKeyboardButton(text="stop", callback_data=f"stop {message.from_user.id}")
        callback_button5 = types.InlineKeyboardButton(text="reboot", callback_data=f"reboot {message.from_user.id}")
        callback_button6 = types.InlineKeyboardButton(text="live migrate", callback_data=f"live_migrate {message.from_user.id}")
        keyboard.add(callback_button1, callback_button2, callback_button3, callback_button4, callback_button5, callback_button6)
        bot.send_message(message.chat.id, "choose action:", reply_markup=keyboard)
        state.set_state(message.from_user.id, config.States.S_start.value)
        logger.info("response keybord action server")
    else:
        bot.send_message(message.chat.id, "Complete previous action or reset active command /cancel")