rubbos installation guide
[bottlenecks.git] / vstf / vstf / agent / unittest / env / test_vs_plugin_manager.py
1 """
2 Created on 2015-9-24
3
4 @author: y00228926
5 """
6 import unittest
7
8 from vstf.agent.unittest.env import model
9 from vstf.agent.env.vswitch_plugins import manager
10 from vstf.common.utils import check_call
11
12
13 class TestVsPlugins(model.Test):
14     def setUp(self):
15         super(TestVsPlugins, self).setUp()
16         self.cfg = {
17             "type": "ovs",
18             "name": "ovs1",
19             "uplinks": [
20                 {
21                     "bdf": self.bdf_of_eth[0],
22                     "vlan_mode": "trunk",
23                     "vlan_id": "100,200,300,400"
24                 },
25                 {
26                     "bdf": self.bdf_of_eth[1],
27                     "vlan_mode": "trunk",
28                     "vlan_id": "100,200,300,400"
29                 }
30             ],
31             "vtep": {}
32         }
33         self.mgr = manager.VswitchPluginManager()
34
35     def tearDown(self):
36         super(TestVsPlugins, self).tearDown()
37
38     def _check_br_exists(self, name):
39         try:
40             check_call('ifconfig %s' % name, shell=True)
41         except Exception, e:
42             return False
43         return True
44
45     def test_create_bridge(self):
46         self.cfg['name'] = 'br1'
47         self.br = self.mgr.get_vs_plugin('bridge')
48         self.br.clean()
49         self.br.init()
50         self.br.create_br(self.cfg)
51         self.assertTrue(self._check_br_exists('br1'))
52         self.br.clean()
53         self.assertFalse(self._check_br_exists('br1'))
54
55     def test_clean(self):
56         self.mgr.clean()
57
58     def test_get_supported_plugins(self):
59         ret = self.mgr.get_supported_plugins()
60         self.assertEqual(set(ret), {'bridge',  'ovs'})
61
62
63 if __name__ == "__main__":
64     import logging
65
66     logging.basicConfig(level=logging.INFO)
67     LOG = logging.getLogger(__name__)
68     unittest.main()