2222import junit .framework .TestCase ;
2323import java .util .List ;
2424import com .cloud .hypervisor .kvm .resource .LibvirtVMDef .DiskDef ;
25+ import com .cloud .hypervisor .kvm .resource .LibvirtVMDef .InterfaceDef ;
2526
2627public class LibvirtDomainXMLParserTest extends TestCase {
2728
@@ -34,6 +35,9 @@ public void testDomainXMLParser() {
3435 DiskDef .diskFmtType diskFormat = DiskDef .diskFmtType .QCOW2 ;
3536 DiskDef .diskCacheMode diskCache = DiskDef .diskCacheMode .NONE ;
3637
38+ InterfaceDef .nicModel ifModel = InterfaceDef .nicModel .VIRTIO ;
39+ InterfaceDef .guestNetType ifType = InterfaceDef .guestNetType .BRIDGE ;
40+
3741 String diskLabel ="vda" ;
3842 String diskPath = "/var/lib/libvirt/images/my-test-image.qcow2" ;
3943
@@ -96,35 +100,35 @@ public void testDomainXMLParser() {
96100 "<alias name='virtio-serial0'/>" +
97101 "<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>" +
98102 "</controller>" +
99- "<interface type='bridge '>" +
103+ "<interface type='" + ifType . toString () + " '>" +
100104 "<mac address='0e:00:a9:fe:02:00'/>" +
101105 "<source bridge='cloud0'/>" +
102106 "<target dev='vnet0'/>" +
103- "<model type='virtio '/>" +
107+ "<model type='" + ifModel . toString () + " '/>" +
104108 "<alias name='net0'/>" +
105109 "<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>" +
106110 "</interface>" +
107- "<interface type='bridge '>" +
111+ "<interface type='" + ifType . toString () + " '>" +
108112 "<mac address='06:c5:94:00:05:65'/>" +
109113 "<source bridge='cloudbr1'/>" +
110114 "<target dev='vnet1'/>" +
111- "<model type='virtio '/>" +
115+ "<model type='" + ifModel . toString () + " '/>" +
112116 "<alias name='net1'/>" +
113117 "<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>" +
114118 "</interface>" +
115- "<interface type='bridge '>" +
119+ "<interface type='" + ifType . toString () + " '>" +
116120 "<mac address='06:c9:f4:00:04:40'/>" +
117121 "<source bridge='cloudbr0'/>" +
118122 "<target dev='vnet2'/>" +
119- "<model type='virtio '/>" +
123+ "<model type='" + ifModel . toString () + " '/>" +
120124 "<alias name='net2'/>" +
121125 "<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>" +
122126 "</interface>" +
123- "<interface type='bridge '>" +
127+ "<interface type='" + ifType . toString () + " '>" +
124128 "<mac address='06:7e:c6:00:05:68'/>" +
125129 "<source bridge='cloudbr1'/>" +
126130 "<target dev='vnet3'/>" +
127- "<model type='virtio '/>" +
131+ "<model type='" + ifModel . toString () + " '/>" +
128132 "<alias name='net3'/>" +
129133 "<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>" +
130134 "</interface>" +
@@ -180,5 +184,11 @@ public void testDomainXMLParser() {
180184 assertEquals (diskType , disks .get (diskId ).getDiskType ());
181185 assertEquals (deviceType , disks .get (diskId ).getDeviceType ());
182186 assertEquals (diskFormat , disks .get (diskId ).getDiskFormatType ());
187+
188+ List <InterfaceDef > ifs = parser .getInterfaces ();
189+ for (int i = 0 ; i < ifs .size (); i ++) {
190+ assertEquals (ifModel , ifs .get (i ).getModel ());
191+ assertEquals (ifType , ifs .get (i ).getNetType ());
192+ }
183193 }
184194}
0 commit comments