def set_default_paths(topo=None): if topo == None: topo = topo_discovery.SDCTopo(sdcon_config.ODL_CONTROLLER_URL, sdcon_config.ODL_CONTROLLER_ID, sdcon_config.ODL_CONTROLLER_PW) for switch_id in topo.get_all_switches(): set_default_path_switch(topo, switch_id)
def test_set_path(): print "\nTesting..." topo = topo_discovery.SDCTopo(sdcon_config.ODL_CONTROLLER_URL, sdcon_config.ODL_CONTROLLER_ID, sdcon_config.ODL_CONTROLLER_PW) print "\nAll hosts..." topo.print_all_hosts() print "\nAll links..." topo.print_all_links() src_ip, dst_ip = "192.168.0.4", "192.168.0.7" print "\nBefore setting a special path..." print_all_paths(src_ip, dst_ip) print "\nCreating a special path for %s -> %s..." % (src_ip, dst_ip) create_special_path(src_ip, dst_ip) print "\nAfter setting a special path..." print_all_paths(src_ip, dst_ip) print "\nDeleting the special path" delete_special_path(src_ip, dst_ip) print "\nBack to default path..." print_all_paths(src_ip, dst_ip) print "\nDefault path for %s -> %s :" % (src_ip, dst_ip) print get_default_path(topo, src_ip, dst_ip)
def test_queue_manager(is_create): topo = topo_discovery.SDCTopo(sdcon_config.ODL_CONTROLLER_URL, sdcon_config.ODL_CONTROLLER_ID, sdcon_config.ODL_CONTROLLER_PW) toal_rate = NETWORK_MAX_BW_RATE QOS_QUEUE.add_qos_bw("192.168.0.4", "192.168.0.6", 60000000, toal_rate) QOS_QUEUE.add_qos_bw("192.168.0.4", "192.168.0.7", 10000000, 20000000) QOS_QUEUE.add_qos_bw("192.168.0.4", "192.168.0.8", 50000000, toal_rate) QOS_QUEUE.build_qos_config(topo) print "Queue configs..." print QOS_QUEUE.get_qos_config_dump() print "Q-no at %s for %s -> %s: %s" % ( "40960021", "192.168.0.4", "192.168.0.7", str(QOS_QUEUE.get_queue_no("40960021", "192.168.0.4", "192.168.0.7"))) print "Q-no at %s for %s -> %s: %s" % ( "40960022", "192.168.0.4", "192.168.0.7", str(QOS_QUEUE.get_queue_no("40960022", "192.168.0.4", "192.168.0.7"))) if (is_create): QOS_QUEUE.install_all_queue_flow() else: QOS_QUEUE.delete_all_queue_flow()
def clear_all_paths(): topo = topo_discovery.SDCTopo(sdcon_config.ODL_CONTROLLER_URL, sdcon_config.ODL_CONTROLLER_ID, sdcon_config.ODL_CONTROLLER_PW) del_all_flows_match_name(topo, FLOWNAME_SPECIAL, table_id=0) del_all_flows_match_name(topo, FLOWNAME_SPECIAL_QUEUE, table_id=0) network_defpath.del_all_default_paths(topo)
def apply_qos(): topo = topo_discovery.SDCTopo(sdcon_config.ODL_CONTROLLER_URL, sdcon_config.ODL_CONTROLLER_ID, sdcon_config.ODL_CONTROLLER_PW) QOS_QUEUE.build_qos_config(topo) print "Queue configs..." print QOS_QUEUE.get_qos_config_dump() QOS_QUEUE.install_all_queue_flow()
def all_clear(): topo = topo_discovery.SDCTopo(sdcon_config.ODL_CONTROLLER_URL, sdcon_config.ODL_CONTROLLER_ID, sdcon_config.ODL_CONTROLLER_PW) # Clear flows from forwarding tables del_all_queue_paths(topo) # Clear Queue settings from del_all_queues(topo)
def create_special_path(src_ip, dst_ip, src_vm_ip=None, dst_vm_ip=None): # To set a rule for vm traffic, give the compute nodes IP at src_ip/dst_ip, # and provide VM IPs as src_vm_ip/dst_vm_ip. # If xxx_vm_ip is set, we use them as a flow matching rule. topo = topo_discovery.SDCTopo(sdcon_config.ODL_CONTROLLER_URL, sdcon_config.ODL_CONTROLLER_ID, sdcon_config.ODL_CONTROLLER_PW) add_path_along_low_utilization(topo, src_ip, dst_ip, src_vm_ip, dst_vm_ip)
def __get_data(flow_name=network_monitor.SFLOW_FLOW_NORMAL): topo = topo_discovery.SDCTopo(sdcon_config.ODL_CONTROLLER_URL, sdcon_config.ODL_CONTROLLER_ID, sdcon_config.ODL_CONTROLLER_PW) basic = get_data_base(topo, flow_name) extra = get_data_extra(topo, flow_name) basic["links2"] = extra return json.dumps(basic, indent=4)
def print_all_paths(src_ip, dst_ip): topo = topo_discovery.SDCTopo(sdcon_config.ODL_CONTROLLER_URL, sdcon_config.ODL_CONTROLLER_ID, sdcon_config.ODL_CONTROLLER_PW) print "\nCurrently utilizing path for %s -> %s" % (src_ip, dst_ip) print path_string_format( network_monitor.monitor_get_current_path(topo, src_ip, dst_ip)) print "\nPort-switch mappings of the path:" print path_string_format( network_monitor.monitor_get_current_path_port_map( topo, src_ip, dst_ip)) all_path = topo.find_all_path_port_map(src_ip, dst_ip) print "\nAll paths %s -> %s: (in_port, switch, out_port)" % (src_ip, dst_ip) for path in all_path: print path_string_format(path)
def main(): if len(sys.argv) < 2: _print_usage() return if ENABLE_SELF_LEARN and os.getuid() != 0: print "Self learning mode needs to run with 'root' account! \nPlease change your account, or disable ENABLE_SELF_LEARN in source code." return topo = topo_discovery.SDCTopo(sdcon_config.ODL_CONTROLLER_URL, sdcon_config.ODL_CONTROLLER_ID, sdcon_config.ODL_CONTROLLER_PW) if sys.argv[1] == "set": set_default_paths(topo) elif sys.argv[1] == "del": del_all_default_paths(topo) elif sys.argv[1] == "test": test_new_function(topo) else: _print_usage() return
def delete_special_path(src_ip, dst_ip): topo = topo_discovery.SDCTopo(sdcon_config.ODL_CONTROLLER_URL, sdcon_config.ODL_CONTROLLER_ID, sdcon_config.ODL_CONTROLLER_PW) del_all_flows_match_src_dst_ip(topo, src_ip, dst_ip)