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

Commit 5834fba

Browse files
nertpinxnyoxi
authored andcommitted
Initial preparation for two-phase conversion
Signed-off-by: Martin Kletzander <[email protected]>
1 parent d5ddcb8 commit 5834fba

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

docs/Virt-v2v-wrapper.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@ The expected usage is as follows:
99

1010
1) *wrapper start*: client runs the wrapper; at the moment there are no
1111
command line arguments and everything is configured by JSON data presented
12-
on stdin.
12+
on stdin
1313

1414
2) *initialization*: wrapper read JSON data from stdin, parses and validates
1515
the content; based on the situation it may also change the effective user
1616
to a non-root account; wrapper writes to stdout simple JSON containing
1717
paths to wrapper log file (`wrapper_log`), virt-v2v log file (`v2v_log`),
1818
state file (`state_file`) that can be used to monitor the progress
1919

20+
3) Optionally, if `two_phase` conversion is selected (not supported for all
21+
input and output modes), it will copy the disks to their destinations and
22+
generate a libvirt XML to be used as an input to the virt-v2v process
23+
2024
4) *conversion*: finally, virt-v2v process is executed; wrapper monitors its
2125
output and updates the state file on a regular basis
2226

@@ -55,6 +59,12 @@ following can be specified:
5559
* `ssh_key`: optional, private part of SSH key to use. If this is not provided
5660
then keys in ~/.ssh directory are used.
5761

62+
Two-phase conversion can be requested by setting `two_phase` to `True` at which
63+
point the following key is mandatory:
64+
65+
* `conversion_host_uuid`: the UUID of a VM in which the actual conversion is
66+
being performed.
67+
5868
Output configuration: reffer to the section [Output
5969
configuration](#output-configuration) below.
6070

@@ -144,6 +154,11 @@ Example:
144154
State file is a JSON file. Its content changes as the conversion goes through
145155
various stages. With it also the keys present in the file.
146156

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.
161+
147162
Once virt-v2v is executed the state file is created with the following keys:
148163

149164
* `started`: with value `true`

wrapper/hosts.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ def validate_data(self, data):
7777
""" Validate input data, fill in defaults, etc """
7878
hard_error("Cannot validate data for unknown host type")
7979

80+
def prepare_disks(self, data):
81+
""" Validate input data, fill in defaults, etc """
82+
if data['two_phase']:
83+
hard_error("Host implementation did not forbid two phase "
84+
"conversion, but did not implement `prepare_disks`")
85+
8086

8187
class KubevirtHost(_BaseHost):
8288

@@ -152,7 +158,11 @@ def update_progress(self):
152158

153159
def validate_data(self, data):
154160
""" Validate input data, fill in defaults, etc """
155-
pass
161+
if data['two_phase']:
162+
# If adding support for two-phase conversion, do not forget to fix
163+
# the update_progress() method
164+
hard_error('Two-phase conversion is not supported for '
165+
'Kubevirt host')
156166

157167

158168
class _K8SCommunicator(object):
@@ -482,6 +492,9 @@ def validate_data(self, data):
482492
for mapping in data['network_mappings']:
483493
if 'mac_address' not in mapping:
484494
hard_error('Missing mac address in one of network mappings')
495+
if data['two_phase']:
496+
hard_error('Two-phase conversion is not supported for '
497+
'Openstack host')
485498
return data
486499

487500
def _check_ip_in_network(self, ipaddr, network):
@@ -707,6 +720,10 @@ def validate_data(self, data):
707720
else:
708721
hard_error('No target specified')
709722

723+
if data['two_phase']:
724+
hard_error('Two-phase conversion is not supported for '
725+
'Ovirt host')
726+
710727
if 'rhv_url' in data:
711728
with self.sdk_connection(data) as c:
712729
vm_svc = c.system_service().vms_service()

0 commit comments

Comments
 (0)