Esempio n. 1
0
def runXmppAsyncCommand(cmd, infomachine):
    sessionid = name_random(8, "quick_")
    cmd = cmd.strip()
    if cmd.startswith("plugin_"):
        # call plugin master
        lineplugincalling = [x.strip() for x in cmd.split("@_@")]
        plugincalling = lineplugincalling[0]
        del lineplugincalling[0]
        action = plugincalling.strip().split("_")
        action.pop(0)
        action = "_".join(action)
        data = {
            "action": action,
            "sessionid": sessionid,
            "data": [infomachine['jid'], infomachine, lineplugincalling]
        }
        XmppMasterDatabase().setCommand_action(
            infomachine['uuid_inventorymachine'], infomachine['cmdid'],
            sessionid, "call plugin %s for Quick Action" % (action), "log")
        callXmppPlugin(action, data)
    else:
        data = {
            "action": "asynchroremoteQA",
            "sessionid": sessionid,
            "data": infomachine,
            "base64": False
        }
        callXmppPlugin("asynchroremoteQA", data)
Esempio n. 2
0
def runXmppCommand(cmd, machine, information=""):
    data = {
        "action": "cmd",
        "sessionid": name_random(8, "quick_"),
        "data": [machine, information],
        "base64": False
    }
    cmd = cmd.strip()
    if cmd.startswith("plugin_"):
        # call plugin master
        lineplugincalling = [x.strip() for x in cmd.split("@_@")]
        plugincalling = lineplugincalling[0]
        del lineplugincalling[0]
        action = plugincalling.strip().split("_")[1]
        data = {
            "action": action,
            "sessionid": name_random(8, "quick_"),
            "data": [machine, information, lineplugincalling],
            "base64": False
        }
        callXmppPlugin(action, data)
        return {
            u'action': u'resultshellcommand',
            u'sessionid': u'mcc_221n4h6h',
            u'base64': False,
            u'data': {
                'result':
                'call plugin : %s to machine : %s' % (action, machine)
            },
            u'ret': 0
        }
    else:
        data = {
            "action": "shellcommand",
            "sessionid": name_random(8, "mcc_"),
            "data": {
                'cmd': cmd
            },
            "base64": False
        }
        a = XmppSimpleCommand(machine, data, 70)
        d = a.t2.join()
        print type(a.result)
    return a.result
Esempio n. 3
0
def CallXmppPlugin(*args, **kwargs):
    return callXmppPlugin(*args, **kwargs)