Commit ba5619c2 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Use IPv6 for import/export


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 855d2fc7
......@@ -7802,9 +7802,11 @@ class LUCreateInstance(LogicalUnit):
connect_timeout = constants.RIE_CONNECT_TIMEOUT
timeouts = masterd.instance.ImportExportTimeouts(connect_timeout)
disk_results = masterd.instance.RemoteImport(self, feedback_fn, iobj,
self.source_x509_ca,
self._cds, timeouts)
assert iobj.primary_node == self.pnode.name
disk_results = \
masterd.instance.RemoteImport(self, feedback_fn, iobj, self.pnode,
self.source_x509_ca,
self._cds, timeouts)
if not compat.all(disk_results):
# TODO: Should the instance still be started, even if some disks
# failed to import (valid for local imports, too)?
......@@ -9551,7 +9553,6 @@ class LUSetInstanceParams(LogicalUnit):
self.LogWarning("Could not remove metadata for disk %d on node %s,"
" continuing anyway: %s", idx, pnode, msg)
def Exec(self, feedback_fn):
"""Modifies an instance.
......
......@@ -1270,9 +1270,12 @@ class ExportInstanceHelper:
try:
for idx, (dev, (host, port, magic)) in enumerate(zip(instance.disks,
disk_info)):
# Decide whether to use IPv6
ipv6 = netutils.IP6Address.IsValid(host)
opts = objects.ImportExportOptions(key_name=key_name,
ca_pem=dest_ca_pem,
magic=magic)
magic=magic, ipv6=ipv6)
self._feedback_fn("Sending disk %s to %s:%s" % (idx, host, port))
finished_fn = compat.partial(self._TransferFinished, idx)
......@@ -1404,13 +1407,16 @@ class _RemoteImportCb(ImportExportCbBase):
self._dresults[idx] = bool(ie.success)
def RemoteImport(lu, feedback_fn, instance, source_x509_ca, cds, timeouts):
def RemoteImport(lu, feedback_fn, instance, pnode, source_x509_ca,
cds, timeouts):
"""Imports an instance from another cluster.
@param lu: Logical unit instance
@param feedback_fn: Feedback function
@type instance: L{objects.Instance}
@param instance: Instance object
@type pnode: L{objects.Node}
@param pnode: Primary node of instance as an object
@type source_x509_ca: OpenSSL.crypto.X509
@param source_x509_ca: Import source's X509 CA
@type cds: string
......@@ -1424,6 +1430,9 @@ def RemoteImport(lu, feedback_fn, instance, source_x509_ca, cds, timeouts):
magic_base = utils.GenerateSecret(6)
# Decide whether to use IPv6
ipv6 = netutils.IP6Address.IsValid(pnode.primary_ip)
# Create crypto key
result = lu.rpc.call_x509_cert_create(instance.primary_node,
constants.RIE_CERT_VALIDITY)
......@@ -1440,7 +1449,7 @@ def RemoteImport(lu, feedback_fn, instance, source_x509_ca, cds, timeouts):
utils.SignX509Certificate(x509_cert, cds, utils.GenerateSecret(8))
cbs = _RemoteImportCb(feedback_fn, cds, signed_x509_cert_pem,
len(instance.disks), instance.primary_node)
len(instance.disks), pnode.primary_ip)
ieloop = ImportExportLoop(lu)
try:
......@@ -1450,7 +1459,7 @@ def RemoteImport(lu, feedback_fn, instance, source_x509_ca, cds, timeouts):
# Import daemon options
opts = objects.ImportExportOptions(key_name=x509_key_name,
ca_pem=source_ca_pem,
magic=magic)
magic=magic, ipv6=ipv6)
ieloop.Add(DiskImport(lu, instance.primary_node, opts, instance,
constants.IEIO_SCRIPT, (dev, idx),
......@@ -1554,7 +1563,12 @@ def CheckRemoteExportDiskInfo(cds, disk_index, disk_info):
if not utils.VerifySha1Hmac(cds, msg, hmac_digest, salt=hmac_salt):
raise errors.GenericError("HMAC is wrong")
return (netutils.Hostname.GetNormalizedName(host),
if netutils.IP6Address.IsValid(host) or netutils.IP4Address.IsValid(host):
destination = host
else:
destination = netutils.Hostname.GetNormalizedName(host)
return (destination,
utils.ValidateServiceName(port),
magic)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment