diff options
author | Cole Robinson <crobinso@redhat.com> | 2019-02-07 17:42:25 -0500 |
---|---|---|
committer | Cole Robinson <crobinso@redhat.com> | 2019-02-07 17:42:55 -0500 |
commit | fb5aadc63636349491fbf76c74705b9c3c7ed82c (patch) | |
tree | 0d56a092e3b79976ae9b633f76f7d876af11f04a /virtinst/guest.py | |
parent | 10973c793221c0d74cb0898b4340f3f95eccc094 (diff) | |
download | virt-manager-fb5aadc63636349491fbf76c74705b9c3c7ed82c.tar.gz |
guest: Move compare_device to Device class
It operates on a Device object, so it makes sense
Diffstat (limited to 'virtinst/guest.py')
-rw-r--r-- | virtinst/guest.py | 48 |
1 files changed, 1 insertions, 47 deletions
diff --git a/virtinst/guest.py b/virtinst/guest.py index 6966e6c3..13b88cf2 100644 --- a/virtinst/guest.py +++ b/virtinst/guest.py @@ -22,52 +22,6 @@ from .xmlbuilder import XMLBuilder, XMLProperty, XMLChildProperty _ignore = Device -def compare_device(origdev, newdev, idx): - devprops = { - "disk": ["target", "bus"], - "interface": ["macaddr", "xmlindex"], - "input": ["bus", "type", "xmlindex"], - "sound": ["model", "xmlindex"], - "video": ["model", "xmlindex"], - "watchdog": ["xmlindex"], - "hostdev": ["type", "managed", "xmlindex", - "product", "vendor", - "function", "domain", "slot"], - "serial": ["type", "target_port"], - "parallel": ["type", "target_port"], - "console": ["type", "target_type", "target_port"], - "graphics": ["type", "xmlindex"], - "controller": ["type", "index"], - "channel": ["type", "target_name"], - "filesystem": ["target", "xmlindex"], - "smartcard": ["mode", "xmlindex"], - "redirdev": ["bus", "type", "xmlindex"], - "tpm": ["type", "xmlindex"], - "rng": ["type", "xmlindex"], - "panic": ["type", "xmlindex"], - "vsock": ["xmlindex"], - } - - if id(origdev) == id(newdev): - return True - - if not isinstance(origdev, type(newdev)): - return False - - for devprop in devprops[origdev.DEVICE_TYPE]: - if devprop == "xmlindex": - origval = origdev.get_xml_idx() - newval = idx - else: - origval = getattr(origdev, devprop) - newval = getattr(newdev, devprop) - - if origval != newval: - return False - - return True - - class _DomainDevices(XMLBuilder): XML_NAME = "devices" _XML_PROP_ORDER = ['disk', 'controller', 'filesystem', 'interface', @@ -446,7 +400,7 @@ class Guest(XMLBuilder): """ devlist = getattr(self.devices, origdev.DEVICE_TYPE) for idx, dev in enumerate(devlist): - if compare_device(origdev, dev, idx): + if origdev.compare_device(dev, idx): return dev return None |