69
66
def _clone_helper(self, filebase, disks=None, force_list=None,
70
skip_list=None, compare=True):
67
skip_list=None, compare=True, useconn=None):
71
68
"""Helper for comparing clone input/output from 2 xml files"""
72
69
infile = os.path.join(clonexml_dir, filebase + "-in.xml")
73
70
in_content = utils.read_file(infile)
75
cloneobj = CloneDesign(conn=conn)
72
cloneobj = CloneDesign(conn=useconn or conn)
76
73
cloneobj.original_xml = in_content
77
74
for force in force_list or []:
78
75
cloneobj.force_target = force
92
89
cloneobj.clone_name = "clone-new"
93
90
cloneobj.clone_uuid = "12345678-1234-1234-1234-123456789012"
95
cloneobj.clone_mac = "01:23:45:67:89:00"
96
cloneobj.clone_mac = "01:23:45:67:89:01"
92
cloneobj.clone_mac = "22:23:45:67:89:00"
93
cloneobj.clone_mac = "22:23:45:67:89:01"
152
149
def testRemoteNoStorage(self):
153
150
"""Test remote clone where VM has no storage that needs cloning"""
154
oldfunc = CloneManager._util.is_uri_remote
156
CloneManager._util.is_uri_remote = fake_is_uri_remote
158
for base in [ "nostorage", "noclone-storage" ] :
159
self._clone_helper(base, disks=[])
162
CloneManager._util.is_uri_remote = oldfunc
151
useconn = utils.open_test_remote()
152
for base in [ "nostorage", "noclone-storage" ] :
153
self._clone_helper(base, disks=[], useconn=useconn)
164
155
def testRemoteWithStorage(self):
166
157
Test remote clone with storage needing cloning. Should fail,
167
158
since libvirt has no storage clone api.
169
oldfunc = CloneManager._util.is_uri_remote
171
CloneManager._util.is_uri_remote = fake_is_uri_remote
173
for base in [ "general-cfg" ] :
175
self._clone_helper(base, disks=["%s/1.img" % POOL1,
178
# We shouldn't succeed, so test fails
179
raise AssertionError("Remote clone with storage passed "
180
"when it shouldn't.")
181
except (ValueError, RuntimeError), e:
183
logging.debug("Received expected exception: %s", str(e))
185
CloneManager._util.is_uri_remote = oldfunc
160
useconn = utils.open_test_remote()
161
for base in [ "general-cfg" ] :
163
self._clone_helper(base,
164
disks=["%s/1.img" % POOL1,
168
# We shouldn't succeed, so test fails
169
raise AssertionError("Remote clone with storage passed "
170
"when it shouldn't.")
171
except (ValueError, RuntimeError), e:
173
logging.debug("Received expected exception: %s", str(e))
187
175
def testCloneStorage(self):
188
176
base = "managed-storage"