Commit 99782c4d authored by Waleed Akbar's avatar Waleed Akbar
Browse files

feat: Enhance error handling and logging in SIMAP network configuration

parent fdce401e
Loading
Loading
Loading
Loading
+91 −70
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ def set_simap_network(simap_client: SimapClient, network_id: str,
    """

    if network_id == 'e2e':
        try:
            # E2E Network Configuration
            simap = simap_client.network('e2e')
            simap.update(supporting_network_ids=['admin', 'agg'])
@@ -65,8 +66,15 @@ def set_simap_network(simap_client: SimapClient, network_id: str,
                    ('admin', 'L1'), ('admin', 'L3'), ('agg', 'AggNet-L1')
                ]
            )
        except (KeyError, IndexError, ValueError) as e:
            LOGGER.error(f'Error configuring E2E network: {e}')
            return
        except Exception as e:
            LOGGER.error(f'Unexpected error configuring E2E network: {e}')
            return
        
    elif network_id == 'agg':
        try:
            # Aggregation Network Configuration
            simap = simap_client.network('agg')
            simap.update(supporting_network_ids=['admin', 'trans-pkt'])
@@ -92,8 +100,15 @@ def set_simap_network(simap_client: SimapClient, network_id: str,
                    ('trans-pkt', 'Trans-L1'), ('admin', 'L13')
                ]
            )
        except (KeyError, IndexError, ValueError) as e:
            LOGGER.error(f'Error configuring Aggregation network: {e}')
            return
        except Exception as e:
            LOGGER.error(f'Unexpected error configuring Aggregation network: {e}')
            return
        
    elif network_id == 'trans-pkt':
        try:
            # Transport Packet Network Configuration
            simap = simap_client.network('trans-pkt')
            simap.update(supporting_network_ids=['admin'])
@@ -119,6 +134,12 @@ def set_simap_network(simap_client: SimapClient, network_id: str,
                    ('admin', 'L5'), ('admin', 'L9')
                ]
            )
        except (KeyError, IndexError, ValueError) as e:
            LOGGER.error(f'Error configuring Transport Packet network: {e}')
            return
        except Exception as e:
            LOGGER.error(f'Unexpected error configuring Transport Packet network: {e}')
            return
        
    else:
        MSG = 'Unsupported network_id({:s}) to set SIMAP'