diff --git a/cocluto/netmap.py b/cocluto/netmap.py index 6326e41..34d87c6 100644 --- a/cocluto/netmap.py +++ b/cocluto/netmap.py @@ -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[0-9]+)-(?P[0-9]+)$', port_id) + # handle port ranges such as 1-8 (for switches) + match = re.match(r'^(?P[0-9]+)-(?P[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-" ' + if port_id != '': + valid_port_ids = { + 'oob': 'out of band' + } + + if port_id not in valid_port_ids.keys(): + + match = re.match(r'(?P[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 )' + 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(): diff --git a/cocluto/version.py b/cocluto/version.py index c9f8622..2eabfeb 100644 --- a/cocluto/version.py +++ b/cocluto/version.py @@ -1,4 +1,4 @@ -__version__ = '1.0.41' +__version__ = '1.0.42' class Version(object):