Revision 1ecc03c1
b/lib/backend.py | ||
---|---|---|
3081 | 3081 |
return BlockdevSnapshot(disk.children[0]) |
3082 | 3082 |
elif disk.dev_type == constants.DT_PLAIN: |
3083 | 3083 |
return _DiskSnapshot(disk) |
3084 |
elif disk.dev_type == constants.DT_EXT: |
|
3085 |
return _DiskSnapshot(disk) |
|
3084 | 3086 |
else: |
3085 |
_Fail("Cannot snapshot non-lvm block device '%s' of type '%s'",
|
|
3087 |
_Fail("Cannot snapshot block device '%s' of type '%s'", |
|
3086 | 3088 |
disk.logical_id, disk.dev_type) |
3087 | 3089 |
|
3088 | 3090 |
|
b/lib/masterd/instance.py | ||
---|---|---|
1194 | 1194 |
" result '%s'", idx, src_node_name, result.payload) |
1195 | 1195 |
else: |
1196 | 1196 |
disk_id = tuple(result.payload) |
1197 |
disk_params = constants.DISK_LD_DEFAULTS[constants.DT_PLAIN].copy() |
|
1198 |
new_dev = objects.Disk(dev_type=constants.DT_PLAIN, size=disk.size, |
|
1197 |
# Snapshot is currently supported for ExtStorage and LogicalVolume. |
|
1198 |
# In case disk is of type drbd the snapshot will be of type plain. |
|
1199 |
if disk.dev_type == constants.DT_EXT: |
|
1200 |
dev_type = constants.DT_EXT |
|
1201 |
else: |
|
1202 |
dev_type = constants.DT_PLAIN |
|
1203 |
disk_params = constants.DISK_LD_DEFAULTS[dev_type].copy() |
|
1204 |
new_dev = objects.Disk(dev_type=dev_type, size=disk.size, |
|
1199 | 1205 |
logical_id=disk_id, iv_name=disk.iv_name, |
1200 | 1206 |
params=disk_params) |
1201 | 1207 |
|
b/lib/objects.py | ||
---|---|---|
1340 | 1340 |
"detach_script", |
1341 | 1341 |
"setinfo_script", |
1342 | 1342 |
"verify_script", |
1343 |
"snapshot_script", |
|
1343 | 1344 |
"supported_parameters", |
1344 | 1345 |
] |
1345 | 1346 |
|
b/lib/storage/extstorage.py | ||
---|---|---|
257 | 257 |
" ExtStorage provider for the '%s' hypervisor" |
258 | 258 |
% (self.driver, hypervisor)) |
259 | 259 |
|
260 |
def Snapshot(self, snap_name=None, snap_size=None): |
|
261 |
"""Take a snapshot of the block device. |
|
262 |
|
|
263 |
""" |
|
264 |
provider, vol_name = self.unique_id |
|
265 |
if not snap_name: |
|
266 |
snap_name = vol_name + ".snap" |
|
267 |
if not snap_size: |
|
268 |
snap_size = self.size |
|
269 |
|
|
270 |
_ExtStorageAction(constants.ES_ACTION_SNAPSHOT, self.unique_id, |
|
271 |
self.ext_params, snap_name=snap_name, snap_size=snap_size) |
|
272 |
|
|
273 |
return (provider, snap_name) |
|
274 |
|
|
260 | 275 |
|
261 | 276 |
def _ExtStorageAction(action, unique_id, ext_params, |
262 | 277 |
size=None, grow=None, metadata=None, |
263 |
name=None, uuid=None): |
|
278 |
name=None, uuid=None, |
|
279 |
snap_name=None, snap_size=None): |
|
264 | 280 |
"""Take an External Storage action. |
265 | 281 |
|
266 | 282 |
Take an External Storage action concerning or affecting |
... | ... | |
268 | 284 |
|
269 | 285 |
@type action: string |
270 | 286 |
@param action: which action to perform. One of: |
271 |
create / remove / grow / attach / detach |
|
287 |
create / remove / grow / attach / detach / snapshot
|
|
272 | 288 |
@type unique_id: tuple (driver, vol_name) |
273 | 289 |
@param unique_id: a tuple containing the type of ExtStorage (driver) |
274 | 290 |
and the Volume name |
... | ... | |
283 | 299 |
@type name: string |
284 | 300 |
@param name: name of the Volume (objects.Disk.name) |
285 | 301 |
@type uuid: string |
302 |
@type snap_size: integer |
|
303 |
@param snap_size: the size of the snapshot |
|
304 |
@type snap_name: string |
|
305 |
@param snap_name: the name of the snapshot |
|
286 | 306 |
@param uuid: uuid of the Volume (objects.Disk.uuid) |
287 | 307 |
@rtype: None or a block device path (during attach) |
288 | 308 |
|
... | ... | |
296 | 316 |
|
297 | 317 |
# Create the basic environment for the driver's scripts |
298 | 318 |
create_env = _ExtStorageEnvironment(unique_id, ext_params, size, |
299 |
grow, metadata, name, uuid) |
|
319 |
grow, metadata, name, uuid, |
|
320 |
snap_name, snap_size) |
|
300 | 321 |
|
301 | 322 |
# Do not use log file for action `attach' as we need |
302 | 323 |
# to get the output from RunResult |
... | ... | |
408 | 429 |
detach_script=es_files[constants.ES_SCRIPT_DETACH], |
409 | 430 |
setinfo_script=es_files[constants.ES_SCRIPT_SETINFO], |
410 | 431 |
verify_script=es_files[constants.ES_SCRIPT_VERIFY], |
432 |
snapshot_script=es_files[constants.ES_SCRIPT_SNAPSHOT], |
|
411 | 433 |
supported_parameters=parameters) |
412 | 434 |
return True, es_obj |
413 | 435 |
|
414 | 436 |
|
415 | 437 |
def _ExtStorageEnvironment(unique_id, ext_params, |
416 | 438 |
size=None, grow=None, metadata=None, |
417 |
name=None, uuid=None): |
|
439 |
name=None, uuid=None, |
|
440 |
snap_name=None, snap_size=None): |
|
418 | 441 |
"""Calculate the environment for an External Storage script. |
419 | 442 |
|
420 | 443 |
@type unique_id: tuple (driver, vol_name) |
... | ... | |
431 | 454 |
@param name: name of the Volume (objects.Disk.name) |
432 | 455 |
@type uuid: string |
433 | 456 |
@param uuid: uuid of the Volume (objects.Disk.uuid) |
457 |
@type snap_size: integer |
|
458 |
@param snap_size: the size of the snapshot |
|
459 |
@type snap_name: string |
|
460 |
@param snap_name: the name of the snapshot |
|
434 | 461 |
@rtype: dict |
435 | 462 |
@return: dict of environment variables |
436 | 463 |
|
... | ... | |
459 | 486 |
if uuid is not None: |
460 | 487 |
result["VOL_UUID"] = uuid |
461 | 488 |
|
489 |
if snap_name is not None: |
|
490 |
result["VOL_SNAPSHOT_NAME"] = snap_name |
|
491 |
|
|
492 |
if snap_size is not None: |
|
493 |
result["VOL_SNAPSHOT_SIZE"] = snap_size |
|
494 |
|
|
462 | 495 |
return result |
463 | 496 |
|
464 | 497 |
|
b/src/Ganeti/Constants.hs | ||
---|---|---|
1334 | 1334 |
esActionVerify :: String |
1335 | 1335 |
esActionVerify = "verify" |
1336 | 1336 |
|
1337 |
esActionSnapshot :: String |
|
1338 |
esActionSnapshot = "snapshot" |
|
1339 |
|
|
1337 | 1340 |
esScriptCreate :: String |
1338 | 1341 |
esScriptCreate = esActionCreate |
1339 | 1342 |
|
... | ... | |
1355 | 1358 |
esScriptVerify :: String |
1356 | 1359 |
esScriptVerify = esActionVerify |
1357 | 1360 |
|
1361 |
esScriptSnapshot :: String |
|
1362 |
esScriptSnapshot = esActionSnapshot |
|
1363 |
|
|
1358 | 1364 |
esScripts :: FrozenSet String |
1359 | 1365 |
esScripts = |
1360 | 1366 |
ConstantUtils.mkSet [esScriptAttach, |
... | ... | |
1363 | 1369 |
esScriptGrow, |
1364 | 1370 |
esScriptRemove, |
1365 | 1371 |
esScriptSetinfo, |
1366 |
esScriptVerify] |
|
1372 |
esScriptVerify, |
|
1373 |
esScriptSnapshot] |
|
1367 | 1374 |
|
1368 | 1375 |
esParametersFile :: String |
1369 | 1376 |
esParametersFile = "parameters.list" |
Also available in: Unified diff