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

Diff of /trunk/src/GLIStorageDevice.py

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

Revision 922 Revision 923
37 _parted_disk = None 37 _parted_disk = None
38 _sector_bytes = 0 38 _sector_bytes = 0
39 _total_mb = 0 39 _total_mb = 0
40 _arch = None 40 _arch = None
41 _disklabel = None 41 _disklabel = None
42 _applied_recommended = False
43 42
44 ## 43 ##
45 # Initialization function for GLIStorageDevice class 44 # Initialization function for GLIStorageDevice class
46 # @param device Device node (e.g. /dev/hda) of device being represented 45 # @param device Device node (e.g. /dev/hda) of device being represented
47 # @param arch="x86" Architecture that we're partition for (defaults to 'x86' for now) 46 # @param arch="x86" Architecture that we're partition for (defaults to 'x86' for now)
122 free_minor = 0 121 free_minor = 0
123 recommended_parts = [ { 'type': "ext2", 'size': 256, 'mountpoint': "/boot" }, 122 recommended_parts = [ { 'type': "ext2", 'size': 256, 'mountpoint': "/boot" },
124 { 'type': "linux-swap", 'size': 1024, 'mountpoint': "" }, 123 { 'type': "linux-swap", 'size': 1024, 'mountpoint': "" },
125 { 'type': "ext3", 'size': "*", 'mountpoint': "/" } ] 124 { 'type': "ext3", 'size': "*", 'mountpoint': "/" } ]
126 to_create = [] 125 to_create = []
127 if self._applied_recommended:
128 raise GLIException("RecommendedPartitionLayoutError", "notice", "do_recommended", "You have already applied the recommended partition layout.")
129 parts = self.get_ordered_partition_list() 126 parts = self.get_ordered_partition_list()
130 for part in parts: 127 for part in parts:
131 if self._partitions[part].get_type() == "free" and self._partitions[part].get_mb() >= 4096: 128 if self._partitions[part].get_type() == "free" and self._partitions[part].get_mb() >= 4096:
132# if "1" in self._partitions and "2" in self._partitions and part < 4 and self.get_extended_partition():
133# continue
134 free_minor = part 129 free_minor = part
135 break 130 break
136 if not free_minor: 131 if not free_minor:
137 raise GLIException("RecommendedPartitionLayoutError", "notice", "do_recommended", "You do not have atleast 4GB of concurrent unallocated space. Please remove some partitions and try again.") 132 raise GLIException("RecommendedPartitionLayoutError", "notice", "do_recommended", "You do not have atleast 4GB of concurrent unallocated space. Please remove some partitions and try again.")
138# if archinfo[self._arch]['extended']:
139# if "1" in self._partitions and "2" in self._partitions and free_minor < 4 and self.get_extended_partition():
140# raise GLIException("RecommendedPartitionLayoutError", "notice", "do_recommended", "This code is not yet robust enough to handle automatic partitioning with your current layout.")
141 remaining_free = self._partitions[free_minor].get_mb() 133 remaining_free = self._partitions[free_minor].get_mb()
142 for newpart in recommended_parts: 134 for newpart in recommended_parts:
143 if archinfo[self._arch]['extended'] and free_minor == (3 + FREE_MINOR_FRAC_PRI): 135 if archinfo[self._arch]['extended'] and free_minor == (3 + FREE_MINOR_FRAC_PRI) and not newpart == recommended_parts[-1]:
144 if self.get_extended_partition(): 136 if self.get_extended_partition():
145 raise GLIException("RecommendedPartitionLayoutError", "notice", "do_recommended", "This code is not yet robust enough to handle automatic partitioning with your current layout.") 137 raise GLIException("RecommendedPartitionLayoutError", "notice", "do_recommended", "This code is not yet robust enough to handle automatic partitioning with your current layout.")
146 to_create.append({ 'type': "extended", 'size': remaining_free, 'mountpoint': "", 'free_minor': free_minor }) 138 to_create.append({ 'type': "extended", 'size': remaining_free, 'mountpoint': "", 'free_minor': free_minor })
147 free_minor = 4 + FREE_MINOR_FRAC_LOG 139 free_minor = 4 + FREE_MINOR_FRAC_LOG
148 newpart['free_minor'] = free_minor 140 newpart['free_minor'] = free_minor
152 remaining_free = remaining_free - newpart['size'] 144 remaining_free = remaining_free - newpart['size']
153 for newpart in to_create: 145 for newpart in to_create:
154 if newpart['size'] == "*": 146 if newpart['size'] == "*":
155 newpart['size'] = self._partitions[newpart['free_minor']].get_mb() 147 newpart['size'] = self._partitions[newpart['free_minor']].get_mb()
156 self.add_partition(newpart['free_minor'], newpart['size'], 0, 0, newpart['type'], mountpoint=newpart['mountpoint']) 148 self.add_partition(newpart['free_minor'], newpart['size'], 0, 0, newpart['type'], mountpoint=newpart['mountpoint'])
157 self._applied_recommended = True
158 return True
159 149
160 ## 150 ##
161 # Combines free space and closes gaps in minor numbers. This is used internally 151 # Combines free space and closes gaps in minor numbers. This is used internally
162 def tidy_partitions(self): 152 def tidy_partitions(self):
163 last_minor = 0 153 last_minor = 0
273 self._partitions[free_minor].set_mb(self._partitions[free_minor].get_mb() + tmppart.get_mb()) 263 self._partitions[free_minor].set_mb(self._partitions[free_minor].get_mb() + tmppart.get_mb())
274 else: 264 else:
275 self._partitions[free_minor] = Partition(self, free_minor, tmppart.get_mb(), 0, 0, "free", format=False, existing=False) 265 self._partitions[free_minor] = Partition(self, free_minor, tmppart.get_mb(), 0, 0, "free", format=False, existing=False)
276 del self._partitions[int(minor)] 266 del self._partitions[int(minor)]
277 self.tidy_partitions() 267 self.tidy_partitions()
268
269 ##
270 # This function clears the partition table
271 def clear_partitions(self):
272# parts = self._partitions.keys()
273# parts.sort()
274# parts.reverse()
275# for part in parts:
276# if not self._partitions[part].get_type() == "free":
277# self.remove_partition(part)
278 self._partitions = { (0 + FREE_MINOR_FRAC_PRI): Partition(self, (0 + FREE_MINOR_FRAC_PRI), self.get_total_mb(), 0, 0, "free", format=False, existing=False) }
278 279
279 ## 280 ##
280 # Returns an ordered list (disk order) of partition minors 281 # Returns an ordered list (disk order) of partition minors
281 def get_ordered_partition_list(self): 282 def get_ordered_partition_list(self):
282 parts = self._partitions.keys() 283 parts = self._partitions.keys()

Legend:
Removed from v.922  
changed lines
  Added in v.923

  ViewVC Help
Powered by ViewVC 1.1.20