Fix bug 1030 forcing to wait taskIds
[osm/RO.git] / RO-SDN-arista / osm_rosdn_arista / aristaConfigLet.py
1 # -*- coding: utf-8 -*-
2 ##
3 # Copyright 2019 Atos - CoE Telco NFV Team
4 # All Rights Reserved.
5 #
6 # Contributors: Oscar Luis Peral, Atos
7 #
8 # Licensed under the Apache License, Version 2.0 (the "License"); you may
9 # not use this file except in compliance with the License. You may obtain
10 # a copy of the License at
11 #
12 # http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17 # License for the specific language governing permissions and limitations
18 # under the License.
19 #
20 # For those usages not covered by the Apache License, Version 2.0 please
21 # contact with: <oscarluis.peral@atos.net>
22 #
23 # Neither the name of Atos nor the names of its
24 # contributors may be used to endorse or promote products derived from
25 # this software without specific prior written permission.
26 #
27 # This work has been performed in the context of Arista Telefonica OSM PoC.
28 ##
29
30
31 class AristaSDNConfigLet:
32 _configLet_SRIOV = """
33 interface {interface}
34 !! service: {uuid}
35 switchport
36 switchport mode trunk
37 switchport trunk group {service}{vlan_id}
38 !
39 """
40
41 def _get_sriov(self, uuid, interface, vlan_id, s_type, index):
42 return self._configLet_SRIOV.format(uuid=uuid, interface=interface, service=s_type, vlan_id=vlan_id)
43
44 def getElan_sriov(self, uuid, interface, vlan_id, index):
45 return self._get_sriov(uuid, interface, vlan_id, "ELAN", index)
46
47 def getEline_sriov(self, uuid, interface, vlan_id, index):
48 return self._get_sriov(uuid, interface, vlan_id, "ELINE", index)
49
50 _configLet_PASSTROUGH = """
51 interface {interface}
52 !! service: {uuid}
53 switchport
54 switchport mode access
55 switchport access vlan {vlan_id}
56 !
57 """
58
59 def _get_passthrough(self, uuid, interface, vlan_id, s_type, index):
60 return self._configLet_PASSTROUGH.format(uuid=uuid, interface=interface, vlan_id=vlan_id)
61
62 def getElan_passthrough(self, uuid, interface, vlan_id, index):
63 return self._get_passthrough(uuid, interface, vlan_id, "ELAN", index)
64
65 def getEline_passthrough(self, uuid, interface, vlan_id, index):
66 return self._get_passthrough(uuid, interface, vlan_id, "ELINE", index)
67
68 _configLet_VLAN = """
69 vlan {vlan}
70 !! service: {service} {vlan} {uuid}
71 name {service}{vlan}
72 trunk group {service}{vlan}
73 trunk group MLAGPEER
74
75 interface VXLAN1
76 VXLAN vlan {vlan} vni {vni}
77 !
78 """
79
80 def _get_vlan(self, uuid, vlan_id, vni_id, s_type):
81 return self._configLet_VLAN.format(service=s_type, vlan=vlan_id, uuid=uuid, vni=vni_id)
82
83 def getElan_vlan(self, uuid, vlan_id, vni_id):
84 return self._get_vlan(uuid, vlan_id, vni_id, "ELAN")
85
86 def getEline_vlan(self, uuid, vlan_id, vni_id):
87 return self._get_vlan(uuid, vlan_id, vni_id, "ELINE")
88
89 _configLet_BGP = """
90 router bgp {bgp}
91 vlan {vlan}
92 !! service: {uuid}
93 rd {loopback}:{vni}
94 route-target both {vni}:{vni}
95 redistribute learned
96 !
97 """
98
99 def _get_bgp(self, uuid, vlan_id, vni_id, loopback0, bgp, s_type):
100 return self._configLet_BGP.format(uuid=uuid, bgp=bgp, vlan=vlan_id, loopback=loopback0, vni=vni_id)
101
102 def getElan_bgp(self, uuid, vlan_id, vni_id, loopback0, bgp):
103 return self._get_bgp(uuid, vlan_id, vni_id, loopback0, bgp, "ELAN")
104
105 def getEline_bgp(self, uuid, vlan_id, vni_id, loopback0, bgp):
106 return self._get_bgp(uuid, vlan_id, vni_id, loopback0, bgp, "ELINE")