mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
v2v: Add a test of --network and --bridge command line options.
This enhances commit aaf84abca9.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -553,5 +553,6 @@ Makefile.in
|
||||
/v2v/rhel-6.5.img
|
||||
/v2v/rhel-7.0.img
|
||||
/v2v/stamp-virt-v2v.pod
|
||||
/v2v/test-v2v-networks-and-bridges.xml
|
||||
/v2v/virt-v2v
|
||||
/v2v/virt-v2v.1
|
||||
|
||||
@@ -1736,7 +1736,8 @@ AC_CONFIG_FILES([Makefile
|
||||
tests/xfs/Makefile
|
||||
tests/xml/Makefile
|
||||
tools/Makefile
|
||||
v2v/Makefile])
|
||||
v2v/Makefile
|
||||
v2v/test-v2v-networks-and-bridges.xml])
|
||||
AC_OUTPUT
|
||||
|
||||
dnl Produce summary.
|
||||
|
||||
@@ -20,6 +20,8 @@ include $(top_srcdir)/subdir-rules.mk
|
||||
EXTRA_DIST = \
|
||||
$(SOURCES_MLI) $(SOURCES_ML) $(SOURCES_C) \
|
||||
$(TESTS) $(SLOW_TESTS) \
|
||||
test-v2v-networks-and-bridges-expected.xml \
|
||||
test-v2v-networks-and-bridges.xml.in \
|
||||
virt-v2v.pod
|
||||
|
||||
CLEANFILES = *~ *.cmi *.cmo *.cmx *.cmxa *.o virt-v2v
|
||||
@@ -181,6 +183,7 @@ if ENABLE_APPLIANCE
|
||||
TESTS = \
|
||||
test-v2v-i-disk.sh \
|
||||
test-v2v-machine-readable.sh \
|
||||
test-v2v-networks-and-bridges.sh \
|
||||
test-v2v-no-copy.sh \
|
||||
test-v2v-o-libvirt.sh \
|
||||
test-v2v-o-rhev.sh \
|
||||
@@ -191,6 +194,11 @@ TESTS = \
|
||||
test-v2v-windows-conversion.sh
|
||||
endif ENABLE_APPLIANCE
|
||||
|
||||
# This forces the file to be updated before running the tests, in case
|
||||
# the .xml.in file has been changed. Be nice if automake just did the
|
||||
# right thing here.
|
||||
check_DATA = test-v2v-networks-and-bridges.xml
|
||||
|
||||
check-valgrind:
|
||||
$(MAKE) VG="$(top_builddir)/run @VG@" check
|
||||
|
||||
|
||||
34
v2v/test-v2v-networks-and-bridges-expected.xml
Normal file
34
v2v/test-v2v-networks-and-bridges-expected.xml
Normal file
@@ -0,0 +1,34 @@
|
||||
<interface type='bridge'>
|
||||
<source bridge='bridge1'/>
|
||||
<model type='rtl8139'/>
|
||||
</interface>
|
||||
<interface type='bridge'>
|
||||
<source bridge='bridge2'/>
|
||||
<model type='rtl8139'/>
|
||||
<mac address='52:54:00:01:02:03'/>
|
||||
</interface>
|
||||
<interface type='network'>
|
||||
<source network='network1'/>
|
||||
<model type='rtl8139'/>
|
||||
<mac address='52:54:00:01:02:04'/>
|
||||
</interface>
|
||||
<interface type='network'>
|
||||
<source network='network2'/>
|
||||
<model type='rtl8139'/>
|
||||
<mac address='52:54:00:01:02:05'/>
|
||||
</interface>
|
||||
<interface type='network'>
|
||||
<source network='network3'/>
|
||||
<model type='rtl8139'/>
|
||||
<mac address='52:54:00:01:02:06'/>
|
||||
</interface>
|
||||
<interface type='network'>
|
||||
<source network='network4'/>
|
||||
<model type='rtl8139'/>
|
||||
<mac address='52:54:00:01:02:07'/>
|
||||
</interface>
|
||||
<interface type='network'>
|
||||
<source network='network4'/>
|
||||
<model type='rtl8139'/>
|
||||
<mac address='52:54:00:01:02:08'/>
|
||||
</interface>
|
||||
74
v2v/test-v2v-networks-and-bridges.sh
Executable file
74
v2v/test-v2v-networks-and-bridges.sh
Executable file
@@ -0,0 +1,74 @@
|
||||
#!/bin/bash -
|
||||
# libguestfs virt-v2v test script
|
||||
# Copyright (C) 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.
|
||||
|
||||
# Test --network and --bridge parameters.
|
||||
|
||||
unset CDPATH
|
||||
export LANG=C
|
||||
set -e
|
||||
|
||||
if [ -n "$SKIP_TEST_V2V_NETWORKS_AND_BRIDGES_SH" ]; then
|
||||
echo "$0: test skipped because environment variable is set"
|
||||
exit 77
|
||||
fi
|
||||
|
||||
if [ "$(../fish/guestfish get-backend)" = "uml" ]; then
|
||||
echo "$0: test skipped because UML backend does not support network"
|
||||
exit 77
|
||||
fi
|
||||
|
||||
abs_builddir="$(pwd)"
|
||||
libvirt_uri="test://$abs_builddir/test-v2v-networks-and-bridges.xml"
|
||||
|
||||
f=../tests/guests/windows.img
|
||||
if ! test -f $f || ! test -s $f; then
|
||||
echo "$0: test skipped because phony Windows image was not created"
|
||||
exit 77
|
||||
fi
|
||||
|
||||
virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools}
|
||||
if ! test -r $virt_tools_data_dir/rhsrvany.exe; then
|
||||
echo "$0: test skipped because rhsrvany.exe is not installed"
|
||||
exit 77
|
||||
fi
|
||||
|
||||
d=test-v2v-networks-and-bridges.d
|
||||
rm -rf $d
|
||||
mkdir $d
|
||||
|
||||
# Use --no-copy because we only care about metadata for this test.
|
||||
$VG ./virt-v2v --debug-gc \
|
||||
-i libvirt -ic "$libvirt_uri" windows \
|
||||
-o local -os $d --no-copy \
|
||||
--bridge "VM Network:bridge1" \
|
||||
--bridge bridge2 \
|
||||
--network default:network1 \
|
||||
--network john:network2 \
|
||||
--network paul:network3 \
|
||||
--network network4
|
||||
|
||||
# Test the libvirt XML metadata was created.
|
||||
test -f $d/windows.xml
|
||||
|
||||
# Extract just the network interfaces from the XML.
|
||||
sed -n '/interface/,/\/interface/p' $d/windows.xml > $d/networks
|
||||
|
||||
# Test that the output has mapped the networks and bridges correctly.
|
||||
diff -ur test-v2v-networks-and-bridges-expected.xml $d/networks
|
||||
|
||||
rm -r $d
|
||||
87
v2v/test-v2v-networks-and-bridges.xml.in
Normal file
87
v2v/test-v2v-networks-and-bridges.xml.in
Normal file
@@ -0,0 +1,87 @@
|
||||
<!--
|
||||
libguestfs virt-v2v tool
|
||||
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.
|
||||
|
||||
@configure_input@
|
||||
-->
|
||||
<node>
|
||||
<domain type='test'>
|
||||
<name>windows</name>
|
||||
<memory>1048576</memory>
|
||||
<os>
|
||||
<type>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<devices>
|
||||
<disk type='file' device='disk'>
|
||||
<driver name='qemu' type='raw'/>
|
||||
<source file='@abs_top_builddir@/tests/guests/windows.img'/>
|
||||
<target dev='vda' bus='virtio'/>
|
||||
</disk>
|
||||
|
||||
<!-- various different networks and bridges which should
|
||||
be renamed by the test -->
|
||||
|
||||
<!-- standard ESX bridge -->
|
||||
<interface type='bridge'>
|
||||
<mac address='00:00:00:00:00:00'/>
|
||||
<source bridge='VM Network'/>
|
||||
<model type='e1000'/>
|
||||
</interface>
|
||||
|
||||
<!-- another bridge to be remapped -->
|
||||
<interface type='bridge'>
|
||||
<mac address='52:54:00:01:02:03'/>
|
||||
<source bridge='bob'/>
|
||||
<model type='e1000'/>
|
||||
</interface>
|
||||
|
||||
<!-- typical libvirt network -->
|
||||
<interface type='network'>
|
||||
<mac address='52:54:00:01:02:04'/>
|
||||
<source network='default'/>
|
||||
<model type='virtio'/>
|
||||
</interface>
|
||||
|
||||
<!-- some more random networks to map -->
|
||||
<interface type='network'>
|
||||
<mac address='52:54:00:01:02:05'/>
|
||||
<source network='john'/>
|
||||
<model type='virtio'/>
|
||||
</interface>
|
||||
|
||||
<interface type='network'>
|
||||
<source network='paul'/>
|
||||
<model type='virtio'/>
|
||||
<mac address='52:54:00:01:02:06'/>
|
||||
</interface>
|
||||
|
||||
<interface type='network'>
|
||||
<model type='rtl8139'/>
|
||||
<source network='george'/>
|
||||
<mac address='52:54:00:01:02:07'/>
|
||||
</interface>
|
||||
|
||||
<interface type='network'>
|
||||
<mac address='52:54:00:01:02:08'/>
|
||||
<model type='virtio'/>
|
||||
<source network='ringo'/>
|
||||
</interface>
|
||||
|
||||
</devices>
|
||||
</domain>
|
||||
</node>
|
||||
Reference in New Issue
Block a user