Revision 1005d816 lib/bdev.py
b/lib/bdev.py | ||
---|---|---|
255 | 255 |
for child in self._children: |
256 | 256 |
child.SetInfo(text) |
257 | 257 |
|
258 |
def Grow(self, amount): |
|
259 |
"""Grow the block device. |
|
260 |
|
|
261 |
Arguments: |
|
262 |
amount: the amount (in mebibytes) to grow with |
|
263 |
|
|
264 |
Returns: None |
|
265 |
|
|
266 |
""" |
|
267 |
raise NotImplementedError |
|
258 | 268 |
|
259 | 269 |
def __repr__(self): |
260 | 270 |
return ("<%s: unique_id: %s, children: %s, %s:%s, %s>" % |
... | ... | |
518 | 528 |
raise errors.BlockDeviceError("Command: %s error: %s - %s" % |
519 | 529 |
(result.cmd, result.fail_reason, |
520 | 530 |
result.output)) |
531 |
def Grow(self, amount): |
|
532 |
"""Grow the logical volume. |
|
533 |
|
|
534 |
""" |
|
535 |
# we try multiple algorithms since the 'best' ones might not have |
|
536 |
# space available in the right place, but later ones might (since |
|
537 |
# they have less constraints); also note that only recent LVM |
|
538 |
# supports 'cling' |
|
539 |
for alloc_policy in "contiguous", "cling", "normal": |
|
540 |
result = utils.RunCmd(["lvextend", "--alloc", alloc_policy, |
|
541 |
"-L", "+%dm" % amount, self.dev_path]) |
|
542 |
if not result.failed: |
|
543 |
return |
|
544 |
raise errors.BlockDeviceError("Can't grow LV %s: %s" % |
|
545 |
(self.dev_path, result.output)) |
|
521 | 546 |
|
522 | 547 |
|
523 | 548 |
class BaseDRBD(BlockDev): |
... | ... | |
1330 | 1355 |
raise errors.BlockDeviceError("Cannot initalize meta device") |
1331 | 1356 |
return cls(unique_id, children) |
1332 | 1357 |
|
1358 |
def Grow(self, amount): |
|
1359 |
"""Resize the DRBD device and its backing storage. |
|
1360 |
|
|
1361 |
""" |
|
1362 |
if self.minor is None: |
|
1363 |
raise errors.ProgrammerError("drbd8: Grow called while not attached") |
|
1364 |
if len(self._children) != 2 or None in self._children: |
|
1365 |
raise errors.BlockDeviceError("Cannot grow diskless DRBD8 device") |
|
1366 |
self._children[0].Grow(amount) |
|
1367 |
result = utils.RunCmd(["drbdsetup", self.dev_path, "resize"]) |
|
1368 |
if result.failed: |
|
1369 |
raise errors.BlockDeviceError("resize failed for %s: %s" % |
|
1370 |
(self.dev_path, result.output)) |
|
1371 |
return |
|
1372 |
|
|
1333 | 1373 |
|
1334 | 1374 |
class FileStorage(BlockDev): |
1335 | 1375 |
"""File device. |
Also available in: Unified diff