1 ##############################################################################
2 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 from vstf.rpc_frame_work import rpc_producer
13 class EnvCollectApi(object):
15 def __init__(self, rb_mq_server):
17 When use collect, a connection of rabbitmq is needed.
19 super(EnvCollectApi, self).__init__()
20 if rb_mq_server is None:
21 raise Exception("The connection of rabbitmq is None.")
22 self.conn = rb_mq_server
24 def collect_host_info(self, host):
25 msg = self.conn.make_msg("collect_host_info")
26 return self.conn.call(msg, host, timeout=2)
28 def get_device_detail(self, host, nic_identity):
29 msg = self.conn.make_msg("get_device_detail", identity=nic_identity)
30 return self.conn.call(msg, host, timeout=2)
32 def list_nic_devices(self, host):
33 msg = self.conn.make_msg("list_nic_devices")
34 return self.conn.call(msg, host, timeout=2)
37 if __name__ == "__main__":
38 conn = rpc_producer.Server("192.168.188.10")
39 c = EnvCollectApi(conn)
40 print c.collect_host_info("local")