daemon: xml files will now write and read loss, but fallback to looking for per for compatibility

This commit is contained in:
Blake Harnden 2020-06-13 17:41:13 -07:00
parent b74395049a
commit e18ffaafce

View file

@ -569,7 +569,7 @@ class CoreXmlWriter:
options = etree.Element("options") options = etree.Element("options")
add_attribute(options, "delay", link_data.delay) add_attribute(options, "delay", link_data.delay)
add_attribute(options, "bandwidth", link_data.bandwidth) add_attribute(options, "bandwidth", link_data.bandwidth)
add_attribute(options, "per", link_data.loss) add_attribute(options, "loss", link_data.loss)
add_attribute(options, "dup", link_data.dup) add_attribute(options, "dup", link_data.dup)
add_attribute(options, "jitter", link_data.jitter) add_attribute(options, "jitter", link_data.jitter)
add_attribute(options, "mer", link_data.mer) add_attribute(options, "mer", link_data.mer)
@ -947,37 +947,39 @@ class CoreXmlReader:
interface_two = create_interface_data(interface_two_element) interface_two = create_interface_data(interface_two_element)
options_element = link_element.find("options") options_element = link_element.find("options")
link_options = LinkOptions() options = LinkOptions()
if options_element is not None: if options_element is not None:
link_options.bandwidth = get_int(options_element, "bandwidth") options.bandwidth = get_int(options_element, "bandwidth")
link_options.burst = get_int(options_element, "burst") options.burst = get_int(options_element, "burst")
link_options.delay = get_int(options_element, "delay") options.delay = get_int(options_element, "delay")
link_options.dup = get_int(options_element, "dup") options.dup = get_int(options_element, "dup")
link_options.mer = get_int(options_element, "mer") options.mer = get_int(options_element, "mer")
link_options.mburst = get_int(options_element, "mburst") options.mburst = get_int(options_element, "mburst")
link_options.jitter = get_int(options_element, "jitter") options.jitter = get_int(options_element, "jitter")
link_options.key = get_int(options_element, "key") options.key = get_int(options_element, "key")
link_options.loss = get_float(options_element, "per") options.loss = get_float(options_element, "loss")
link_options.unidirectional = get_int(options_element, "unidirectional") if options.loss is None:
link_options.session = options_element.get("session") options.loss = get_float(options_element, "per")
link_options.emulation_id = get_int(options_element, "emulation_id") options.unidirectional = get_int(options_element, "unidirectional")
link_options.network_id = get_int(options_element, "network_id") options.session = options_element.get("session")
link_options.opaque = options_element.get("opaque") options.emulation_id = get_int(options_element, "emulation_id")
link_options.gui_attributes = options_element.get("gui_attributes") options.network_id = get_int(options_element, "network_id")
options.opaque = options_element.get("opaque")
options.gui_attributes = options_element.get("gui_attributes")
if link_options.unidirectional == 1 and node_set in node_sets: if options.unidirectional == 1 and node_set in node_sets:
logging.info( logging.info(
"updating link node_one(%s) node_two(%s)", node_one, node_two "updating link node_one(%s) node_two(%s)", node_one, node_two
) )
self.session.update_link( self.session.update_link(
node_one, node_two, interface_one.id, interface_two.id, link_options node_one, node_two, interface_one.id, interface_two.id, options
) )
else: else:
logging.info( logging.info(
"adding link node_one(%s) node_two(%s)", node_one, node_two "adding link node_one(%s) node_two(%s)", node_one, node_two
) )
self.session.add_link( self.session.add_link(
node_one, node_two, interface_one, interface_two, link_options node_one, node_two, interface_one, interface_two, options
) )
node_sets.add(node_set) node_sets.add(node_set)