1 from vstf.rpc_frame_work import rpc_producer
4 class EnvCollectApi(object):
5 def __init__(self, rb_mq_server):
7 When use collect, a connection of rabbitmq is needed.
9 super(EnvCollectApi, self).__init__()
10 if rb_mq_server is None:
11 raise Exception("The connection of rabbitmq is None.")
12 self.conn = rb_mq_server
14 def collect_host_info(self, host):
15 msg = self.conn.make_msg("collect_host_info")
16 return self.conn.call(msg, host, timeout=2)
18 def get_device_detail(self, host, nic_identity):
19 msg = self.conn.make_msg("get_device_detail", identity=nic_identity)
20 return self.conn.call(msg, host, timeout=2)
22 def list_nic_devices(self, host):
23 msg = self.conn.make_msg("list_nic_devices")
24 return self.conn.call(msg, host, timeout=2)
27 if __name__ == "__main__":
28 conn = rpc_producer.Server("192.168.188.10")
29 c = EnvCollectApi(conn)
30 print c.collect_host_info("local")