Skip to content

Commit

Permalink
fix(ns-api): find storage by mount point
Browse files Browse the repository at this point in the history
The local storage is identified by a names section
`ns_data`.

On upgrade, the fstab UCI config is rewritten:
existing sections are preserved but all names are deleted.

This prevent to correctly display the configured storage
inside the UI.
  • Loading branch information
gsanchietti committed Dec 6, 2024
1 parent abfe30f commit e3d87f8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/ns-api/files/ns.storage
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ def run(cmd):
except:
return utils.generic_error("command_failed")

def get_storage_info(u):
for section in utils.get_all_by_type(u, 'fstab', 'mount'):
if u.get('fstab', section, 'target', default='') == '/mnt/data':
return u.get_all('fstab', section)
return None

def list_devices():
devices = []
p = subprocess.run(["/usr/bin/lsblk", "--json", "-b", "--output-all"], check=True, capture_output=True, text=True)
Expand Down Expand Up @@ -63,7 +69,7 @@ def get_configuration():

ret = {"name": None, "size": None, "path": None, "model": None, "vendor": None}
try:
info = u.get_all("fstab", "ns_data")
info = get_storage_info(u)
p = subprocess.run(["/usr/bin/lsblk", "--json", "-b", "--output-all"], check=True, capture_output=True, text=True)
data = json.loads(p.stdout)
cur = None
Expand Down

0 comments on commit e3d87f8

Please sign in to comment.