Skip to content

Commit 65c41f8

Browse files
committed
WIP install 5/n: create VIFs for VM
TODO: - allow using network_name - doc
1 parent 39a964a commit 65c41f8

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,10 @@ def create_vms(request, host):
400400
vbds.append(vbd)
401401
vbd.param_set(param_name="userdevice", value=vdi_def["userdevice"])
402402

403+
if "vifs" in marker:
404+
for vif_def in marker["vifs"]:
405+
vm.create_vif(vif_def["index"], vif_def["network_uuid"])
406+
403407
yield vms
404408

405409
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+
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.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class TestNested:
66
dict(name="vm 1",
77
template="Other install media",
88
vdis=[dict(name="vm 1 system disk", size="100GiB", device="xvda", userdevice="0")],
9+
vifs=[dict(index=0, network_uuid="eabc1038-e40f-2ae5-0781-a3adbec1cae8")], # FIXME
910
))
1011
def test_nested_821_uefi(self, create_vms):
1112
assert len(create_vms) == 1

0 commit comments

Comments
 (0)