Move this function to the VCenter module. This is easier since it
doesn't have to do dcPath calculation (see previous commit).
The readhead parameter is no longer labelled.
In libvirt >= 1.2.20, the VMware libvirt driver supplies the correct
dcPath to use via <vmware:datacenterpath> in the libvirt XML. If
libvirt passes us this element, use it.
This code still allows the user to override dcPath using the --dcPath
option on the command line, but that's mainly for safety so we can fix
any problems in virt-v2v or libvirt in the field. As we get more
confident in libvirt and as libvirt 1.2.20 is more widely adopted, we
will be able to deprecate this parameter entirely.
Thanks: Matthias Bolte for adding the <vmware:datacenterpath> element
to libvirt in
https://libvirt.org/git/?p=libvirt.git;a=commit;h=636a99058758a0447482f3baad94de8de3ab1151
This is just a straight refactoring. Various ad hoc string_*
functions that appeared in Common_utils have been renamed and placed
in the String.* namespace. The old vs "new" functions are:
string_prefix -> String.is_prefix
string_suffix -> String.is_suffix
string_find -> String.find
replace_str -> String.replace
string_nsplit -> String.nsplit
string_split -> String.split
string_lines_split -> String.lines_split
string_random8 -> String.random8
It's currently impossible to correctly predict the dcPath parameter
from the data that libvirt gives us. So allow the user to override
--dcpath themselves.
Eventually we will get better support in libvirt for this, and this
option will no longer be needed:
https://www.redhat.com/archives/libvir-list/2015-September/thread.html#00201
This enhances commit 51bc573d0c
and commit 20f1eb400b.
Previously given a path such as:
vpx://vcenter/Folder/Datacenter/esxi
we calculated dcPath=Folder. However this is obviously wrong. We
should chop the path at the final (esxi) element to give
dcPath=Folder/Datacenter.
In vCenter, the datacenter is identified by a path, and the parameter
used for this is called 'dcPath'. Rename the function to avoid any
confusion about what we're getting here.
This is just renaming function/variable names and has no other effect.
This large commit is just code refactoring. Instead of having
every OCaml tool define 'prog' the same way, always as:
let prog = Filename.basename Sys.executable_name
move that into a single place, Common_utils.prog. Then we can use
that global value everywhere else, instead of having to pass it as a
parameter into a dozen different functions.
Instead of making up an ordinary curl command line, write a temporary
config file and use 'curl --config tmpfile' to pass the arguments.
The advantage is that it's more secure if we want to supply passwords
to curl, since a '--user username:password' parameter on the command
line could be read (eg. by 'ps ax'), but the temporary file has mode
0600 and cannot be read by other users.
This is mostly code motion, but it also passes the '-q' option to curl
to stop it from reading default configuration files.
Previously I modified the parse_libvirt_xml function to get rid of the
awkward 'map_source*' functions, and have the callers map over and
modify the source disks afterwards. However this broke the case where
an "nbd:..." URL was returned by parse_libvirt_xml, since the callers
might try to map this URL (eg. turning it into an absolute path).
This broke virt-p2v specifically.
This commit changes parse_libvirt_xml to return a list of tuples
containing disk information, giving the callers more information with
which to do the mapping.
This fixes commit 3596165282.
Take the opportunity presented by the refactoring in the previous
commit to inline and simplify functions in these input subclasses.
This finally removes the map_source* functions.
This refactors the code into more logical units, based on the previous
commits. So Xen + the input_libvirt Xen code is grouped and moved
into a new module called Input_libvirt_xen_ssh. Similarly VCenter +
input_libvirt vCenter code is moved to Input_libvirt_vcenter_https.
There is no change here, purely code motion.