blob: 756ff89b5bf9445b5d0b17b5b8dc10cdb2d7e9f5 [file] [log] [blame]
peusterm9c252b62016-01-06 16:59:53 +01001"""
2 For now only a dummy client. Connects to the zerorpc interface of the
3 emulator and performs some actions (start/stop/list).
peusterme4e89d32016-01-07 09:14:54 +01004
5 We will provide a full CLI here later on which looks like:
6
7 cli compute start dc1 my_name flavor_a
8 cli network create dc1 11.0.0.0/24
peusterm9c252b62016-01-06 16:59:53 +01009"""
10import time
peusterm056fd452016-01-12 15:32:25 +010011import pprint
peusterm9c252b62016-01-06 16:59:53 +010012import zerorpc
13
14
15def main():
peusterm056fd452016-01-12 15:32:25 +010016 pp = pprint.PrettyPrinter(indent=4)
peusterm9c252b62016-01-06 16:59:53 +010017 print "Example CLI client"
18 # create connection to remote Mininet instance
19 c = zerorpc.Client()
20 c.connect("tcp://127.0.0.1:4242")
21
22 # do some API tests
peusterme6092692016-01-11 16:32:58 +010023 print c.compute_action_start("dc2", "d1")
peustermc3b977e2016-01-12 10:09:35 +010024 print c.compute_action_start("dc2", "d2")
peusterm9c252b62016-01-06 16:59:53 +010025
peusterm4e98b632016-01-12 14:08:07 +010026 time.sleep(1)
27 print c.compute_list("dc2")
28
29 time.sleep(1)
peusterm056fd452016-01-12 15:32:25 +010030 pp.pprint(c.compute_status("dc2", "d1"))
31 pp.pprint(c.compute_status("dc2", "d2"))
peusterm4e98b632016-01-12 14:08:07 +010032
33 time.sleep(5)
peusterm9c252b62016-01-06 16:59:53 +010034
peusterme6092692016-01-11 16:32:58 +010035 print c.compute_action_stop("dc2", "d1")
peustermc3b977e2016-01-12 10:09:35 +010036 print c.compute_action_stop("dc2", "d2")
peusterm9c252b62016-01-06 16:59:53 +010037
38
39if __name__ == '__main__':
40 main()