Skip to content

Commit 28b5d0a

Browse files
committed
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: 794d47c bf26efc 5d24843 95a92ad da8ee45 50054fe 50054fe ecf57c3
1 parent 7c4831d commit 28b5d0a

4 files changed

Lines changed: 82 additions & 2 deletions

File tree

tools/appliance/build.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ done
6060
vboxmanage modifyhd $hdd_uuid --compact
6161

6262
# Start exporting
63-
rm -fr dist *.ova *.vhd *.vdi *.qcow* *.bz2
63+
rm -fr dist *.ova *.vhd *.vdi *.qcow* *.bz2 *.vmdk *.ovf
6464
mkdir dist
6565

6666
# Export for Xen
@@ -92,7 +92,11 @@ echo "$appliance exported for KVM: dist/$appliance-$build_date-$branch-kvm.qcow2
9292
vboxmanage clonehd $hdd_uuid $appliance-$build_date-$branch-vmware.vmdk --format VMDK
9393
bzip2 $appliance-$build_date-$branch-vmware.vmdk
9494
echo "$appliance exported for VMWare: dist/$appliance-$build_date-$branch-vmware.vmdk.bz2"
95-
vboxmanage export $machine_uuid --output $appliance-$build_date-$branch-vmware.ova
95+
vboxmanage export $machine_uuid --output $appliance-$build_date-$branch-vmware.ovf
96+
mv $appliance-$build_date-$branch-vmware.ovf $appliance-$build_date-$branch-vmware.ovf-orig
97+
java -cp convert Convert convert_ovf_vbox_to_esx.xslt $appliance-$build_date-$branch-vmware.ovf-orig $appliance-$build_date-$branch-vmware.ovf
98+
tar -cf $appliance-$build_date-$branch-vmware.ova $appliance-$build_date-$branch-vmware.ovf $appliance-$build_date-$branch-vmware-disk1.vmdk
99+
rm -f $appliance-$build_date-$branch-vmware.ovf $appliance-$build_date-$branch-vmware.ovf-orig $appliance-$build_date-$branch-vmware-disk1.vmdk
96100
echo "$appliance exported for VMWare: dist/$appliance-$build_date-$branch-vmware.ova"
97101

98102
# Export for HyperV
984 Bytes
Binary file not shown.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
import javax.xml.transform.*;
19+
import javax.xml.transform.stream.StreamResult;
20+
import javax.xml.transform.stream.StreamSource;
21+
import java.io.File;
22+
import java.io.IOException;
23+
import java.net.URISyntaxException;
24+
25+
public class Convert {
26+
public static void main(String[] args) throws IOException, URISyntaxException, TransformerException {
27+
TransformerFactory factory = TransformerFactory.newInstance();
28+
Source xslt = new StreamSource(new File(args[0]));
29+
Transformer transformer = factory.newTransformer(xslt);
30+
31+
Source text = new StreamSource(new File(args[1]));
32+
transformer.transform(text, new StreamResult(new File(args[2])));
33+
}
34+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
-->
20+
<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">
21+
22+
<xsl:template match="vssd:VirtualSystemType/text()">vmx-07</xsl:template>
23+
24+
<xsl:template match="ovf:Item[./rasd:ResourceType/text()=20]">
25+
<Item>
26+
<xsl:copy-of select="rasd:Address"/>
27+
<rasd:Caption>scsiController0</rasd:Caption>
28+
<rasd:Description>SCSI Controller</rasd:Description>
29+
<rasd:ElementName>scsiController0</rasd:ElementName>
30+
<xsl:copy-of select="rasd:InstanceID"/>
31+
<rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>
32+
<rasd:ResourceType>6</rasd:ResourceType>
33+
</Item>
34+
</xsl:template>
35+
36+
<xsl:template match="node()|@*">
37+
<xsl:copy>
38+
<xsl:apply-templates select="node()|@*"/>
39+
</xsl:copy>
40+
</xsl:template>
41+
42+
</xsl:stylesheet>

0 commit comments

Comments
 (0)