def step_1(network, conns, yconns, filter=filter): yangcli_script_local = ''' merge /interfaces/interface[name='ge0'] -- type='ethernetCsmacd' merge /interfaces/interface[name='ge1'] -- type='ethernetCsmacd' merge /interfaces/interface[name='ge2'] -- type='ethernetCsmacd' merge /interfaces/interface[name='ge3'] -- type='ethernetCsmacd' merge /interfaces/interface[name='ge4'] -- type='ethernetCsmacd' merge /interfaces/interface[name='ge5'] -- type='ethernetCsmacd' merge /interfaces/interface[name='ge6'] -- type='ethernetCsmacd' merge /interfaces/interface[name='ge7'] -- type='ethernetCsmacd' merge /interfaces/interface[name='ge8'] -- type='ethernetCsmacd' merge /interfaces/interface[name='ge9'] -- type='ethernetCsmacd' #replace /interfaces/interface[name='ge0']/traffic-generator -- frame-size=1500 interframe-gap=15000 ether-type=1234 frames-per-burst=100 interburst-gap=150000 direction=ingress replace /interfaces/interface[name='ge1']/traffic-generator -- frame-size=1500 interframe-gap=64 ether-type=1234 direction=ingress replace /interfaces/interface[name='ge2']/traffic-generator -- frame-size=1500 interframe-gap=64 ether-type=1234 direction=ingress replace /interfaces/interface[name='ge3']/traffic-generator -- frame-size=1500 interframe-gap=64 ether-type=1234 direction=ingress #replace /interfaces/interface[name='ge4']/traffic-generator -- frame-size=1500 interframe-gap=15000 ether-type=1234 frames-per-burst=100 interburst-gap=150000 direction=ingress #replace /interfaces/interface[name='ge5']/traffic-generator -- frame-size=1500 interframe-gap=15000 ether-type=1234 frames-per-burst=100 interburst-gap=150000 direction=ingress #replace /interfaces/interface[name='ge6']/traffic-generator -- frame-size=1500 interframe-gap=15000 ether-type=1234 frames-per-burst=100 interburst-gap=150000 direction=ingress #replace /interfaces/interface[name='ge7']/traffic-generator -- frame-size=1500 interframe-gap=15000 ether-type=1234 frames-per-burst=100 interburst-gap=150000 direction=ingress #replace /interfaces/interface[name='ge8']/traffic-generator -- frame-size=1500 interframe-gap=15000 ether-type=1234 frames-per-burst=100 interburst-gap=150000 direction=ingress #replace /interfaces/interface[name='ge9']/traffic-generator -- frame-size=1500 interframe-gap=15000 ether-type=1234 frames-per-burst=100 interburst-gap=150000 direction=ingress ''' yangcli_script_middle = ''' merge /interfaces/interface[name='ge0'] -- type='ethernetCsmacd' merge /interfaces/interface[name='ge1'] -- type='ethernetCsmacd' merge /interfaces/interface[name='ge2'] -- type='ethernetCsmacd' merge /interfaces/interface[name='ge3'] -- type='ethernetCsmacd' merge /interfaces/interface[name='ge4'] -- type='ethernetCsmacd' merge /interfaces/interface[name='ge5'] -- type='ethernetCsmacd' merge /interfaces/interface[name='ge6'] -- type='ethernetCsmacd' merge /interfaces/interface[name='ge7'] -- type='ethernetCsmacd' merge /interfaces/interface[name='ge8'] -- type='ethernetCsmacd' merge /interfaces/interface[name='ge9'] -- type='ethernetCsmacd' #replace /interfaces/interface[name='ge0']/traffic-generator -- frame-size=1500 interframe-gap=15000 ether-type=1234 direction=ingress frames-per-burst=100 interburst-gap=150000 #replace /interfaces/interface[name='ge1']/traffic-generator -- frame-size=1500 interframe-gap=15000 ether-type=1234 direction=ingress frames-per-burst=100 interburst-gap=150000 #replace /interfaces/interface[name='ge2']/traffic-generator -- frame-size=1500 interframe-gap=15000 ether-type=1234 direction=ingress frames-per-burst=100 interburst-gap=150000 #replace /interfaces/interface[name='ge3']/traffic-generator -- frame-size=1500 interframe-gap=15000 ether-type=1234 direction=ingress frames-per-burst=100 interburst-gap=150000 replace /interfaces/interface[name='ge4']/traffic-generator -- frame-size=1500 interframe-gap=1500 ether-type=1234 direction=ingress frames-per-burst=100 interburst-gap=150000 replace /interfaces/interface[name='ge5']/traffic-generator -- frame-size=1500 interframe-gap=1500 ether-type=1234 direction=ingress replace /interfaces/interface[name='ge6']/traffic-generator -- frame-size=1500 interframe-gap=1500 ether-type=1234 direction=ingress replace /interfaces/interface[name='ge7']/traffic-generator -- frame-size=1500 interframe-gap=1500 ether-type=1234 direction=ingress replace /interfaces/interface[name='ge8']/traffic-generator -- frame-size=1500 interframe-gap=1500 ether-type=1234 direction=ingress replace /interfaces/interface[name='ge9']/traffic-generator -- frame-size=1500 interframe-gap=1500 ether-type=1234 direction=ingress ''' yangcli_ok_script(yconns["local"], yangcli_script_local) yangcli_ok_script(yconns["middle"], yangcli_script_middle) tntapi.network_commit(conns) state_before = tntapi.network_get_state(network, conns, filter=filter) time.sleep(5) state_after = tntapi.network_get_state(network, conns, filter=filter) validate_step_1(state_before, state_after)
def step_1(network, conns, filter=filter): idle_config_bridge = """ <config> <bridge xmlns="urn:ietf:params:xml:ns:yang:ietf-network-bridge" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="replace"/> <flows xmlns="urn:ietf:params:xml:ns:yang:ietf-network-bridge-flows" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="replace"/> <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces" nc:operation="replace"/> </config> """ tntapi.edit_config(conns["local"],idle_config_bridge) tntapi.edit_config(conns["remote"],idle_config_bridge) tntapi.edit_config(conns["middle"],idle_config_bridge) idle_config_h100_1dot6 = """ <config> <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="replace"> <interface> <name>xe0</name> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> </interface> <interface> <name>ge15</name> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> </interface> <interface> <name>ge0</name> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> </interface> </interfaces> <fusion-streams xmlns="http://transpacket.com/ns/transpacket-fusion-streams" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="replace"> </fusion-streams> </config> """ idle_config_h100_1dot0 = """ <config> <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces" nc:operation="replace"/> <vlans xmlns="http://transpacket.com/ns/hadm1-vlans" nc:operation="replace"/> <hadm xmlns="http://transpacket.com/ns/hadm" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="replace"/> </config> """ tntapi.edit_config(conns["local"],idle_config_h100_1dot6) tntapi.edit_config(conns["remote"],idle_config_h100_1dot6) tntapi.edit_config(conns["middle"],idle_config_h100_1dot0) tntapi.network_commit(conns) state_before = tntapi.network_get_state(network, conns, filter=filter) time.sleep(2) state_after = tntapi.network_get_state(network, conns, filter=filter) validate_step_1(state_before, state_after)
def pause(network, conns, filter=filter): rpc = """<discard-changes/>""" for conn_id in conns: conns[conn_id].send(rpc) for conn_id in conns: conns[conn_id].receive() state_before = tntapi.network_get_state(network, conns, filter=filter) time.sleep(1) state_after = tntapi.network_get_state(network, conns, filter=filter) validate_pause(state_before, state_after)
def init(network, conns, filter=filter): idle_config_analyzer = """ <config> <hadm xmlns="http://transpacket.com/ns/hadm" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="replace"> </hadm> <vlans xmlns="http://transpacket.com/ns/hadm1-vlans" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="replace"> </vlans> <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"> <interface xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="replace"> <name>xe0</name> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> </interface> <interface xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="replace"> <name>xe1</name> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> </interface> <interface xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="replace"> <name>ge0</name> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> <ethernet xmlns="urn:ieee:params:xml:ns:yang:ethernet"> <auto-negotiation> <status>enabled</status> </auto-negotiation> </ethernet> </interface> <interface xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="replace"> <name>ge1</name> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> <ethernet xmlns="urn:ieee:params:xml:ns:yang:ethernet"> <auto-negotiation> <status>enabled</status> </auto-negotiation> </ethernet> </interface> </interfaces> </config> """ tntapi.edit_config(conns["analyzer"], idle_config_analyzer) #tntapi.edit_config(conns["local"],idle_config_local) #tntapi.edit_config(conns["remote"],idle_config_remote) tntapi.network_commit(conns) state_before = tntapi.network_get_state(network, conns, filter=filter) time.sleep(5) state_after = tntapi.network_get_state(network, conns, filter=filter) validate_init(state_before, state_after)
def validate(network, conns, yconns, filter, step, with_sm, with_gst): if(with_sm): ok = yangcli(yconns["analyzer"], "create /interfaces/interface[name='xe0']/traffic-analyzer").xpath('./ok') assert(len(ok)==1) if(with_gst): ok = yangcli(yconns["analyzer"], "create /interfaces/interface[name='ge0']/traffic-analyzer").xpath('./ok') assert(len(ok)==1) tntapi.network_commit(conns) if(with_sm): ok = yangcli(yconns["analyzer"], "create /interfaces/interface[name='xe0']/traffic-generator -- frame-size=1500 interframe-gap=12 ether-type=8100 frames-per-burst=100 interburst-gap=10000").xpath('./ok') assert(len(ok)==1) if(with_gst): ok = yangcli(yconns["analyzer"], "create /interfaces/interface[name='ge0']/traffic-generator -- frame-size=64 interframe-gap=12 ether-type=88F7 frames-per-burst=100 interburst-gap=10000").xpath('./ok') assert(len(ok)==1) state_before = tntapi.network_get_state(network, conns, filter=filter) tntapi.network_commit(conns) print("Start traffic ...") time.sleep(10) print("Stop traffic ...") if(with_sm): ok = yangcli(yconns["analyzer"], "delete /interfaces/interface[name='xe0']/traffic-generator").xpath('./ok') assert(len(ok)==1) if(with_gst): ok = yangcli(yconns["analyzer"], "delete /interfaces/interface[name='ge0']/traffic-generator").xpath('./ok') assert(len(ok)==1) tntapi.network_commit(conns) state_after = tntapi.network_get_state(network, conns, filter=filter) if(with_sm): ok = yangcli(yconns["analyzer"], "delete /interfaces/interface[name='xe0']/traffic-analyzer").xpath('./ok') assert(len(ok)==1) if(with_gst): ok = yangcli(yconns["analyzer"], "delete /interfaces/interface[name='ge0']/traffic-analyzer").xpath('./ok') assert(len(ok)==1) tntapi.network_commit(conns) return validate_step_common(state_before, state_after, step, with_sm, with_gst)
def step_1(network, conns, yconns, filter=filter): yangcli_script_common = ''' remove /interfaces/interface[name='ge0']/traffic-generator remove /interfaces/interface[name='ge1']/traffic-generator remove /interfaces/interface[name='ge2']/traffic-generator remove /interfaces/interface[name='ge3']/traffic-generator remove /interfaces/interface[name='ge4']/traffic-generator remove /interfaces/interface[name='ge5']/traffic-generator remove /interfaces/interface[name='ge6']/traffic-generator remove /interfaces/interface[name='ge7']/traffic-generator remove /interfaces/interface[name='ge8']/traffic-generator remove /interfaces/interface[name='ge9']/traffic-generator commit ''' yangcli_ok_script(yconns["local"], yangcli_script_common) yangcli_ok_script(yconns["middle"], yangcli_script_common) tntapi.network_commit(conns) state_before = tntapi.network_get_state(network, conns, filter=filter) time.sleep(5) state_after = tntapi.network_get_state(network, conns, filter=filter) validate_step_1(state_before, state_after)
def step_1(network, conns, filter): state_before = tntapi.network_get_state(network, conns, filter=filter) print("Enable analyzers ...") analyzer_config = """ <config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"> <interface> <name>ge0</name> <traffic-analyzer xmlns="http://transpacket.com/ns/transpacket-traffic-analyzer" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="create"></traffic-analyzer> </interface> </interfaces> </config> """ tntapi.edit_config(conns["analyzer"], analyzer_config) tntapi.network_commit(conns) print("Start traffic ...") generator_if = """ <interface> <name>%(name)s</name> <traffic-generator xmlns="http://transpacket.com/ns/transpacket-traffic-generator" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="create"> <frame-size>64</frame-size> <interframe-gap>%(interframe_gap)s</interframe-gap> <total-frames>1000000</total-frames> <ether-type xmlns="http://transpacket.com/ns/transpacket-traffic-generator-ethernet">88F7</ether-type> </traffic-generator> </interface> """ generator_config = """ <config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"> %(xe0)s %(xe1)s </interfaces> </config> """ % { 'xe0': generator_if % { 'name': "xe0", 'interframe_gap': 640 }, 'xe1': generator_if % { 'name': "xe1", 'interframe_gap': 640 } } tntapi.edit_config(conns["analyzer"], generator_config) tntapi.network_commit(conns) time.sleep(10) print("Stop traffic ...") generator_config = """ <config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"> <interface> <name>xe0</name> <traffic-generator xmlns="http://transpacket.com/ns/transpacket-traffic-generator" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="delete"> </traffic-generator> </interface> <interface> <name>xe1</name> <traffic-generator xmlns="http://transpacket.com/ns/transpacket-traffic-generator" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="delete"> </traffic-generator> </interface> </interfaces> </config> """ tntapi.edit_config(conns["analyzer"], generator_config) tntapi.network_commit(conns) print("Disable analyzers ...") analyzer_config = """ <config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"> <interface> <name>ge0</name> <traffic-analyzer xmlns="http://transpacket.com/ns/transpacket-traffic-analyzer" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="delete"></traffic-analyzer> </interface> </interfaces> </config> """ tntapi.edit_config(conns["analyzer"], analyzer_config) tntapi.network_commit(conns) state_after = tntapi.network_get_state(network, conns, filter=filter) return validate_step1(state_before, state_after)
def validate(network, conns, yconns, inks, load_percent=99, frame_size=1500, interframe_gap=12, frames_per_burst=0, interburst_gap=0): global args filter = "" #"""<filter type="xpath" select="/*[local-name()='interfaces-state' or local-name()='interfaces']/interface/*[local-name()='traffic-analyzer' or local-name()='oper-status' or local-name()='statistics' or local-name()='speed']"/>""" config_idle = {} nodes = network.xpath('nd:node', namespaces=namespaces) for node in nodes: node_id = node.xpath('nd:node-id', namespaces=namespaces)[0].text config = "" print node_id termination_points = node.xpath('./nt:termination-point', namespaces=namespaces) for termination_point in termination_points: tp_id = termination_point.xpath('nt:tp-id', namespaces=namespaces)[0].text if (not is_interface_test_enabled(node_id, tp_id)): continue ok = yangcli( yconns[node_id], """replace /interfaces/interface[name='%(name)s'] -- type=ethernetCsmacd""" % { 'name': tp_id }).xpath('./ok') assert (len(ok) == 1) tntapi.network_commit(conns) state_before = tntapi.network_get_state(network, conns, filter=filter) print("Waiting " + "5" + " sec. ...") time.sleep(5) print("Done.") state_after = tntapi.network_get_state(network, conns, filter=filter) mylinks = tntapi.parse_network_links(state_before) t1 = tntapi.parse_network_nodes(state_before) t2 = tntapi.parse_network_nodes(state_after) delta = tntapi.get_network_counters_delta(state_before, state_after) tntapi.print_state_ietf_interfaces_statistics_delta( network, state_before, state_after) for node in nodes: node_id = node.xpath('nd:node-id', namespaces=namespaces)[0].text termination_points = node.xpath('./nt:termination-point', namespaces=namespaces) for termination_point in termination_points: tp_id = termination_point.xpath('nt:tp-id', namespaces=namespaces)[0].text if (not is_interface_test_enabled(node_id, tp_id)): continue validate_traffic_off(node_id, tp_id, state_before, state_after, delta, frame_size) load = float(load_percent) / 100 print "ifg=" + str(interframe_gap) if (args.test_internal_loopback == "true"): print("Enabling internal loopbacks.") for node in nodes: node_id = node.xpath('nd:node-id', namespaces=namespaces)[0].text termination_points = node.xpath('./nt:termination-point', namespaces=namespaces) for termination_point in termination_points: tp_id = termination_point.xpath('nt:tp-id', namespaces=namespaces)[0].text if (not is_interface_test_enabled(node_id, tp_id)): continue ok = yangcli( yconns[node_id], """merge /interfaces/interface[name='%(name)s'] -- loopback=internal""" % { 'name': tp_id }).xpath('./ok') assert (len(ok) == 1) tntapi.network_commit(conns) if (args.test_analyzer == "true"): print("Enabling analyzer.") for node in nodes: node_id = node.xpath('nd:node-id', namespaces=namespaces)[0].text termination_points = node.xpath('./nt:termination-point', namespaces=namespaces) for termination_point in termination_points: tp_id = termination_point.xpath('nt:tp-id', namespaces=namespaces)[0].text if (not is_interface_test_enabled(node_id, tp_id)): continue if (args.direction == 'ingress'): ok = yangcli( yconns[node_id], """create /interfaces/interface[name='%(name)s']/traffic-analyzer-egress""" % { 'name': tp_id }).xpath('./ok') else: ok = yangcli( yconns[node_id], """create /interfaces/interface[name='%(name)s']/traffic-analyzer""" % { 'name': tp_id }).xpath('./ok') assert (len(ok) == 1) tntapi.network_commit(conns) for node in nodes: node_id = node.xpath('nd:node-id', namespaces=namespaces)[0].text config = "" termination_points = node.xpath('./nt:termination-point', namespaces=namespaces) for termination_point in termination_points: tp_id = termination_point.xpath('nt:tp-id', namespaces=namespaces)[0].text if (not is_interface_test_enabled(node_id, tp_id)): continue if (frames_per_burst > 0): my_burst_config = """frames-per-burst=%(frames-per-burst)d interburst-gap=%(interburst-gap)d""" % { 'frames-per-burst': frames_per_burst, 'interburst-gap': interburst_gap - 8 } else: my_burst_config = "" if (args.direction == 'ingress'): generator_direction_suffix = '-ingress' analyzer_direction_suffix = '-egress' else: generator_direction_suffix = '' analyzer_direction_suffix = '' ok = yangcli( yconns[node_id], """create /interfaces/interface[name='%(name)s']/traffic-generator%(generator-direction-suffix)s -- ether-type=%(ether-type)d frame-size=%(frame-size)d interframe-gap=%(interframe-gap)d %(burst)s""" % { 'name': tp_id, 'generator-direction-suffix': generator_direction_suffix, 'frame-size': frame_size, 'ether-type': 0x1234, 'interframe-gap': interframe_gap - 8, 'burst': my_burst_config }).xpath('./ok') assert (len(ok) == 1) state_before = tntapi.network_get_state(network, conns, filter=filter) tntapi.network_commit(conns) print("Waiting " + str(test_time) + " sec. ...") time.sleep(test_time) print("Stopping generators ...") for node in nodes: node_id = node.xpath('nd:node-id', namespaces=namespaces)[0].text config = "" termination_points = node.xpath('./nt:termination-point', namespaces=namespaces) for termination_point in termination_points: tp_id = termination_point.xpath('nt:tp-id', namespaces=namespaces)[0].text if (not is_interface_test_enabled(node_id, tp_id)): continue ok = yangcli( yconns[node_id], """delete /interfaces/interface[name='%(name)s']/traffic-generator%(generator-direction-suffix)s""" % { 'name': tp_id, 'generator-direction-suffix': generator_direction_suffix }).xpath('./ok') assert (len(ok) == 1) tntapi.network_commit(conns) print("Done.") state_after = tntapi.network_get_state(network, conns, filter=filter) t1 = tntapi.parse_network_nodes(state_before) t2 = tntapi.parse_network_nodes(state_after) delta = tntapi.get_network_counters_delta(state_before, state_after) tntapi.print_state_ietf_interfaces_statistics_delta( network, state_before, state_after) load_generated = {} for node in nodes: node_id = node.xpath('nd:node-id', namespaces=namespaces)[0].text termination_points = node.xpath('./nt:termination-point', namespaces=namespaces) for termination_point in termination_points: tp_id = termination_point.xpath('nt:tp-id', namespaces=namespaces)[0].text if (not is_interface_test_enabled(node_id, tp_id)): continue load_generated[node_id, tp_id] = validate_traffic_on( node_id, tp_id, state_before, state_after, delta, test_time, load_percent, frame_size, interframe_gap, frames_per_burst, interburst_gap) if (args.test_analyzer == "true"): print("Disabling analyzer.") for node in nodes: node_id = node.xpath('nd:node-id', namespaces=namespaces)[0].text termination_points = node.xpath('./nt:termination-point', namespaces=namespaces) for termination_point in termination_points: tp_id = termination_point.xpath('nt:tp-id', namespaces=namespaces)[0].text if (not is_interface_test_enabled(node_id, tp_id)): continue ok = yangcli( yconns[node_id], """delete /interfaces/interface[name='%(name)s']/traffic-analyzer%(analyzer-direction-suffix)s""" % { 'name': tp_id, 'analyzer-direction-suffix': analyzer_direction_suffix }).xpath('./ok') assert (len(ok) == 1) tntapi.network_commit(conns) if (args.test_internal_loopback == "true"): print("Disabling internal loopbacks.") for node in nodes: node_id = node.xpath('nd:node-id', namespaces=namespaces)[0].text termination_points = node.xpath('./nt:termination-point', namespaces=namespaces) for termination_point in termination_points: tp_id = termination_point.xpath('nt:tp-id', namespaces=namespaces)[0].text if (not is_interface_test_enabled(node_id, tp_id)): continue ok = yangcli( yconns[node_id], """delete /interfaces/interface[name='%(name)s']/loopback""" % { 'name': tp_id }).xpath('./ok') assert (len(ok) == 1) tntapi.network_commit(conns) return (load_percent, load_generated)
def validate(network, conns, yconns, inks, load_percent=99, frame_size=1500, interframe_gap=12, frames_per_burst=0, interburst_gap=0): filter = """<filter type="xpath" select="/interfaces-state/interface/*[local-name()='traffic-analyzer' or local-name()='oper-status' or local-name()='statistics' or local-name()='speed']"/>""" # config_idle=""" #<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> #</config> #""" config_idle = {} nodes = network.xpath('nd:node', namespaces=namespaces) for node in nodes: node_id = node.xpath('nd:node-id', namespaces=namespaces)[0].text config = "" termination_points = node.xpath('./nt:termination-point', namespaces=namespaces) for termination_point in termination_points: tp_id = termination_point.xpath('nt:tp-id', namespaces=namespaces)[0].text ok = yangcli( yconns[node_id], """replace /interfaces/interface[name='%(name)s'] -- type=ethernetCsmacd""" % { 'name': tp_id }).xpath('./ok') assert (len(ok) == 1) tntapi.network_commit(conns) state_before = tntapi.network_get_state(network, conns, filter=filter) print("Waiting " + "5" + " sec. ...") time.sleep(5) print("Done.") state_after = tntapi.network_get_state(network, conns, filter=filter) mylinks = tntapi.parse_network_links(state_before) t1 = tntapi.parse_network_nodes(state_before) t2 = tntapi.parse_network_nodes(state_after) delta = tntapi.get_network_counters_delta(state_before, state_after) tntapi.print_state_ietf_interfaces_statistics_delta( network, state_before, state_after) for node in nodes: node_id = node.xpath('nd:node-id', namespaces=namespaces)[0].text termination_points = node.xpath('./nt:termination-point', namespaces=namespaces) for termination_point in termination_points: tp_id = termination_point.xpath('nt:tp-id', namespaces=namespaces)[0].text validate_traffic_off(node_id, tp_id, state_before, state_after, delta) load = float(load_percent) / 100 print "ifg=" + str(interframe_gap) for node in nodes: node_id = node.xpath('nd:node-id', namespaces=namespaces)[0].text config = "" termination_points = node.xpath('./nt:termination-point', namespaces=namespaces) for termination_point in termination_points: tp_id = termination_point.xpath('nt:tp-id', namespaces=namespaces)[0].text if (frames_per_burst > 0): my_burst_config = """frames-per-burst=%(frames-per-burst)d interburst-gap=%(interburst-gap)d""" % { 'frames-per-burst': frames_per_burst, 'interburst-gap': interburst_gap - 8 } else: my_burst_config = "" ok = yangcli( yconns[node_id], """create /interfaces/interface[name='%(name)s']/traffic-generator -- frame-size=%(frame-size)d interframe-gap=%(interframe-gap)d %(burst)s""" % { 'name': tp_id, 'frame-size': frame_size, 'interframe-gap': interframe_gap - 8, 'burst': my_burst_config }).xpath('./ok') assert (len(ok) == 1) state_before = tntapi.network_get_state(network, conns, filter=filter) tntapi.network_commit(conns) print("Waiting " + str(test_time) + " sec. ...") time.sleep(test_time) print("Stopping generators ...") for node in nodes: node_id = node.xpath('nd:node-id', namespaces=namespaces)[0].text config = "" termination_points = node.xpath('./nt:termination-point', namespaces=namespaces) for termination_point in termination_points: tp_id = termination_point.xpath('nt:tp-id', namespaces=namespaces)[0].text ok = yangcli( yconns[node_id], """replace /interfaces/interface[name='%(name)s'] -- type=ethernetCsmacd""" % { 'name': tp_id }).xpath('./ok') assert (len(ok) == 1) tntapi.network_commit(conns) print("Done.") state_after = tntapi.network_get_state(network, conns, filter=filter) t1 = tntapi.parse_network_nodes(state_before) t2 = tntapi.parse_network_nodes(state_after) delta = tntapi.get_network_counters_delta(state_before, state_after) tntapi.print_state_ietf_interfaces_statistics_delta( network, state_before, state_after) load_generated = {} for node in nodes: node_id = node.xpath('nd:node-id', namespaces=namespaces)[0].text termination_points = node.xpath('./nt:termination-point', namespaces=namespaces) for termination_point in termination_points: tp_id = termination_point.xpath('nt:tp-id', namespaces=namespaces)[0].text load_generated[node_id, tp_id] = validate_traffic_on( node_id, tp_id, state_before, state_after, delta, test_time, load_percent, frame_size, interframe_gap, frames_per_burst, interburst_gap) return (load_percent, load_generated)
def step_1(network, conns, yconns, filter=filter): #Delete all result = yangcli(yconns["local"], "delete /fusion-streams") result = yangcli(yconns["remote"], "delete /fusion-streams") tntapi.network_commit(conns) yangcli_script_local = ''' create /fusion-streams/drop-and-forward[in-port='n0'][filter-rule='matched-tpid'] -- priority=gst filter/tpid=88F7 push-vlan-tag/vlanid=100 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 forward/pop-vlan-tag=false drop[out-port='e0']/pop-vlan-tag=true drop[out-port='e1']/pop-vlan-tag=true drop[out-port='e2']/pop-vlan-tag=true drop[out-port='e3']/pop-vlan-tag=true drop[out-port='e4']/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n0'][filter-rule='unmatched'] -- priority=sm push-vlan-tag/vlanid=200 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 forward/pop-vlan-tag=false create /fusion-streams/aggregation[in-port='e0']/sm -- out-port=n1 push-vlan-tag/vlanid=10 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e1']/sm -- out-port=n1 push-vlan-tag/vlanid=11 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e2']/sm -- out-port=n1 push-vlan-tag/vlanid=12 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e3']/sm -- out-port=n1 push-vlan-tag/vlanid=13 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e4']/sm -- out-port=n1 push-vlan-tag/vlanid=14 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e5']/sm -- out-port=n1 push-vlan-tag/vlanid=15 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e6']/sm -- out-port=n1 push-vlan-tag/vlanid=16 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e7']/sm -- out-port=n1 push-vlan-tag/vlanid=17 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e8']/sm -- out-port=n1 push-vlan-tag/vlanid=18 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e9']/sm -- out-port=n1 push-vlan-tag/vlanid=19 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e0']/gst -- out-port=n0 filter/ether-type=88F7 filter/tpid=88F7 filter/vlanid=1 create /fusion-streams/aggregation[in-port='e1']/gst -- out-port=n0 filter/ether-type=88F7 filter/tpid=88F7 filter/vlanid=1 create /fusion-streams/aggregation[in-port='e2']/gst -- out-port=n0 filter/ether-type=88F7 filter/tpid=88F7 filter/vlanid=1 create /fusion-streams/aggregation[in-port='e3']/gst -- out-port=n0 filter/ether-type=88F7 filter/tpid=88F7 filter/vlanid=1 create /fusion-streams/aggregation[in-port='e4']/gst -- out-port=n0 filter/ether-type=88F7 filter/tpid=88F7 filter/vlanid=1 create /fusion-streams/aggregation[in-port='e5']/gst -- out-port=n0 filter/ether-type=88F7 filter/tpid=88F7 filter/vlanid=1 create /fusion-streams/aggregation[in-port='e6']/gst -- out-port=n0 filter/ether-type=88F7 filter/tpid=88F7 filter/vlanid=1 create /fusion-streams/aggregation[in-port='e7']/gst -- out-port=n0 filter/ether-type=88F7 filter/tpid=88F7 filter/vlanid=1 create /fusion-streams/aggregation[in-port='e8']/gst -- out-port=n0 filter/ether-type=88F7 filter/tpid=88F7 filter/vlanid=1 create /fusion-streams/aggregation[in-port='e9']/gst -- out-port=n0 filter/ether-type=88F7 filter/tpid=88F7 filter/vlanid=1 create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='100'] -- priority=gst filter/tpid=9100 forward/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='200'] -- priority=sm filter/tpid=9100 forward/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='10'] -- priority=sm filter/tpid=9100 drop[out-port='e0']/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='11'] -- priority=sm filter/tpid=9100 drop[out-port='e1']/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='12'] -- priority=sm filter/tpid=9100 drop[out-port='e2']/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='13'] -- priority=sm filter/tpid=9100 drop[out-port='e3']/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='14'] -- priority=sm filter/tpid=9100 drop[out-port='e4']/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='15'] -- priority=sm filter/tpid=9100 drop[out-port='e5']/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='16'] -- priority=sm filter/tpid=9100 drop[out-port='e6']/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='17'] -- priority=sm filter/tpid=9100 drop[out-port='e7']/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='18'] -- priority=sm filter/tpid=9100 drop[out-port='e8']/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='19'] -- priority=sm filter/tpid=9100 drop[out-port='e9']/pop-vlan-tag=true ''' yangcli_script_remote = ''' create /fusion-streams/drop-and-forward[in-port='n0'][filter-rule='matched-tpid'] -- priority=gst filter/tpid=88F7 push-vlan-tag/vlanid=100 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 forward/pop-vlan-tag=false create /fusion-streams/drop-and-forward[in-port='n0'][filter-rule='unmatched'] -- priority=sm push-vlan-tag/vlanid=200 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 forward/pop-vlan-tag=false create /fusion-streams/aggregation[in-port='e0']/gst -- filter/ether-type=88F7 filter/tpid=88F7 filter/vlanid=1 out-port=n1 push-vlan-tag/vlanid=100 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e1']/gst -- filter/ether-type=88F7 filter/tpid=88F7 filter/vlanid=1 out-port=n1 push-vlan-tag/vlanid=100 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e2']/gst -- filter/ether-type=88F7 filter/tpid=88F7 filter/vlanid=1 out-port=n1 push-vlan-tag/vlanid=100 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e3']/gst -- filter/ether-type=88F7 filter/tpid=88F7 filter/vlanid=1 out-port=n1 push-vlan-tag/vlanid=100 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e4']/gst -- filter/ether-type=88F7 filter/tpid=88F7 filter/vlanid=1 out-port=n1 push-vlan-tag/vlanid=100 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e5']/gst -- filter/ether-type=88F7 filter/tpid=88F7 filter/vlanid=1 out-port=n1 push-vlan-tag/vlanid=100 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e6']/gst -- filter/ether-type=88F7 filter/tpid=88F7 filter/vlanid=1 out-port=n1 push-vlan-tag/vlanid=100 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e7']/gst -- filter/ether-type=88F7 filter/tpid=88F7 filter/vlanid=1 out-port=n1 push-vlan-tag/vlanid=100 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e8']/gst -- filter/ether-type=88F7 filter/tpid=88F7 filter/vlanid=1 out-port=n1 push-vlan-tag/vlanid=100 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e9']/gst -- filter/ether-type=88F7 filter/tpid=88F7 filter/vlanid=1 out-port=n1 push-vlan-tag/vlanid=100 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e0']/sm -- out-port=n1 push-vlan-tag/vlanid=10 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e1']/sm -- out-port=n1 push-vlan-tag/vlanid=11 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e2']/sm -- out-port=n1 push-vlan-tag/vlanid=12 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e3']/sm -- out-port=n1 push-vlan-tag/vlanid=13 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e4']/sm -- out-port=n1 push-vlan-tag/vlanid=14 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e5']/sm -- out-port=n1 push-vlan-tag/vlanid=25 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e6']/sm -- out-port=n1 push-vlan-tag/vlanid=26 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e7']/sm -- out-port=n1 push-vlan-tag/vlanid=27 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e8']/sm -- out-port=n1 push-vlan-tag/vlanid=28 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/aggregation[in-port='e9']/sm -- out-port=n1 push-vlan-tag/vlanid=29 push-vlan-tag/pcp=0 push-vlan-tag/tpid=9100 push-vlan-tag/cfi=1 create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='100'] -- priority=gst filter/tpid=9100 drop[out-port='e0']/pop-vlan-tag=true drop[out-port='e1']/pop-vlan-tag=true drop[out-port='e2']/pop-vlan-tag=true drop[out-port='e3']/pop-vlan-tag=true drop[out-port='e4']/pop-vlan-tag=true forward/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='200'] -- priority=sm filter/tpid=9100 forward/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='10'] -- filter/tpid=9100 priority=sm drop[out-port='e0']/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='11'] -- filter/tpid=9100 priority=sm drop[out-port='e1']/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='12'] -- filter/tpid=9100 priority=sm drop[out-port='e2']/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='13'] -- filter/tpid=9100 priority=sm drop[out-port='e3']/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='14'] -- filter/tpid=9100 priority=sm drop[out-port='e4']/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='25'] -- filter/tpid=9100 priority=sm drop[out-port='e5']/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='26'] -- filter/tpid=9100 priority=sm drop[out-port='e6']/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='27'] -- filter/tpid=9100 priority=sm drop[out-port='e7']/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='28'] -- filter/tpid=9100 priority=sm drop[out-port='e8']/pop-vlan-tag=true create /fusion-streams/drop-and-forward[in-port='n1'][filter-rule='29'] -- filter/tpid=9100 priority=sm drop[out-port='e9']/pop-vlan-tag=true ''' yangcli_script_middle = ''' replace /vlans/vlan -- name=trunk id=500 tpid=0x9100 replace /interfaces/interface -- name='xe0' type=ethernetCsmacd replace /interfaces/interface[name='xe0']/ethernet-switching/trunk-interface/vlans/vlan/vlan-name value=trunk replace /interfaces/interface -- name='xe1' type=ethernetCsmacd replace /interfaces/interface[name='xe1']/ethernet-switching/trunk-interface/vlans/vlan/vlan-name value=trunk replace /hadm/forward-unmatched-packets value=true replace /vlans/vlan -- name=vlan10 id=10 tpid=0x9100 replace /vlans/vlan -- name=vlan11 id=11 tpid=0x9100 replace /vlans/vlan -- name=vlan12 id=12 tpid=0x9100 replace /vlans/vlan -- name=vlan13 id=13 tpid=0x9100 replace /vlans/vlan -- name=vlan14 id=14 tpid=0x9100 replace /vlans/vlan -- name=vlan15 id=15 tpid=0x9100 replace /vlans/vlan -- name=vlan16 id=16 tpid=0x9100 replace /vlans/vlan -- name=vlan17 id=17 tpid=0x9100 replace /vlans/vlan -- name=vlan18 id=18 tpid=0x9100 replace /vlans/vlan -- name=vlan19 id=19 tpid=0x9100 replace /vlans/vlan -- name=vlan20 id=20 tpid=0x9100 replace /vlans/vlan -- name=vlan21 id=21 tpid=0x9100 replace /vlans/vlan -- name=vlan22 id=22 tpid=0x9100 replace /vlans/vlan -- name=vlan23 id=23 tpid=0x9100 replace /vlans/vlan -- name=vlan24 id=24 tpid=0x9100 replace /vlans/vlan -- name=vlan25 id=25 tpid=0x9100 replace /vlans/vlan -- name=vlan26 id=26 tpid=0x9100 replace /vlans/vlan -- name=vlan27 id=27 tpid=0x9100 replace /vlans/vlan -- name=vlan28 id=28 tpid=0x9100 replace /vlans/vlan -- name=vlan29 id=29 tpid=0x9100 create /interfaces/interface -- name='ge0' type=ethernetCsmacd create /interfaces/interface -- name='ge1' type=ethernetCsmacd create /interfaces/interface -- name='ge2' type=ethernetCsmacd create /interfaces/interface -- name='ge3' type=ethernetCsmacd create /interfaces/interface -- name='ge4' type=ethernetCsmacd create /interfaces/interface -- name='ge5' type=ethernetCsmacd create /interfaces/interface -- name='ge6' type=ethernetCsmacd create /interfaces/interface -- name='ge7' type=ethernetCsmacd create /interfaces/interface -- name='ge8' type=ethernetCsmacd create /interfaces/interface -- name='ge9' type=ethernetCsmacd create /interfaces/interface[name='xe1']/ethernet-switching/trunk-interface/vlans/vlan -- vlan-name=vlan20 create /interfaces/interface[name='xe1']/ethernet-switching/trunk-interface/vlans/vlan -- vlan-name=vlan21 create /interfaces/interface[name='xe1']/ethernet-switching/trunk-interface/vlans/vlan -- vlan-name=vlan22 create /interfaces/interface[name='xe1']/ethernet-switching/trunk-interface/vlans/vlan -- vlan-name=vlan23 create /interfaces/interface[name='xe1']/ethernet-switching/trunk-interface/vlans/vlan -- vlan-name=vlan24 create /interfaces/interface[name='xe1']/ethernet-switching/trunk-interface/vlans/vlan -- vlan-name=vlan25 create /interfaces/interface[name='xe1']/ethernet-switching/trunk-interface/vlans/vlan -- vlan-name=vlan26 create /interfaces/interface[name='xe1']/ethernet-switching/trunk-interface/vlans/vlan -- vlan-name=vlan27 create /interfaces/interface[name='xe1']/ethernet-switching/trunk-interface/vlans/vlan -- vlan-name=vlan28 create /interfaces/interface[name='xe1']/ethernet-switching/trunk-interface/vlans/vlan -- vlan-name=vlan29 create /interfaces/interface[name='ge0']/ethernet-switching/access-interface/vlan -- vlan-name=vlan20 create /interfaces/interface[name='ge1']/ethernet-switching/access-interface/vlan -- vlan-name=vlan21 create /interfaces/interface[name='ge2']/ethernet-switching/access-interface/vlan -- vlan-name=vlan22 create /interfaces/interface[name='ge3']/ethernet-switching/access-interface/vlan -- vlan-name=vlan23 create /interfaces/interface[name='ge4']/ethernet-switching/access-interface/vlan -- vlan-name=vlan24 create /interfaces/interface[name='ge5']/ethernet-switching/access-interface/vlan -- vlan-name=vlan25 create /interfaces/interface[name='ge6']/ethernet-switching/access-interface/vlan -- vlan-name=vlan26 create /interfaces/interface[name='ge7']/ethernet-switching/access-interface/vlan -- vlan-name=vlan27 create /interfaces/interface[name='ge8']/ethernet-switching/access-interface/vlan -- vlan-name=vlan28 create /interfaces/interface[name='ge9']/ethernet-switching/access-interface/vlan -- vlan-name=vlan29 ''' yangcli_ok_script(yconns["local"], yangcli_script_local) yangcli_ok_script(yconns["remote"], yangcli_script_remote) yangcli_ok_script(yconns["middle"], yangcli_script_middle) tntapi.network_commit(conns) state_before = tntapi.network_get_state(network, conns, filter=filter) time.sleep(5) state_after = tntapi.network_get_state(network, conns, filter=filter) validate_step_1(state_before, state_after)
def step_1(network, conns, filter=filter): fusion_streams_config_h100_local = """ <config> <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="replace"> <interface> <name>xe0</name> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> </interface> <interface> <name>ge15</name> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> </interface> <interface> <name>ge0</name> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> </interface> </interfaces> <fusion-streams xmlns="http://transpacket.com/ns/transpacket-fusion-streams" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="replace"> <aggregation> <in-port>e0</in-port> <sm> <out-port>n1</out-port> <push-vlan-tag> <vlanid>10</vlanid> <tpid>9100</tpid> <pcp>0</pcp> <cfi>1</cfi> </push-vlan-tag> </sm> <gst> <out-port>n0</out-port> <filter> <ether-type>88F7</ether-type> <tpid>88F7</tpid> <vlanid>1</vlanid> </filter> </gst> </aggregation> <aggregation> <in-port>e1</in-port> <sm> <out-port>n1</out-port> <push-vlan-tag> <vlanid>11</vlanid> <tpid>9100</tpid> <pcp>0</pcp> <cfi>1</cfi> </push-vlan-tag> </sm> <gst> <out-port>n0</out-port> <filter> <ether-type>88F7</ether-type> <tpid>88F7</tpid> <vlanid>1</vlanid> </filter> </gst> </aggregation> <aggregation> <in-port>e2</in-port> <sm> <out-port>n1</out-port> <push-vlan-tag> <vlanid>12</vlanid> <tpid>9100</tpid> <pcp>0</pcp> <cfi>1</cfi> </push-vlan-tag> </sm> <gst> <out-port>n0</out-port> <filter> <ether-type>88F7</ether-type> <tpid>88F7</tpid> <vlanid>1</vlanid> </filter> </gst> </aggregation> <aggregation> <in-port>e3</in-port> <sm> <out-port>n1</out-port> <push-vlan-tag> <vlanid>13</vlanid> <tpid>9100</tpid> <pcp>0</pcp> <cfi>1</cfi> </push-vlan-tag> </sm> <gst> <out-port>n0</out-port> <filter> <ether-type>88F7</ether-type> <tpid>88F7</tpid> <vlanid>1</vlanid> </filter> </gst> </aggregation> <aggregation> <in-port>e4</in-port> <sm> <out-port>n1</out-port> <push-vlan-tag> <vlanid>14</vlanid> <tpid>9100</tpid> <pcp>0</pcp> <cfi>1</cfi> </push-vlan-tag> </sm> <gst> <out-port>n0</out-port> <filter> <ether-type>88F7</ether-type> <tpid>88F7</tpid> <vlanid>1</vlanid> </filter> </gst> </aggregation> <drop-and-forward> <in-port>n0</in-port> <filter-rule>matched-tpid</filter-rule> <priority>gst</priority> <push-vlan-tag> <vlanid>100</vlanid> <tpid>9100</tpid> <pcp>0</pcp> <cfi>1</cfi> </push-vlan-tag> <filter> <tpid>88F7</tpid> </filter> <drop> <out-port>e0</out-port> <pop-vlan-tag>true</pop-vlan-tag> </drop> <drop> <out-port>e1</out-port> <pop-vlan-tag>true</pop-vlan-tag> </drop> <drop> <out-port>e2</out-port> <pop-vlan-tag>true</pop-vlan-tag> </drop> <drop> <out-port>e3</out-port> <pop-vlan-tag>true</pop-vlan-tag> </drop> <drop> <out-port>e4</out-port> <pop-vlan-tag>true</pop-vlan-tag> </drop> <forward> <pop-vlan-tag>false</pop-vlan-tag> </forward> </drop-and-forward> <drop-and-forward> <in-port>n0</in-port> <filter-rule>unmatched</filter-rule> <priority>sm</priority> <push-vlan-tag> <vlanid>200</vlanid> <tpid>9100</tpid> <pcp>0</pcp> <cfi>1</cfi> </push-vlan-tag> <forward> <pop-vlan-tag>false</pop-vlan-tag> </forward> </drop-and-forward> <drop-and-forward> <in-port>n1</in-port> <filter-rule>10</filter-rule> <priority>sm</priority> <filter> <tpid>9100</tpid> </filter> <drop> <out-port>e0</out-port> <pop-vlan-tag>true</pop-vlan-tag> </drop> </drop-and-forward> <drop-and-forward> <in-port>n1</in-port> <filter-rule>100</filter-rule> <priority>gst</priority> <filter> <tpid>9100</tpid> </filter> <forward> <pop-vlan-tag>true</pop-vlan-tag> </forward> </drop-and-forward> <drop-and-forward> <in-port>n1</in-port> <filter-rule>11</filter-rule> <priority>sm</priority> <filter> <tpid>9100</tpid> </filter> <drop> <out-port>e1</out-port> <pop-vlan-tag>true</pop-vlan-tag> </drop> </drop-and-forward> <drop-and-forward> <in-port>n1</in-port> <filter-rule>12</filter-rule> <priority>sm</priority> <filter> <tpid>9100</tpid> </filter> <drop> <out-port>e2</out-port> <pop-vlan-tag>true</pop-vlan-tag> </drop> </drop-and-forward> <drop-and-forward> <in-port>n1</in-port> <filter-rule>13</filter-rule> <priority>sm</priority> <filter> <tpid>9100</tpid> </filter> <drop> <out-port>e3</out-port> <pop-vlan-tag>true</pop-vlan-tag> </drop> </drop-and-forward> <drop-and-forward> <in-port>n1</in-port> <filter-rule>14</filter-rule> <priority>sm</priority> <filter> <tpid>9100</tpid> </filter> <drop> <out-port>e4</out-port> <pop-vlan-tag>true</pop-vlan-tag> </drop> </drop-and-forward> <drop-and-forward> <in-port>n1</in-port> <filter-rule>200</filter-rule> <priority>sm</priority> <filter> <tpid>9100</tpid> </filter> <forward> <pop-vlan-tag>true</pop-vlan-tag> </forward> </drop-and-forward> </fusion-streams> </config> """ fusion_streams_config_h100_remote = """ <config> <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="replace"> <interface> <name>xe0</name> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> </interface> <interface> <name>ge15</name> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> </interface> <interface> <name>ge0</name> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> </interface> </interfaces> <fusion-streams xmlns="http://transpacket.com/ns/transpacket-fusion-streams" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="replace"> <aggregation> <in-port>e0</in-port> <sm> <out-port>n1</out-port> <push-vlan-tag> <vlanid>10</vlanid> <tpid>9100</tpid> <pcp>0</pcp> <cfi>1</cfi> </push-vlan-tag> </sm> <gst> <out-port>n1</out-port> <push-vlan-tag> <vlanid>100</vlanid> <tpid>9100</tpid> <pcp>0</pcp> <cfi>1</cfi> </push-vlan-tag> <filter> <ether-type>88F7</ether-type> <tpid>88F7</tpid> <vlanid>1</vlanid> </filter> </gst> </aggregation> <aggregation> <in-port>e1</in-port> <sm> <out-port>n1</out-port> <push-vlan-tag> <vlanid>11</vlanid> <tpid>9100</tpid> <pcp>0</pcp> <cfi>1</cfi> </push-vlan-tag> </sm> <gst> <out-port>n1</out-port> <push-vlan-tag> <vlanid>100</vlanid> <tpid>9100</tpid> <pcp>0</pcp> <cfi>1</cfi> </push-vlan-tag> <filter> <ether-type>88F7</ether-type> <tpid>88F7</tpid> <vlanid>1</vlanid> </filter> </gst> </aggregation> <aggregation> <in-port>e2</in-port> <sm> <out-port>n1</out-port> <push-vlan-tag> <vlanid>12</vlanid> <tpid>9100</tpid> <pcp>0</pcp> <cfi>1</cfi> </push-vlan-tag> </sm> <gst> <out-port>n1</out-port> <push-vlan-tag> <vlanid>100</vlanid> <tpid>9100</tpid> <pcp>0</pcp> <cfi>1</cfi> </push-vlan-tag> <filter> <ether-type>88F7</ether-type> <tpid>88F7</tpid> <vlanid>1</vlanid> </filter> </gst> </aggregation> <aggregation> <in-port>e3</in-port> <sm> <out-port>n1</out-port> <push-vlan-tag> <vlanid>13</vlanid> <tpid>9100</tpid> <pcp>0</pcp> <cfi>1</cfi> </push-vlan-tag> </sm> <gst> <out-port>n1</out-port> <push-vlan-tag> <vlanid>100</vlanid> <tpid>9100</tpid> <pcp>0</pcp> <cfi>1</cfi> </push-vlan-tag> <filter> <ether-type>88F7</ether-type> <tpid>88F7</tpid> <vlanid>1</vlanid> </filter> </gst> </aggregation> <aggregation> <in-port>e4</in-port> <sm> <out-port>n1</out-port> <push-vlan-tag> <vlanid>14</vlanid> <tpid>9100</tpid> <pcp>0</pcp> <cfi>1</cfi> </push-vlan-tag> </sm> <gst> <out-port>n1</out-port> <push-vlan-tag> <vlanid>100</vlanid> <tpid>9100</tpid> <pcp>0</pcp> <cfi>1</cfi> </push-vlan-tag> <filter> <ether-type>88F7</ether-type> <tpid>88F7</tpid> <vlanid>1</vlanid> </filter> </gst> </aggregation> <drop-and-forward> <in-port>n0</in-port> <filter-rule>matched-tpid</filter-rule> <priority>gst</priority> <push-vlan-tag> <vlanid>100</vlanid> <tpid>9100</tpid> <pcp>0</pcp> <cfi>1</cfi> </push-vlan-tag> <filter> <tpid>88F7</tpid> </filter> <forward> <pop-vlan-tag>false</pop-vlan-tag> </forward> </drop-and-forward> <drop-and-forward> <in-port>n0</in-port> <filter-rule>unmatched</filter-rule> <priority>sm</priority> <push-vlan-tag> <vlanid>200</vlanid> <tpid>9100</tpid> <pcp>0</pcp> <cfi>1</cfi> </push-vlan-tag> <forward> <pop-vlan-tag>false</pop-vlan-tag> </forward> </drop-and-forward> <drop-and-forward> <in-port>n1</in-port> <filter-rule>10</filter-rule> <priority>sm</priority> <filter> <tpid>9100</tpid> </filter> <drop> <out-port>e0</out-port> <pop-vlan-tag>true</pop-vlan-tag> </drop> </drop-and-forward> <drop-and-forward> <in-port>n1</in-port> <filter-rule>100</filter-rule> <priority>gst</priority> <filter> <tpid>9100</tpid> </filter> <drop> <out-port>e0</out-port> <pop-vlan-tag>true</pop-vlan-tag> </drop> <drop> <out-port>e1</out-port> <pop-vlan-tag>true</pop-vlan-tag> </drop> <drop> <out-port>e2</out-port> <pop-vlan-tag>true</pop-vlan-tag> </drop> <drop> <out-port>e3</out-port> <pop-vlan-tag>true</pop-vlan-tag> </drop> <drop> <out-port>e4</out-port> <pop-vlan-tag>true</pop-vlan-tag> </drop> <forward> <pop-vlan-tag>true</pop-vlan-tag> </forward> </drop-and-forward> <drop-and-forward> <in-port>n1</in-port> <filter-rule>11</filter-rule> <priority>sm</priority> <filter> <tpid>9100</tpid> </filter> <drop> <out-port>e1</out-port> <pop-vlan-tag>true</pop-vlan-tag> </drop> </drop-and-forward> <drop-and-forward> <in-port>n1</in-port> <filter-rule>12</filter-rule> <priority>sm</priority> <filter> <tpid>9100</tpid> </filter> <drop> <out-port>e2</out-port> <pop-vlan-tag>true</pop-vlan-tag> </drop> </drop-and-forward> <drop-and-forward> <in-port>n1</in-port> <filter-rule>13</filter-rule> <priority>sm</priority> <filter> <tpid>9100</tpid> </filter> <drop> <out-port>e3</out-port> <pop-vlan-tag>true</pop-vlan-tag> </drop> </drop-and-forward> <drop-and-forward> <in-port>n1</in-port> <filter-rule>14</filter-rule> <priority>sm</priority> <filter> <tpid>9100</tpid> </filter> <drop> <out-port>e4</out-port> <pop-vlan-tag>true</pop-vlan-tag> </drop> </drop-and-forward> <drop-and-forward> <in-port>n1</in-port> <filter-rule>200</filter-rule> <priority>sm</priority> <filter> <tpid>9100</tpid> </filter> <forward> <pop-vlan-tag>true</pop-vlan-tag> </forward> </drop-and-forward> </fusion-streams> </config> """ idle_config_analyzer = """ <config> <hadm xmlns="http://transpacket.com/ns/hadm" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="replace"> </hadm> <vlans xmlns="http://transpacket.com/ns/hadm1-vlans" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="replace"> </vlans> <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"> <interface xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="replace"> <name>xe0</name> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> </interface> <interface xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="replace"> <name>xe1</name> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> </interface> <interface xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="replace"> <name>ge0</name> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> <ethernet xmlns="urn:ieee:params:xml:ns:yang:ethernet"> <auto-negotiation> <status>enabled</status> </auto-negotiation> </ethernet> </interface> <interface xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="replace"> <name>ge1</name> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> <ethernet xmlns="urn:ieee:params:xml:ns:yang:ethernet"> <auto-negotiation> <status>enabled</status> </auto-negotiation> </ethernet> </interface> </interfaces> </config> """ tntapi.edit_config(conns["analyzer"],idle_config_analyzer) tntapi.edit_config(conns["local"],fusion_streams_config_h100_local) tntapi.edit_config(conns["remote"],fusion_streams_config_h100_remote) tntapi.network_commit(conns) state_before = tntapi.network_get_state(network, conns, filter=filter) time.sleep(5) state_after = tntapi.network_get_state(network, conns, filter=filter) validate_step_1(state_before, state_after)
def step_1(network, conns, yconns, filter=filter): #Delete all result=yangcli(yconns["local"], "discard-changes") result=yangcli(yconns["local"], "delete /flows") result=yangcli(yconns["local"], "delete /bridge") result=yangcli(yconns["remote"], "discard-changes") result=yangcli(yconns["remote"], "delete /flows") result=yangcli(yconns["remote"], "delete /bridge") result=yangcli(yconns["middle"], "discard-changes") result=yangcli(yconns["middle"], "delete /flows") result=yangcli(yconns["middle"], "delete /bridge") tntapi.network_commit(conns) yangcli_script_local=''' create /bridge/ports/port -- name=n0 create /bridge/ports/port -- name=gm0 create /bridge/ports/port -- name=e0 create /bridge/ports/port -- name=e1 create /bridge/ports/port -- name=e2 create /bridge/ports/port -- name=e3 create /bridge/ports/port -- name=e4 create /bridge/ports/port -- name=e5 create /bridge/ports/port -- name=e6 create /bridge/ports/port -- name=e7 create /bridge/ports/port -- name=e8 create /bridge/ports/port -- name=e9 merge /interfaces/interface -- name=xe0 type=ethernetCsmacd port-name=n0 merge /interfaces/interface -- name=ge15 type=ethernetCsmacd port-name=gm0 merge /interfaces/interface -- name=ge0 type=ethernetCsmacd port-name=e0 merge /interfaces/interface -- name=ge1 type=ethernetCsmacd port-name=e1 merge /interfaces/interface -- name=ge2 type=ethernetCsmacd port-name=e2 merge /interfaces/interface -- name=ge3 type=ethernetCsmacd port-name=e3 merge /interfaces/interface -- name=ge4 type=ethernetCsmacd port-name=e4 merge /interfaces/interface -- name=ge5 type=ethernetCsmacd port-name=e5 merge /interfaces/interface -- name=ge6 type=ethernetCsmacd port-name=e6 merge /interfaces/interface -- name=ge7 type=ethernetCsmacd port-name=e7 merge /interfaces/interface -- name=ge8 type=ethernetCsmacd port-name=e8 merge /interfaces/interface -- name=ge9 type=ethernetCsmacd port-name=e9 create /flows/flow[id='gm0-to-n0-ptp'] -- match/in-port=gm0 match/ethernet-match/ethernet-type/type=35063 actions/action[order='0']/output-action/out-port=e0 actions/action[order='1']/output-action/out-port=e1 actions/action[order='2']/output-action/out-port=e2 actions/action[order='3']/output-action/out-port=e3 actions/action[order='4']/output-action/out-port=e4 actions/action[order='5']/output-action/out-port=e5 actions/action[order='6']/output-action/out-port=e6 actions/action[order='7']/output-action/out-port=e7 actions/action[order='8']/output-action/out-port=e8 actions/action[order='9']/output-action/out-port=e9 actions/action[order='10']/push-vlan-action/vlan-id=100 actions/action[order='10']/push-vlan-action/ethernet-type=37120 actions/action[order='11']/output-action/out-port=n0 create /flows/flow[id='gm0-to-n0-unmatched'] -- match/in-port=gm0 actions/action[order='0']/push-vlan-action/vlan-id=200 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n0 create /flows/flow[id='e0-to-n0-unmatched'] -- match/in-port=e0 actions/action[order='0']/push-vlan-action/vlan-id=10 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n0 create /flows/flow[id='e1-to-n0-unmatched'] -- match/in-port=e1 actions/action[order='0']/push-vlan-action/vlan-id=11 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n0 create /flows/flow[id='e2-to-n0-unmatched'] -- match/in-port=e2 actions/action[order='0']/push-vlan-action/vlan-id=12 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n0 create /flows/flow[id='e3-to-n0-unmatched'] -- match/in-port=e3 actions/action[order='0']/push-vlan-action/vlan-id=13 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n0 create /flows/flow[id='e4-to-n0-unmatched'] -- match/in-port=e4 actions/action[order='0']/push-vlan-action/vlan-id=14 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n0 create /flows/flow[id='e5-to-n0-unmatched'] -- match/in-port=e5 actions/action[order='0']/push-vlan-action/vlan-id=15 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n0 create /flows/flow[id='e6-to-n0-unmatched'] -- match/in-port=e6 actions/action[order='0']/push-vlan-action/vlan-id=16 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n0 create /flows/flow[id='e7-to-n0-unmatched'] -- match/in-port=e7 actions/action[order='0']/push-vlan-action/vlan-id=17 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n0 create /flows/flow[id='e8-to-n0-unmatched'] -- match/in-port=e8 actions/action[order='0']/push-vlan-action/vlan-id=18 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n0 create /flows/flow[id='e9-to-n0-unmatched'] -- match/in-port=e9 actions/action[order='0']/push-vlan-action/vlan-id=19 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n0 create /flows/flow[id='e0-to-n0-ptp'] -- match/in-port=e0 match/ethernet-match/ethernet-type/type=35063 actions/action[order='0']/output-action/out-port=n0 create /flows/flow[id='e1-to-n0-ptp'] -- match/in-port=e1 match/ethernet-match/ethernet-type/type=35063 actions/action[order='0']/output-action/out-port=n0 create /flows/flow[id='e2-to-n0-ptp'] -- match/in-port=e2 match/ethernet-match/ethernet-type/type=35063 actions/action[order='0']/output-action/out-port=n0 create /flows/flow[id='e3-to-n0-ptp'] -- match/in-port=e3 match/ethernet-match/ethernet-type/type=35063 actions/action[order='0']/output-action/out-port=n0 create /flows/flow[id='e4-to-n0-ptp'] -- match/in-port=e4 match/ethernet-match/ethernet-type/type=35063 actions/action[order='0']/output-action/out-port=n0 create /flows/flow[id='e5-to-n0-ptp'] -- match/in-port=e5 match/ethernet-match/ethernet-type/type=35063 actions/action[order='0']/output-action/out-port=n0 create /flows/flow[id='e6-to-n0-ptp'] -- match/in-port=e6 match/ethernet-match/ethernet-type/type=35063 actions/action[order='0']/output-action/out-port=n0 create /flows/flow[id='e7-to-n0-ptp'] -- match/in-port=e7 match/ethernet-match/ethernet-type/type=35063 actions/action[order='0']/output-action/out-port=n0 create /flows/flow[id='e8-to-n0-ptp'] -- match/in-port=e8 match/ethernet-match/ethernet-type/type=35063 actions/action[order='0']/output-action/out-port=n0 create /flows/flow[id='e9-to-n0-ptp'] -- match/in-port=e9 match/ethernet-match/ethernet-type/type=35063 actions/action[order='0']/output-action/out-port=n0 create /flows/flow[id='n0-to-gm0-ptp'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=100 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=gm0 create /flows/flow[id='n0-to-gm0-unmatched'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=200 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=gm0 create /flows/flow[id='n0-to-e0'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=10 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e0 create /flows/flow[id='n0-to-e1'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=11 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e1 create /flows/flow[id='n0-to-e2'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=12 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e2 create /flows/flow[id='n0-to-e3'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=13 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e3 create /flows/flow[id='n0-to-e4'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=14 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e4 create /flows/flow[id='n0-to-e5'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=15 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e5 create /flows/flow[id='n0-to-e6'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=16 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e6 create /flows/flow[id='n0-to-e7'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=17 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e7 create /flows/flow[id='n0-to-e8'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=18 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e8 create /flows/flow[id='n0-to-e9'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=19 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e9 ''' yangcli_script_remote=''' create /bridge/ports/port -- name=n0 create /bridge/ports/port -- name=gm0 create /bridge/ports/port -- name=e0 create /bridge/ports/port -- name=e1 create /bridge/ports/port -- name=e2 create /bridge/ports/port -- name=e3 create /bridge/ports/port -- name=e4 create /bridge/ports/port -- name=e5 create /bridge/ports/port -- name=e6 create /bridge/ports/port -- name=e7 create /bridge/ports/port -- name=e8 create /bridge/ports/port -- name=e9 merge /interfaces/interface -- name=xe0 type=ethernetCsmacd port-name=n0 merge /interfaces/interface -- name=ge15 type=ethernetCsmacd port-name=gm0 merge /interfaces/interface -- name=ge0 type=ethernetCsmacd port-name=e0 merge /interfaces/interface -- name=ge1 type=ethernetCsmacd port-name=e1 merge /interfaces/interface -- name=ge2 type=ethernetCsmacd port-name=e2 merge /interfaces/interface -- name=ge3 type=ethernetCsmacd port-name=e3 merge /interfaces/interface -- name=ge4 type=ethernetCsmacd port-name=e4 merge /interfaces/interface -- name=ge5 type=ethernetCsmacd port-name=e5 merge /interfaces/interface -- name=ge6 type=ethernetCsmacd port-name=e6 merge /interfaces/interface -- name=ge7 type=ethernetCsmacd port-name=e7 merge /interfaces/interface -- name=ge8 type=ethernetCsmacd port-name=e8 merge /interfaces/interface -- name=ge9 type=ethernetCsmacd port-name=e9 create /flows/flow[id='gm0-to-n0-ptp'] -- match/in-port=gm0 match/ethernet-match/ethernet-type/type=35063 actions/action[order='0']/output-action/out-port=e0 actions/action[order='1']/output-action/out-port=e1 actions/action[order='2']/output-action/out-port=e2 actions/action[order='3']/output-action/out-port=e3 actions/action[order='4']/output-action/out-port=e4 actions/action[order='5']/output-action/out-port=e5 actions/action[order='6']/output-action/out-port=e6 actions/action[order='7']/output-action/out-port=e7 actions/action[order='8']/output-action/out-port=e8 actions/action[order='9']/output-action/out-port=e9 actions/action[order='10']/push-vlan-action/vlan-id=100 actions/action[order='10']/push-vlan-action/ethernet-type=37120 actions/action[order='11']/output-action/out-port=n0 create /flows/flow[id='gm0-to-n0-unmatched'] -- match/in-port=gm0 actions/action[order='0']/push-vlan-action/vlan-id=200 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n0 create /flows/flow[id='e0-to-n0-unmatched'] -- match/in-port=e0 actions/action[order='0']/push-vlan-action/vlan-id=20 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n0 create /flows/flow[id='e1-to-n0-unmatched'] -- match/in-port=e1 actions/action[order='0']/push-vlan-action/vlan-id=21 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n0 create /flows/flow[id='e2-to-n0-unmatched'] -- match/in-port=e2 actions/action[order='0']/push-vlan-action/vlan-id=22 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n0 create /flows/flow[id='e3-to-n0-unmatched'] -- match/in-port=e3 actions/action[order='0']/push-vlan-action/vlan-id=23 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n0 create /flows/flow[id='e4-to-n0-unmatched'] -- match/in-port=e4 actions/action[order='0']/push-vlan-action/vlan-id=24 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n0 create /flows/flow[id='e5-to-n0-unmatched'] -- match/in-port=e5 actions/action[order='0']/push-vlan-action/vlan-id=25 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n0 create /flows/flow[id='e6-to-n0-unmatched'] -- match/in-port=e6 actions/action[order='0']/push-vlan-action/vlan-id=26 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n0 create /flows/flow[id='e7-to-n0-unmatched'] -- match/in-port=e7 actions/action[order='0']/push-vlan-action/vlan-id=27 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n0 create /flows/flow[id='e8-to-n0-unmatched'] -- match/in-port=e8 actions/action[order='0']/push-vlan-action/vlan-id=28 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n0 create /flows/flow[id='e9-to-n0-unmatched'] -- match/in-port=e9 actions/action[order='0']/push-vlan-action/vlan-id=29 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n0 create /flows/flow[id='e0-to-n0-ptp'] -- match/in-port=e0 match/ethernet-match/ethernet-type/type=35063 actions/action[order='0']/output-action/out-port=n0 create /flows/flow[id='e1-to-n0-ptp'] -- match/in-port=e1 match/ethernet-match/ethernet-type/type=35063 actions/action[order='0']/output-action/out-port=n0 create /flows/flow[id='e2-to-n0-ptp'] -- match/in-port=e2 match/ethernet-match/ethernet-type/type=35063 actions/action[order='0']/output-action/out-port=n0 create /flows/flow[id='e3-to-n0-ptp'] -- match/in-port=e3 match/ethernet-match/ethernet-type/type=35063 actions/action[order='0']/output-action/out-port=n0 create /flows/flow[id='e4-to-n0-ptp'] -- match/in-port=e4 match/ethernet-match/ethernet-type/type=35063 actions/action[order='0']/output-action/out-port=n0 create /flows/flow[id='e5-to-n0-ptp'] -- match/in-port=e5 match/ethernet-match/ethernet-type/type=35063 actions/action[order='0']/output-action/out-port=n0 create /flows/flow[id='e6-to-n0-ptp'] -- match/in-port=e6 match/ethernet-match/ethernet-type/type=35063 actions/action[order='0']/output-action/out-port=n0 create /flows/flow[id='e7-to-n0-ptp'] -- match/in-port=e7 match/ethernet-match/ethernet-type/type=35063 actions/action[order='0']/output-action/out-port=n0 create /flows/flow[id='e8-to-n0-ptp'] -- match/in-port=e8 match/ethernet-match/ethernet-type/type=35063 actions/action[order='0']/output-action/out-port=n0 create /flows/flow[id='e9-to-n0-ptp'] -- match/in-port=e9 match/ethernet-match/ethernet-type/type=35063 actions/action[order='0']/output-action/out-port=n0 create /flows/flow[id='n0-to-gm0-ptp'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=100 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=gm0 create /flows/flow[id='n0-to-gm0-unmatched'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=200 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=gm0 create /flows/flow[id='n0-to-e0'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=20 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e0 create /flows/flow[id='n0-to-e1'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=21 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e1 create /flows/flow[id='n0-to-e2'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=22 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e2 create /flows/flow[id='n0-to-e3'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=23 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e3 create /flows/flow[id='n0-to-e4'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=24 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e4 create /flows/flow[id='n0-to-e5'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=25 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e5 create /flows/flow[id='n0-to-e6'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=26 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e6 create /flows/flow[id='n0-to-e7'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=27 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e7 create /flows/flow[id='n0-to-e8'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=28 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e8 create /flows/flow[id='n0-to-e9'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=29 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e9 ''' yangcli_script_middle=''' create /bridge/ports/port -- name=n0 create /bridge/ports/port -- name=n1 create /bridge/ports/port -- name=e0 create /bridge/ports/port -- name=e1 create /bridge/ports/port -- name=e2 create /bridge/ports/port -- name=e3 create /bridge/ports/port -- name=e4 create /bridge/ports/port -- name=e5 create /bridge/ports/port -- name=e6 create /bridge/ports/port -- name=e7 create /bridge/ports/port -- name=e8 create /bridge/ports/port -- name=e9 merge /interfaces/interface -- name=xe0 type=ethernetCsmacd port-name=n0 merge /interfaces/interface -- name=xe1 type=ethernetCsmacd port-name=n1 merge /interfaces/interface -- name=ge0 type=ethernetCsmacd port-name=e0 merge /interfaces/interface -- name=ge1 type=ethernetCsmacd port-name=e1 merge /interfaces/interface -- name=ge2 type=ethernetCsmacd port-name=e2 merge /interfaces/interface -- name=ge3 type=ethernetCsmacd port-name=e3 merge /interfaces/interface -- name=ge4 type=ethernetCsmacd port-name=e4 merge /interfaces/interface -- name=ge5 type=ethernetCsmacd port-name=e5 merge /interfaces/interface -- name=ge6 type=ethernetCsmacd port-name=e6 merge /interfaces/interface -- name=ge7 type=ethernetCsmacd port-name=e7 merge /interfaces/interface -- name=ge8 type=ethernetCsmacd port-name=e8 merge /interfaces/interface -- name=ge9 type=ethernetCsmacd port-name=e9 create /flows/flow[id='e0-to-n1'] -- match/in-port=e0 actions/action[order='0']/push-vlan-action/vlan-id=20 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n1 create /flows/flow[id='e1-to-n1'] -- match/in-port=e1 actions/action[order='0']/push-vlan-action/vlan-id=21 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n1 create /flows/flow[id='e2-to-n1'] -- match/in-port=e2 actions/action[order='0']/push-vlan-action/vlan-id=22 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n1 create /flows/flow[id='e3-to-n1'] -- match/in-port=e3 actions/action[order='0']/push-vlan-action/vlan-id=23 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n1 create /flows/flow[id='e4-to-n1'] -- match/in-port=e4 actions/action[order='0']/push-vlan-action/vlan-id=24 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n1 create /flows/flow[id='e5-to-n1'] -- match/in-port=e5 actions/action[order='0']/push-vlan-action/vlan-id=25 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n1 create /flows/flow[id='e6-to-n1'] -- match/in-port=e6 actions/action[order='0']/push-vlan-action/vlan-id=26 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n1 create /flows/flow[id='e7-to-n1'] -- match/in-port=e7 actions/action[order='0']/push-vlan-action/vlan-id=27 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n1 create /flows/flow[id='e8-to-n1'] -- match/in-port=e8 actions/action[order='0']/push-vlan-action/vlan-id=28 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n1 create /flows/flow[id='e9-to-n1'] -- match/in-port=e9 actions/action[order='0']/push-vlan-action/vlan-id=29 actions/action[order='0']/push-vlan-action/ethernet-type=37120 actions/action[order='1']/output-action/out-port=n1 create /flows/flow[id='n0-to-e0'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=20 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e0 create /flows/flow[id='n0-to-e1'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=21 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e1 create /flows/flow[id='n0-to-e2'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=22 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e2 create /flows/flow[id='n0-to-e3'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=23 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e3 create /flows/flow[id='n0-to-e4'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=24 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e4 create /flows/flow[id='n0-to-e5'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=25 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e5 create /flows/flow[id='n0-to-e6'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=26 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e6 create /flows/flow[id='n0-to-e7'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=27 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e7 create /flows/flow[id='n0-to-e8'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=28 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e8 create /flows/flow[id='n0-to-e9'] -- match/in-port=n0 match/vlan-match/vlan-id/vlan-id=29 match/ethernet-match/ethernet-type/type=37120 actions/action[order='0']/pop-vlan-action actions/action[order='1']/output-action/out-port=e9 create /flows/flow[id='n0-to-n1'] -- match/in-port=n0 actions/action[order='0']/output-action/out-port=n1 create /flows/flow[id='n1-to-n0'] -- match/in-port=n1 actions/action[order='0']/output-action/out-port=n0 ''' yangcli_ok_script(yconns["local"], yangcli_script_local) yangcli_ok_script(yconns["remote"], yangcli_script_remote) yangcli_ok_script(yconns["middle"], yangcli_script_middle) tntapi.network_commit(conns) state_before = tntapi.network_get_state(network, conns, filter=filter) time.sleep(5) state_after = tntapi.network_get_state(network, conns, filter=filter) validate_step_1(state_before, state_after)
def step_common(network, conns, filter, step): state_before = tntapi.network_get_state(network, conns, filter=filter) # print("Enable analyzers ...") # analyzer_config=""" #<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> # <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"> # <interface> # <name>ge0</name> # <traffic-analyzer xmlns="http://transpacket.com/ns/traffic-analyzer" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="create"></traffic-analyzer> # </interface> # </interfaces> #</config> #""" # tntapi.edit_config(conns["analyzer"],analyzer_config) # tntapi.network_commit(conns) print("Create loopbacks ...") config = """ <config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"> """ for if_name in { "ge0", "ge1", "ge2", "ge3", "ge4", "ge5", "ge6", "ge7", "ge8", "ge9" }: config = config + """ <interface> <name>%(name)s</name> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> <loopback xmlns="http://transpacket.com/ns/transpacket-loopback" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="create">near-end</loopback> </interface> """ % { 'name': if_name } config = config + """ </interfaces> </config> """ tntapi.edit_config(conns["remote"], config) tntapi.network_commit(conns) time.sleep(1) print("Start traffic ...") config = """ <config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"> """ if (step == 2): sm_traffic_interfaces = {"ge0", "ge1", "ge2", "ge3", "ge4"} gst_traffic_interfaces = {"ge5", "ge6", "ge7", "ge8", "ge9"} else: sm_traffic_interfaces = { "ge0", "ge1", "ge2", "ge3", "ge4", "ge5", "ge6", "ge7", "ge8", "ge9" } gst_traffic_interfaces = {} for if_name in sm_traffic_interfaces: config = config + """ <interface> <name>%(name)s</name> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> <traffic-generator xmlns="http://transpacket.com/ns/transpacket-traffic-generator" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="create"> <frame-size>1500</frame-size> <interframe-gap>12</interframe-gap> <total-frames>1000000</total-frames> <ether-type xmlns="http://transpacket.com/ns/transpacket-traffic-generator-ethernet">ABCD</ether-type> </traffic-generator> </interface> """ % { 'name': if_name } for if_name in gst_traffic_interfaces: config = config + """ <interface> <name>%(name)s</name> <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type> <traffic-generator xmlns="http://transpacket.com/ns/transpacket-traffic-generator" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="create"> <frame-size>64</frame-size> <interframe-gap>12</interframe-gap> <total-frames>1000000</total-frames> <ether-type xmlns="http://transpacket.com/ns/transpacket-traffic-generator-ethernet">88F7</ether-type> </traffic-generator> </interface> """ % { 'name': if_name } config = config + """ </interfaces> </config> """ tntapi.edit_config(conns["remote"], config) tntapi.network_commit(conns) if (step == 2): time.sleep(100) else: time.sleep(10) print("Stop traffic ...") config = """ <config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"> """ for if_name in sm_traffic_interfaces.union(gst_traffic_interfaces): config = config + """ <interface> <name>%(name)s</name> <traffic-generator xmlns="http://transpacket.com/ns/transpacket-traffic-generator" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="delete"/> </interface> """ % { 'name': if_name } config = config + """ </interfaces> </config> """ tntapi.edit_config(conns["remote"], config) tntapi.network_commit(conns) time.sleep(1) print("Remove loopbacks ...") config = """ <config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"> """ for if_name in { "ge0", "ge1", "ge2", "ge3", "ge4", "ge5", "ge6", "ge7", "ge8", "ge9" }: config = config + """ <interface> <name>%(name)s</name> <loopback xmlns="http://transpacket.com/ns/transpacket-loopback" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="delete"/> </interface> """ % { 'name': if_name } config = config + """ </interfaces> </config> """ tntapi.edit_config(conns["remote"], config) tntapi.network_commit(conns) # print("Disable analyzers ...") # analyzer_config=""" #<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> # <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"> # <interface> # <name>ge0</name> # <traffic-analyzer xmlns="http://transpacket.com/ns/traffic-analyzer" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="delete"></traffic-analyzer> # </interface> # </interfaces> #</config> #""" # tntapi.edit_config(conns["analyzer"],analyzer_config) # tntapi.network_commit(conns) state_after = tntapi.network_get_state(network, conns, filter=filter) return validate_step_common(state_before, state_after, step)
def netconfNet(): "Create network from scratch using netconfd instance on each node." info("*** Creating nodes\n") h0 = Node('h0', inNamespace=True) h1 = Node('h1', inNamespace=True) b0 = Node('b0', inNamespace=False) b1 = Node('b1', inNamespace=False) ncproxy = Node('ncproxy', inNamespace=False) info("*** Creating links\n") b0.cmd("ip link del b0-eth0") b0.cmd("ip link del b0-eth1") b1.cmd("ip link del b1-eth0") b1.cmd("ip link del b1-eth1") Link(h0, b0, intfName2="b0-eth0") Link(b0, b1, intfName1="b0-eth1", intfName2="b1-eth0") Link(h1, b1, intfName2="b1-eth1") info("*** Configuring hosts\n") h0.setIP('192.168.123.1/24') h1.setIP('192.168.123.2/24') info(str(h0) + '\n') info(str(h1) + '\n') info(str(b0) + '\n') info(str(b1) + '\n') info("*** Starting network\n") h0.cmd( '''INTERFACE_NAME_PREFIX=h0- ./run-netconfd --module=ietf-interfaces --no-startup --port=8832 --ncxserver-sockname=/tmp/ncxserver.8832.sock --superuser=${USER} &''' ) ncproxy.cmd( '''./run-sshd-for-netconfd --port=8832 --ncxserver-sockname=/tmp/ncxserver.8832.sock &''' ) h1.cmd( '''INTERFACE_NAME_PREFIX=h1- ./run-netconfd --module=ietf-interfaces --no-startup --port=8833 --ncxserver-sockname=/tmp/ncxserver.8833.sock --superuser=${USER} &''' ) ncproxy.cmd( '''./run-sshd-for-netconfd --port=8833 --ncxserver-sockname=/tmp/ncxserver.8833.sock &''' ) #bridge b0 b0.cmd( '''VCONN_ARG=ptcp:16636 ./run-netconfd --module=ietf-network-bridge-openflow --no-startup --superuser=${USER} --port=8830 --ncxserver-sockname=/tmp/ncxserver.8830.sock &''' ) b0.cmd('ovs-vsctl del-br dp0') b0.cmd('ovs-vsctl add-br dp0') for intf in b0.intfs.values(): print "Setting: " + str(intf) print b0.cmd('ovs-vsctl add-port dp0 %s' % intf) print b0.cmd('ifconfig -a') # Note: controller and switch are in root namespace, and we # can connect via loopback interface b0.cmd('ovs-vsctl set-controller dp0 tcp:127.0.0.1:16636') info('*** Waiting for switch to connect to controller') while 'is_connected' not in quietRun('ovs-vsctl show'): sleep(1) info('.') info('\n') #bridge b1 b1.cmd( '''VCONN_ARG=ptcp:16635 ./run-netconfd --module=ietf-network-bridge-openflow --no-startup --superuser=${USER} --port=8831 --ncxserver-sockname=/tmp/ncxserver.8831.sock &''' ) b1.cmd('ovs-vsctl del-br dp1') b1.cmd('ovs-vsctl add-br dp1') for intf in b1.intfs.values(): print "Setting: " + str(intf) print b1.cmd('ovs-vsctl add-port dp1 %s' % intf) print b1.cmd('ifconfig -a') # Note: controller and switch are in root namespace, and we # can connect via loopback interface b1.cmd('ovs-vsctl set-controller dp1 tcp:127.0.0.1:16635') sleep(10) raw_input("Press Enter to continue...") tree = etree.parse("topology.xml") network = tree.xpath('/nc:config/nd:networks/nd:network', namespaces=namespaces)[0] conns = tntapi.network_connect(network) yconns = tntapi.network_connect_yangrpc(network) mylinks = tntapi.parse_network_links(network) print("Done") state_before = tntapi.network_get_state(network, conns) info("*** Running test\n") #create flows configuration yangcli_script = """ merge /bridge/ports/port -- name=b0-eth0 merge /interfaces/interface -- name=b0-eth0 type=ethernetCsmacd port-name=b0-eth0 merge /bridge/ports/port -- name=b0-eth1 merge /interfaces/interface -- name=b0-eth1 type=ethernetCsmacd port-name=b0-eth1 create /flows/flow[id='h0-to-h1'] -- match/in-port=b0-eth0 actions/action[order='0']/output-action/out-port=b0-eth1 create /flows/flow[id='h1-to-h0'] -- match/in-port=b0-eth1 actions/action[order='0']/output-action/out-port=b0-eth0 """ result = tntapi.yangcli_ok_script(yconns["b0"], yangcli_script) yangcli_script = """ merge /bridge/ports/port -- name=b1-eth0 merge /interfaces/interface -- name=b1-eth0 type=ethernetCsmacd port-name=b1-eth0 merge /bridge/ports/port -- name=b1-eth1 merge /interfaces/interface -- name=b1-eth1 type=ethernetCsmacd port-name=b1-eth1 create /flows/flow[id='h0-to-h1'] -- match/in-port=b1-eth0 actions/action[order='0']/output-action/out-port=b1-eth1 create /flows/flow[id='h1-to-h0'] -- match/in-port=b1-eth1 actions/action[order='0']/output-action/out-port=b1-eth0 """ result = tntapi.yangcli_ok_script(yconns["b1"], yangcli_script) tntapi.network_commit(conns) # The commit should cause the netconfd server to execute the OpenFlow equivalent of: #switch.cmd( 'ovs-ofctl add-flow dp0 in_port=2,actions=output:1' ) #switch.cmd( 'ovs-ofctl add-flow dp0 in_port=1,actions=output:2' ) b0.cmdPrint('ovs-ofctl dump-flows dp0') info("*** Running test\n") h0.cmdPrint('ping -I h0-eth0 -c10 ' + h1.IP()) b0.cmdPrint('ovs-ofctl dump-flows dp0') state_after = tntapi.network_get_state(network, conns) #delta = tntapi.get_network_counters_delta(state_before,state_after) tntapi.print_state_ietf_interfaces_statistics_delta( network, state_before, state_after) raw_input("Press Enter to continue...") info("*** Stopping network\n") b0.cmd('killall -KILL netconfd') b0.cmd('ovs-vsctl del-br dp0') b0.deleteIntfs() b1.cmd('killall -KILL netconfd') b1.cmd('ovs-vsctl del-br dp1') b1.deleteIntfs() info('\n')
def trial(network, conns, yconns, test_time=60, frame_size=1500, interframe_gap=20, interburst_gap=0, frames_per_burst=0, src_node=[], src_node_interface=[], dst_node=[], dst_node_interface=[], src_mac_address=[], dst_mac_address=[], frame_data=[], testframe_type=[]): global args filter ="" #"""<filter type="xpath" select="/*[local-name()='interfaces-state' or local-name()='interfaces']/interface/*[local-name()='traffic-analyzer' or local-name()='oper-status' or local-name()='statistics' or local-name()='speed']"/>""" config_idle={} print(dst_node) result=yangcli(yconns[dst_node],"""replace /interfaces/interface[name='%(name)s'] -- type=ethernetCsmacd"""%{'name':dst_node_interface}) ok = result.xpath('./ok') assert(len(ok)==1) ok=yangcli(yconns[src_node],"""replace /interfaces/interface[name='%(name)s'] -- type=ethernetCsmacd"""%{'name':src_node_interface}).xpath('./ok') assert(len(ok)==1) tntapi.network_commit(conns) ok=yangcli(yconns[dst_node],"""create /interfaces/interface[name='%(name)s']/traffic-analyzer"""%{'name':dst_node_interface}).xpath('./ok') assert(len(ok)==1) tntapi.network_commit(conns) if(frames_per_burst>0): my_burst_config="""frames-per-burst=%(frames-per-burst)d interburst-gap=%(interburst-gap)d""" % {'frames-per-burst':frames_per_burst,'interburst-gap':interburst_gap-8} else: my_burst_config="" generator_direction_suffix='' analyzer_direction_suffix='' state_before = tntapi.network_get_state(network, conns, filter=filter) state_before_wo_ns=tntapi.strip_namespaces(state_before) #speed=1000000000 # 1Gb speed = long(state_before_wo_ns.xpath("node[node-id='%s']/data/interfaces-state/interface[name='%s']/speed"%(src_node, src_node_interface))[0].text) if(frames_per_burst == 0): total_frames = int(math.floor(test_time*speed/((interframe_gap+frame_size)*8))) else: total_frames = int(math.floor(frames_per_burst*test_time*speed/(((frames_per_burst-1)*interframe_gap+frames_per_burst*frame_size+interburst_gap)*8))) testframe = "" if(testframe_type != []): testframe = "testframe-type=%s" % testframe_type print """create /interfaces/interface[name="%(name)s"]/traffic-generator -- frame-size=%(frame-size)d interframe-gap=%(interframe-gap)d total-frames=%(total-frames)s %(burst)s frame-data=%(frame-data)s %(testframe)s""" % {'name':src_node_interface,'frame-size':frame_size, 'interframe-gap':interframe_gap, 'burst':my_burst_config, 'total-frames':total_frames, 'frame-data':frame_data, 'testframe':testframe} ok=yangcli(yconns[src_node],"""create /interfaces/interface[name="%(name)s"]/traffic-generator -- frame-size=%(frame-size)d interframe-gap=%(interframe-gap)d total-frames=%(total-frames)s %(burst)s frame-data=%(frame-data)s %(testframe)s""" % {'name':src_node_interface,'frame-size':frame_size, 'interframe-gap':interframe_gap, 'burst':my_burst_config, 'total-frames':total_frames, 'frame-data':frame_data, 'testframe':testframe}).xpath('./ok') assert(len(ok)==1) state_before = tntapi.network_get_state(network, conns, filter=filter) tntapi.network_commit(conns) print("Waiting " + str(test_time) + " sec. ..." ) time.sleep(test_time+1) print("Stopping generators ...") ok=yangcli(yconns[src_node],"""delete /interfaces/interface[name='%(name)s']/traffic-generator"""%{'name':src_node_interface}).xpath('./ok') assert(len(ok)==1) tntapi.network_commit(conns) print("Done.") time.sleep(2) state_after = tntapi.network_get_state(network, conns, filter=filter) t1 = tntapi.parse_network_nodes(state_before) t2 = tntapi.parse_network_nodes(state_after) delta = tntapi.get_network_counters_delta(state_before,state_after) tntapi.print_state_ietf_interfaces_statistics_delta(network, state_before, state_after) (rx_in_pkts, rx_testframe_pkts, generated_pkts, sequence_errors, latency_min, latency_max, latency_average)=get_traffic_stats(dst_node, dst_node_interface, src_node, src_node_interface, state_before, state_after, delta, test_time, frame_size, interframe_gap, frames_per_burst, interburst_gap, total_frames) print("Disabling analyzer.") ok=yangcli(yconns[dst_node],"""delete /interfaces/interface[name='%(name)s']/traffic-analyzer%(analyzer-direction-suffix)s"""%{'name':dst_node_interface, 'analyzer-direction-suffix':analyzer_direction_suffix}).xpath('./ok') assert(len(ok)==1) tntapi.network_commit(conns) return (rx_in_pkts, rx_testframe_pkts, generated_pkts, sequence_errors, latency_min, latency_max, latency_average)