Skip to content

Commit

Permalink
NFS exports restored as read-only #2912
Browse files Browse the repository at this point in the history
Fix translation of DB dump derived config-save field names to
NFS export create API field names.

Affects Web-UI surfaced NFS export config of:
- Access type ('Writable'/'Read only')
- Response type ('async'/'sync')
for NFS exports created via a config restore process.

Note that we maintain DB dump derived config-save field names
in the generated API calls (ignored currently), to enable
future API field name alignment to DB model field names.
At which point the additional fields added here to the API
payload would themselves become redundant and up for
deprecation, and in the change-over period ignored.
  • Loading branch information
phillxnet committed Nov 14, 2024
1 parent a8e7d23 commit cd82803
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/rockstor/storageadmin/views/config_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ def restore_samba_exports(ml: list):


def restore_nfs_exports(ml: list):
"""
Parses storageadmin model list from config-backup DB dump.
Assumes Share mount-point is Share name.
@param ml: Model list (storageadmin)
"""
logger.info("Started restoring NFS exports.")
exports = []
export_groups = {}
Expand All @@ -127,13 +132,21 @@ def restore_nfs_exports(ml: list):
if m["model"] == "storageadmin.nfsexport":
exports.append(m["fields"])
elif m["model"] == "storageadmin.nfsexportgroup":
logger.debug(f"Processing nfsexportgroup = {m}")
m["fields"]["pk"] = m["pk"]
export_groups[m["pk"]] = m["fields"]
# Derive API field names & structure from nfsexportgroup DB dump field names:
nfse_api_fields: dict = m["fields"]
# Maintaining "editable" and "syncable" enables future API sync to DB model.
if "editable" in nfse_api_fields: # 'mod_choice' from 'editable'
nfse_api_fields["mod_choice"] = nfse_api_fields["editable"]
if "syncable" in nfse_api_fields: # 'sync_choice' from 'syncable'
nfse_api_fields["sync_choice"] = nfse_api_fields["syncable"]
export_groups[m["pk"]] = nfse_api_fields
elif m["model"] == "storageadmin.advancednfsexport":
adv_exports["entries"].append(m["fields"]["export_str"])
for e in exports:
if len(e["mount"].split("/")) != 3:
logger.info("skipping nfs export with mount: {}".format(e["mount"]))
logger.info(f"skipping nfs export with mount: {e['mount']}")
continue
e["shares"] = [e["mount"].split("/")[2]]
payload = dict(export_groups[e["export_group"]], **e)
Expand Down

0 comments on commit cd82803

Please sign in to comment.