Hello everybody
I am currently in the process of writing support for the container
feature in routeros
for the community.routeros.api_modify
module.
Implementing /container/envs
, /container/mounts
and /container/config
was rather trivial. My fork contains the changes.
Now I’ve got two problems when trying to support the /container
path itself.
problem #1: uncertain primary key situation
The primary key for an container
entry is the name
field.
Unfortunately this field contains an automatically generated uuid
that cannot be altered:
[admin@sax-hts1-gw-core01] /container> add remote-image=alpine:latest interface=container_test
[admin@sax-hts1-gw-core01] /container> print detail
0 name="37ab9172-31eb-4fb2-ad55-414f4047a597" tag="alpine:latest" os="" arch="" interface=container_test mounts="" dns="" status=extracting
[admin@sax-hts1-gw-core01] /container> set name=hello 0
My code for handling this endpoint is this:
('container', ): APIData(
versioned=[
# available since 7.4beta4
('7.4', '>', VersionedAPIData(
fully_understood=True,
fields={
[...]
'name': KeyInfo(read_only=True),
[...]
},
)),
],
),
I explicitly did not define a primary_key
. This seems to work fine with:
handle_absent_entries: remove
handle_entries_content: remove_as_much_as_possible
but I am not sure if this is the correct way.
problem #2: remote-image | file -> tag
When creating or manipulating an container
one can set the image for it via remote-image
(if the image should be pulled from a registry) or via file
(if the image is a local .tar
archive).
Whichever method is chosen afterwords the resolved image tag will be written into the read only attribute tag
(as seen in the routeros cli example above).
The problem with this behaviour is that community.routeros.api_modify
does not know that remote-tag
(or file
) sets tag
and is therefore unable to detect changes.
I have already tried to mark tag
as automatically_computed_by="remote-image"
but that did not do the trick.
This is the relevant code snippet:
('container', ): APIData(
versioned=[
# available since 7.4beta4
('7.4', '>', VersionedAPIData(
fully_understood=True,
fields={
[...]
'file': KeyInfo(write_only=True),
[...]
'remote-image': KeyInfo(write_only=True),
[...]
'tag': KeyInfo(read_only=True, automatically_computed_from='remote-image'),
[...]
},
)),
],
),
Could someone help me figure out how to correctly implement the container
support for community.routeros.api_modify
?
I only found @felixfontein on the forums therefore you are the only maintainer I am tagging in the post.
Thanks you all so much for reading !