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

Allow control of import/export compression method



For exports to/imports from the same machine, compression will
not be used anymore.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent eb630f50
......@@ -2697,6 +2697,9 @@ def StartImportExportDaemon(mode, opts, host, port, instance, ieio, ieioargs):
if port:
cmd.append("--port=%s" % port)
if opts.compress:
cmd.append("--compress=%s" % opts.compress)
if cmd_prefix:
cmd.append("--cmd-prefix=%s" % cmd_prefix)
......
......@@ -743,7 +743,7 @@ class ImportExportLoop:
class _TransferInstCbBase(ImportExportCbBase):
def __init__(self, lu, feedback_fn, instance, timeouts, src_node, src_cbs,
dest_node, dest_ip):
dest_node, dest_ip, export_opts):
"""Initializes this class.
"""
......@@ -757,6 +757,7 @@ class _TransferInstCbBase(ImportExportCbBase):
self.src_cbs = src_cbs
self.dest_node = dest_node
self.dest_ip = dest_ip
self.export_opts = export_opts
class _TransferInstSourceCb(_TransferInstCbBase):
......@@ -808,10 +809,9 @@ class _TransferInstDestCb(_TransferInstCbBase):
self.feedback_fn("%s is now listening, starting export" % dtp.data.name)
opts = objects.ImportExportOptions(key_name=None, ca_pem=None)
# Start export on source node
de = DiskExport(self.lu, self.src_node, opts, self.dest_ip, ie.listen_port,
de = DiskExport(self.lu, self.src_node, self.export_opts,
self.dest_ip, ie.listen_port,
self.instance, dtp.data.src_io, dtp.data.src_ioargs,
self.timeouts, self.src_cbs, private=dtp)
ie.loop.Add(de)
......@@ -914,12 +914,23 @@ def TransferInstanceData(lu, feedback_fn, src_node, dest_node, dest_ip,
each transfer
"""
opts = objects.ImportExportOptions(key_name=None, ca_pem=None)
# Compress only if transfer is to another node
if src_node == dest_node:
compress = constants.IEC_NONE
else:
compress = constants.IEC_GZIP
logging.debug("Source node %s, destination node %s, compression '%s'",
src_node, dest_node, compress)
opts = objects.ImportExportOptions(key_name=None, ca_pem=None,
compress=compress)
timeouts = ImportExportTimeouts(constants.DISK_TRANSFER_CONNECT_TIMEOUT)
src_cbs = _TransferInstSourceCb(lu, feedback_fn, instance, timeouts,
src_node, None, dest_node, dest_ip)
src_node, None, dest_node, dest_ip, opts)
dest_cbs = _TransferInstDestCb(lu, feedback_fn, instance, timeouts,
src_node, src_cbs, dest_node, dest_ip)
src_node, src_cbs, dest_node, dest_ip, opts)
all_dtp = []
......
......@@ -1027,11 +1027,13 @@ class ImportExportOptions(ConfigObject):
@ivar key_name: X509 key name (None for cluster certificate)
@ivar ca_pem: Remote peer CA in PEM format (None for cluster certificate)
@ivar compress: Compression method (one of L{constants.IEC_ALL})
"""
__slots__ = [
"key_name",
"ca_pem",
"compress",
]
......
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