Merge "Move equality check into LibvirtConfigGuestInterface"

This commit is contained in:
Zuul
2020-09-08 18:40:27 +00:00
committed by Gerrit Code Review
2 changed files with 17 additions and 8 deletions
+14
View File
@@ -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
+3 -8
View File
@@ -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):