Revision 821d1bd1
b/daemons/ganeti-noded | ||
---|---|---|
113 | 113 |
bdev = objects.Disk.FromDict(bdev_s) |
114 | 114 |
if bdev is None: |
115 | 115 |
raise ValueError("can't unserialize data!") |
116 |
return backend.CreateBlockDevice(bdev, size, owner, on_primary, info)
|
|
116 |
return backend.BlockdevCreate(bdev, size, owner, on_primary, info)
|
|
117 | 117 |
|
118 | 118 |
@staticmethod |
119 | 119 |
def perspective_blockdev_remove(params): |
... | ... | |
122 | 122 |
""" |
123 | 123 |
bdev_s = params[0] |
124 | 124 |
bdev = objects.Disk.FromDict(bdev_s) |
125 |
return backend.RemoveBlockDevice(bdev)
|
|
125 |
return backend.BlockdevRemove(bdev)
|
|
126 | 126 |
|
127 | 127 |
@staticmethod |
128 | 128 |
def perspective_blockdev_rename(params): |
... | ... | |
130 | 130 |
|
131 | 131 |
""" |
132 | 132 |
devlist = [(objects.Disk.FromDict(ds), uid) for ds, uid in params] |
133 |
return backend.RenameBlockDevices(devlist)
|
|
133 |
return backend.BlockdevRename(devlist)
|
|
134 | 134 |
|
135 | 135 |
@staticmethod |
136 | 136 |
def perspective_blockdev_assemble(params): |
... | ... | |
141 | 141 |
bdev = objects.Disk.FromDict(bdev_s) |
142 | 142 |
if bdev is None: |
143 | 143 |
raise ValueError("can't unserialize data!") |
144 |
return backend.AssembleBlockDevice(bdev, owner, on_primary)
|
|
144 |
return backend.BlockdevAssemble(bdev, owner, on_primary)
|
|
145 | 145 |
|
146 | 146 |
@staticmethod |
147 | 147 |
def perspective_blockdev_shutdown(params): |
... | ... | |
152 | 152 |
bdev = objects.Disk.FromDict(bdev_s) |
153 | 153 |
if bdev is None: |
154 | 154 |
raise ValueError("can't unserialize data!") |
155 |
return backend.ShutdownBlockDevice(bdev)
|
|
155 |
return backend.BlockdevShutdown(bdev)
|
|
156 | 156 |
|
157 | 157 |
@staticmethod |
158 | 158 |
def perspective_blockdev_addchildren(params): |
... | ... | |
167 | 167 |
ndevs = [objects.Disk.FromDict(disk_s) for disk_s in ndev_s] |
168 | 168 |
if bdev is None or ndevs.count(None) > 0: |
169 | 169 |
raise ValueError("can't unserialize data!") |
170 |
return backend.MirrorAddChildren(bdev, ndevs)
|
|
170 |
return backend.BlockdevAddchildren(bdev, ndevs)
|
|
171 | 171 |
|
172 | 172 |
@staticmethod |
173 | 173 |
def perspective_blockdev_removechildren(params): |
... | ... | |
182 | 182 |
ndevs = [objects.Disk.FromDict(disk_s) for disk_s in ndev_s] |
183 | 183 |
if bdev is None or ndevs.count(None) > 0: |
184 | 184 |
raise ValueError("can't unserialize data!") |
185 |
return backend.MirrorRemoveChildren(bdev, ndevs)
|
|
185 |
return backend.BlockdevRemovechildren(bdev, ndevs)
|
|
186 | 186 |
|
187 | 187 |
@staticmethod |
188 | 188 |
def perspective_blockdev_getmirrorstatus(params): |
... | ... | |
191 | 191 |
""" |
192 | 192 |
disks = [objects.Disk.FromDict(dsk_s) |
193 | 193 |
for dsk_s in params] |
194 |
return backend.GetMirrorStatus(disks)
|
|
194 |
return backend.BlockdevGetmirrorstatus(disks)
|
|
195 | 195 |
|
196 | 196 |
@staticmethod |
197 | 197 |
def perspective_blockdev_find(params): |
... | ... | |
201 | 201 |
|
202 | 202 |
""" |
203 | 203 |
disk = objects.Disk.FromDict(params[0]) |
204 |
return backend.CallBlockdevFind(disk)
|
|
204 |
return backend.BlockdevFind(disk) |
|
205 | 205 |
|
206 | 206 |
@staticmethod |
207 | 207 |
def perspective_blockdev_snapshot(params): |
... | ... | |
213 | 213 |
|
214 | 214 |
""" |
215 | 215 |
cfbd = objects.Disk.FromDict(params[0]) |
216 |
return backend.SnapshotBlockDevice(cfbd)
|
|
216 |
return backend.BlockdevSnapshot(cfbd)
|
|
217 | 217 |
|
218 | 218 |
@staticmethod |
219 | 219 |
def perspective_blockdev_grow(params): |
... | ... | |
222 | 222 |
""" |
223 | 223 |
cfbd = objects.Disk.FromDict(params[0]) |
224 | 224 |
amount = params[1] |
225 |
return backend.GrowBlockDevice(cfbd, amount)
|
|
225 |
return backend.BlockdevGrow(cfbd, amount)
|
|
226 | 226 |
|
227 | 227 |
@staticmethod |
228 | 228 |
def perspective_blockdev_close(params): |
... | ... | |
230 | 230 |
|
231 | 231 |
""" |
232 | 232 |
disks = [objects.Disk.FromDict(cf) for cf in params[1]] |
233 |
return backend.CloseBlockDevices(params[0], disks)
|
|
233 |
return backend.BlockdevClose(params[0], disks)
|
|
234 | 234 |
|
235 | 235 |
# blockdev/drbd specific methods ---------- |
236 | 236 |
|
... | ... | |
256 | 256 |
""" |
257 | 257 |
nodes_ip, disks, instance_name, multimaster = params |
258 | 258 |
disks = [objects.Disk.FromDict(cf) for cf in disks] |
259 |
return backend.DrbdAttachNet(nodes_ip, disks, instance_name, multimaster) |
|
259 |
return backend.DrbdAttachNet(nodes_ip, disks, |
|
260 |
instance_name, multimaster) |
|
260 | 261 |
|
261 | 262 |
@staticmethod |
262 | 263 |
def perspective_drbd_wait_sync(params): |
... | ... | |
593 | 594 |
"""Query detailed information about existing OSes. |
594 | 595 |
|
595 | 596 |
""" |
596 |
return [os.ToDict() for os in backend.DiagnoseOS()]
|
|
597 |
return [os_obj.ToDict() for os_obj in backend.DiagnoseOS()]
|
|
597 | 598 |
|
598 | 599 |
@staticmethod |
599 | 600 |
def perspective_os_get(params): |
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 |
b/lib/cmdlib.py | ||
---|---|---|
3832 | 3832 |
(this will be represented as a LVM tag) |
3833 | 3833 |
@type force_open: boolean |
3834 | 3834 |
@param force_open: this parameter will be passes to the |
3835 |
L{backend.CreateBlockDevice} function where it specifies
|
|
3835 |
L{backend.BlockdevCreate} function where it specifies
|
|
3836 | 3836 |
whether we run on primary or not, and it affects both |
3837 | 3837 |
the child assembly and the device own Open() execution |
3838 | 3838 |
|
... | ... | |
3867 | 3867 |
(this will be represented as a LVM tag) |
3868 | 3868 |
@type force_open: boolean |
3869 | 3869 |
@param force_open: this parameter will be passes to the |
3870 |
L{backend.CreateBlockDevice} function where it specifies
|
|
3870 |
L{backend.BlockdevCreate} function where it specifies
|
|
3871 | 3871 |
whether we run on primary or not, and it affects both |
3872 | 3872 |
the child assembly and the device own Open() execution |
3873 | 3873 |
|
Also available in: Unified diff