1270 |
1270 |
try:
|
1271 |
1271 |
for idx, (dev, (host, port, magic)) in enumerate(zip(instance.disks,
|
1272 |
1272 |
disk_info)):
|
|
1273 |
# Decide whether to use IPv6
|
|
1274 |
ipv6 = netutils.IP6Address.IsValid(host)
|
|
1275 |
|
1273 |
1276 |
opts = objects.ImportExportOptions(key_name=key_name,
|
1274 |
1277 |
ca_pem=dest_ca_pem,
|
1275 |
|
magic=magic)
|
|
1278 |
magic=magic, ipv6=ipv6)
|
1276 |
1279 |
|
1277 |
1280 |
self._feedback_fn("Sending disk %s to %s:%s" % (idx, host, port))
|
1278 |
1281 |
finished_fn = compat.partial(self._TransferFinished, idx)
|
... | ... | |
1404 |
1407 |
self._dresults[idx] = bool(ie.success)
|
1405 |
1408 |
|
1406 |
1409 |
|
1407 |
|
def RemoteImport(lu, feedback_fn, instance, source_x509_ca, cds, timeouts):
|
|
1410 |
def RemoteImport(lu, feedback_fn, instance, pnode, source_x509_ca,
|
|
1411 |
cds, timeouts):
|
1408 |
1412 |
"""Imports an instance from another cluster.
|
1409 |
1413 |
|
1410 |
1414 |
@param lu: Logical unit instance
|
1411 |
1415 |
@param feedback_fn: Feedback function
|
1412 |
1416 |
@type instance: L{objects.Instance}
|
1413 |
1417 |
@param instance: Instance object
|
|
1418 |
@type pnode: L{objects.Node}
|
|
1419 |
@param pnode: Primary node of instance as an object
|
1414 |
1420 |
@type source_x509_ca: OpenSSL.crypto.X509
|
1415 |
1421 |
@param source_x509_ca: Import source's X509 CA
|
1416 |
1422 |
@type cds: string
|
... | ... | |
1424 |
1430 |
|
1425 |
1431 |
magic_base = utils.GenerateSecret(6)
|
1426 |
1432 |
|
|
1433 |
# Decide whether to use IPv6
|
|
1434 |
ipv6 = netutils.IP6Address.IsValid(pnode.primary_ip)
|
|
1435 |
|
1427 |
1436 |
# Create crypto key
|
1428 |
1437 |
result = lu.rpc.call_x509_cert_create(instance.primary_node,
|
1429 |
1438 |
constants.RIE_CERT_VALIDITY)
|
... | ... | |
1440 |
1449 |
utils.SignX509Certificate(x509_cert, cds, utils.GenerateSecret(8))
|
1441 |
1450 |
|
1442 |
1451 |
cbs = _RemoteImportCb(feedback_fn, cds, signed_x509_cert_pem,
|
1443 |
|
len(instance.disks), instance.primary_node)
|
|
1452 |
len(instance.disks), pnode.primary_ip)
|
1444 |
1453 |
|
1445 |
1454 |
ieloop = ImportExportLoop(lu)
|
1446 |
1455 |
try:
|
... | ... | |
1450 |
1459 |
# Import daemon options
|
1451 |
1460 |
opts = objects.ImportExportOptions(key_name=x509_key_name,
|
1452 |
1461 |
ca_pem=source_ca_pem,
|
1453 |
|
magic=magic)
|
|
1462 |
magic=magic, ipv6=ipv6)
|
1454 |
1463 |
|
1455 |
1464 |
ieloop.Add(DiskImport(lu, instance.primary_node, opts, instance,
|
1456 |
1465 |
constants.IEIO_SCRIPT, (dev, idx),
|
... | ... | |
1554 |
1563 |
if not utils.VerifySha1Hmac(cds, msg, hmac_digest, salt=hmac_salt):
|
1555 |
1564 |
raise errors.GenericError("HMAC is wrong")
|
1556 |
1565 |
|
1557 |
|
return (netutils.Hostname.GetNormalizedName(host),
|
|
1566 |
if netutils.IP6Address.IsValid(host) or netutils.IP4Address.IsValid(host):
|
|
1567 |
destination = host
|
|
1568 |
else:
|
|
1569 |
destination = netutils.Hostname.GetNormalizedName(host)
|
|
1570 |
|
|
1571 |
return (destination,
|
1558 |
1572 |
utils.ValidateServiceName(port),
|
1559 |
1573 |
magic)
|
1560 |
1574 |
|