Skip to content
This repository was archived by the owner on Jul 21, 2023. It is now read-only.

Commit 1c06050

Browse files
nertpinxnyoxi
authored andcommittedJan 29, 2020
Implement first phase of two-phase conversion
This commit implements the first phase of the two-phase conversion, basically everything unrelated to the actual output mode. This also adds parsing of one more piece of information (paths to created overlays -- currently an implementation detail which is not supposed to be exposed and will be refactored later) into `log_parser.py`. Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
1 parent 5834fba commit 1c06050

16 files changed

+902
-22
lines changed
 

‎.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ addons:
1919
packages:
2020
- python-pip
2121
- libgnutls.dev # required by pycurl
22+
- libvirt.dev
2223

2324
install:
2425
- pip install tox

‎Pipfile

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ name = "pypi"
77
ovirt-engine-sdk-python = "*"
88
pycurl = "*"
99
six = "*"
10+
libvirt-python = "*"
11+
pyvmomi = "*"
12+
packaging = "*"
13+
# TODO: Uncomment this when it becomes available in pypi and also do the same in
14+
# setup.py, add it to requirements.txt and remove the mocked nbd.py
15+
# libnbd-python = ">1.0.0"
1016

1117
[dev-packages]
1218
yamllint = "*"

‎docs/Virt-v2v-wrapper.md

+13-4
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ Example:
154154
State file is a JSON file. Its content changes as the conversion goes through
155155
various stages. With it also the keys present in the file.
156156

157-
If two-phase conversion is selected there will be a key `pre_copy` with various
158-
information related to the first (pre-copy) phase of the conversion. The
159-
particular keys and information is, at the time of this writing, subject to
160-
change, but whould be as self-explanatory as possible.
157+
the output differs based on the type of conversion that is running:
158+
159+
<a id="anchor_onephase"></a>
160+
### One-Phase Conversion
161161

162162
Once virt-v2v is executed the state file is created with the following keys:
163163

@@ -203,6 +203,15 @@ Right before the wrapper terminates it updates the state with:
203203

204204
* `failed`: with value `true` if the conversion process failed.
205205

206+
### Two-Phase Conversion
207+
208+
* `disks`: This key includes a list of disks and for each one there is
209+
information about the progress of copying disks before running virt-v2v. The
210+
data are pulled from the source server and they are being updated depending on
211+
the progress.
212+
213+
Once virt-v2v is started all keys from the [One-Phase Conversion](#anchor_onephase)
214+
except `disks` and `disk_count` are updated in a similar fashion.
206215

207216
## LUKS encrypted devices
208217

‎requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ tox
66
flake8
77
pep8-naming
88
pylint
9+
libvirt-python
10+
pyvmomi
11+
packaging

‎setup.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@
2323
},
2424
install_requires=[
2525
'pycurl',
26-
'six'
26+
'six',
27+
'libvirt-python',
28+
'pyvmomi',
29+
'packaging',
30+
# TODO: Uncomment this when it becomes available in pypi and also do
31+
# the same in Pipfile, add it to requirements.txt and remove the mocked
32+
# nbd.py
33+
# 'libnbd-python',
2734
],
2835
extras_require={
2936
'ovirt': 'ovirt-engine-sdk-python',

‎tox.ini

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ skip_missing_interpreters=True
77
exclude = .git,.eggs,.tox,__pycache__,venv,build,dist
88

99
[testenv]
10+
setenv =
11+
PYTHONPATH={toxinidir}/wrapper/tests/mocks/
1012
usedevelop = True
1113
deps =
1214
-r{toxinidir}/requirements.txt

‎v2v-conversion-host.spec.in

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ BuildArch: noarch
3838
Requires: libcgroup-tools
3939
Requires: python3
4040
Requires: %{py3_dist pycurl}
41+
Requires: %{py3_dist packaging}
42+
Requires: %{py3_dist pyvmomi}
43+
Requires: %{py3_dist libnbd}
44+
Requires: %{py3_dist libvirt}
4145

4246
%description wrapper
4347
Daemonizing wrapper for virt-v2v.

‎wrapper/log_parser.py

+19
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class OutputParser(object):
3434
br' \'?virt_v2v_disk_index=(?P<volume>[0-9]+)/[0-9]+.*'
3535
br' \'?(?P<uuid>[a-fA-F0-9-]*)\'?$')
3636
SSH_VMX_GUEST_NAME = re.compile(br'^displayName = "(.*)"$')
37+
OVERLAY_PATH_RE = re.compile(
38+
br'virt-v2v: Overlay saved as (?P<path>/.*\.qcow2) ')
3739

3840
def __init__(self, duplicate=False):
3941
# Wait for the log files to appear
@@ -47,6 +49,7 @@ def __init__(self, duplicate=False):
4749
self._current_disk = None
4850
self._current_path = None
4951
self._duplicate = duplicate
52+
self._current_overlay_disk = 0
5053

5154
def __del__(self):
5255
self._log.close()
@@ -81,6 +84,22 @@ def parse_line(self, line):
8184
STATE.vm_id = vm_id
8285
logging.info('Created VM with id=%s', vm_id)
8386

87+
if STATE.pre_copy:
88+
# Ovelays to commit in two_phase mode
89+
m = self.OVERLAY_PATH_RE.match(line)
90+
if m is not None:
91+
path = m.group('path').decode('utf-8')
92+
disks = STATE.pre_copy.disks
93+
if self._current_overlay_disk >= len(disks):
94+
error('Disk list mismatch when getting overlay data')
95+
disks[self._current_overlay_disk].overlay = path
96+
logging.debug('Attaching overlay path "%s" to disk "%d"',
97+
path, self._current_overlay_disk)
98+
self._current_overlay_disk += 1
99+
100+
# There is nothing else to parse for two-phase conversion
101+
return
102+
84103
m = self.COPY_DISK_RE.match(line)
85104
if m is not None:
86105
try:

0 commit comments

Comments
 (0)
This repository has been archived.