Beispiel #1
0
def _services_action(type):
    requests = []
    if type == "start":
        action = {"object": "device", "action": "restart"}
    elif type == "stop":
        action = {"object": "device", "action": "stop"}
    elif type == "restart":
        pass

    try:
        client = AGENT_CLIENT(AGENT_ADDR, AGENT_PORT)
        res = client.system_action(requests)
    except Exception, e:
        client = AGENT_CLIENT(AGENT_ADDR, AGENT_PORT)
        res = client.system_action(requests)
Beispiel #2
0
def _device_action(type):
    client = AGENT_CLIENT(AGENT_ADDR, AGENT_PORT)
    if type == "reboot":
        action = {"object": "device", "action": "restart"}
    elif type == "shutdown":
        action = {"object": "device", "action": "stop"}
    res = client.system_action(action)
    res_json = json.loads(res)
    if res_json["responseCode"] != 200:
        return ""
    else:
        return u"操作成功"
    pass