Skip to content

Commit

Permalink
Merge pull request #2927 from phillxnet/2912-NFS-exports-restored-as-…
Browse files Browse the repository at this point in the history
…read-only

NFS exports restored as read-only #2912
  • Loading branch information
phillxnet authored Nov 15, 2024
2 parents a8e7d23 + cd82803 commit 366324d
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 366324d

Please sign in to comment.