Skip to content

Commit deaf3d7

Browse files
committed
Merge branch 'node-mac' into 'master'
updated the build script to allow how the MAC should be levereaged See merge request networkRob/rLab-eos!23
2 parents 020ad75 + 917f594 commit deaf3d7

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

Readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ cv:
8686
infra:
8787
bridge: {MGMT_BRIDGE}
8888
gateway: {MGMT_NETWORK_GATEWAY}
89+
mac_mgmt: {MAC_MGMT}
8990
images:
9091
registry: {LOCATION}
9192
ceos: {ceosimage_tag}
@@ -123,6 +124,7 @@ commands:
123124
- The `PASSWORD` parameter is optional, this is if a bare startup-config is created. It will generate the password for the local user account.
124125
- The `MGMT_BRIDGE` parameter is optional, this is if you wish to attach the cEOS containers Management0 Interface to this network.
125126
- The `MGMT_NETWORK_GATEWAY` parameter is optional, this is if a bare startup-config is created, but should be specified if the `MGMT_BRIDGE` parameter is set.
127+
- The `MAC_MGMT` parameter lets the script know, if the supplied MAC Address for each node should be used for the System ID or Ma0 Interface. (bool) True/False
126128
- The `LOCATION` parameter should be set to `local` as default. Update this to the url of any private/remote registries.
127129
- The `mac` section for each cEOS-lab node needs to be unique, this sets the mgmt interface MAC Address which also sets the system-id.
128130
- The `links` section is used to create a "virtual" patch cable between each node.

build/topo-builder.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,23 @@
3232
)
3333

3434
class CEOS_NODE():
35-
def __init__(self, node_name, node_ip, node_mgmt_mac, node_neighbors, _tag, image):
35+
def __init__(self, node_name, node_ip, mgmt_mac, node_mac, node_neighbors, _tag, image):
3636
self.name = node_name
3737
self.ip = node_ip
3838
self.tag = _tag.lower()
3939
self.image = image
4040
self.ceos_name = self.tag + self.name
4141
self.intfs = {}
42-
self.mgmt_mac = node_mgmt_mac
43-
self.system_mac = generateMac()
4442
self.dev_id = CEOS_MAPPER[self.name]
4543
self.portMappings(node_neighbors)
44+
if mgmt_mac:
45+
self.mgmt_mac = node_mac
46+
self.system_mac = generateMac()
47+
else:
48+
self.mgmt_mac = generateMac()
49+
self.system_mac = node_mac
50+
51+
4652

4753
def portMappings(self, node_neighbors):
4854
"""
@@ -343,7 +349,16 @@ def main(args):
343349
except:
344350
pS("INFO", "New CV schema not formatted correctly")
345351
cv_nodes = False
346-
352+
# Perform check to see if the defined MAC should be used for the System ID or Ma0 Interface
353+
try:
354+
mgmt_mac = topo_yaml['infra']['mac_mgmt']
355+
if mgmt_mac:
356+
pS("INFO", "Device MAC Address will be used for the Ma0 interface")
357+
else:
358+
pS("INFO", "Device MAC Address will be used for the System ID")
359+
except:
360+
mgmt_mac = False
361+
pS("INFO", "Mgmt Mac Parameter not found. Device MAC Address will be used for the System ID")
347362
# Load and Gather network Link information
348363
pS("INFO", "Gathering patch cable lengths and quantities...")
349364
for _link in links:
@@ -405,7 +420,7 @@ def main(args):
405420
except KeyError:
406421
_node_ip = ""
407422
_node_name = list(_node.keys())[0]
408-
CEOS[_node_name] = CEOS_NODE(_node_name, _node_ip, _node['mac'], CEOS_LINKS[_node_name], _tag, ceos_image)
423+
CEOS[_node_name] = CEOS_NODE(_node_name, _node_ip, mgmt_mac, _node['mac'], CEOS_LINKS[_node_name], _tag, ceos_image)
409424
DEVICE_INFO.append(f"# {_node_name} = {CEOS[_node_name].tag}{CEOS[_node_name].dev_id}\n")
410425
# Load Host nodes specific information
411426
if hosts:

examples/topologies/l2.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ infra:
1616
bridge: vmgmt
1717
vrf: MGMT
1818
gateway: 192.168.50.1
19+
mac_mgmt: False
1920
images:
2021
registry: local
2122
ceos: 4.28.0F

examples/topologies/l3.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ infra:
1616
bridge: vmgmt
1717
vrf: MGMT
1818
gateway: 192.168.50.1
19+
mac_mgmt: False
1920
images:
2021
registry: local
2122
ceos: 4.28.0F

0 commit comments

Comments
 (0)