Loading src/nbi/service/qkd_app/Resources.py +17 −8 Original line number Diff line number Diff line Loading @@ -82,21 +82,30 @@ class CreateQKDApp(_Resource): def post(self): app = request.get_json()['app'] devices = self.context_client.ListDevices(Empty()).devices local_device = None local_qkdn_id = app['local_qkdn_id'] local_qkdn_id = app.get('local_qkdn_id') if local_qkdn_id is None: MSG = 'local_qkdn_id not specified in qkd_app({:s})' msg = MSG.format(str(app)) LOGGER.exception(msg) response = jsonify({'error': msg}) response.status_code = HTTP_SERVERERROR return response # This for-loop won't be necessary if Device ID is guaranteed to be the same as QKDN Id local_device = None for device in devices: for config_rule in device.device_config.config_rules: if config_rule.custom.resource_key == '__node__': if config_rule.custom.resource_key != '__node__': continue value = json.loads(config_rule.custom.resource_value) if local_qkdn_id != value['qkdn_id']: continue qkdn_id = value.get('qkdn_id') if qkdn_id is None: continue if local_qkdn_id != qkdn_id: continue local_device = device break if local_device is None: MSG = 'Unable to find local_device for local_qkdn_id({:s})' MSG = 'Unable to find device for local_qkdn_id({:s})' msg = MSG.format(str(local_qkdn_id)) LOGGER.exception(msg) response = jsonify({'error': msg}) Loading Loading
src/nbi/service/qkd_app/Resources.py +17 −8 Original line number Diff line number Diff line Loading @@ -82,21 +82,30 @@ class CreateQKDApp(_Resource): def post(self): app = request.get_json()['app'] devices = self.context_client.ListDevices(Empty()).devices local_device = None local_qkdn_id = app['local_qkdn_id'] local_qkdn_id = app.get('local_qkdn_id') if local_qkdn_id is None: MSG = 'local_qkdn_id not specified in qkd_app({:s})' msg = MSG.format(str(app)) LOGGER.exception(msg) response = jsonify({'error': msg}) response.status_code = HTTP_SERVERERROR return response # This for-loop won't be necessary if Device ID is guaranteed to be the same as QKDN Id local_device = None for device in devices: for config_rule in device.device_config.config_rules: if config_rule.custom.resource_key == '__node__': if config_rule.custom.resource_key != '__node__': continue value = json.loads(config_rule.custom.resource_value) if local_qkdn_id != value['qkdn_id']: continue qkdn_id = value.get('qkdn_id') if qkdn_id is None: continue if local_qkdn_id != qkdn_id: continue local_device = device break if local_device is None: MSG = 'Unable to find local_device for local_qkdn_id({:s})' MSG = 'Unable to find device for local_qkdn_id({:s})' msg = MSG.format(str(local_qkdn_id)) LOGGER.exception(msg) response = jsonify({'error': msg}) Loading