cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject [4/4] git commit: updated refs/heads/4.3 to 28b5d0a
Date Tue, 21 Jan 2014 07:19:20 GMT
CLOUDSTACK-5883 Convert ovf file to proper format for ESXi

Virtualbox export creates an OVF file that is not compatible with VMware import functions.
This causes import errors when the systemvm ova is imported into cloudstack. This patch fixes
the issue by using an XSLT transformation to convert the generated ovf into a format this
is compatible with vmware.

This is a squashed commit Based on the following commits in master:
794d47c5f279bc8cbd212d9dd87673b8302de9db bf26efc551e56d21a24049952ebe81f9686df5ec 5d24843ef59b4d28a9a81ade4510c44b2a048b06
95a92ad2e3e7a8ceade4e5cd2e4ebd717c1cc2ab da8ee45a249f89f2ef2a74d225854b37785f6922 50054fe0603673d04655362ea515d3b5c5bb3610
50054fe0603673d04655362ea515d3b5c5bb3610 ecf57c368a9790e28e47bb83b51201763bd2b1ef


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/28b5d0a9
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/28b5d0a9
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/28b5d0a9

Branch: refs/heads/4.3
Commit: 28b5d0a9ed4e87b93626d2f2cf3dc30eb02d9192
Parents: 7c4831d
Author: Hugo Trippaers <htrippaers@schubergphilis.com>
Authored: Thu Jan 16 14:42:34 2014 +0100
Committer: Hugo Trippaers <htrippaers@schubergphilis.com>
Committed: Tue Jan 21 08:18:33 2014 +0100

----------------------------------------------------------------------
 tools/appliance/build.sh                     |   8 +++--
 tools/appliance/convert/Convert.class        | Bin 0 -> 984 bytes
 tools/appliance/convert/Convert.java         |  34 ++++++++++++++++++
 tools/appliance/convert_ovf_vbox_to_esx.xslt |  42 ++++++++++++++++++++++
 4 files changed, 82 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/28b5d0a9/tools/appliance/build.sh
----------------------------------------------------------------------
diff --git a/tools/appliance/build.sh b/tools/appliance/build.sh
index 61ee793..ddcaec9 100644
--- a/tools/appliance/build.sh
+++ b/tools/appliance/build.sh
@@ -60,7 +60,7 @@ done
 vboxmanage modifyhd $hdd_uuid --compact
 
 # Start exporting
-rm -fr dist *.ova *.vhd *.vdi *.qcow* *.bz2
+rm -fr dist *.ova *.vhd *.vdi *.qcow* *.bz2 *.vmdk *.ovf
 mkdir dist
 
 # Export for Xen
@@ -92,7 +92,11 @@ echo "$appliance exported for KVM: dist/$appliance-$build_date-$branch-kvm.qcow2
 vboxmanage clonehd $hdd_uuid $appliance-$build_date-$branch-vmware.vmdk --format VMDK
 bzip2 $appliance-$build_date-$branch-vmware.vmdk
 echo "$appliance exported for VMWare: dist/$appliance-$build_date-$branch-vmware.vmdk.bz2"
-vboxmanage export $machine_uuid --output $appliance-$build_date-$branch-vmware.ova
+vboxmanage export $machine_uuid --output $appliance-$build_date-$branch-vmware.ovf
+mv $appliance-$build_date-$branch-vmware.ovf $appliance-$build_date-$branch-vmware.ovf-orig
+java -cp convert Convert convert_ovf_vbox_to_esx.xslt $appliance-$build_date-$branch-vmware.ovf-orig
$appliance-$build_date-$branch-vmware.ovf
+tar -cf $appliance-$build_date-$branch-vmware.ova $appliance-$build_date-$branch-vmware.ovf
$appliance-$build_date-$branch-vmware-disk1.vmdk
+rm -f $appliance-$build_date-$branch-vmware.ovf $appliance-$build_date-$branch-vmware.ovf-orig
$appliance-$build_date-$branch-vmware-disk1.vmdk
 echo "$appliance exported for VMWare: dist/$appliance-$build_date-$branch-vmware.ova"
 
 # Export for HyperV

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/28b5d0a9/tools/appliance/convert/Convert.class
----------------------------------------------------------------------
diff --git a/tools/appliance/convert/Convert.class b/tools/appliance/convert/Convert.class
new file mode 100644
index 0000000..3f24341
Binary files /dev/null and b/tools/appliance/convert/Convert.class differ

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/28b5d0a9/tools/appliance/convert/Convert.java
----------------------------------------------------------------------
diff --git a/tools/appliance/convert/Convert.java b/tools/appliance/convert/Convert.java
new file mode 100644
index 0000000..e29fdb2
--- /dev/null
+++ b/tools/appliance/convert/Convert.java
@@ -0,0 +1,34 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+// 
+// http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import javax.xml.transform.*;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+public class Convert {
+    public static void main(String[] args) throws IOException, URISyntaxException, TransformerException
{
+        TransformerFactory factory = TransformerFactory.newInstance();
+        Source xslt = new StreamSource(new File(args[0]));
+        Transformer transformer = factory.newTransformer(xslt);
+
+        Source text = new StreamSource(new File(args[1]));
+        transformer.transform(text, new StreamResult(new File(args[2])));
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/28b5d0a9/tools/appliance/convert_ovf_vbox_to_esx.xslt
----------------------------------------------------------------------
diff --git a/tools/appliance/convert_ovf_vbox_to_esx.xslt b/tools/appliance/convert_ovf_vbox_to_esx.xslt
new file mode 100644
index 0000000..a6c086d
--- /dev/null
+++ b/tools/appliance/convert_ovf_vbox_to_esx.xslt
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<xsl:stylesheet version="1.0" xmlns="http://schemas.dmtf.org/ovf/envelope/1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"
xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:vbox="http://www.virtualbox.org/ovf/machine">
+
+    <xsl:template match="vssd:VirtualSystemType/text()">vmx-07</xsl:template>
+  
+    <xsl:template match="ovf:Item[./rasd:ResourceType/text()=20]">
+        <Item>
+        <xsl:copy-of select="rasd:Address"/>
+        <rasd:Caption>scsiController0</rasd:Caption>
+        <rasd:Description>SCSI Controller</rasd:Description>
+        <rasd:ElementName>scsiController0</rasd:ElementName>
+        <xsl:copy-of select="rasd:InstanceID"/>
+        <rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>
+        <rasd:ResourceType>6</rasd:ResourceType>
+        </Item>
+    </xsl:template>
+
+    <xsl:template match="node()|@*">
+        <xsl:copy>
+            <xsl:apply-templates select="node()|@*"/>
+        </xsl:copy>
+    </xsl:template>
+    
+</xsl:stylesheet>


Mime
View raw message