Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit 65466b2

Browse files
committed
Add Interface module for building libvirt interface XML
1 parent 1ec6ff6 commit 65466b2

17 files changed

Lines changed: 1417 additions & 10 deletions

tests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,4 @@ def diff_compare(actual_out, filename, expect_out=None):
8181
import clonetest
8282
import nodedev
8383
import virtconvtest
84+
import interface

tests/clitest.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
'MANAGEDNEW1' : "/default-pool/clonevol",
7676
'MANAGEDNEW2' : "/default-pool/clonevol",
7777
'MANAGEDDISKNEW1' : "/disk-pool/newvol1.img",
78+
'COLLIDE' : "/default-pool/collidevol1.img",
7879

7980
'VIRTCONV_OUT' : "%s/test.out" % virtconv_out,
8081
'VC_IMG1' : "%s/virtimage/test1.virt-image" % vcdir,
@@ -161,6 +162,8 @@
161162
"--disk %(EXISTIMG1)s",
162163
# Not specifying path= but creating storage
163164
"--disk %(NEWIMG1)s,format=raw,size=.0000001",
165+
# Colliding storage with --force
166+
"--disk %(COLLIDE)s --force"
164167
],
165168

166169
"invalid": [
@@ -192,6 +195,8 @@
192195
"--disk path=%(MANAGEDDISKNEW1)s,format=raw,size=.0000001",
193196
# Not specifying path= and non existent storage w/ no size
194197
"--disk %(NEWIMG1)s",
198+
# Colliding storage without --force
199+
"--disk %(COLLIDE)s"
195200
]
196201
}, # category "storage"
197202

@@ -352,13 +357,13 @@
352357

353358
"valid": [
354359
# Just a macaddr
355-
"--mac 11:22:33:44:55:66",
360+
"--mac 11:22:33:44:55:AF",
356361
# user networking
357362
"--network=user",
358363
# Old bridge option
359364
"--bridge mybr0",
360365
# Old bridge w/ mac
361-
"--bridge mybr0 --mac 11:22:33:44:55:66",
366+
"--bridge mybr0 --mac 11:22:33:44:55:AF",
362367
# --network bridge:
363368
"--network bridge:mybr0,model=e1000",
364369
# VirtualNetwork with a random macaddr
@@ -370,17 +375,19 @@
370375
# with NIC model
371376
"--network=user,model=e1000",
372377
# several networks
373-
"--network=network:default,model=e1000 --network=user,model=virtio,mac=11:22:33:44:55:66",
378+
"--network=network:default,model=e1000 --network=user,model=virtio,mac=11:22:33:44:55:AF",
374379
],
375380
"invalid": [
376381
# Nonexistent network
377382
"--network=FOO",
378383
# Invalid mac
379384
"--network=network:default --mac 1234",
380385
# More mac addrs than nics
381-
"--network user --mac 00:11:22:33:44:55 --mac 00:11:22:33:44:66",
386+
"--network user --mac 00:11:22:33:44:EF --mac 00:11:22:33:44:AB",
382387
# Mixing bridge and network
383388
"--network user --bridge foo0",
389+
# Colliding macaddr
390+
"--mac 11:22:33:44:55:66",
384391
],
385392

386393
}, # category "network"
@@ -438,7 +445,7 @@
438445
# XML w/ managed storage, specify managed path
439446
"--original-xml %(CLONE_STORAGE_XML)s --file %(MANAGEDNEW1)s",
440447
# XML w/ managed storage, specify managed path across pools
441-
#"--original-xml %(CLONE_STORAGE_XML)s --file /cross-pool/clonevol",
448+
"--original-xml %(CLONE_STORAGE_XML)s --file /cross-pool/clonevol",
442449
],
443450

444451
"invalid": [
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<interface type='bond' name='test-bond-arp'>
2+
<start mode='onboot'/>
3+
<mac address='AA:AA:AA:AA:AA:AA'/>
4+
<mtu size='1501'/>
5+
<protocol family='ipv4'>
6+
</protocol>
7+
<bond>
8+
<arpmon interval='100' target='192.168.100.200' validate='backup'/>
9+
<interface type='ethernet' name='eth0'>
10+
<start mode='none'/>
11+
<mac address='00:FF:EE:FF:EE:FF'/>
12+
</interface>
13+
<interface type='ethernet' name='eth1'>
14+
<mac address='00:FF:EE:FF:EE:AB'/>
15+
</interface>
16+
<interface type='ethernet' name='eth2'>
17+
<start mode='hotplug'/>
18+
<mac address='00:FF:EE:FF:EE:CD'/>
19+
</interface>
20+
</bond>
21+
</interface>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<interface type='bond' name='test-bond-mii'>
2+
<start mode='onboot'/>
3+
<mac address='AA:AA:AA:AA:AA:AA'/>
4+
<mtu size='1501'/>
5+
<protocol family='ipv4'>
6+
</protocol>
7+
<bond>
8+
<miimon freq='123' downdelay='34' updelay='12' carrier='netif'/>
9+
<interface type='ethernet' name='eth0'>
10+
<start mode='none'/>
11+
<mac address='00:FF:EE:FF:EE:FF'/>
12+
</interface>
13+
<interface type='ethernet' name='eth1'>
14+
<mac address='00:FF:EE:FF:EE:AB'/>
15+
</interface>
16+
<interface type='ethernet' name='eth2'>
17+
<start mode='hotplug'/>
18+
<mac address='00:FF:EE:FF:EE:CD'/>
19+
</interface>
20+
</bond>
21+
</interface>

tests/interface-xml/test-bond.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<interface type='bond' name='test-bond'>
2+
<start mode='onboot'/>
3+
<mac address='AA:AA:AA:AA:AA:AA'/>
4+
<mtu size='1501'/>
5+
<protocol family='ipv4'>
6+
</protocol>
7+
<bond>
8+
<interface type='ethernet' name='eth0'>
9+
<start mode='none'/>
10+
<mac address='00:FF:EE:FF:EE:FF'/>
11+
</interface>
12+
<interface type='ethernet' name='eth1'>
13+
<mac address='00:FF:EE:FF:EE:AB'/>
14+
</interface>
15+
<interface type='ethernet' name='eth2'>
16+
<start mode='hotplug'/>
17+
<mac address='00:FF:EE:FF:EE:CD'/>
18+
</interface>
19+
</bond>
20+
</interface>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<interface type='bridge' name='test-bridge-ip'>
2+
<protocol family='ipv4'>
3+
<dhcp peerdns='yes'/>
4+
<ip address='129.63.1.2'/>
5+
<ip address='255.255.255.0'/>
6+
<route gateway='1.2.3.4'/>
7+
</protocol>
8+
<protocol family='ipv6'>
9+
<autoconf/>
10+
<dhcp peerdns='yes'/>
11+
<ip address='fe99::215:58ff:fe6e:5' prefix='32'/>
12+
<ip address='fe80::215:58ff:fe6e:5' prefix='64'/>
13+
<route gateway='1.2.3.4'/>
14+
</protocol>
15+
<bridge>
16+
<interface type='ethernet' name='vlaneth1'>
17+
</interface>
18+
<interface type='bond' name='bond-brbond'>
19+
<start mode='none'/>
20+
<bond mode='active-backup'>
21+
<miimon freq='100' updelay='10' carrier='ioctl'/>
22+
<interface type='ethernet' name='brbond-eth0'>
23+
</interface>
24+
<interface type='ethernet' name='brbond-eth1'>
25+
</interface>
26+
</bond>
27+
</interface>
28+
<interface type='ethernet' name='eth0'>
29+
<start mode='none'/>
30+
<mac address='00:FF:EE:FF:EE:FF'/>
31+
</interface>
32+
</bridge>
33+
</interface>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<interface type='bridge' name='test-bridge'>
2+
<bridge stp='off' delay='7'>
3+
<interface type='ethernet' name='vlaneth1'>
4+
</interface>
5+
<interface type='bond' name='bond-brbond'>
6+
<start mode='none'/>
7+
<bond mode='active-backup'>
8+
<miimon freq='100' updelay='10' carrier='ioctl'/>
9+
<interface type='ethernet' name='brbond-eth0'>
10+
</interface>
11+
<interface type='ethernet' name='brbond-eth1'>
12+
</interface>
13+
</bond>
14+
</interface>
15+
<interface type='ethernet' name='eth0'>
16+
<start mode='none'/>
17+
<mac address='00:FF:EE:FF:EE:FF'/>
18+
</interface>
19+
</bridge>
20+
</interface>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<interface type='ethernet' name='test-ethernet-params'>
2+
<start mode='hotplug'/>
3+
<mtu size='1234'/>
4+
</interface>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<interface type='ethernet' name='test-ethernet'>
2+
</interface>

tests/interface-xml/test-vlan.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<interface type='vlan' name='test-vlan'>
2+
<vlan tag='123'>
3+
<interface name='eth2'/>
4+
</vlan>
5+
</interface>

0 commit comments

Comments
 (0)