summaryrefslogtreecommitdiff
path: root/ironic/tests/unit/drivers/modules/network/test_noop.py
blob: be432988e0be21967dc812862267fd1a93d7cfad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

from ironic.conductor import task_manager
from ironic.drivers.modules.network import noop
from ironic.tests.unit.db import base as db_base
from ironic.tests.unit.objects import utils


class NoopInterfaceTestCase(db_base.DbTestCase):

    def setUp(self):
        super(NoopInterfaceTestCase, self).setUp()
        self.interface = noop.NoopNetwork()
        self.node = utils.create_test_node(self.context,
                                           network_interface='noop')
        self.port = utils.create_test_port(
            self.context, node_id=self.node.id, address='52:54:00:cf:2d:32')

    def test_get_properties(self):
        result = self.interface.get_properties()
        self.assertEqual({}, result)

    def test_validate(self):
        with task_manager.acquire(self.context, self.node.id) as task:
            self.interface.validate(task)

    def test_port_changed(self):
        with task_manager.acquire(self.context, self.node.id) as task:
            self.interface.port_changed(task, self.port)

    def test_portgroup_changed(self):
        portgroup = utils.create_test_portgroup(self.context)
        with task_manager.acquire(self.context, self.node.id) as task:
            self.interface.portgroup_changed(task, portgroup)

    def test_vif_attach(self):
        vif = {'id': 'vif-id'}
        with task_manager.acquire(self.context, self.node.id) as task:
            self.interface.vif_attach(task, vif)

    def test_vif_detach(self):
        vif_id = 'vif-id'
        with task_manager.acquire(self.context, self.node.id) as task:
            self.interface.vif_detach(task, vif_id)

    def test_vif_list(self):
        with task_manager.acquire(self.context, self.node.id) as task:
            result = self.interface.vif_list(task)
        self.assertEqual([], result)

    def test_get_current_vif(self):
        with task_manager.acquire(self.context, self.node.id) as task:
            result = self.interface.get_current_vif(task, self.port)
        self.assertIsNone(result)

    def test_add_provisioning_network(self):
        with task_manager.acquire(self.context, self.node.id) as task:
            self.interface.add_provisioning_network(task)

    def test_remove_provisioning_network(self):
        with task_manager.acquire(self.context, self.node.id) as task:
            self.interface.remove_provisioning_network(task)

    def test_configure_tenant_networks(self):
        with task_manager.acquire(self.context, self.node.id) as task:
            self.interface.configure_tenant_networks(task)

    def test_unconfigure_tenant_networks(self):
        with task_manager.acquire(self.context, self.node.id) as task:
            self.interface.unconfigure_tenant_networks(task)

    def test_add_cleaning_network(self):
        with task_manager.acquire(self.context, self.node.id) as task:
            self.interface.add_cleaning_network(task)

    def test_remove_cleaning_network(self):
        with task_manager.acquire(self.context, self.node.id) as task:
            self.interface.remove_cleaning_network(task)

    def test_add_inspection_network(self):
        with task_manager.acquire(self.context, self.node.id) as task:
            self.interface.add_inspection_network(task)

    def test_remove_inspection_network(self):
        with task_manager.acquire(self.context, self.node.id) as task:
            self.interface.remove_inspection_network(task)