-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use workflows for custom operation handlers #3095
Comments
I'd be in favour of defining the mapping rules at the existing location for C8y itself (e.g: One other key aspect is the payload manipulation mechanisms available. The proposed sample showcases a simple example where a sub-fragments from the input is passed as-is to the command. But, additional manipulations might be required for more complex operations and hence keep the config format open so that we can accept not just JSON paths but more complex JSON transformation expressions or even an |
The proposal for the mapping rules and the file format looks fine. Since the mapping rules defined in the operation file applies to both main and child devices, all devices should be able to re-use the same. And we need to provide a better way for the devices (esp child devices) to declare that they support the given custom operation and reuse the same mapping rules for the same. In the current proposal, it is not clear to me as to who creates these operation files and when. As far as I understood, the current proposal expects the user to manually create these operation definition files under So, I'd propose that we define that operation definition file in some c8y-specific but device-neutral location once during the device bootstrapping phase (not directly under |
Drop 1 is done by #3144 |
Is your feature improvement request related to a problem? Please describe.
The custom operation is currently limited to SmartREST input and main device. Since we have workflow feature, mapper can focus on generating a thin-edge command, and move the actual execution of the operation to tedge-agent.
Describe the solution you'd like
Mapper provides a way for users how to map the c8y JSON to thin-edge JSON.
Let's use this custom operation
com_cumulocity_model_WebCamDevice
as an example.C8Y JSON input
All operations including custom operations will be delivered to the JSON over MQTT topic
c8y/devicecontrol/notifications
.Drop 1
File:
/etc/tedge/operations/c8y/com_cumulocity_model_WebCamDevice
(for main device)The mapper spawns a child process (= same mechanism as the existing custom operation handler) from the JSON over MQTT input.
The filename is used for declaring supported operation. The key
on_fragment
is used to check if the mapping file matches the input payload. Iftopic
is not provided, the device control topic is used by default unlesson_message
is defined.skip_status_update
is optional. Iftrue
, mapper doesn't send operation status update messages (501-503/504-506).FYI: existing custom operation handler definition
Drop 2
Mapping definition by user
The mapper converts the incoming JSON over MQTT message to thin-edge command message as per the definition file.
User is supposed to create a master custom operation definition file with
.template
extension. e.g./etc/tedge/operations/c8y/com_cumulocity_model_WebCamDevice.template
To indicate that devices are supporting the operation, the device must publish a command capability message.
On receiving, mapper creates a simlink in
/etc/tedge/operations/c8y/com_cumulocity_model_WebCamDevice
(main),/etc/tedge/operations/c8y/<external_id>/com_cumulocity_model_WebCamDevice
(child/service) to the master file.Mapper detects the change in the
/etc/tedge/operations/c8y
directory except.template
file. When the change is detected,114
(supported operation) message must be sent to c8y.Convert to thin-edge command
Topic:
te/device/<name>///cmd/take_picture/c8y-mapper-1800380
Status update to C8Y
Topic:
te/device/<name>///cmd/take_picture/c8y-mapper-1800380
Mapper converts it to SmartREST
504
or501
for executing status.The same pattern is applied to successful/failed message,
502
/504
, and503
/506
.Describe alternatives you've considered
Another option is using command metadata message to define mapping.
Additional context
The original roadmap ticket is here.
The text was updated successfully, but these errors were encountered: