On Friday, 8 December 2017 17:02:30 CET Richard W.M. Jones wrote:
This enhances the existing VMX input support allowing it to be
used over SSH to the ESXi server.
The original command (for local .vmx files) was:
$ virt-v2v -i vmx guest.vmx -o local -os /var/tmp
Adding ‘-it ssh’ and using an SSH remote path gives the new syntax:
$ virt-v2v \
-i vmx -it ssh \
"root@esxi.example.com:/vmfs/volumes/datastore1/guest/guest.vmx" \
-o local -os /var/tmp
I anticipate that this input method will be widely used enough that it
deserves its own example at the top of the man page.
---
[...]
+(* The single filename on the command line is intepreted either as
+ * a local file or a remote SSH path (only if ‘-it ssh’).
+ *)
+let vmx_source_of_arg input_transport arg =
+ match input_transport, arg with
+ | None, arg -> File arg
+ | Some `SSH, arg ->
+ let arg1, path = String.split ":" arg in
+ if path = "" then
+ error (f_"expecting [user@]server:path with ‘-it ssh’");
+ let user, server = match String.split "@" arg1 with
+ | server, "" -> None, server
+ | user, server -> Some user, server in
+ SSH (user, server, path)
IMHO this new transport could use the standard URI syntax, so
root(a)esxi.example.com/vmfs/volumes/datastore1/guest/guest.vmx
instead of
root@esxi.example.com:/vmfs/volumes/datastore1/guest/guest.vmx
This way, Xml.parse_uri can be used to parse it, giving a better code
for extracting all the parts (including the port, for example).
The rest seems fine, at a quick glance.
--
Pino Toscano