Revision 769b0bde lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
4515 | 4515 |
return not cumul_degraded |
4516 | 4516 |
|
4517 | 4517 |
|
4518 |
def _BlockdevFind(lu, node, dev, instance): |
|
4519 |
"""Wrapper around call_blockdev_find to annotate diskparams. |
|
4520 |
|
|
4521 |
@param lu: A reference to the lu object |
|
4522 |
@param node: The node to call out |
|
4523 |
@param dev: The device to find |
|
4524 |
@param instance: The instance object the device belongs to |
|
4525 |
@returns The result of the rpc call |
|
4526 |
|
|
4527 |
""" |
|
4528 |
(disk,) = _AnnotateDiskParams(instance, [dev], lu.cfg) |
|
4529 |
return lu.rpc.call_blockdev_find(node, disk) |
|
4530 |
|
|
4531 |
|
|
4518 | 4532 |
def _CheckDiskConsistency(lu, instance, dev, node, on_primary, ldisk=False): |
4533 |
"""Wrapper around L{_CheckDiskConistencyInner}. |
|
4534 |
|
|
4535 |
""" |
|
4536 |
(disk,) = _AnnotateDiskParams(instance, [dev], lu.cfg) |
|
4537 |
return _CheckDiskConsistencyInner(lu, instance, disk, node, on_primary, |
|
4538 |
ldisk=ldisk) |
|
4539 |
|
|
4540 |
|
|
4541 |
def _CheckDiskConsistencyInner(lu, instance, dev, node, on_primary, |
|
4542 |
ldisk=False): |
|
4519 | 4543 |
"""Check that mirrors are not degraded. |
4520 | 4544 |
|
4545 |
@attention: The device has to be annotated already. |
|
4546 |
|
|
4521 | 4547 |
The ldisk parameter, if True, will change the test from the |
4522 | 4548 |
is_degraded attribute (which represents overall non-ok status for |
4523 | 4549 |
the device(s)) to the ldisk (representing the local storage status). |
... | ... | |
4544 | 4570 |
|
4545 | 4571 |
if dev.children: |
4546 | 4572 |
for child in dev.children: |
4547 |
result = result and _CheckDiskConsistency(lu, instance, child, node, |
|
4548 |
on_primary) |
|
4573 |
result = result and _CheckDiskConsistencyInner(lu, instance, child, node,
|
|
4574 |
on_primary)
|
|
4549 | 4575 |
|
4550 | 4576 |
return result |
4551 | 4577 |
|
... | ... | |
10514 | 10540 |
self.lu.LogInfo("Checking disk/%d on %s", idx, node) |
10515 | 10541 |
self.cfg.SetDiskID(dev, node) |
10516 | 10542 |
|
10517 |
result = self.rpc.call_blockdev_find(node, dev)
|
|
10543 |
result = _BlockdevFind(self, node, dev, instance)
|
|
10518 | 10544 |
|
10519 | 10545 |
if result.offline: |
10520 | 10546 |
continue |
... | ... | |
10779 | 10805 |
self.lu.LogInfo("Checking disk/%d on %s" % (idx, node)) |
10780 | 10806 |
self.cfg.SetDiskID(dev, node) |
10781 | 10807 |
|
10782 |
result = self.rpc.call_blockdev_find(node, dev)
|
|
10808 |
result = _BlockdevFind(self, node, dev, self.instance)
|
|
10783 | 10809 |
|
10784 | 10810 |
msg = result.fail_msg |
10785 | 10811 |
if msg or not result.payload: |
... | ... | |
10848 | 10874 |
for name, (dev, _, _) in iv_names.iteritems(): |
10849 | 10875 |
self.cfg.SetDiskID(dev, node_name) |
10850 | 10876 |
|
10851 |
result = self.rpc.call_blockdev_find(node_name, dev)
|
|
10877 |
result = _BlockdevFind(self, node_name, dev, self.instance)
|
|
10852 | 10878 |
|
10853 | 10879 |
msg = result.fail_msg |
10854 | 10880 |
if msg or not result.payload: |
... | ... | |
10970 | 10996 |
# Now that the new lvs have the old name, we can add them to the device |
10971 | 10997 |
self.lu.LogInfo("Adding new mirror component on %s" % self.target_node) |
10972 | 10998 |
result = self.rpc.call_blockdev_addchildren(self.target_node, |
10973 |
(dev, self.instance), |
|
10974 |
(new_lvs, self.instance)) |
|
10999 |
(dev, self.instance), new_lvs) |
|
10975 | 11000 |
msg = result.fail_msg |
10976 | 11001 |
if msg: |
10977 | 11002 |
for new_lv in new_lvs: |
... | ... | |
11761 | 11786 |
"""Compute block device status. |
11762 | 11787 |
|
11763 | 11788 |
""" |
11789 |
(anno_dev,) = _AnnotateDiskParams(instance, [dev], self.cfg) |
|
11790 |
|
|
11791 |
return self._ComputeDiskStatusInner(instance, snode, anno_dev) |
|
11792 |
|
|
11793 |
def _ComputeDiskStatusInner(self, instance, snode, dev): |
|
11794 |
"""Compute block device status. |
|
11795 |
|
|
11796 |
@attention: The device has to be annotated already. |
|
11797 |
|
|
11798 |
""" |
|
11764 | 11799 |
if dev.dev_type in constants.LDS_DRBD: |
11765 | 11800 |
# we change the snode then (otherwise we use the one passed in) |
11766 | 11801 |
if dev.logical_id[0] == instance.primary_node: |
... | ... | |
11773 | 11808 |
dev_sstatus = self._ComputeBlockdevStatus(snode, instance, dev) |
11774 | 11809 |
|
11775 | 11810 |
if dev.children: |
11776 |
dev_children = map(compat.partial(self._ComputeDiskStatus, |
|
11811 |
dev_children = map(compat.partial(self._ComputeDiskStatusInner,
|
|
11777 | 11812 |
instance, snode), |
11778 | 11813 |
dev.children) |
11779 | 11814 |
else: |
Also available in: Unified diff