diff options
Diffstat (limited to 'ogcp')
-rw-r--r-- | ogcp/views.py | 59 |
1 files changed, 24 insertions, 35 deletions
diff --git a/ogcp/views.py b/ogcp/views.py index bf4fdb0..86b27cb 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -658,8 +658,10 @@ def action_image_restore(): part_id = partition['partition'] if part_id == 0: # This is the disk data, not a partition. continue + part_code = partition['code'] + filesystem = partition['filesystem'] - choice_value = (disk_id, part_id) + choice_value = (disk_id, part_id, part_code, filesystem) parts.append(choice_value) if not part_choices: # Use first computer as reference part setup conf @@ -672,9 +674,12 @@ def action_image_restore(): flash(_('ogServer was unable to obtain setup of selected computer {}').format(ip), category='error') return redirect(url_for('commands')) - form.partition.choices = [ (f'{disk_id} {part_id}', _('Disk: {} | Part: {}').format(disk_id, part_id)) - for disk_id, part_id in part_choices ] - + form.partition.choices = [ + (f"{disk_id} {part_id}", + f"Disk {disk_id} | Partition {part_id} " + f"| {PART_TYPE_CODES[part_code]} " + f"{FS_CODES[filesystem]}") + for disk_id, part_id, part_code, filesystem in part_choices ] scopes, clients = get_scopes(set(ips)) selected_clients = list(get_selected_clients(scopes['scope']).items()) @@ -749,7 +754,7 @@ def action_software(): for part in r.json()['partitions'][1:]: form.os.choices.append( (f"{part.get('disk')} {part.get('partition')}", - f"Disco {part.get('disk')} | ParticiĆ³n {part.get('partition')} " + f"Disk {part.get('disk')} | Partition {part.get('partition')} " f"| {PART_TYPE_CODES[part.get('code')]} " f"{FS_CODES[part.get('filesystem')]}") ) @@ -1201,22 +1206,14 @@ def action_image_create(): server = get_server_from_clients(ips) r = server.get('/client/setup', payload={'client': list(ips)}) - for partition in r.json()['partitions']: - disk_id = partition['disk'] - part_id = partition['partition'] - fs_id = partition['filesystem'] - code = partition['code'] - - if part_id == 0: - # This is the disk data, not a partition. - continue - - choice_value = f"{disk_id} {part_id} {code}" - choice_name = (f"{_('Disk')} {disk_id} | " - f"{_('Partition')} {part_id} | " - f"{_('FS')} {FS_CODES[fs_id]}") - form.os.choices.append((choice_value, choice_name)) + for part in r.json()['partitions'][1:]: + form.os.choices.append( + (f"{part.get('disk')} {part.get('partition')}", + f"Disk {part.get('disk')} | Partition {part.get('partition')} " + f"| {PART_TYPE_CODES[part.get('code')]} " + f"{FS_CODES[part.get('filesystem')]}") + ) repositories = get_repositories(server) for repo in repositories: form.repository.choices.append((repo['id'], repo['name'])) @@ -1272,21 +1269,13 @@ def action_image_update(): form.image.choices.append((image['id'], image['name'])) r = server.get('/client/setup', payload={'client': list(ips)}) - for partition in r.json()['partitions']: - disk_id = partition['disk'] - part_id = partition['partition'] - fs_id = partition['filesystem'] - code = partition['code'] - - if part_id == 0: - # This is the disk data, not a partition. - continue - - choice_value = f'{disk_id} {part_id} {code}' - choice_name = (f"{_('Disk')} {disk_id} | " - f"{_('Partition')} {part_id} | " - f"{_('FS')} {FS_CODES[fs_id]}") - form.os.choices.append((choice_value, choice_name)) + for part in r.json()['partitions'][1:]: + form.os.choices.append( + (f"{part.get('disk')} {part.get('partition')}", + f"Disk {part.get('disk')} | Partition {part.get('partition')} " + f"| {PART_TYPE_CODES[part.get('code')]} " + f"{FS_CODES[part.get('filesystem')]}") + ) scopes, _clients = get_scopes(set(ips)) selected_clients = list(get_selected_clients(scopes['scope']).items()) |