Repository navigation
Expand file tree
/
Copy pathtransform.cue
More file actions
132 lines (126 loc) · 2.88 KB
/
Copy pathtransform.cue
File metadata and controls
132 lines (126 loc) · 2.88 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package main
import (
nvidia "github.com/networkop/cue-networking-II/schemas/nvidia:schema"
arista "github.com/networkop/cue-networking-II/schemas/arista:schema"
"strings"
)
// Transforming hostvars into structred device configs
config: {
for host, vars in hostvars {
(host): {
if vars.device_type.manufacturer.name == "NVIDIA1" {
nvidiaX & {_input: vars}
}
if vars.device_type.manufacturer.name == "Arista1" {
aristaX & {_input: vars}
}
}
}
}
// nvidia-specific transformations
nvidiaX: {
_input: {}
nvidia.#set & {
interface: {
for _, intf in _input.interfaces {
if strings.HasPrefix(intf.name, "loopback") {
lo: {
ip: address: (intf.ip_addresses[0].address): {}
type: "loopback"
}
}
}
for _, intf in _input.local_context_data.bgp_intfs {
(intf): type: "swp"
}
}
router: bgp: enable: "on"
vrf: default: router: bgp: {
"address-family": "ipv4-unicast": {
enable: "on"
redistribute: connected: enable: "on"
}
"autonomous-system": _input.local_context_data.bgp_asn
"router-id": _input.routerID
enable: "on"
for _, intf in _input.local_context_data.bgp_intfs {
neighbor: (intf): {
"remote-as": "external"
type: "unnumbered"
}
}
}
}
}
aristaX: {
_input: {}
arista.#config & {
ipv6_unicast_routing: true
ip_routing_ipv6_interfaces: true
for _, intf in _input.interfaces {
if strings.HasPrefix(intf.name, "loopback") {
loopback_interfaces: [{
name: intf.name
ip_address: intf.ip_addresses[0].address
// workarounds for jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'mpls'
mpls: ldp: {}
node_segment: {}
}]
}
}
for _, intf in _input.local_context_data.bgp_intfs {
ethernet_interfaces: [{
name: intf
type: "routed"
ipv6_enable: true
}]
}
peer_filters: [{
name: "PF"
sequence_numbers: [{
sequence: 10
match: "as-range 64512-65535 result accept"
}]
}]
router_bgp: {
peer_groups: [{
name: "PG"
// workarounds for jinja2.exceptions.UndefinedError
remove_private_as: {}
remove_private_as_ingress: {}
allowas_in: {}
rib_in_pre_policy_retain: {}
default_originate: {}
link_bandwidth: {}
}]
router_id: _input.routerID
as: _input.local_context_data.bgp_asn
neighbor_interfaces: [
for _, intf in _input.local_context_data.bgp_intfs {
{
name: intf
peer_group: "PG"
peer_filter: "PF"
}
},
]
address_family_ipv4: {
peer_groups: [{
name: "PG"
activate: true
next_hop: {
address_family_ipv6_originate: true
}
}]
}
redistribute_routes: [{
source_protocol: "connected"
}]
// workarounds for jinja2.exceptions.UndefinedError
distance: {}
maximum_paths: {}
updates: {}
bgp: bestpath: {}
}
}
}