added interface name and nemid for emane connected interfaces to generated xml
This commit is contained in:
parent
08b27ad0d7
commit
cf6f8391b0
2 changed files with 72 additions and 55 deletions
|
@ -222,8 +222,8 @@ class ServiceManager(object):
|
|||
:param CoreService service: service to add
|
||||
:return: nothing
|
||||
"""
|
||||
logger.info("loading service: %s", service.__name__)
|
||||
name = service.name
|
||||
logger.info("loading service: class(%s) name(%s)", service.__name__, name)
|
||||
|
||||
# avoid duplicate services
|
||||
if name in cls.services:
|
||||
|
|
|
@ -161,59 +161,6 @@ def get_downstream_l2_devices(node):
|
|||
return l2_devices, all_endpoints
|
||||
|
||||
|
||||
def create_link_element(link_data):
|
||||
link_element = etree.Element("link")
|
||||
add_attribute(link_element, "node_one", link_data.node1_id)
|
||||
add_attribute(link_element, "node_two", link_data.node2_id)
|
||||
|
||||
# check for interface one
|
||||
interface_one = etree.Element("interface_one")
|
||||
add_attribute(interface_one, "id", link_data.interface1_id)
|
||||
add_attribute(interface_one, "name", link_data.interface1_name)
|
||||
add_attribute(interface_one, "mac", link_data.interface1_mac)
|
||||
add_attribute(interface_one, "ip4", link_data.interface1_ip4)
|
||||
add_attribute(interface_one, "ip4_mask", link_data.interface1_ip4_mask)
|
||||
add_attribute(interface_one, "ip6", link_data.interface1_ip6)
|
||||
add_attribute(interface_one, "ip6_mask", link_data.interface1_ip6_mask)
|
||||
if interface_one.items():
|
||||
link_element.append(interface_one)
|
||||
|
||||
# check for interface two
|
||||
interface_two = etree.Element("interface_two")
|
||||
add_attribute(interface_two, "id", link_data.interface2_id)
|
||||
add_attribute(interface_two, "name", link_data.interface2_name)
|
||||
add_attribute(interface_two, "mac", link_data.interface2_mac)
|
||||
add_attribute(interface_two, "ip4", link_data.interface2_ip4)
|
||||
add_attribute(interface_two, "ip4_mask", link_data.interface2_ip4_mask)
|
||||
add_attribute(interface_two, "ip6", link_data.interface2_ip6)
|
||||
add_attribute(interface_two, "ip6_mask", link_data.interface2_ip6_mask)
|
||||
if interface_two.items():
|
||||
link_element.append(interface_two)
|
||||
|
||||
# check for options
|
||||
options = etree.Element("options")
|
||||
add_attribute(options, "delay", link_data.delay)
|
||||
add_attribute(options, "bandwidth", link_data.bandwidth)
|
||||
add_attribute(options, "per", link_data.per)
|
||||
add_attribute(options, "dup", link_data.dup)
|
||||
add_attribute(options, "jitter", link_data.jitter)
|
||||
add_attribute(options, "mer", link_data.mer)
|
||||
add_attribute(options, "burst", link_data.burst)
|
||||
add_attribute(options, "mburst", link_data.mburst)
|
||||
add_attribute(options, "type", link_data.link_type)
|
||||
add_attribute(options, "gui_attributes", link_data.gui_attributes)
|
||||
add_attribute(options, "unidirectional", link_data.unidirectional)
|
||||
add_attribute(options, "emulation_id", link_data.emulation_id)
|
||||
add_attribute(options, "network_id", link_data.network_id)
|
||||
add_attribute(options, "key", link_data.key)
|
||||
add_attribute(options, "opaque", link_data.opaque)
|
||||
add_attribute(options, "session", link_data.session)
|
||||
if options.items():
|
||||
link_element.append(options)
|
||||
|
||||
return link_element
|
||||
|
||||
|
||||
class Endpoint(object):
|
||||
def __init__(self, network, interface, _type=None, _id=None, l2devport=None, params=None):
|
||||
self.network = network
|
||||
|
@ -625,7 +572,7 @@ class CoreXmlWriter(object):
|
|||
if link_data.interface1_id is None and link_data.interface2_id is None:
|
||||
continue
|
||||
|
||||
link_element = create_link_element(link_data)
|
||||
link_element = self.create_link_element(link_data)
|
||||
link_elements.append(link_element)
|
||||
|
||||
if link_elements.getchildren():
|
||||
|
@ -635,6 +582,76 @@ class CoreXmlWriter(object):
|
|||
device = DeviceElement(self.session, node)
|
||||
self.devices.append(device.element)
|
||||
|
||||
def create_link_element(self, link_data):
|
||||
link_element = etree.Element("link")
|
||||
add_attribute(link_element, "node_one", link_data.node1_id)
|
||||
add_attribute(link_element, "node_two", link_data.node2_id)
|
||||
|
||||
# check for interface one
|
||||
if link_data.interface1_id is not None:
|
||||
interface_one = etree.Element("interface_one")
|
||||
node = self.session.get_object(link_data.node1_id)
|
||||
node_interface = node.netif(link_data.interface1_id)
|
||||
|
||||
add_attribute(interface_one, "id", link_data.interface1_id)
|
||||
add_attribute(interface_one, "name", node_interface.name)
|
||||
add_attribute(interface_one, "mac", link_data.interface1_mac)
|
||||
add_attribute(interface_one, "ip4", link_data.interface1_ip4)
|
||||
add_attribute(interface_one, "ip4_mask", link_data.interface1_ip4_mask)
|
||||
add_attribute(interface_one, "ip6", link_data.interface1_ip6)
|
||||
add_attribute(interface_one, "ip6_mask", link_data.interface1_ip6_mask)
|
||||
|
||||
# check if emane interface
|
||||
if nodeutils.is_node(node_interface.net, NodeTypes.EMANE):
|
||||
nem = node_interface.net.getnemid(node_interface)
|
||||
add_attribute(interface_one, "nem", nem)
|
||||
|
||||
link_element.append(interface_one)
|
||||
|
||||
# check for interface two
|
||||
if link_data.interface2_id is not None:
|
||||
interface_two = etree.Element("interface_two")
|
||||
node = self.session.get_object(link_data.node2_id)
|
||||
node_interface = node.netif(link_data.interface2_id)
|
||||
|
||||
add_attribute(interface_two, "id", link_data.interface2_id)
|
||||
add_attribute(interface_two, "name", node_interface.name)
|
||||
add_attribute(interface_two, "mac", link_data.interface2_mac)
|
||||
add_attribute(interface_two, "ip4", link_data.interface2_ip4)
|
||||
add_attribute(interface_two, "ip4_mask", link_data.interface2_ip4_mask)
|
||||
add_attribute(interface_two, "ip6", link_data.interface2_ip6)
|
||||
add_attribute(interface_two, "ip6_mask", link_data.interface2_ip6_mask)
|
||||
|
||||
# check if emane interface
|
||||
if nodeutils.is_node(node_interface.net, NodeTypes.EMANE):
|
||||
nem = node_interface.net.getnemid(node_interface)
|
||||
add_attribute(interface_two, "nem", nem)
|
||||
|
||||
link_element.append(interface_two)
|
||||
|
||||
# check for options
|
||||
options = etree.Element("options")
|
||||
add_attribute(options, "delay", link_data.delay)
|
||||
add_attribute(options, "bandwidth", link_data.bandwidth)
|
||||
add_attribute(options, "per", link_data.per)
|
||||
add_attribute(options, "dup", link_data.dup)
|
||||
add_attribute(options, "jitter", link_data.jitter)
|
||||
add_attribute(options, "mer", link_data.mer)
|
||||
add_attribute(options, "burst", link_data.burst)
|
||||
add_attribute(options, "mburst", link_data.mburst)
|
||||
add_attribute(options, "type", link_data.link_type)
|
||||
add_attribute(options, "gui_attributes", link_data.gui_attributes)
|
||||
add_attribute(options, "unidirectional", link_data.unidirectional)
|
||||
add_attribute(options, "emulation_id", link_data.emulation_id)
|
||||
add_attribute(options, "network_id", link_data.network_id)
|
||||
add_attribute(options, "key", link_data.key)
|
||||
add_attribute(options, "opaque", link_data.opaque)
|
||||
add_attribute(options, "session", link_data.session)
|
||||
if options.items():
|
||||
link_element.append(options)
|
||||
|
||||
return link_element
|
||||
|
||||
|
||||
class CoreXmlReader(object):
|
||||
def __init__(self, session):
|
||||
|
|
Loading…
Reference in a new issue