From dc40f22c31f82e43a2b4ef0fe10210dd793e2894 Mon Sep 17 00:00:00 2001 From: Matt Low Date: Sun, 9 Oct 2022 14:29:18 -0600 Subject: [PATCH] Fix lint errors --- plugins/modules/virt.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/modules/virt.py b/plugins/modules/virt.py index ef31c76..529e6cd 100644 --- a/plugins/modules/virt.py +++ b/plugins/modules/virt.py @@ -478,6 +478,7 @@ def define(self, xml): self.__get_conn() return self.conn.define_from_xml(xml) + # A dict of interface types (found in their `type` attribute) to the # corresponding "source" attribute name of their elements # user networks don't have a element @@ -491,6 +492,7 @@ def define(self, xml): 'user': None, } + def handle_define(module, v): ''' handle `command: define` ''' xml = module.params.get('xml', None) @@ -589,6 +591,7 @@ def handle_define(module, v): # the counts of interfaces of a similar type/source # key'd with tuple of (type, source) similar_interface_counts = {} + def get_interface_count(_type, source=None): key = (_type, source if _type != "user" else None) if key not in similar_interface_counts: @@ -605,7 +608,7 @@ def get_interface_count(_type, source=None): continue if _type not in INTERFACE_SOURCE_ATTRS: - module.warn("Skipping fuzzy MAC matching for interface %i of incoming XML: unsupported interface type '%s'" %( + module.warn("Skipping fuzzy MAC matching for interface %i of incoming XML: unsupported interface type '%s'." % ( interface.getparent().index(interface) + 1, _type )) continue @@ -614,6 +617,10 @@ def get_interface_count(_type, source=None): source = interface.find('source').get(source_attr) if source_attr else None similar_count = get_interface_count(_type, source) + if interface.find('mac') is not None: + # we want to count these, but not try to change their MAC address + continue + if source: xpath = "./interface[@type='%s' and source[@%s='%s']]" % ( _type, source_attr, source)