def onMessage(client, server, message): messageString = str(message.payload) print "MQTT message received:" print messageString response = server.request(messageString) clientName = decodeJSON(response)['to'] publishTopic = clientName client.publish(publishTopic, response) print "MQTT message sent:" print response
# print " Response:", hostTCPResponse print "All hosts added to list." print print "Running benchmark:" for hostName in hostNames: print " Running 'ppserver.py' on", hostName, "..." host = virtualNetwork.get(hostName) host.popen("python ppserver.py -d -a -b " + localIp + " -w 1") print "Getting list of hosts ..." hostRequestJSON = encodeJSON({"from": "root", "command": "getVirtualHosts"}) hostRequestCommand = TCP_REQUEST_COMMAND + "'" + hostRequestJSON + "'" hostResponse = rootNode.cmd(hostRequestCommand).strip() hostList = decodeJSON(hostResponse)["virtualHosts"] print 'hostList:', hostList numberOfAvailableHosts = 0 hostIpAddresses = [] for host in hostList: if host['available']: numberOfAvailableHosts += 1 hostIpAddresses.append(host['ip']) print " Running benchmark on root node ..." jobServer = rootNode popens = {} jobServerCommand = JOB_SERVER_COMMAND + str(numberOfAvailableHosts) + " " for ipAddress in hostIpAddresses: jobServerCommand += ipAddress + " "
tmp += f'[\'{q}\']' if eval(f'type(ret{last}) == dict and not \'{q}\' in ret{last}.keys()' ): exec(f'r{tmp}=' + '{}', {'r': ret}) last = tmp exec(f'ret{tmp} = v', {'ret': ret, 'v': v}) else: ret[k] = v return ret # VALIDACION if len(argv) >= 1: fileConfName = f'./conf/{argv[0].lower()}.json'.replace('//', '/') if path.isfile(fileConfName): conf = decodeJSON(open(fileConfName, encoding='utf8').read()) invalidValues = [ z[0] for z in filter(lambda x: x[1] is None, conf.items()) ] entvars = { z[0]: z[1] if not z[1].isnumeric() else int(z[1]) for z in [x.split('=') for x in filter(lambda q: '=' in q, argv[1:])] } conf = {**conf, **entvars} conf = dictDeconstruction({ k: v if type(v) != str else setEnv(v) for k, v in safeComplexity(conf).items() }) if len(invalidValues) > 0: print(