@@ -231,13 +231,16 @@ def get_interfaces(self):
231
231
232
232
return interfaces
233
233
234
- def get_interface_by_cfg (self , cfg , from_persistent_config = False ):
234
+ def get_interface_by_cfg (
235
+ self ,
236
+ cfg : vconfig .LibvirtConfigGuestDevice ,
237
+ from_persistent_config : bool = False
238
+ ) -> ty .Optional [vconfig .LibvirtConfigGuestDevice ]:
235
239
"""Lookup a full LibvirtConfigGuestDevice with
236
240
LibvirtConfigGuesDevice generated
237
241
by nova.virt.libvirt.vif.get_config.
238
242
239
243
:param cfg: config object that represents the guest interface.
240
- :type cfg: a subtype of LibvirtConfigGuestDevice object
241
244
:param from_persistent_config: query the device from the persistent
242
245
domain instead of the live domain configuration
243
246
:returns: nova.virt.libvirt.config.LibvirtConfigGuestDevice instance
@@ -255,6 +258,7 @@ def get_interface_by_cfg(self, cfg, from_persistent_config=False):
255
258
# equality check based on available information on nova side
256
259
if cfg == interface :
257
260
return interface
261
+ return None
258
262
259
263
def get_vcpus_info (self ):
260
264
"""Returns virtual cpus information of guest.
@@ -341,10 +345,18 @@ def get_config(self):
341
345
config .parse_str (self ._domain .XMLDesc (0 ))
342
346
return config
343
347
344
- def get_disk (self , device , from_persistent_config = False ):
348
+ def get_disk (
349
+ self ,
350
+ device : str ,
351
+ from_persistent_config : bool = False
352
+ ) -> ty .Optional [vconfig .LibvirtConfigGuestDisk ]:
345
353
"""Returns the disk mounted at device
346
354
347
- :returns LivirtConfigGuestDisk: mounted at device or None
355
+ :param device: the name of either the source or the target device
356
+ :param from_persistent_config: query the device from the persistent
357
+ domain (i.e. inactive XML configuration that'll be used on next
358
+ start of the domain) instead of the live domain configuration
359
+ :returns LibvirtConfigGuestDisk: mounted at device or None
348
360
"""
349
361
flags = 0
350
362
if from_persistent_config :
@@ -367,6 +379,8 @@ def get_disk(self, device, from_persistent_config=False):
367
379
conf .parse_dom (node )
368
380
return conf
369
381
382
+ return None
383
+
370
384
def get_all_disks (self ):
371
385
"""Returns all the disks for a guest
372
386
@@ -375,7 +389,11 @@ def get_all_disks(self):
375
389
376
390
return self .get_all_devices (vconfig .LibvirtConfigGuestDisk )
377
391
378
- def get_all_devices (self , devtype = None , from_persistent_config = False ):
392
+ def get_all_devices (
393
+ self ,
394
+ devtype : vconfig .LibvirtConfigGuestDevice = None ,
395
+ from_persistent_config : bool = False
396
+ ) -> ty .List [vconfig .LibvirtConfigGuestDevice ]:
379
397
"""Returns all devices for a guest
380
398
381
399
:param devtype: a LibvirtConfigGuestDevice subclass class
0 commit comments