diff --git a/new_partition/partition_data.py b/new_partition/partition_data.py index 5cb8151..0608a78 100755 --- a/new_partition/partition_data.py +++ b/new_partition/partition_data.py @@ -381,12 +381,25 @@ def delete_all_partitions(d, k): for key in d[k]['partition'].keys(): d[k]['partition'].pop(key, None) + _device = _ped.device_get(k) + _disk = _ped.Disk(_device) + '''find the end !meta parititon end as disks end ''' + _part = _disk.next_partition() + while _part: + if _part.type & 8: + _part = _disk.next_partition(_part) + continue + p_g = _part.geom + end = _device.unit_format_byte((p_g.end + 1) * _device.sector_size - 1) + _part = _disk.next_partition(_part) + + partition = 'free 1' - sz = se = d[k]['disk_size'] + sz = d[k]['disk_size'] d[k]['partition'][partition]['sn']= 1 d[k]['partition'][partition]['num']= 1 d[k]['partition'][partition]['start'] = '0' - d[k]['partition'][partition]['end'] = se + d[k]['partition'][partition]['end'] = end d[k]['partition'][partition]['size'] = sz d[k]['partition'][partition]['type'] = '' d[k]['partition'][partition]['filesystem'] = '' @@ -450,7 +463,7 @@ if __name__ == "__main__": #for d in Partition.get_raid_devices(): # print d #print Partition.dict.keys() - pretty(Partition.dict) + #pretty(Partition.dict) #print Partition.unit #write_to_xml_file() #disks = Partition.dict.keys() @@ -464,6 +477,7 @@ if __name__ == "__main__": #init_from_xml() #pretty(Partition.dict) #delete_all_partitions(Partition.dict, "/dev/sda") + #delete_all_partitions(Partition.dict, "/dev/sdf") #delete_one_partition(Partition.dict, "/dev/sdb", "free 1") #pretty(Partition.dict) #print sort_partitions(Partition.dict, "/dev/sda", "all")