def si(nch_and_spacing, bw): """parametrize a channel comb with nb_channel, spacing and signal bw""" nb_channel, spacing = nch_and_spacing f_min = 191.3e12 f_max = automatic_fmax(f_min, spacing, nb_channel) return create_input_spectral_information(f_min, f_max, 0.15, bw, 1e-3, spacing)
def requests_from_json(json_data, equipment): """Extract list of requests from data parsed from JSON""" requests_list = [] for req in json_data['path-request']: # init all params from request params = {} params['request_id'] = req['request-id'] params['source'] = req['source'] params['bidir'] = req['bidirectional'] params['destination'] = req['destination'] params['trx_type'] = req['path-constraints']['te-bandwidth']['trx_type'] params['trx_mode'] = req['path-constraints']['te-bandwidth']['trx_mode'] params['format'] = params['trx_mode'] params['spacing'] = req['path-constraints']['te-bandwidth']['spacing'] try: nd_list = req['explicit-route-objects']['route-object-include-exclude'] except KeyError: nd_list = [] params['nodes_list'] = [n['num-unnum-hop']['node-id'] for n in nd_list] params['loose_list'] = [n['num-unnum-hop']['hop-type'] for n in nd_list] # recover trx physical param (baudrate, ...) from type and mode # in trx_mode_params optical power is read from equipment['SI']['default'] and # nb_channel is computed based on min max frequency and spacing trx_params = trx_mode_params(equipment, params['trx_type'], params['trx_mode'], True) params.update(trx_params) # print(trx_params['min_spacing']) # optical power might be set differently in the request. if it is indicated then the # params['power'] is updated try: if req['path-constraints']['te-bandwidth']['output-power']: params['power'] = req['path-constraints']['te-bandwidth']['output-power'] except KeyError: pass # same process for nb-channel f_min = params['f_min'] f_max_from_si = params['f_max'] try: if req['path-constraints']['te-bandwidth']['max-nb-of-channel'] is not None: nch = req['path-constraints']['te-bandwidth']['max-nb-of-channel'] params['nb_channel'] = nch spacing = params['spacing'] params['f_max'] = automatic_fmax(f_min, spacing, nch) else: params['nb_channel'] = automatic_nch(f_min, f_max_from_si, params['spacing']) except KeyError: params['nb_channel'] = automatic_nch(f_min, f_max_from_si, params['spacing']) _check_one_request(params, f_max_from_si) try: params['path_bandwidth'] = req['path-constraints']['te-bandwidth']['path_bandwidth'] except KeyError: pass requests_list.append(PathRequest(**params)) return requests_list