MPLS support + loop_vm_arp test fix
[nfvbench.git] / nfvbench / specs.py
1 # Copyright 2016 Cisco Systems, Inc.  All rights reserved.
2 #
3 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
4 #    not use this file except in compliance with the License. You may obtain
5 #    a copy of the License at
6 #
7 #         http://www.apache.org/licenses/LICENSE-2.0
8 #
9 #    Unless required by applicable law or agreed to in writing, software
10 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 #    License for the specific language governing permissions and limitations
13 #    under the License.
14 #
15
16
17 class Encaps(object):
18     VLAN = "VLAN"
19     VxLAN = "VxLAN"
20     MPLS = "MPLS"
21     NO_ENCAPS = "NONE"
22
23     encaps_mapping = {
24         'VLAN': VLAN,
25         'VXLAN': VxLAN,
26         'MPLS': MPLS,
27         'NONE': NO_ENCAPS
28     }
29
30     @classmethod
31     def get(cls, network_type):
32         return cls.encaps_mapping.get(network_type.upper(), None)
33
34
35 class ChainType(object):
36     PVP = "PVP"
37     PVVP = "PVVP"
38     EXT = "EXT"
39     names = [EXT, PVP, PVVP]
40
41
42 class OpenStackSpec(object):
43     def __init__(self):
44         self.__vswitch = "BASIC"
45         self.__encaps = Encaps.NO_ENCAPS
46
47     @property
48     def vswitch(self):
49         return self.__vswitch
50
51     @vswitch.setter
52     def vswitch(self, vsw):
53         if vsw is None:
54             raise Exception('Trying to set vSwitch as None.')
55
56         self.__vswitch = vsw.upper()
57
58     @property
59     def encaps(self):
60         return self.__encaps
61
62     @encaps.setter
63     def encaps(self, enc):
64         if enc is None:
65             raise Exception('Trying to set Encaps as None.')
66
67         self.__encaps = enc
68
69
70 class RunSpec(object):
71     def __init__(self, no_vswitch_access, openstack_spec):
72         self.use_vswitch = (not no_vswitch_access) and openstack_spec \
73             and openstack_spec.vswitch != "BASIC"
74
75
76 class Specs(object):
77     def __init__(self):
78         self.openstack = None
79         self.run_spec = None
80
81     def set_openstack_spec(self, openstack_spec):
82         self.openstack = openstack_spec
83
84     def set_run_spec(self, run_spec):
85         self.run_spec = run_spec