Revision 821d1bd1 lib/backend.py
b/lib/backend.py | ||
---|---|---|
1070 | 1070 |
return (True, "Migration successfull") |
1071 | 1071 |
|
1072 | 1072 |
|
1073 |
def CreateBlockDevice(disk, size, owner, on_primary, info):
|
|
1073 |
def BlockdevCreate(disk, size, owner, on_primary, info):
|
|
1074 | 1074 |
"""Creates a block device for an instance. |
1075 | 1075 |
|
1076 | 1076 |
@type disk: L{objects.Disk} |
... | ... | |
1123 | 1123 |
return True, physical_id |
1124 | 1124 |
|
1125 | 1125 |
|
1126 |
def RemoveBlockDevice(disk):
|
|
1126 |
def BlockdevRemove(disk):
|
|
1127 | 1127 |
"""Remove a block device. |
1128 | 1128 |
|
1129 | 1129 |
@note: This is intended to be called recursively. |
... | ... | |
1149 | 1149 |
result = True |
1150 | 1150 |
if disk.children: |
1151 | 1151 |
for child in disk.children: |
1152 |
result = result and RemoveBlockDevice(child)
|
|
1152 |
result = result and BlockdevRemove(child)
|
|
1153 | 1153 |
return result |
1154 | 1154 |
|
1155 | 1155 |
|
... | ... | |
1189 | 1189 |
if children.count(None) >= mcn: |
1190 | 1190 |
raise |
1191 | 1191 |
cdev = None |
1192 |
logging.debug("Error in child activation: %s", str(err))
|
|
1192 |
logging.error("Error in child activation: %s", str(err))
|
|
1193 | 1193 |
children.append(cdev) |
1194 | 1194 |
|
1195 | 1195 |
if as_primary or disk.AssembleOnSecondary(): |
... | ... | |
1206 | 1206 |
return result |
1207 | 1207 |
|
1208 | 1208 |
|
1209 |
def AssembleBlockDevice(disk, owner, as_primary):
|
|
1209 |
def BlockdevAssemble(disk, owner, as_primary):
|
|
1210 | 1210 |
"""Activate a block device for an instance. |
1211 | 1211 |
|
1212 | 1212 |
This is a wrapper over _RecursiveAssembleBD. |
... | ... | |
1222 | 1222 |
return result |
1223 | 1223 |
|
1224 | 1224 |
|
1225 |
def ShutdownBlockDevice(disk):
|
|
1225 |
def BlockdevShutdown(disk):
|
|
1226 | 1226 |
"""Shut down a block device. |
1227 | 1227 |
|
1228 | 1228 |
First, if the device is assembled (Attach() is successfull), then |
... | ... | |
1250 | 1250 |
result = True |
1251 | 1251 |
if disk.children: |
1252 | 1252 |
for child in disk.children: |
1253 |
result = result and ShutdownBlockDevice(child)
|
|
1253 |
result = result and BlockdevShutdown(child)
|
|
1254 | 1254 |
return result |
1255 | 1255 |
|
1256 | 1256 |
|
1257 |
def MirrorAddChildren(parent_cdev, new_cdevs):
|
|
1257 |
def BlockdevAddchildren(parent_cdev, new_cdevs):
|
|
1258 | 1258 |
"""Extend a mirrored block device. |
1259 | 1259 |
|
1260 | 1260 |
@type parent_cdev: L{objects.Disk} |
... | ... | |
1278 | 1278 |
return True |
1279 | 1279 |
|
1280 | 1280 |
|
1281 |
def MirrorRemoveChildren(parent_cdev, new_cdevs):
|
|
1281 |
def BlockdevRemovechildren(parent_cdev, new_cdevs):
|
|
1282 | 1282 |
"""Shrink a mirrored block device. |
1283 | 1283 |
|
1284 | 1284 |
@type parent_cdev: L{objects.Disk} |
... | ... | |
1310 | 1310 |
return True |
1311 | 1311 |
|
1312 | 1312 |
|
1313 |
def GetMirrorStatus(disks):
|
|
1313 |
def BlockdevGetmirrorstatus(disks):
|
|
1314 | 1314 |
"""Get the mirroring status of a list of devices. |
1315 | 1315 |
|
1316 | 1316 |
@type disks: list of L{objects.Disk} |
... | ... | |
1352 | 1352 |
return bdev.FindDevice(disk.dev_type, disk.physical_id, children) |
1353 | 1353 |
|
1354 | 1354 |
|
1355 |
def CallBlockdevFind(disk):
|
|
1355 |
def BlockdevFind(disk): |
|
1356 | 1356 |
"""Check if a device is activated. |
1357 | 1357 |
|
1358 | 1358 |
If it is, return informations about the real device. |
... | ... | |
1638 | 1638 |
|
1639 | 1639 |
return result |
1640 | 1640 |
|
1641 |
def GrowBlockDevice(disk, amount):
|
|
1641 |
def BlockdevGrow(disk, amount):
|
|
1642 | 1642 |
"""Grow a stack of block devices. |
1643 | 1643 |
|
1644 | 1644 |
This function is called recursively, with the childrens being the |
... | ... | |
1664 | 1664 |
return True, None |
1665 | 1665 |
|
1666 | 1666 |
|
1667 |
def SnapshotBlockDevice(disk):
|
|
1667 |
def BlockdevSnapshot(disk):
|
|
1668 | 1668 |
"""Create a snapshot copy of a block device. |
1669 | 1669 |
|
1670 | 1670 |
This function is called recursively, and the snapshot is actually created |
... | ... | |
1679 | 1679 |
if disk.children: |
1680 | 1680 |
if len(disk.children) == 1: |
1681 | 1681 |
# only one child, let's recurse on it |
1682 |
return SnapshotBlockDevice(disk.children[0])
|
|
1682 |
return BlockdevSnapshot(disk.children[0])
|
|
1683 | 1683 |
else: |
1684 | 1684 |
# more than one child, choose one that matches |
1685 | 1685 |
for child in disk.children: |
1686 | 1686 |
if child.size == disk.size: |
1687 | 1687 |
# return implies breaking the loop |
1688 |
return SnapshotBlockDevice(child)
|
|
1688 |
return BlockdevSnapshot(child)
|
|
1689 | 1689 |
elif disk.dev_type == constants.LD_LV: |
1690 | 1690 |
r_dev = _RecursiveFindBD(disk) |
1691 | 1691 |
if r_dev is not None: |
... | ... | |
1935 | 1935 |
return True |
1936 | 1936 |
|
1937 | 1937 |
|
1938 |
def RenameBlockDevices(devlist):
|
|
1938 |
def BlockdevRename(devlist):
|
|
1939 | 1939 |
"""Rename a list of block devices. |
1940 | 1940 |
|
1941 | 1941 |
@type devlist: list of tuples |
... | ... | |
2177 | 2177 |
return True |
2178 | 2178 |
|
2179 | 2179 |
|
2180 |
def CloseBlockDevices(instance_name, disks):
|
|
2180 |
def BlockdevClose(instance_name, disks):
|
|
2181 | 2181 |
"""Closes the given block devices. |
2182 | 2182 |
|
2183 | 2183 |
This means they will be switched to secondary mode (in case of |
Also available in: Unified diff