cocluto v1.0.42 - added network ports naming convention

- netmap now checks that the port ids name follow the convention that was decided with judasilva yesterday

 needed to decommission r630[abc] for [https://bugzilla.ipr.univ-rennes.fr/show_bug.cgi?id=4466]
This commit is contained in:
Guillaume Raffy 2026-09-09 14:28:51 +02:00
parent 8caac5a4c8
commit 5cd59542fb
2 changed files with 21 additions and 5 deletions

View File

@ -193,13 +193,29 @@ class NetConfig(object):
# print row
# eg ('r630a', 's3p2', 'sfp+', '10g', 'a0:36:9F:90:E1:12', 0, 0, 0, 0, '', 'normal', 'NIC Slot 3: Intel(R) 10G 2P X520 Adapter - port 2 enp4s0f1'),
(machine_name, port_id, connector_type, bandwidth_as_str, mac_address, port_id, port_type, comment) = row
# handle port ranges such as p1-8
match = re.match(r'^p(?P<min_port_index>[0-9]+)-(?P<max_port_index>[0-9]+)$', port_id)
# handle port ranges such as 1-8 (for switches)
match = re.match(r'^(?P<min_port_index>[0-9]+)-(?P<max_port_index>[0-9]+)$', port_id)
if match:
ports_ids = [ f'p{port_index}' for port_index in range(int(match['min_port_index']), int(match['max_port_index'])+1)]
ports_ids = [ f'{port_index}' for port_index in range(int(match['min_port_index']), int(match['max_port_index'])+1)]
logging.debug('ports_ids: %s', str(ports_ids))
else:
assert port_id.find('-') == -1, f'port id ({port_id}) contains the invalid "-" character, which is reserved for port ranges in the form "p<from>-<to>" '
if port_id != '':
valid_port_ids = {
'oob': 'out of band'
}
if port_id not in valid_port_ids.keys():
match = re.match(r'(?P<port_type>[a-z]+)[0-9]+', port_id)
assert match, f'unexpected port id {port_id} for {machine_name}.{port_id} (it is expected to be of the form <port-type><port-number>)'
valid_port_types = {
'r': 'rj45',
's': 'sfp+',
'q': 'qsfp+',
'up': 'uplink',
}
assert match['port_type'] in valid_port_types.keys(), f'invalid port type for {machine_name}.{port_id}: valid port types: {valid_port_types}'
ports_ids = [port_id]
for pid in ports_ids:
to_port_as_str = f'{machine_name}.{pid}'
@ -211,7 +227,7 @@ class NetConfig(object):
'25g': 25.0e9,
'40g': 40.0e9,
}[bandwidth_as_str]
logging.debug('bandwidth of port %s: %f gbit/s', to_port, bandwidth)
logging.debug('bandwidth of port %s: %d bit/s', to_port, int(bandwidth))
to_port.set_bandwidth(bandwidth)
for machine in self.machines.values():

View File

@ -1,4 +1,4 @@
__version__ = '1.0.41'
__version__ = '1.0.42'
class Version(object):