Skip to content

Commit 24d4202

Browse files
committed
WIP install 5/n: create VIFs for VM
1 parent 382c9fa commit 24d4202

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,10 @@ def create_vms(request, host):
374374
vbd = vm.create_vbd("sda", vdi.uuid)
375375
vbds.append(vbd)
376376

377+
if "vifs" in marker:
378+
for vif_def in marker["vifs"]:
379+
vm.create_vif(vif_def["index"], vif_def["network_uuid"])
380+
377381
yield vms
378382

379383
except Exception:

lib/vm.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,14 @@ def vifs(self):
248248
_vifs.append(VIF(vif_uuid, self))
249249
return _vifs
250250

251+
# FIXME: use network_name instead?
252+
def create_vif(self, vif_num, network_uuid):
253+
logging.info("Create VIF %d to network %r on VM %s", vif_num, network_uuid, self.uuid)
254+
vbd_uuid = self.host.xe('vif-create', {'vm-uuid': self.uuid,
255+
'device': str(vif_num),
256+
'network-uuid': network_uuid,
257+
})
258+
251259
def is_running_on_host(self, host):
252260
return self.is_running() and self.param_get('resident-on') == host.uuid
253261

tests/install/test_install.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
@pytest.mark.vm_definitions(dict(name="vm 1",
55
template="Other install media",
66
vdis=[dict(name="vm 1 system disk", size="1GiB")],
7+
vifs=[dict(index=0,
8+
# FIXME
9+
network_uuid="eabc1038-e40f-2ae5-0781-a3adbec1cae8")],
710
))
811
class TestInstallNested:
912
def test_install_nested_821(self, create_vms):

0 commit comments

Comments
 (0)