daemon: added support for link options buffer read/write to xml

This commit is contained in:
Blake Harnden 2020-12-07 22:31:53 -08:00
parent 6793382f44
commit 5b93c2d7ac
3 changed files with 14 additions and 0 deletions

View file

@ -241,12 +241,16 @@ class CoreInterface:
jitter = self.getparam("jitter")
if jitter is not None:
jitter = int(jitter)
buffer = self.getparam("buffer")
if buffer is not None:
buffer = int(buffer)
return LinkOptions(
delay=delay,
bandwidth=bandwidth,
dup=dup,
jitter=jitter,
loss=self.getparam("loss"),
buffer=buffer,
unidirectional=unidirectional,
)

View file

@ -570,6 +570,7 @@ class CoreXmlWriter:
add_attribute(options, "unidirectional", options_data.unidirectional)
add_attribute(options, "network_id", link_data.network_id)
add_attribute(options, "key", options_data.key)
add_attribute(options, "buffer", options_data.buffer)
if options.items():
link_element.append(options)
@ -976,6 +977,7 @@ class CoreXmlReader:
if options.loss is None:
options.loss = get_float(options_element, "per")
options.unidirectional = get_int(options_element, "unidirectional")
options.buffer = get_int(options_element, "buffer")
if options.unidirectional == 1 and node_set in node_sets:
logging.info("updating link node1(%s) node2(%s)", node1_id, node2_id)

View file

@ -309,6 +309,7 @@ class TestXml:
options.jitter = 10
options.delay = 30
options.dup = 5
options.buffer = 100
session.add_link(node1.id, switch.id, iface1_data, options=options)
# instantiate session
@ -352,6 +353,7 @@ class TestXml:
assert options.jitter == link.options.jitter
assert options.delay == link.options.delay
assert options.dup == link.options.dup
assert options.buffer == link.options.buffer
def test_link_options_ptp(
self, session: Session, tmpdir: TemporaryFile, ip_prefixes: IpPrefixes
@ -376,6 +378,7 @@ class TestXml:
options.jitter = 10
options.delay = 30
options.dup = 5
options.buffer = 100
session.add_link(node1.id, node2.id, iface1_data, iface2_data, options)
# instantiate session
@ -419,6 +422,7 @@ class TestXml:
assert options.jitter == link.options.jitter
assert options.delay == link.options.delay
assert options.dup == link.options.dup
assert options.buffer == link.options.buffer
def test_link_options_bidirectional(
self, session: Session, tmpdir: TemporaryFile, ip_prefixes: IpPrefixes
@ -444,6 +448,7 @@ class TestXml:
options1.loss = 10.5
options1.dup = 5
options1.jitter = 5
options1.buffer = 50
session.add_link(node1.id, node2.id, iface1_data, iface2_data, options1)
options2 = LinkOptions()
options2.unidirectional = 1
@ -452,6 +457,7 @@ class TestXml:
options2.loss = 10
options2.dup = 10
options2.jitter = 10
options2.buffer = 100
session.update_link(
node2.id, node1.id, iface2_data.id, iface1_data.id, options2
)
@ -499,8 +505,10 @@ class TestXml:
assert options1.loss == link1.options.loss
assert options1.dup == link1.options.dup
assert options1.jitter == link1.options.jitter
assert options1.buffer == link1.options.buffer
assert options2.bandwidth == link2.options.bandwidth
assert options2.delay == link2.options.delay
assert options2.loss == link2.options.loss
assert options2.dup == link2.options.dup
assert options2.jitter == link2.options.jitter
assert options2.buffer == link2.options.buffer