refactored LinkOptions to be used within LinkData, instead of duplicating data, removed session from LinkOptions and LinkData

This commit is contained in:
Blake Harnden 2020-06-16 14:18:19 -07:00
parent eeca33e722
commit a29a7a5582
10 changed files with 120 additions and 113 deletions

View file

@ -7,6 +7,7 @@ import time
from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Tuple
from core import utils
from core.emulator.data import LinkOptions
from core.emulator.enumerations import MessageFlags, TransportType
from core.errors import CoreCommandError
from core.nodes.netclient import LinuxNetClient, get_net_client
@ -169,6 +170,34 @@ class CoreInterface:
"""
return self._params.get(key)
def get_link_options(self, unidirectional: int) -> LinkOptions:
"""
Get currently set params as link options.
:param unidirectional: unidirectional setting
:return: link options
"""
delay = self.getparam("delay")
if delay is not None:
delay = int(delay)
bandwidth = self.getparam("bw")
if bandwidth is not None:
bandwidth = int(bandwidth)
dup = self.getparam("duplicate")
if dup is not None:
dup = int(dup)
jitter = self.getparam("jitter")
if jitter is not None:
jitter = int(jitter)
return LinkOptions(
delay=delay,
bandwidth=bandwidth,
dup=dup,
jitter=jitter,
loss=self.getparam("loss"),
unidirectional=unidirectional,
)
def getparams(self) -> List[Tuple[str, float]]:
"""
Return (key, value) pairs for parameters.