fixup! fixup! wip: dynamic inventory
parent
73ae3b8a78
commit
18a9a7e8ae
|
@ -1,7 +1,7 @@
|
|||
import enum
|
||||
import functools
|
||||
import logging
|
||||
from typing import cast, Any, Optional
|
||||
from typing import cast, Any, Iterator, Optional
|
||||
from xml.etree import ElementTree as etree
|
||||
|
||||
import libvirt
|
||||
|
@ -152,13 +152,7 @@ class Host:
|
|||
|
||||
@functools.cached_property
|
||||
def groups(self) -> list[str]:
|
||||
grouplist = []
|
||||
if self.metadata:
|
||||
if groups := self.metadata.find('groups'):
|
||||
for elem in groups.iter('group'):
|
||||
if group_name := elem.get('name'):
|
||||
grouplist.append(group_name)
|
||||
return grouplist
|
||||
return list(self._groups())
|
||||
|
||||
@functools.cached_property
|
||||
def libosinfo(self) -> Optional[etree.Element]:
|
||||
|
@ -244,3 +238,11 @@ class Host:
|
|||
values['guest_info'] = guest_info
|
||||
|
||||
return values
|
||||
|
||||
def _groups(self) -> Iterator[str]:
|
||||
if self.metadata is None:
|
||||
return
|
||||
if groups := self.metadata.find('groups'):
|
||||
for elem in groups.iter('group'):
|
||||
if group_name := elem.get('name'):
|
||||
yield group_name
|
||||
|
|
Loading…
Reference in New Issue