888f71c7a4bdb9d4e86c206b44988782fc2fa18b
[bottlenecks.git] / vstf / vstf / controller / env_build / env_collect.py
1 from vstf.rpc_frame_work import rpc_producer
2
3
4 class EnvCollectApi(object):
5     def __init__(self, rb_mq_server):
6         """
7         When use collect, a connection of rabbitmq is needed.
8         """
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
13
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)
17
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)
21
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)
25
26
27 if __name__ == "__main__":
28     conn = rpc_producer.Server("192.168.188.10")
29     c = EnvCollectApi(conn)
30     print c.collect_host_info("local")