def run(self, input_cmd):
body = input_cmd.split("run \"")[1].split("\" ")[0]
hosts = input_cmd.split("--hosts")[1].strip().split(" ")
for host_ip in hosts:
if self.judge_legal_ip(host_ip): # ??IP??????
'''
self.connections = {
host_ip1:{
'connection': pika.BlockingConnection(),
'channel': Channel1,
'callback_queue': result.method.queue
},
host_ip2:{
'connection': pika.BlockingConnection(),
'channel': Channel2,
'callback_queue': result.method.queue
}
}
'''
print("IP [%s] is Legal ip" % host)
conn_info = {}
conn_info['connection'] = pika.BlockingConnection(
pika.ConnectionParameters(host=host))
conn_info['channel'] = conn_info['connection'].channel(
)
result = self.channel.queue_declare(exclusive=True)
conn_info['callback_queue'] = result.method.queue
conn_info['channel'].basic_consume(
self.on_response, no_ack=True, queue=conn_info['callback_queue'])
conn_info['response'] = None
self.connections[host_ip] = conn_info
else:
print("IP [%s] is Illegal ip" % host_ip)
评论列表
文章目录