On 06/26/2012 01:28 PM, Alex Jia wrote:
> With this module, we will be able to implement a virt-v2v test.
>
> As of implementation details, we uses virt-v2v command line tool
> to convert an existing VM into libvirt-managed KVM, or an open
> manageable virtualized environment - oVirt.
>
> Signed-off-by: Alex Jia<[email protected]>
> Signed-off-by: Wayne Sun<[email protected]>
> ---
> client/virt/virt_v2v.py | 59
> ++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 59 insertions(+)
> create mode 100644 client/virt/virt_v2v.py
>
> diff --git a/client/virt/virt_v2v.py b/client/virt/virt_v2v.py
> new file mode 100644
> index 0000000..973d8ca
> --- /dev/null
> +++ b/client/virt/virt_v2v.py
> @@ -0,0 +1,59 @@
> +"""
> +Utility functions to handle Virtual Machine conversion using virt-v2v.
> +
> +@copyright: 2008-2012 Red Hat Inc.
> +"""
> +
> +import logging
> +from autotest.client import os_dep, utils
> +from autotest.server.hosts.ssh_host import SSHHost
> +import virt_v2v_utils as v2v_utils
> +
> +DEBUG = False
> +
> +try:
> + V2V_EXEC = os_dep.command('virt-v2v')
> +except ValueError:
> + V2V_EXEC = None
> +
> +
> +def v2v_cmd(params):
> + """
> + Append cmd to 'virt-v2v' and execute, optionally return full results.
> +
> + @param: params: A dictionary includes all of required parameters such as
> + 'target', 'hypervisor', 'hostname', 'storage', 'network'.
> + @return: stdout of command
> + """
> + if V2V_EXEC is None:
> + raise ValueError('Missing command: virt-v2v')
> +
> + target = params.get('target')
> + hypervisor = params.get('hypervisor')
> + hostname = params.get('hostname')
> + storage = params.get('storage')
> + network = params.get('network')
> + username = params.get('username')
> + password = params.get('password')
> +
> + uri_obj = v2v_utils.URI(hypervisor)
> + # Return actual 'uri' according to 'hostname' and 'hypervisor'
> + uri = uri_obj.get_uri(hostname)
> +
> + tgt_obj = v2v_utils.TARGERT(target, uri)
I thought TARGERT was a typo here, but I see from v2v_utils it is not.
> + # Return virt-v2v command line options based on 'target' and 'hypervisor'
> + options = tgt_obj.get_cmd_options(params)
> +
> + # Convert a existing VM without or with connection autoorization.
Typo, "Authorization" (one 'o')
> + if hypervisor == 'esx':
> + v2v_utils.build_esx_no_verify(params)
> + elif hypervisor == 'xen':
> + SSHHost(hostname, user=username, port=22, password=password)
I'm unclear on what this is doing. It seems to create instance but then
throw it away (N/B/ I only took quick look at SSHHost code).
> + else:
> + pass
> +
> + # Construct a final virt-v2v command
> + cmd = '%s %s' % (V2V_EXEC, options)
> + logging.debug('%s' % cmd)
> + cmd_result = utils.run(cmd, verbose=DEBUG)
> + return cmd_result.stdout.strip()
Maybe it makes sense to just return cmd_result directly? This would let
tests exercise v2v tools with invalid options or scrutinize result more
thoroughly if they need to. Just an idea.
--
Chris Evich, RHCA, RHCE, RHCDS, RHCSS
Quality Assurance Engineer
e-mail: cevich + `@' + redhat.com o: 1-888-RED-HAT1 x44214
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest