/[gli]/trunk/src/GLIStorageDevice.py
Gentoo

Diff of /trunk/src/GLIStorageDevice.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 596 Revision 627
95 for part in ips: 95 for part in ips:
96 tmppart = ips[part] 96 tmppart = ips[part]
97 existing = False 97 existing = False
98 if tmppart['origminor'] and not tmppart['format']: 98 if tmppart['origminor'] and not tmppart['format']:
99 existing = True 99 existing = True
100 self._partitions[tmppart['minor']] = Partition(self, tmppart['minor'], tmppart['mb'], tmppart['start'], tmppart['end'], tmppart['type'], format=tmppart['format'], origminor=tmppart['origminor'], existing=existing, mountpoint=tmppart['mountpoint'], mountopts=['mountopts']) 100 self._partitions[tmppart['minor']] = Partition(self, tmppart['minor'], tmppart['mb'], tmppart['start'], tmppart['end'], tmppart['type'], format=tmppart['format'], origminor=tmppart['origminor'], existing=existing, mountpoint=tmppart['mountpoint'], mountopts=tmppart['mountopts'])
101 101
102 ## 102 ##
103 # Returns name of device (e.g. /dev/hda) being represented 103 # Returns name of device (e.g. /dev/hda) being represented
104 def get_device(self): 104 def get_device(self):
105 return self._device 105 return self._device
126 del self._partitions[part_log] 126 del self._partitions[part_log]
127 else: 127 else:
128 if not last_log_free: 128 if not last_log_free:
129 last_log_free = last_log_minor + 0.9 129 last_log_free = last_log_minor + 0.9
130 else: 130 else:
131 lost_log_free = part_log 131 last_log_free = part_log
132 tmppart_log.set_minor(last_log_free) 132 tmppart_log.set_minor(last_log_free)
133 self._partitions[last_log_free] = tmppart_log 133 self._partitions[last_log_free] = tmppart_log
134 if part_log != last_log_free: del self._partitions[part_log] 134 if part_log != last_log_free: del self._partitions[part_log]
135 continue
136 else: 135 else:
137 if part_log > (last_log_minor + 1): 136 if part_log > (last_log_minor + 1):
138 tmppart_log.set_minor(last_log_minor + 1) 137 tmppart_log.set_minor(last_log_minor + 1)
139 last_log_minor = last_log_minor + 1 138 last_log_minor = last_log_minor + 1
140 self._partitions[last_log_minor] = tmppart_log 139 self._partitions[last_log_minor] = tmppart_log
141 del self._partitions[part_log] 140 del self._partitions[part_log]
142 continue
143 else: 141 else:
144 last_log_minor = part_log 142 last_log_minor = part_log
145 if tmppart.get_type() == "free": 143 elif tmppart.get_type() == "free":
146 if last_minor < last_free: 144 if last_minor < last_free:
147 self._partitions[last_free].set_mb(self._partitions[last_free].get_mb()+tmppart.get_mb()) 145 self._partitions[last_free].set_mb(self._partitions[last_free].get_mb()+tmppart.get_mb())
148 del self._partitions[part] 146 del self._partitions[part]
149 else: 147 else:
150 if not last_free: 148 if not last_free:
152 else: 150 else:
153 last_free = part 151 last_free = part
154 tmppart.set_minor(last_free) 152 tmppart.set_minor(last_free)
155 self._partitions[last_free] = tmppart 153 self._partitions[last_free] = tmppart
156 if part != last_free: del self._partitions[part] 154 if part != last_free: del self._partitions[part]
157 continue
158 else: 155 else:
159 if part > (last_minor + 1): 156 if part > (last_minor + 1):
160 tmppart.set_minor(last_minor + 1) 157 tmppart.set_minor(last_minor + 1)
161 last_minor = last_minor + 1 158 last_minor = last_minor + 1
162 self._partitions[last_minor] = tmppart 159 self._partitions[last_minor] = tmppart
163 del self._partitions[part] 160 del self._partitions[part]
164 continue
165 else: 161 else:
166 last_minor = part 162 last_minor = part
167 163
168 ## 164 ##
169 # Adds a new partition to the partition info 165 # Adds a new partition to the partition info
175 # @param mountpoint='' Partition mountpoint 171 # @param mountpoint='' Partition mountpoint
176 # @param mountopts='' Partition mount options 172 # @param mountopts='' Partition mount options
177 def add_partition(self, free_minor, mb, start, end, type, mountpoint='', mountopts=''): 173 def add_partition(self, free_minor, mb, start, end, type, mountpoint='', mountopts=''):
178 free_minor = free_minor 174 free_minor = free_minor
179 new_minor = int(free_minor) + 1 175 new_minor = int(free_minor) + 1
180# print "add_partition(): free_minor=" + str(free_minor) + ", new_minor=" + str(new_minor)
181 if self._partitions.has_key(new_minor): 176 if self._partitions.has_key(new_minor):
182 parts = self._partitions.keys() 177 parts = self._partitions.keys()
183 parts.sort() 178 parts.sort()
184 parts.reverse() 179 parts.reverse()
185 hole_at = 0 180 hole_at = 0
313 return minor 308 return minor
314 309
315 ## 310 ##
316 # Returns an ordered list (disk order) of partition minors 311 # Returns an ordered list (disk order) of partition minors
317 def get_ordered_partition_list(self): 312 def get_ordered_partition_list(self):
318 parts = self._partitions.keys() 313 parts = self._partitions.keys()
319 parts.sort() 314 parts.sort()
320 partlist = [] 315 partlist = []
321 tmppart = None 316 tmppart = None
322 for part in parts: 317 for part in parts:
323 if archinfo[self._arch]['extended'] and part > 4.1: break 318 if archinfo[self._arch]['extended'] and part > 4.1: break
324 tmppart = self._partitions[part] 319 tmppart = self._partitions[part]
325 partlist.append(part) 320 partlist.append(part)
344 for part in self._partitions: 339 for part in self._partitions:
345 tmppart = self._partitions[part] 340 tmppart = self._partitions[part]
346 if tmppart.is_extended(): 341 if tmppart.is_extended():
347 return part 342 return part
348 return 0 343 return 0
344
345 ##
346 # Returns the drive model
347 def get_model(self):
348 return self._parted_dev.model
349 349
350 ## 350 ##
351 # Sets the disklabel type 351 # Sets the disklabel type
352 def set_disklabel(self, disklabel): 352 def set_disklabel(self, disklabel):
353 self._disklabel = disklabel 353 self._disklabel = disklabel
474 label_type = device._parted_disk.type.name 474 label_type = device._parted_disk.type.name
475 if label_type == "loop": 475 if label_type == "loop":
476 dev_node = device._device 476 dev_node = device._device
477 else: 477 else:
478 dev_node = device._device + str(self._orig_minor) 478 dev_node = device._device + str(self._orig_minor)
479 print "dev_node = " + dev_node 479# print "dev_node = " + dev_node
480 if type == "ntfs": 480 if type == "ntfs":
481 min_bytes = int(commands.getoutput("ntfsresize -f --info " + dev_node + " | grep -e '^You might resize' | sed -e 's/You might resize at //' -e 's/ bytes or .\+//'")) 481 min_bytes = int(commands.getoutput("ntfsresize -f --info " + dev_node + " | grep -e '^You might resize' | sed -e 's/You might resize at //' -e 's/ bytes or .\+//'"))
482 self._min_mb_for_resize = int(min_bytes / MEGABYTE) + 1 482 self._min_mb_for_resize = int(min_bytes / MEGABYTE) + 1
483 self._resizeable = True 483 self._resizeable = True
484 elif type == "ext2" or type == "ext3": 484 elif type == "ext2" or type == "ext3":

Legend:
Removed from v.596  
changed lines
  Added in v.627

  ViewVC Help
Powered by ViewVC 1.1.20