2.0 beta NFVBENCH-91 Allow multi-chaining with separate edge networks
[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     NO_ENCAPS = "NONE"
21
22     encaps_mapping = {
23         'VLAN': VLAN,
24         'VXLAN': VxLAN,
25         'NONE': NO_ENCAPS
26     }
27
28     @classmethod
29     def get(cls, network_type):
30         return cls.encaps_mapping.get(network_type.upper(), None)
31
32
33 class ChainType(object):
34     PVP = "PVP"
35     PVVP = "PVVP"
36     EXT = "EXT"
37     names = [EXT, PVP, PVVP]
38
39
40 class OpenStackSpec(object):
41     def __init__(self):
42         self.__vswitch = "BASIC"
43         self.__encaps = Encaps.NO_ENCAPS
44
45     @property
46     def vswitch(self):
47         return self.__vswitch
48
49     @vswitch.setter
50     def vswitch(self, vsw):
51         if vsw is None:
52             raise Exception('Trying to set vSwitch as None.')
53
54         self.__vswitch = vsw.upper()
55
56     @property
57     def encaps(self):
58         return self.__encaps
59
60     @encaps.setter
61     def encaps(self, enc):
62         if enc is None:
63             raise Exception('Trying to set Encaps as None.')
64
65         self.__encaps = enc
66
67
68 class RunSpec(object):
69     def __init__(self, no_vswitch_access, openstack_spec):
70         self.use_vswitch = (not no_vswitch_access) and openstack_spec \
71             and openstack_spec.vswitch != "BASIC"
72
73
74 class Specs(object):
75     def __init__(self):
76         self.openstack = None
77         self.run_spec = None
78
79     def set_openstack_spec(self, openstack_spec):
80         self.openstack = openstack_spec
81
82     def set_run_spec(self, run_spec):
83         self.run_spec = run_spec