Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mlow committed Oct 9, 2022
1 parent 8bd508c commit dc40f22
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion plugins/modules/virt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <source> elements
# user networks don't have a <source> element
Expand All @@ -491,6 +492,7 @@ def define(self, xml):
'user': None,
}


def handle_define(module, v):
''' handle `command: define` '''
xml = module.params.get('xml', None)
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit dc40f22

Please sign in to comment.