Init the test directory with CSIT_Test tool code.
[integration/test.git] / test / tools / CSIT_Test / base / cases / container_manager.py
1 """
2 CSIT test tools.
3 Authors: Baohua Yang@IBM, Denghui Huang@IBM
4 Updated: 2013-11-01
5 """
6
7 import sys
8
9 sys.path.append('..')
10 from restlib import *
11 from testmodule import TestModule
12
13 sys.path.remove('..')
14
15
16 class ContainerManager(TestModule):
17     """
18     Test for the container manager.
19     Start 2-layer tree topology network. e.g., in Mininet, run  'sudo mn --controller=remote,ip=127.0.0.1 --mac --topo tree,2'
20     """
21
22     def __init__(self, restSubContext='/controller/nb/v2/containermanager', user=DEFAULT_USER, password=DEFAULT_PWD,
23                  container=None, contentType='json', prefix=DEFAULT_PREFIX):
24         super(self.__class__, self).__init__(restSubContext, user, password, container, contentType, prefix)
25
26     def get_containers(self):
27         """
28         The name is suggested to match the NB API.
29         Show the containers
30         """
31         return super(self.__class__, self).get_entries('containers')
32
33     def add_container(self, name, body):
34         """
35         Add a container
36         """
37         self.container = 'container'
38         super(self.__class__, self).add_entry('containermanager', name, body)
39
40     def remove_container(self, name):
41         """
42         Remove a container
43         """
44         self.container = 'container'
45         super(self.__class__, self).remove_entry('containermanager', name)
46
47     def test_container_operations(self, name, body):
48         """
49         Test subnet operations, like adding and removeing a subnet.
50         >>> ContainerManager().test_container_operations('cont1',{'container':'cont1','flowSpecs': [], 'staticVlan':'10','nodeConnectors':["OF|1@OF|00:00:00:00:00:00:00:01","OF|23@OF|00:00:00:00:00:00:20:21"]})
51         True
52         """
53         return super(self.__class__, self).test_add_remove_operations('containers', 'container', name, body,
54                                                                       'container-config')