Revision f3e513ad lib/bdev.py
b/lib/bdev.py | ||
---|---|---|
172 | 172 |
raise NotImplementedError |
173 | 173 |
|
174 | 174 |
|
175 |
def Rename(self, new_id): |
|
176 |
"""Rename this device. |
|
177 |
|
|
178 |
This may or may not make sense for a given device type. |
|
179 |
|
|
180 |
""" |
|
181 |
raise NotImplementedError |
|
182 |
|
|
183 |
|
|
175 | 184 |
def GetStatus(self): |
176 | 185 |
"""Return the status of the device. |
177 | 186 |
|
... | ... | |
368 | 377 |
|
369 | 378 |
return not result.failed |
370 | 379 |
|
380 |
def Rename(self, new_id): |
|
381 |
"""Rename this logical volume. |
|
382 |
|
|
383 |
""" |
|
384 |
if not isinstance(new_id, (tuple, list)) or len(new_id) != 2: |
|
385 |
raise errors.ProgrammerError("Invalid new logical id '%s'" % new_id) |
|
386 |
new_vg, new_name = new_id |
|
387 |
if new_vg != self._vg_name: |
|
388 |
raise errors.ProgrammerError("Can't move a logical volume across" |
|
389 |
" volume groups (from %s to to %s)" % |
|
390 |
(self._vg_name, new_vg)) |
|
391 |
result = utils.RunCmd(["lvrename", new_vg, self._lv_name, new_name]) |
|
392 |
if result.failed: |
|
393 |
raise errors.BlockDeviceError("Failed to rename the logical volume: %s" % |
|
394 |
result.output) |
|
371 | 395 |
|
372 | 396 |
def Attach(self): |
373 | 397 |
"""Attach to an existing LV. |
... | ... | |
700 | 724 |
#TODO: maybe zero superblock on child devices? |
701 | 725 |
return self.Shutdown() |
702 | 726 |
|
727 |
def Rename(self, new_id): |
|
728 |
"""Rename a device. |
|
729 |
|
|
730 |
This is not supported for md raid1 devices. |
|
731 |
|
|
732 |
""" |
|
733 |
raise errors.ProgrammerError("Can't rename a md raid1 device") |
|
703 | 734 |
|
704 | 735 |
def AddChildren(self, devices): |
705 | 736 |
"""Add new member(s) to the md raid1. |
... | ... | |
1056 | 1087 |
return False |
1057 | 1088 |
return True |
1058 | 1089 |
|
1090 |
def Rename(self, new_id): |
|
1091 |
"""Rename a device. |
|
1092 |
|
|
1093 |
This is not supported for drbd devices. |
|
1094 |
|
|
1095 |
""" |
|
1096 |
raise errors.ProgrammerError("Can't rename a drbd device") |
|
1097 |
|
|
1059 | 1098 |
|
1060 | 1099 |
class DRBDev(BaseDRBD): |
1061 | 1100 |
"""DRBD block device. |
... | ... | |
1562 | 1601 |
""" |
1563 | 1602 |
return self.Shutdown() |
1564 | 1603 |
|
1604 |
|
|
1565 | 1605 |
class DRBD8(BaseDRBD): |
1566 | 1606 |
"""DRBD v8.x block device. |
1567 | 1607 |
|
... | ... | |
2042 | 2082 |
return True |
2043 | 2083 |
|
2044 | 2084 |
@classmethod |
2085 |
def _ShutdownNet(cls, minor): |
|
2086 |
"""Disconnect from the remote peer. |
|
2087 |
|
|
2088 |
This fails if we don't have a local device. |
|
2089 |
|
|
2090 |
""" |
|
2091 |
result = utils.RunCmd(["drbdsetup", cls._DevPath(minor), "disconnect"]) |
|
2092 |
logger.Error("Can't shutdown network: %s" % result.output) |
|
2093 |
return not result.failed |
|
2094 |
|
|
2095 |
@classmethod |
|
2045 | 2096 |
def _ShutdownAll(cls, minor): |
2046 | 2097 |
"""Deactivate the device. |
2047 | 2098 |
|
... | ... | |
2066 | 2117 |
self.dev_path = None |
2067 | 2118 |
return True |
2068 | 2119 |
|
2120 |
def Rename(self, new_uid): |
|
2121 |
"""Re-connect this device to another peer. |
|
2122 |
|
|
2123 |
""" |
|
2124 |
if self.minor is None: |
|
2125 |
raise errors.BlockDeviceError("Device not attached during rename") |
|
2126 |
if self._rhost is not None: |
|
2127 |
# this means we did have a host when we attached, so we are connected |
|
2128 |
if not self._ShutdownNet(self.minor): |
|
2129 |
raise errors.BlockDeviceError("Can't disconnect from remote peer") |
|
2130 |
old_id = self.unique_id |
|
2131 |
else: |
|
2132 |
old_id = None |
|
2133 |
self.unique_id = new_uid |
|
2134 |
if not self._AssembleNet(self.minor, self.unique_id, "C"): |
|
2135 |
logger.Error("Can't attach to new peer!") |
|
2136 |
if self.old_id is not None: |
|
2137 |
self._AssembleNet(self.minor, old_id, "C") |
|
2138 |
self.unique_id = old_id |
|
2139 |
raise errors.BlockDeviceError("Can't attach to new peer") |
|
2140 |
|
|
2069 | 2141 |
def Remove(self): |
2070 | 2142 |
"""Stub remove for DRBD devices. |
2071 | 2143 |
|
Also available in: Unified diff