mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-10-06 21:46:44 +00:00
fix(oci): qualify import adoption and recovery diagnostics
This commit is contained in:
@@ -44,12 +44,12 @@ def _mount(key, value, vmid):
|
||||
'size_gb': None, 'backup': False, 'read_only': read_only,
|
||||
'create_if_missing': False}
|
||||
if options.get('backup') != '1' or ':' not in source:
|
||||
raise ValueError(f'{key}: {translate("Only backed-up Proxmox volumes can be adopted")}')
|
||||
raise ValueError(f'{key}: {translate("Proxmox volume adoption requires backup=1 and a volume ID")}')
|
||||
storage, volume = source.split(':', 1)
|
||||
if not re.fullmatch(r'[A-Za-z0-9_-]+', storage) or not volume:
|
||||
raise ValueError(f'{key}: {translate("Invalid Proxmox volume ID")}')
|
||||
if not re.search(rf'(?:^|/)(?:vm|subvol)-{vmid}-disk-[0-9]+(?:\.|$)', volume):
|
||||
raise ValueError(f'{key}: {translate("The disk does not belong to this CT; automatic adoption is unsafe")}')
|
||||
raise ValueError(f'{key}: {translate("The volume ID does not contain a disk name for this CT; automatic adoption is unsafe")}')
|
||||
return {'type': 'managed-volume', 'container_path': target, 'source': storage,
|
||||
'size_gb': _managed_size(options.get('size')), 'backup': True,
|
||||
'read_only': read_only}
|
||||
|
||||
@@ -200,9 +200,14 @@ def pending_journal():
|
||||
|
||||
def recovery_hint(after_recovery=False):
|
||||
if after_recovery:
|
||||
msg_warn(translate('The recovery did not complete. Review the log and choose "Recover" again for this container in the OCI management menu.'))
|
||||
source = 'The recovery did not complete. Review the log and choose "{choice}" again for this container in the OCI management menu.'
|
||||
message = translate('The recovery did not complete. Review the log and choose "{choice}" again for this container in the OCI management menu.')
|
||||
else:
|
||||
msg_warn(translate('The operation stopped halfway. Choose "Recover" for this container in the OCI management menu to restore the previous installation.'))
|
||||
source = 'The operation stopped halfway. Choose "{choice}" for this container in the OCI management menu.'
|
||||
message = translate('The operation stopped halfway. Choose "{choice}" for this container in the OCI management menu.')
|
||||
# A malformed cache entry must not leave the user without the menu choice.
|
||||
msg_warn((message if '{choice}' in message else source).replace(
|
||||
'{choice}', translate('Recover the previous installation')))
|
||||
|
||||
|
||||
def recover_untouched(root, journal):
|
||||
|
||||
@@ -140,7 +140,7 @@ def remove(root, vmid):
|
||||
for path, size in image_cache.prune(root, lock=False):
|
||||
msg_ok(f"{translate('Unused image removed from the cache:')} {path.name}")
|
||||
for path in kept:
|
||||
msg_warn(f"{translate('Host directory kept, with its content:')} {path}")
|
||||
msg_warn(f"{translate('Host directory listed in saved records (not targeted for removal):')} {path}")
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in New Issue
Block a user