Move equality check into LibvirtConfigGuestInterface
This is a pure refactoring that moves the equality check of LibvirtConfigGuestInterface objects from get_interface_by_cfg() into the class itself. Later this pattern will be extended to LibvirtConfigGuestHostdevPCI objects to support detaching direct physical interfaces where PCI address based equality is needed. Part of blueprint sriov-interface-attach-detach Change-Id: I6ce9457179f65f82ff721b315e51a67ebd879673
This commit is contained in:
parent
eff6099c82
commit
c21f08f0f6
|
@ -1686,6 +1686,20 @@ class LibvirtConfigGuestInterface(LibvirtConfigGuestDevice):
|
|||
self.device_addr = None
|
||||
self.mtu = None
|
||||
|
||||
def __eq__(self, other):
|
||||
if not isinstance(other, LibvirtConfigGuestInterface):
|
||||
return False
|
||||
|
||||
# NOTE(arches) Skip checking target_dev for vhostuser
|
||||
# vif type; target_dev is not a valid value for vhostuser.
|
||||
return (
|
||||
self.mac_addr == other.mac_addr and
|
||||
self.net_type == other.net_type and
|
||||
self.source_dev == other.source_dev and
|
||||
(self.net_type == 'vhostuser' or
|
||||
self.target_dev == other.target_dev) and
|
||||
self.vhostuser_path == other.vhostuser_path)
|
||||
|
||||
@property
|
||||
def uses_virtio(self):
|
||||
return 'virtio' == self.model
|
||||
|
|
|
@ -246,14 +246,9 @@ class Guest(object):
|
|||
# NOTE(leehom) LibvirtConfigGuestInterface get from domain and
|
||||
# LibvirtConfigGuestInterface generated by
|
||||
# nova.virt.libvirt.vif.get_config must be identical.
|
||||
# NOTE(arches) Skip checking target_dev for vhostuser
|
||||
# vif type; target_dev is not a valid value for vhostuser.
|
||||
if (interface.mac_addr == cfg.mac_addr and
|
||||
interface.net_type == cfg.net_type and
|
||||
interface.source_dev == cfg.source_dev and
|
||||
(cfg.net_type == 'vhostuser' or
|
||||
interface.target_dev == cfg.target_dev) and
|
||||
interface.vhostuser_path == cfg.vhostuser_path):
|
||||
# NOTE(gibi): LibvirtConfigGuestInterface does a custom
|
||||
# equality check based on available information on nova side
|
||||
if cfg == interface:
|
||||
return interface
|
||||
|
||||
def get_vcpus_info(self):
|
||||
|
|
Loading…
Reference in New Issue