Revision 74c47259 lib/backend.py
b/lib/backend.py | ||
---|---|---|
1331 | 1331 |
(disk.unique_id, disk.dev_type)) |
1332 | 1332 |
|
1333 | 1333 |
|
1334 |
def ExportSnapshot(disk, dest_node, instance, cluster_name): |
|
1334 |
def ExportSnapshot(disk, dest_node, instance, cluster_name, idx):
|
|
1335 | 1335 |
"""Export a block device snapshot to a remote node. |
1336 | 1336 |
|
1337 |
Args: |
|
1338 |
disk: the snapshot block device |
|
1339 |
dest_node: the node to send the image to |
|
1340 |
instance: instance being exported |
|
1341 |
|
|
1342 |
Returns: |
|
1343 |
True if successful, False otherwise. |
|
1337 |
@type disk: L{objects.Disk} |
|
1338 |
@param disk: the description of the disk to export |
|
1339 |
@type dest_node: str |
|
1340 |
@param dest_node: the destination node to export to |
|
1341 |
@type instance: L{objects.Instance} |
|
1342 |
@param instance: the instance object to whom the disk belongs |
|
1343 |
@type cluster_name: str |
|
1344 |
@param cluster_name: the cluster name, needed for SSH hostalias |
|
1345 |
@type idx: int |
|
1346 |
@param idx: the index of the disk in the instance's disk list, |
|
1347 |
used to export to the OS scripts environment |
|
1348 |
@rtype: bool |
|
1349 |
@return: the success of the operation |
|
1344 | 1350 |
|
1345 | 1351 |
""" |
1346 | 1352 |
export_env = OSEnvironment(instance) |
... | ... | |
1359 | 1365 |
real_disk.Open() |
1360 | 1366 |
|
1361 | 1367 |
export_env['EXPORT_DEVICE'] = real_disk.dev_path |
1368 |
export_env['EXPORT_INDEX'] = str(idx) |
|
1362 | 1369 |
|
1363 | 1370 |
destdir = os.path.join(constants.EXPORT_DIR, instance.name + ".new") |
1364 | 1371 |
destfile = disk.physical_id[1] |
... | ... | |
1512 | 1519 |
destcmd) |
1513 | 1520 |
command = '|'.join([utils.ShellQuoteArgs(remotecmd), comprcmd, impcmd]) |
1514 | 1521 |
import_env['IMPORT_DEVICE'] = import_env['DISK_%d_PATH' % idx] |
1522 |
import_env['IMPORT_INDEX'] = str(idx) |
|
1515 | 1523 |
result = utils.RunCmd(command, env=import_env) |
1516 | 1524 |
if result.failed: |
1517 | 1525 |
logging.error("disk import command '%s' returned error: %s" |
Also available in: Unified diff