Skip to content

Commit

Permalink
Merge branch 'node-mac' into 'master'
Browse files Browse the repository at this point in the history
updated the build script to allow how the MAC should be levereaged

See merge request networkRob/rLab-eos!23
  • Loading branch information
networkRob committed Mar 15, 2023
2 parents 020ad75 + 917f594 commit deaf3d7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ cv:
infra:
bridge: {MGMT_BRIDGE}
gateway: {MGMT_NETWORK_GATEWAY}
mac_mgmt: {MAC_MGMT}
images:
registry: {LOCATION}
ceos: {ceosimage_tag}
Expand Down Expand Up @@ -123,6 +124,7 @@ commands:
- The `PASSWORD` parameter is optional, this is if a bare startup-config is created. It will generate the password for the local user account.
- The `MGMT_BRIDGE` parameter is optional, this is if you wish to attach the cEOS containers Management0 Interface to this network.
- 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.
- 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
- The `LOCATION` parameter should be set to `local` as default. Update this to the url of any private/remote registries.
- 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.
- The `links` section is used to create a "virtual" patch cable between each node.
Expand Down
25 changes: 20 additions & 5 deletions build/topo-builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,23 @@
)

class CEOS_NODE():
def __init__(self, node_name, node_ip, node_mgmt_mac, node_neighbors, _tag, image):
def __init__(self, node_name, node_ip, mgmt_mac, node_mac, node_neighbors, _tag, image):
self.name = node_name
self.ip = node_ip
self.tag = _tag.lower()
self.image = image
self.ceos_name = self.tag + self.name
self.intfs = {}
self.mgmt_mac = node_mgmt_mac
self.system_mac = generateMac()
self.dev_id = CEOS_MAPPER[self.name]
self.portMappings(node_neighbors)
if mgmt_mac:
self.mgmt_mac = node_mac
self.system_mac = generateMac()
else:
self.mgmt_mac = generateMac()
self.system_mac = node_mac



def portMappings(self, node_neighbors):
"""
Expand Down Expand Up @@ -343,7 +349,16 @@ def main(args):
except:
pS("INFO", "New CV schema not formatted correctly")
cv_nodes = False

# Perform check to see if the defined MAC should be used for the System ID or Ma0 Interface
try:
mgmt_mac = topo_yaml['infra']['mac_mgmt']
if mgmt_mac:
pS("INFO", "Device MAC Address will be used for the Ma0 interface")
else:
pS("INFO", "Device MAC Address will be used for the System ID")
except:
mgmt_mac = False
pS("INFO", "Mgmt Mac Parameter not found. Device MAC Address will be used for the System ID")
# Load and Gather network Link information
pS("INFO", "Gathering patch cable lengths and quantities...")
for _link in links:
Expand Down Expand Up @@ -405,7 +420,7 @@ def main(args):
except KeyError:
_node_ip = ""
_node_name = list(_node.keys())[0]
CEOS[_node_name] = CEOS_NODE(_node_name, _node_ip, _node['mac'], CEOS_LINKS[_node_name], _tag, ceos_image)
CEOS[_node_name] = CEOS_NODE(_node_name, _node_ip, mgmt_mac, _node['mac'], CEOS_LINKS[_node_name], _tag, ceos_image)
DEVICE_INFO.append(f"# {_node_name} = {CEOS[_node_name].tag}{CEOS[_node_name].dev_id}\n")
# Load Host nodes specific information
if hosts:
Expand Down
1 change: 1 addition & 0 deletions examples/topologies/l2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ infra:
bridge: vmgmt
vrf: MGMT
gateway: 192.168.50.1
mac_mgmt: False
images:
registry: local
ceos: 4.28.0F
Expand Down
1 change: 1 addition & 0 deletions examples/topologies/l3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ infra:
bridge: vmgmt
vrf: MGMT
gateway: 192.168.50.1
mac_mgmt: False
images:
registry: local
ceos: 4.28.0F
Expand Down

0 comments on commit deaf3d7

Please sign in to comment.