Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
9 changed files
with
220 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
(* virt-v2v | ||
* Copyright (C) 2009-2014 Red Hat Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*) | ||
|
||
open Printf | ||
|
||
open Common_gettext.Gettext | ||
open Common_utils | ||
|
||
open Types | ||
open Utils | ||
|
||
(* Check the backend is not libvirt. Works around a libvirt bug | ||
* (RHBZ#1134592). This can be removed once the libvirt bug is fixed. | ||
*) | ||
let error_if_libvirt_backend () = | ||
let libguestfs_backend = (new Guestfs.guestfs ())#get_backend () in | ||
if libguestfs_backend = "libvirt" then ( | ||
error (f_"because of libvirt bug https://bugzilla.redhat.com/show_bug.cgi?id=1134592 you must set this environment variable:\n\nexport LIBGUESTFS_BACKEND=direct\n\nand then rerun the virt-v2v command.") | ||
) | ||
|
||
(* xen+ssh URLs use the SSH driver in CURL. Currently this requires | ||
* ssh-agent authentication. Give a clear error if this hasn't been | ||
* set up (RHBZ#1139973). | ||
*) | ||
let error_if_no_ssh_agent () = | ||
try ignore (Sys.getenv "SSH_AUTH_SOCK") | ||
with Not_found -> | ||
error (f_"ssh-agent authentication has not been set up ($SSH_AUTH_SOCK is not set). Please read \"INPUT FROM RHEL 5 XEN\" in the virt-v2v(1) man page.") | ||
|
||
(* Superclass. *) | ||
class virtual input_libvirt verbose libvirt_uri guest = | ||
object | ||
inherit input verbose | ||
|
||
method as_options = | ||
sprintf "-i libvirt%s %s" | ||
(match libvirt_uri with | ||
| None -> "" | ||
| Some uri -> " -ic " ^ uri) | ||
guest | ||
end | ||
|
||
(* Subclass specialized for handling anything that's *not* VMware vCenter | ||
* or Xen. | ||
*) | ||
class input_libvirt_other verbose libvirt_uri guest = | ||
object | ||
inherit input_libvirt verbose libvirt_uri guest | ||
|
||
method source () = | ||
if verbose then printf "input_libvirt_other: source()\n%!"; | ||
|
||
(* Get the libvirt XML. This also checks (as a side-effect) | ||
* that the domain is not running. (RHBZ#1138586) | ||
*) | ||
let xml = Domainxml.dumpxml ?conn:libvirt_uri guest in | ||
|
||
Input_libvirtxml.parse_libvirt_xml ~verbose xml | ||
end | ||
|
||
let input_libvirt_other = new input_libvirt_other |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
(* virt-v2v | ||
* Copyright (C) 2009-2014 Red Hat Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*) | ||
|
||
(** [-i libvirt] source. *) | ||
|
||
val error_if_libvirt_backend : unit -> unit | ||
val error_if_no_ssh_agent : unit -> unit | ||
|
||
class virtual input_libvirt : bool -> string option -> string -> object | ||
method as_options : string | ||
method virtual source : unit -> Types.source | ||
method adjust_overlay_parameters : Types.overlay -> unit | ||
end | ||
|
||
val input_libvirt_other : bool -> string option -> string -> Types.input |
Oops, something went wrong.