The first is to update how the version of Truenas is determined. The product format between Scale and Core is different in that system.version returns <product_name>-<product_version> for Core, but <product_name>-<product_type>-<product_version> for Scale (e.g. TrueNAS-13.0-U5 vs TrueNAS-SCALE-22.12.3.1) meaning that the way the version is currently determined/compared results in the version string not being correctly extracted. This change will strip system.product_type (if it exists) from the leading edge of the sys_version variable before extracting the product version.
The second change is that querying existing NFS shares in Scale returns key:values where the comment is the name.
Example query output:
{'id': 2, 'path': '/mnt/zvol/test', 'aliases': [], 'comment': 'test', 'hosts': [], 'ro': False, 'quiet': False, 'maproot_user': 'root', 'maproot_group': 'wheel', 'mapall_user': None, 'mapall_group': None, 'security': [], 'enabled': True, 'networks': ['172.16.0.0/24'], 'locked': False}\n
This results in a KeyError exception since the name key cannot be found in the export_info object, only comment. I've wrapped the existing functionality in a try/except, that falls back to taking the comment of the share to compare to the proposed name of the NFS share to be updated. This works for me, but there may be a better/cleaner way to do the same thing? 🤷♂️
There are two changes as part of this PR:
The first is to update how the version of Truenas is determined. The product format between Scale and Core is different in that system.version returns
<product_name>-<product_version>
for Core, but<product_name>-<product_type>-<product_version>
for Scale (e.g.TrueNAS-13.0-U5
vsTrueNAS-SCALE-22.12.3.1
) meaning that the way the version is currently determined/compared results in the version string not being correctly extracted. This change will strip system.product_type (if it exists) from the leading edge of the sys_version variable before extracting the product version.The second change is that querying existing NFS shares in Scale returns key:values where the comment is the name. Example query output:
{'id': 2, 'path': '/mnt/zvol/test', 'aliases': [], 'comment': 'test', 'hosts': [], 'ro': False, 'quiet': False, 'maproot_user': 'root', 'maproot_group': 'wheel', 'mapall_user': None, 'mapall_group': None, 'security': [], 'enabled': True, 'networks': ['172.16.0.0/24'], 'locked': False}\n
This results in a KeyError exception since the
name
key cannot be found in theexport_info
object, onlycomment
. I've wrapped the existing functionality in a try/except, that falls back to taking thecomment
of the share to compare to the proposedname
of the NFS share to be updated. This works for me, but there may be a better/cleaner way to do the same thing? 🤷♂️