rm odltools egg files
[netvirt.git] / resources / tools / odltools / mdsal / tests / test_itm_state.py
1 import unittest
2 from mdsal import itm_state
3 from mdsal.model import Model
4 from mdsal.itm_state import DpnEndpoints
5 from odltools import logg
6
7 ip = "127.0.0.1"
8 port = "8080"
9 path = "./resources"
10 # path = "/tmp/robotjob/s1-t1_Create_VLAN_Network_net_1/models"
11
12
13 class TestItmState(unittest.TestCase):
14     def setUp(self):
15         logg.Logger()
16         self.dpn_endpoints = itm_state.dpn_endpoints(Model.CONFIG, ip, port, path)
17         # self.data = self.dpn_endpoints.read_file("./resources/config_itm-state:dpn-endpoints.json")
18
19     def test_read_file(self):
20         print "dpn-endpoints: {}".format(self.dpn_endpoints.data)
21         print "dpn-endpoints: \n{}".format(self.dpn_endpoints.pretty_format(self.dpn_endpoints.data))
22
23     def test_get_ip_address(self):
24         dpn_ids = self.dpn_endpoints.get_dpn_ids()
25         dpn_id = dpn_ids[0]
26         ip_address = self.dpn_endpoints.get_ip_address(dpn_id)
27         print "dpn_id: {}, ip_address: {}".format(dpn_id, ip_address)
28         self.assertEqual(dpn_id, 13878168265586)
29         self.assertEqual(ip_address, "10.29.13.165")
30
31     def test_get_all(self):
32         print "dpn-endpoints: {}".format(self.dpn_endpoints.data)
33         print "dpn-endpoints: \n{}".format(self.dpn_endpoints.pretty_format(self.dpn_endpoints.data))
34
35         dpn_ids = self.dpn_endpoints.get_dpn_ids()
36         dpn_id = dpn_ids[0]
37         dpn_teps_info = self.dpn_endpoints.get_dpn_teps_info(dpn_id)
38         print "dpn_teps_info for {}: {}".format(dpn_id, dpn_teps_info)
39
40         ip_address = self.dpn_endpoints.get_ip_address(dpn_id)
41         print "ip_address: {}".format(ip_address)
42         self.assertEqual(ip_address, "10.29.13.165")
43
44         self.get_info(DpnEndpoints.CONTAINER)
45         self.get_info(DpnEndpoints.DPN_TEPS_INFO)
46         self.get_info(DpnEndpoints.TUNNEL_END_POINTS)
47         self.get_info(DpnEndpoints.DPN_ID)
48
49     def get_info(self, key):
50         info = self.dpn_endpoints.get_kv(key, self.dpn_endpoints.data, values=[])
51         print "dpn info for {}: {}".format(key, info)
52         return info
53
54 if __name__ == '__main__':
55     unittest.main()