Skip to content

Commit d4efcc1

Browse files
committed
lib/vm.py: Return newly created UUID in create_vif
This allows avoiding a subsequent vif-list or similar to immediately operate on the VIF Signed-off-by: Andrii Sultanov <[email protected]>
1 parent d2fdebe commit d4efcc1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/vm.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,11 @@ def create_vif(self, vif_num, *, network_uuid=None, network_name=None):
293293
network_uuid = self.host.pool.network_named(network_name)
294294
assert network_uuid, f"No UUID given, and network name {network_name!r} not found"
295295
logging.info("Create VIF %d to network %r on VM %s", vif_num, network_uuid, self.uuid)
296-
self.host.xe('vif-create', {'vm-uuid': self.uuid,
297-
'device': str(vif_num),
298-
'network-uuid': network_uuid,
299-
})
296+
vif_uuid = self.host.xe('vif-create', {'vm-uuid': self.uuid,
297+
'device': str(vif_num),
298+
'network-uuid': network_uuid,
299+
})
300+
return VIF(vif_uuid, self)
300301

301302
def is_running_on_host(self, host):
302303
return self.is_running() and self.param_get('resident-on') == host.uuid

0 commit comments

Comments
 (0)