Blame SOURCES/0189-v2v-i-ova-Derive-the-name-from-the-OVA-filename.patch

aa0300
From 83aad5289c4c1f1ee7c5b2efabcd27d3b7a08420 Mon Sep 17 00:00:00 2001
aa0300
From: "Richard W.M. Jones" <rjones@redhat.com>
aa0300
Date: Fri, 9 Sep 2016 14:56:11 +0100
aa0300
Subject: [PATCH] v2v: -i ova: Derive the name from the OVA filename.
aa0300
aa0300
If the guest has no <Name> element in the OVF, previously we chose
aa0300
"default" as the name.  This changes that so it uses a name derived
aa0300
from the basename of the OVA file instead.
aa0300
aa0300
For example:
aa0300
aa0300
  virt-v2v -i ova /path/to/myguest.ova [...]
aa0300
aa0300
would use "myguest" as the name (assuming no <Name> was present).
aa0300
aa0300
Modifies the behaviour of
aa0300
commit 1ae4252c93c685cb8561b55c1231502b37212b5a.
aa0300
aa0300
(cherry picked from commit 98619f9c26076d034574b8822dfcc6799741ed96)
aa0300
---
aa0300
 v2v/input_ova.ml      | 3 ++-
aa0300
 v2v/name_from_disk.ml | 2 +-
aa0300
 2 files changed, 3 insertions(+), 2 deletions(-)
aa0300
aa0300
diff --git a/v2v/input_ova.ml b/v2v/input_ova.ml
aa0300
index 932c96b..c5ff19c 100644
aa0300
--- a/v2v/input_ova.ml
aa0300
+++ b/v2v/input_ova.ml
aa0300
@@ -23,6 +23,7 @@ open Common_utils
aa0300
 
aa0300
 open Types
aa0300
 open Utils
aa0300
+open Name_from_disk
aa0300
 
aa0300
 class input_ova ova =
aa0300
   let tmpdir =
aa0300
@@ -186,7 +187,7 @@ object
aa0300
       match xpath_string "/ovf:Envelope/ovf:VirtualSystem/ovf:Name/text()" with
aa0300
       | None | Some "" ->
aa0300
         warning (f_"could not parse ovf:Name from OVF document");
aa0300
-        "default"
aa0300
+        name_from_disk ova
aa0300
       | Some name -> name in
aa0300
 
aa0300
     (* Search for memory. *)
aa0300
diff --git a/v2v/name_from_disk.ml b/v2v/name_from_disk.ml
aa0300
index 73caf34..9ed02ce 100644
aa0300
--- a/v2v/name_from_disk.ml
aa0300
+++ b/v2v/name_from_disk.ml
aa0300
@@ -24,7 +24,7 @@ let name_from_disk disk =
aa0300
   (* Remove the extension (or suffix), only if it's one usually
aa0300
    * used for disk images. *)
aa0300
   let suffixes = [
aa0300
-    ".img"; ".qcow2"; ".raw"; ".vmdk";
aa0300
+    ".img"; ".ova"; ".qcow2"; ".raw"; ".vmdk";
aa0300
     "-sda";
aa0300
   ] in
aa0300
   let rec loop = function
aa0300
-- 
7af31e
1.8.3.1
aa0300