Revision e739bd57
b/lib/backend.py | ||
---|---|---|
807 | 807 |
if parent_bdev is None: |
808 | 808 |
logger.Error("Can't find parent in remove children: %s" % parent_cdev) |
809 | 809 |
return False |
810 |
new_bdevs = [_RecursiveFindBD(disk) for disk in new_cdevs] |
|
811 |
if new_bdevs.count(None) > 0: |
|
812 |
logger.Error("Can't find some devices while removing children: %s %s" % |
|
813 |
(new_cdevs, new_bdevs)) |
|
814 |
return False |
|
815 |
parent_bdev.RemoveChildren(new_bdevs) |
|
810 |
devs = [] |
|
811 |
for disk in new_cdevs: |
|
812 |
rpath = disk.StaticDevPath() |
|
813 |
if rpath is None: |
|
814 |
bd = _RecursiveFindBD(disk) |
|
815 |
if bd is None: |
|
816 |
logger.Error("Can't find dynamic device %s while removing children" % |
|
817 |
disk) |
|
818 |
return False |
|
819 |
else: |
|
820 |
devs.append(bd.dev_path) |
|
821 |
else: |
|
822 |
devs.append(rpath) |
|
823 |
parent_bdev.RemoveChildren(devs) |
|
816 | 824 |
return True |
817 | 825 |
|
818 | 826 |
|
b/lib/bdev.py | ||
---|---|---|
744 | 744 |
args = ["mdadm", "-f", self.dev_path] |
745 | 745 |
orig_devs = [] |
746 | 746 |
for dev in devices: |
747 |
args.append(dev.dev_path)
|
|
747 |
args.append(dev) |
|
748 | 748 |
for c in self._children: |
749 |
if c.dev_path == dev.dev_path:
|
|
749 |
if c.dev_path == dev: |
|
750 | 750 |
orig_devs.append(c) |
751 | 751 |
break |
752 | 752 |
else: |
... | ... | |
1878 | 1878 |
if len(self._children) != 2: |
1879 | 1879 |
raise errors.BlockDeviceError("We don't have two children: %s" % |
1880 | 1880 |
self._children) |
1881 |
|
|
1881 |
if self._children.count(None) == 2: # we don't actually have children :) |
|
1882 |
logger.Error("Requested detach while detached") |
|
1883 |
return |
|
1882 | 1884 |
if len(devices) != 2: |
1883 | 1885 |
raise errors.BlockDeviceError("We need two children in RemoveChildren") |
1884 |
for idx, dev in enumerate(devices): |
|
1885 |
if dev.dev_path != self._children[idx].dev_path: |
|
1886 |
raise errors.BlockDeviceError("Mismatch in local storage (%d) in" |
|
1887 |
" RemoveChildren" % idx) |
|
1886 |
for child, dev in zip(self._children, devices): |
|
1887 |
if dev != child.dev_path: |
|
1888 |
raise errors.BlockDeviceError("Mismatch in local storage" |
|
1889 |
" (%s != %s) in RemoveChildren" % |
|
1890 |
(dev, child.dev_path)) |
|
1888 | 1891 |
|
1889 | 1892 |
if not self._ShutdownLocal(self.minor): |
1890 | 1893 |
raise errors.BlockDeviceError("Can't detach from local storage") |
Also available in: Unified diff