daemon: LinkOptions now leverage dataclass and has type hinting, improve test_gui type hinting
This commit is contained in:
parent
18044f9474
commit
b5e53e573a
4 changed files with 27 additions and 39 deletions
|
@ -86,13 +86,8 @@ def add_link_data(
|
|||
"""
|
||||
interface_one = link_interface(link_proto.interface_one)
|
||||
interface_two = link_interface(link_proto.interface_two)
|
||||
|
||||
link_type = None
|
||||
link_type_value = link_proto.type
|
||||
if link_type_value is not None:
|
||||
link_type = LinkTypes(link_type_value)
|
||||
|
||||
options = LinkOptions(_type=link_type)
|
||||
link_type = LinkTypes(link_proto.type)
|
||||
options = LinkOptions(type=link_type)
|
||||
options_data = link_proto.options
|
||||
if options_data:
|
||||
options.delay = options_data.delay
|
||||
|
@ -106,7 +101,6 @@ def add_link_data(
|
|||
options.unidirectional = options_data.unidirectional
|
||||
options.key = options_data.key
|
||||
options.opaque = options_data.opaque
|
||||
|
||||
return interface_one, interface_two, options
|
||||
|
||||
|
||||
|
|
|
@ -772,7 +772,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
|||
if link_type_value is not None:
|
||||
link_type = LinkTypes(link_type_value)
|
||||
|
||||
link_options = LinkOptions(_type=link_type)
|
||||
link_options = LinkOptions(type=link_type)
|
||||
link_options.delay = message.get_tlv(LinkTlvs.DELAY.value)
|
||||
link_options.bandwidth = message.get_tlv(LinkTlvs.BANDWIDTH.value)
|
||||
link_options.session = message.get_tlv(LinkTlvs.SESSION.value)
|
||||
|
|
|
@ -93,34 +93,28 @@ class NodeOptions:
|
|||
self.alt = alt
|
||||
|
||||
|
||||
@dataclass
|
||||
class LinkOptions:
|
||||
"""
|
||||
Options for creating and updating links within core.
|
||||
"""
|
||||
|
||||
def __init__(self, _type: LinkTypes = LinkTypes.WIRED) -> None:
|
||||
"""
|
||||
Create a LinkOptions object.
|
||||
|
||||
:param _type: type of link, defaults to
|
||||
wired
|
||||
"""
|
||||
self.type = _type
|
||||
self.session = None
|
||||
self.delay = None
|
||||
self.bandwidth = None
|
||||
self.per = None
|
||||
self.dup = None
|
||||
self.jitter = None
|
||||
self.mer = None
|
||||
self.burst = None
|
||||
self.mburst = None
|
||||
self.gui_attributes = None
|
||||
self.unidirectional = None
|
||||
self.emulation_id = None
|
||||
self.network_id = None
|
||||
self.key = None
|
||||
self.opaque = None
|
||||
type: LinkTypes = LinkTypes.WIRED
|
||||
session: int = None
|
||||
delay: int = None
|
||||
bandwidth: int = None
|
||||
per: float = None
|
||||
dup: int = None
|
||||
jitter: int = None
|
||||
mer: int = None
|
||||
burst: int = None
|
||||
mburst: int = None
|
||||
gui_attributes: str = None
|
||||
unidirectional: bool = None
|
||||
emulation_id: int = None
|
||||
network_id: int = None
|
||||
key: int = None
|
||||
opaque: str = None
|
||||
|
||||
|
||||
@dataclass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue