summaryrefslogtreecommitdiffstats
path: root/vstf/vstf/agent/env/vswitch_plugins/model.py
blob: a4d8b3b5b83c9658b75d8dba7689f63f0eb8197a (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
"""
Created on 2015-9-15

@author: y00228926
"""
from abc import ABCMeta
from abc import abstractmethod


class VswitchPlugin:
    __metaclass__ = ABCMeta

    @abstractmethod
    def clean(self):
        """implement this clean function to clean environment before and after calling any other functions.

        """
        pass

    @abstractmethod
    def init(self):
        """implements this init function to setup necessary Preconditions.

        """
        pass

    @abstractmethod
    def create_br(self, br_cfg):
        """Create a bridge(virtual switch). Return True for success, return False for failure.

        :param dict    br_cfg: configuration for bridge creation like
                {
                    "type": "ovs",
                    "name": "ovs1",
                    "uplinks": [
                        {
                            "bdf": "04:00.0",
                            "vlan_mode": "access",
                            "vlan_id": "1"
                        }
                    ],
                    "vtep": {},
                }

        """
        pass

    @abstractmethod
    def set_tap_vid(self, tap_cfg):
        """set vlan id or vxlan id for tap device(virtual nic for vm).

        :param dict    tap_cfg: dictionary config for tap device like
                        {
                            "tap_name": "tap_in",
                            "vlan_mode": "access",
                            "vlan_id": "1"
                        }

        """
        pass

    def set_fastlink(self, br_cfg):
        return True