mirror of
				https://github.com/Telecominfraproject/oopt-gnpy.git
				synced 2025-11-04 12:07:48 +00:00 
			
		
		
		
	chore: refactor json_io
Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com> Change-Id: If764ba7b520a060deb855c0b55e17c78fa22f841
This commit is contained in:
		@@ -692,24 +692,27 @@ def requests_from_json(json_data: dict, equipment: dict) -> List[PathRequest]:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    for req in json_data['path-request']:
 | 
					    for req in json_data['path-request']:
 | 
				
			||||||
        # init all params from request
 | 
					        # init all params from request
 | 
				
			||||||
        params = {}
 | 
					        trx_type = req['path-constraints']['te-bandwidth']['trx_type']
 | 
				
			||||||
        params['request_id'] = f'{req["request-id"]}'
 | 
					        trx_mode = req['path-constraints']['te-bandwidth'].get('trx_mode', None)
 | 
				
			||||||
        params['source'] = req['source']
 | 
					        if trx_type is None:
 | 
				
			||||||
        params['bidir'] = req['bidirectional']
 | 
					 | 
				
			||||||
        params['destination'] = req['destination']
 | 
					 | 
				
			||||||
        params['trx_type'] = req['path-constraints']['te-bandwidth']['trx_type']
 | 
					 | 
				
			||||||
        if params['trx_type'] is None:
 | 
					 | 
				
			||||||
            msg = f'Request {req["request-id"]} has no transceiver type defined.'
 | 
					            msg = f'Request {req["request-id"]} has no transceiver type defined.'
 | 
				
			||||||
            raise ServiceError(msg)
 | 
					            raise ServiceError(msg)
 | 
				
			||||||
        params['trx_mode'] = req['path-constraints']['te-bandwidth'].get('trx_mode', None)
 | 
					 | 
				
			||||||
        params['format'] = params['trx_mode']
 | 
					 | 
				
			||||||
        params['spacing'] = req['path-constraints']['te-bandwidth']['spacing']
 | 
					 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            nd_list = sorted(req['explicit-route-objects']['route-object-include-exclude'], key=lambda x: x['index'])
 | 
					            nd_list = sorted(req['explicit-route-objects']['route-object-include-exclude'], key=lambda x: x['index'])
 | 
				
			||||||
        except KeyError:
 | 
					        except KeyError:
 | 
				
			||||||
            nd_list = []
 | 
					            nd_list = []
 | 
				
			||||||
        params['nodes_list'] = [n['num-unnum-hop']['node-id'] for n in nd_list]
 | 
					        params = {
 | 
				
			||||||
        params['loose_list'] = [n['num-unnum-hop']['hop-type'] for n in nd_list]
 | 
					            'request_id': f'{req["request-id"]}',
 | 
				
			||||||
 | 
					            'source': req['source'],
 | 
				
			||||||
 | 
					            'destination': req['destination'],
 | 
				
			||||||
 | 
					            'bidir': req['bidirectional'],
 | 
				
			||||||
 | 
					            'trx_type': trx_type,
 | 
				
			||||||
 | 
					            'trx_mode': trx_mode,
 | 
				
			||||||
 | 
					            'format': trx_mode,
 | 
				
			||||||
 | 
					            'spacing': req['path-constraints']['te-bandwidth']['spacing'],
 | 
				
			||||||
 | 
					            'nodes_list': [n['num-unnum-hop']['node-id'] for n in nd_list],
 | 
				
			||||||
 | 
					            'loose_list': [n['num-unnum-hop']['hop-type'] for n in nd_list]
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        # recover trx physical param (baudrate, ...) from type and mode
 | 
					        # recover trx physical param (baudrate, ...) from type and mode
 | 
				
			||||||
        # nb_channel is computed based on min max frequency and spacing
 | 
					        # nb_channel is computed based on min max frequency and spacing
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user