Commit 9ff9bdc6 authored by Paul Graydon's avatar Paul Graydon

wendelin_telecom_base: Improve ERP5Site_registerOrs responses

parent 068abf1d
......@@ -18,15 +18,23 @@ data_acquisition_unit = context.portal_catalog.getResultValue(
validation_state='validated'
)
if data_acquisition_unit:
error_msg = "ORS with tag %s already exists." % fluentbit_tag
response_dict = dict(error_msg=error_msg)
status = "ok"
message = "ORS with tag %s already exists." % fluentbit_tag
response_dict = dict(
status=status,
message=message
)
return json.dumps(response_dict)
# Check if the fluentbit tag has a valid format
fluentbit_tag_components = fluentbit_tag.split('_')
if len(fluentbit_tag_components) not in [2, 3]:
error_msg = "Invalid ORS tag %s found" % fluentbit_tag
response_dict = dict(error_msg=error_msg)
status = "error"
message = "Invalid ORS tag %s found" % fluentbit_tag
response_dict = dict(
status=status,
message=message
)
return json.dumps(response_dict)
ors_hostname, ors_comp_id = fluentbit_tag_components[0], fluentbit_tag_components[1]
......@@ -62,4 +70,10 @@ data_acquisition_unit.validate()
data_supply = data_acquisition_unit.DataAcquisitionUnit_createOrsDataSupply(batch=1)
data_supply.setDestinationProject(destination_project)
status = "ok"
message = "ORS with tag %s successfully registered." % fluentbit_tag
response_dict = dict(
status=status,
message=message
)
return json.dumps(response_dict)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment