api/admin: exclude regex attribute from DeviceInfo structure
DeviceInfo may contain 'regex' attribute - it isn't intended to be reported through Admin API. Also, mark 'libvirt_regex' attribute as private.
This commit is contained in:
parent
da97f4d84c
commit
749e8497e3
@ -1067,7 +1067,7 @@ class QubesAdminAPI(qubes.api.AbstractQubesAPI):
|
|||||||
non_default_attrs = set(attr for attr in dir(dev) if
|
non_default_attrs = set(attr for attr in dir(dev) if
|
||||||
not attr.startswith('_')).difference((
|
not attr.startswith('_')).difference((
|
||||||
'backend_domain', 'ident', 'frontend_domain',
|
'backend_domain', 'ident', 'frontend_domain',
|
||||||
'description', 'options'))
|
'description', 'options', 'regex'))
|
||||||
properties_txt = ' '.join(
|
properties_txt = ' '.join(
|
||||||
'{}={!s}'.format(prop, value) for prop, value
|
'{}={!s}'.format(prop, value) for prop, value
|
||||||
in itertools.chain(
|
in itertools.chain(
|
||||||
|
@ -128,13 +128,13 @@ class PCIDevice(qubes.devices.DeviceInfo):
|
|||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
regex = re.compile(
|
regex = re.compile(
|
||||||
r'^(?P<bus>[0-9a-f]+)_(?P<device>[0-9a-f]+)\.(?P<function>[0-9a-f]+)$')
|
r'^(?P<bus>[0-9a-f]+)_(?P<device>[0-9a-f]+)\.(?P<function>[0-9a-f]+)$')
|
||||||
libvirt_regex = re.compile(
|
_libvirt_regex = re.compile(
|
||||||
r'^pci_0000_(?P<bus>[0-9a-f]+)_(?P<device>[0-9a-f]+)_'
|
r'^pci_0000_(?P<bus>[0-9a-f]+)_(?P<device>[0-9a-f]+)_'
|
||||||
r'(?P<function>[0-9a-f]+)$')
|
r'(?P<function>[0-9a-f]+)$')
|
||||||
|
|
||||||
def __init__(self, backend_domain, ident, libvirt_name=None):
|
def __init__(self, backend_domain, ident, libvirt_name=None):
|
||||||
if libvirt_name:
|
if libvirt_name:
|
||||||
dev_match = self.libvirt_regex.match(libvirt_name)
|
dev_match = self._libvirt_regex.match(libvirt_name)
|
||||||
assert dev_match
|
assert dev_match
|
||||||
ident = '{bus}_{device}.{function}'.format(**dev_match.groupdict())
|
ident = '{bus}_{device}.{function}'.format(**dev_match.groupdict())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user