[UX] bundle: port-mapping and storage-mapping `id=` in CIB could be auto-generated and hidden
zzhou1 opened this issue · comments
Bad experience for me to spend noticeable time to troubleshoot a fresh constructed CIB with multiple port-mapping and storage-mapping. I didn't aware the duplication of id=
among different bundles, eg. "bundle nfsserver1", "bundle nfsserver2", ... in the following text.
Actually, bundle resources' port-mapping and storage-mapping id=
in CIB could be auto-generated and hidden just like how crmsh helps with primitive id=
for monitor/start/stop operations.
The solution could be, for example, the following mock-up for the bundle resource.
bundle nfsserver1 \
network ip-range-start=192.168.1.200 \
port-mapping port=111 \
port-mapping port=2049 \
storage \
storage-mapping source-dir="/srv/nfs1/state" target-dir="/var/lib/nfs" options=rw \
storage-mapping source-dir="/srv/nfs1/share" target-dir="/srv/nfs/share" options=rw
get translated into the following CIB xml
<bundle id="nfsserver1">
<network ip-range-start="192.168.1.200">
<port-mapping id="nfsserver1_port_111" port="111"/>
</network>
<storage>
<storage-mapping id="nfsserver1_2941837544" source-dir="/srv/nfs1/state" target-dir="/var/lib/nfs" options="rw"/>
</storage>
Where port-mapping formula can be simple:
f"{bundle_id}_port_{port}", f"{bundle_id}_internal_port_{port}", or f"{bundle_id}_range_{range}"
Wherer storage-mapping id could leverage a simple hash formula, eg.
>>> s="/srv/nfs1/state"
>>> t="/var/lib/nfs"
>>> hash(s+t)&0xffffffff
2941837544
For the id format, see #1319 (comment)
To make it combine with the setting parameters, I think it's a bit of complex, since no any parameter is required for the port-mapping and storage-mapping
Thanks for the code! I'm fine to give it more freedom so far. Initially, I was hoping the hash can help to keep them with the persistent id wherever the order of the elements, and also could potentially detect the duplication in the CIB as an error/warning message.