Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use: virt-v2v [..] -o rhev -os nfs:/export or: virt-v2v [..] -o rhev -os /mountpoint to write to a RHEV-M / oVirt Export Storage Domain.
- Loading branch information
Showing
11 changed files
with
803 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
(* 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. | ||
*) | ||
|
||
(* Poor man's XML DOM, mutable for easy of modification. *) | ||
|
||
open Common_utils | ||
open Utils | ||
|
||
open Printf | ||
|
||
type node = | ||
| PCData of string | ||
| Element of element | ||
and element = { | ||
e_name : string; (* Name of element. *) | ||
mutable e_attrs : attr list; (* Attributes. *) | ||
mutable e_children : node list; (* Child elements. *) | ||
} | ||
and attr = string * string | ||
and doc = element | ||
|
||
let doc name attrs children = | ||
{ e_name = name; e_attrs = attrs; e_children = children } | ||
|
||
let e name attrs children = | ||
Element { e_name = name; e_attrs = attrs; e_children = children } | ||
|
||
let rec node_to_chan chan = function | ||
| PCData str -> output_string chan (xml_quote_pcdata str) | ||
| Element e -> element_to_chan chan e | ||
and element_to_chan chan | ||
{ e_name = name; e_attrs = attrs; e_children = children } = | ||
fprintf chan "<%s" name; | ||
List.iter (fun (n, v) -> fprintf chan " %s='%s'" n (xml_quote_attr v)) attrs; | ||
output_char chan '>'; | ||
List.iter (node_to_chan chan) children; | ||
fprintf chan "</%s>" name | ||
|
||
let doc_to_chan chan doc = | ||
fprintf chan "<?xml version='1.0' encoding='utf-8'?>\n"; | ||
element_to_chan chan doc | ||
|
||
let path_to_nodes doc path = | ||
match path with | ||
| [] -> invalid_arg "path_to_nodes: empty path" | ||
| top_name :: path -> | ||
if doc.e_name <> top_name then [] | ||
else ( | ||
let rec loop nodes path = | ||
match path with | ||
| [] -> [] | ||
| [p] -> | ||
List.filter ( | ||
function | ||
| PCData _ -> false | ||
| Element e when e.e_name = p -> true | ||
| Element _ -> false | ||
) nodes | ||
| p :: ps -> | ||
let children = | ||
filter_map ( | ||
function | ||
| PCData _ -> None | ||
| Element e when e.e_name = p -> Some e.e_children | ||
| Element _ -> None | ||
) nodes in | ||
List.concat (List.map (fun nodes -> loop nodes ps) children) | ||
in | ||
loop doc.e_children path | ||
) | ||
|
||
let filter_node_list_by_attr nodes attr = | ||
List.filter ( | ||
function | ||
| Element { e_attrs = attrs } when List.mem attr attrs -> true | ||
| Element _ | PCData _ -> false | ||
) nodes | ||
|
||
let find_node_by_attr nodes attr = | ||
match filter_node_list_by_attr nodes attr with | ||
| [] -> raise Not_found | ||
| x::_ -> x |
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,52 @@ | ||
(* 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. | ||
*) | ||
|
||
(** Poor man's XML DOM, mutable for easy of modification. *) | ||
|
||
type node = | ||
| PCData of string | ||
| Element of element | ||
and element = { | ||
e_name : string; (** Name of element. *) | ||
mutable e_attrs : attr list; (** Attributes. *) | ||
mutable e_children : node list; (** Child elements. *) | ||
} | ||
and attr = string * string | ||
and doc = element | ||
|
||
val doc : string -> attr list -> node list -> doc | ||
(** A quick way to create a document. *) | ||
|
||
val e : string -> attr list -> node list -> node | ||
(** A quick way to create elements. *) | ||
|
||
val doc_to_chan : out_channel -> doc -> unit | ||
(** Write the XML document to an output channel. *) | ||
|
||
val path_to_nodes : doc -> string list -> node list | ||
(** Search down the path and return a list of all matching elements. | ||
Returns an empty list if none were found. *) | ||
|
||
val filter_node_list_by_attr : node list -> attr -> node list | ||
(** Find DOM elements which have a particular attribute name=value (not | ||
recursively). If not found, returns an empty list. *) | ||
|
||
val find_node_by_attr : node list -> attr -> node | ||
(** Find the first DOM element which has a particular attribute | ||
name=value (not recursively). If not found, raises | ||
[Not_found]. *) |
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
Oops, something went wrong.