2015-04-01 21:07:51 +08:00
|
|
|
# Copyright (C) 2013, 2015 Red Hat, Inc.
|
2013-03-18 05:06:52 +08:00
|
|
|
#
|
2018-04-04 21:35:41 +08:00
|
|
|
# This work is licensed under the GNU GPLv2 or later.
|
2018-03-21 03:00:02 +08:00
|
|
|
# See the COPYING file in the top-level directory.
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
import os
|
2020-09-04 00:03:38 +08:00
|
|
|
import tempfile
|
2013-03-18 05:06:52 +08:00
|
|
|
|
2013-04-11 07:48:07 +08:00
|
|
|
from tests import utils
|
2013-03-18 05:06:52 +08:00
|
|
|
|
2013-07-03 06:30:46 +08:00
|
|
|
from virtinst import Cloner
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
|
2020-09-04 00:03:38 +08:00
|
|
|
CLI_XMLDIR = utils.DATADIR + "/cli/clone/"
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
|
2020-09-04 00:03:38 +08:00
|
|
|
def test_clone_unmanaged():
|
|
|
|
"""
|
|
|
|
Test that unmanaged storage duplication via the clone wizard
|
|
|
|
actually copies data
|
|
|
|
"""
|
|
|
|
xmlpath = CLI_XMLDIR + "clone-disk.xml"
|
|
|
|
conn = utils.URIs.open_testdriver_cached()
|
|
|
|
xml = open(xmlpath).read()
|
2013-03-18 05:06:52 +08:00
|
|
|
|
2020-09-04 00:03:38 +08:00
|
|
|
tmp1 = tempfile.NamedTemporaryFile()
|
|
|
|
tmp2 = tempfile.NamedTemporaryFile()
|
|
|
|
inp1 = os.path.abspath(__file__)
|
|
|
|
inp2 = xmlpath
|
2013-03-18 05:06:52 +08:00
|
|
|
|
2020-09-04 00:03:38 +08:00
|
|
|
xml = xml.replace("/tmp/__virtinst_cli_exist1.img", inp1)
|
|
|
|
xml = xml.replace("/tmp/__virtinst_cli_exist2.img", inp2)
|
|
|
|
cloner = Cloner(conn, src_xml=xml)
|
2013-04-14 02:34:52 +08:00
|
|
|
|
2020-09-04 00:03:38 +08:00
|
|
|
diskinfos = cloner.get_diskinfos_to_clone()
|
|
|
|
assert len(diskinfos) == 2
|
|
|
|
diskinfos[0].set_clone_path(tmp1.name, True, False)
|
|
|
|
diskinfos[1].set_clone_path(tmp2.name, True, False)
|
2013-03-18 05:06:52 +08:00
|
|
|
|
2020-09-04 00:03:38 +08:00
|
|
|
cloner.prepare()
|
|
|
|
cloner.start_duplicate(None)
|
2013-03-18 05:06:52 +08:00
|
|
|
|
2020-09-04 00:03:38 +08:00
|
|
|
assert open(tmp1.name).read() == open(inp1).read()
|
|
|
|
assert open(tmp2.name).read() == open(inp2).read()
|