@@ -231,13 +231,16 @@ def get_interfaces(self):
231231
232232 return interfaces
233233
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 ]:
235239 """Lookup a full LibvirtConfigGuestDevice with
236240 LibvirtConfigGuesDevice generated
237241 by nova.virt.libvirt.vif.get_config.
238242
239243 :param cfg: config object that represents the guest interface.
240- :type cfg: a subtype of LibvirtConfigGuestDevice object
241244 :param from_persistent_config: query the device from the persistent
242245 domain instead of the live domain configuration
243246 :returns: nova.virt.libvirt.config.LibvirtConfigGuestDevice instance
@@ -255,6 +258,7 @@ def get_interface_by_cfg(self, cfg, from_persistent_config=False):
255258 # equality check based on available information on nova side
256259 if cfg == interface :
257260 return interface
261+ return None
258262
259263 def get_vcpus_info (self ):
260264 """Returns virtual cpus information of guest.
@@ -341,10 +345,18 @@ def get_config(self):
341345 config .parse_str (self ._domain .XMLDesc (0 ))
342346 return config
343347
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 ]:
345353 """Returns the disk mounted at device
346354
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
348360 """
349361 flags = 0
350362 if from_persistent_config :
@@ -367,6 +379,8 @@ def get_disk(self, device, from_persistent_config=False):
367379 conf .parse_dom (node )
368380 return conf
369381
382+ return None
383+
370384 def get_all_disks (self ):
371385 """Returns all the disks for a guest
372386
@@ -375,7 +389,11 @@ def get_all_disks(self):
375389
376390 return self .get_all_devices (vconfig .LibvirtConfigGuestDisk )
377391
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 ]:
379397 """Returns all devices for a guest
380398
381399 :param devtype: a LibvirtConfigGuestDevice subclass class
0 commit comments