fixed saving bidirectional params for ptp networks, storing to xml and loading back into running environment

This commit is contained in:
bharnden 2019-06-08 21:46:07 -07:00
parent 191d392c46
commit 10df7d35ee
3 changed files with 24 additions and 8 deletions

View file

@ -843,7 +843,6 @@ class PtpNet(CoreNetwork):
return all_links
if1, if2 = self._netif.values()
unidirectional = 0
if if1.getparams() != if2.getparams():
unidirectional = 1
@ -918,10 +917,11 @@ class PtpNet(CoreNetwork):
message_type=0,
node1_id=if2.node.id,
node2_id=if1.node.id,
delay=if1.getparam("delay"),
bandwidth=if1.getparam("bw"),
dup=if1.getparam("duplicate"),
jitter=if1.getparam("jitter"),
delay=if2.getparam("delay"),
bandwidth=if2.getparam("bw"),
per=if2.getparam("loss"),
dup=if2.getparam("duplicate"),
jitter=if2.getparam("jitter"),
unidirectional=1,
interface1_id=if2.node.getifindex(if2),
interface2_id=if1.node.getifindex(if1)

View file

@ -792,7 +792,7 @@ class CoreXmlReader(object):
if link_options.unidirectional == 1 and node_set in node_sets:
logging.info("updating link node_one(%s) node_two(%s): %s", node_one, node_two, link_options)
self.session.update_link(node_one, node_two, interface_one, interface_two, link_options)
self.session.update_link(node_one, node_two, interface_one.id, interface_two.id, link_options)
else:
logging.info("adding link node_one(%s) node_two(%s): %s", node_one, node_two, link_options)
self.session.add_link(node_one, node_two, interface_one, interface_two, link_options)

View file

@ -480,12 +480,20 @@ class TestXml:
# create link
link_options_one = LinkOptions()
link_options_one.bandwidth = 5000
link_options_one.unidirectional = 1
link_options_one.bandwidth = 5000
link_options_one.delay = 10
link_options_one.per = 5
link_options_one.dup = 5
link_options_one.jitter = 5
session.add_link(node_one.id, node_two.id, interface_one, interface_two, link_options_one)
link_options_two = LinkOptions()
link_options_two.bandwidth = 10000
link_options_two.unidirectional = 1
link_options_two.bandwidth = 10000
link_options_two.delay = 20
link_options_two.per = 10
link_options_two.dup = 10
link_options_two.jitter = 10
session.update_link(node_two.id, node_one.id, interface_two.id, interface_one.id, link_options_two)
# instantiate session
@ -527,4 +535,12 @@ class TestXml:
link_one = links[0]
link_two = links[1]
assert link_options_one.bandwidth == link_one.bandwidth
assert link_options_one.delay == link_one.delay
assert link_options_one.per == link_one.per
assert link_options_one.dup == link_one.dup
assert link_options_one.jitter == link_one.jitter
assert link_options_two.bandwidth == link_two.bandwidth
assert link_options_two.delay == link_two.delay
assert link_options_two.per == link_two.per
assert link_options_two.dup == link_two.dup
assert link_options_two.jitter == link_two.jitter