diff options
Diffstat (limited to 'ogcp/views.py')
-rw-r--r-- | ogcp/views.py | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/ogcp/views.py b/ogcp/views.py index 8b544eb..007ca91 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -682,6 +682,7 @@ def action_setup_select(): @login_required def action_setup_show(): args = request.args.copy() + disk_size = None default_disk = 1 selected_disk = int(args.pop('disk', default_disk)) @@ -694,35 +695,47 @@ def action_setup_show(): ips = set(args['ips'].split(' ')) base_client = args['selected_client'] - try: - db_partitions = get_client_setup(base_client) - except ServerError: - return ogserver_down('commands') - except ServerErrorCode: - return ogserver_error('commands') - if not db_partitions: + for ip in ips: + try: + setup_data = get_client_setup(ip) + except ServerError: + return ogserver_down('commands') + except ServerErrorCode: + return ogserver_error('commands') + + filtered_partitions = [p for p in setup_data + if p.get('disk') == selected_disk] + if not filtered_partitions: + continue + + if ip == base_client: + target_partitions = filtered_partitions + + client_disk_size = filtered_partitions[0]['size'] // 1024 + if disk_size: + disk_size = min(disk_size, client_disk_size) + else: + disk_size = client_disk_size + + if not target_partitions: flash(_('Partition information is not available. Boot client in ogLive mode to obtain it'), category='error') return redirect(url_for('commands')) - filtered_partitions = [p for p in db_partitions - if p.get('disk') == selected_disk] disk_partition = 0 - disks = [d.get('disk') for d in db_partitions + disks = [d.get('disk') for d in target_partitions if d.get('partition') == disk_partition] form = SetupForm() form.ips.data = ips_str form.disk.data = selected_disk # If partition table is empty, set MSDOS - form.disk_type.data = filtered_partitions[0]['code'] or 1 - - disk_size = filtered_partitions[0]['size'] // 1024 + form.disk_type.data = target_partitions[0]['code'] or 1 - # Make form.partition length equal to (filtered_partitions - 1) length - diff = len(filtered_partitions) - 1 - len(form.partitions) + # Make form.partition length equal to (target_partitions - 1) length + diff = len(target_partitions) - 1 - len(form.partitions) [form.partitions.append_entry() for unused in range(diff)] - for partition, db_part in zip(form.partitions, filtered_partitions[1:]): + for partition, db_part in zip(form.partitions, target_partitions[1:]): partition.partition.data = str(db_part['partition']) partition.part_type.data = db_part['code'] partition.fs.data = db_part['filesystem'] |