vm/net: make 'dns' property visible in Admin API
Serialize the list with a space as a separator. QubesOS/qubes-issues#5050
This commit is contained in:
parent
d4b1794c15
commit
2a42b7c7c7
@ -91,6 +91,16 @@ def _setter_provides_network(self, prop, value):
|
|||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
class StrSerializableTuple(tuple):
|
||||||
|
def __str__(self):
|
||||||
|
# verify it can be deserialized later(currently 'dns'
|
||||||
|
# property is the only using this, and it is safe)
|
||||||
|
if any(' ' in el for el in self):
|
||||||
|
raise ValueError(
|
||||||
|
'space found in a list element {!r}'.format(self))
|
||||||
|
return ' '.join(self)
|
||||||
|
|
||||||
|
|
||||||
class NetVMMixin(qubes.events.Emitter):
|
class NetVMMixin(qubes.events.Emitter):
|
||||||
''' Mixin containing network functionality '''
|
''' Mixin containing network functionality '''
|
||||||
mac = qubes.property('mac', type=str,
|
mac = qubes.property('mac', type=str,
|
||||||
@ -224,14 +234,14 @@ class NetVMMixin(qubes.events.Emitter):
|
|||||||
# used in both
|
# used in both
|
||||||
#
|
#
|
||||||
|
|
||||||
@property
|
@qubes.stateless_property
|
||||||
def dns(self):
|
def dns(self):
|
||||||
'''Secondary DNS server set up for this domain.'''
|
'''DNS servers set up for this domain.'''
|
||||||
if self.netvm is not None or self.provides_network:
|
if self.netvm is not None or self.provides_network:
|
||||||
return (
|
return StrSerializableTuple((
|
||||||
'10.139.1.1',
|
'10.139.1.1',
|
||||||
'10.139.1.2',
|
'10.139.1.2',
|
||||||
)
|
))
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user