if transport == 'TLS': session_config = SessionConfig(SessionConfig.SessionTransportMode.TLS) session_config.ca_certs = cert ne.connect(user, pswd, session_config) elif transport == 'TIPC': session_config = SessionConfig(SessionConfig.SessionTransportMode.TIPC) ne.connect(user, pswd, session_config) else: print "Please set-up a valid transport type: TIPC or TLS" exit(0) RX_BYTES = InterfaceStatistics.InterfaceStatisticsParameter.ONEP_IF_STAT_RX_BYTES FILTER = InterfaceFilter(None, NetworkInterface.InterfaceTypes.ONEP_IF_TYPE_ETHERNET) print "Getting Interface Statistics on", switchIP intf_list_ne = ne.get_interface_list(FILTER) for intf in intf_list_ne: try: int = ne.get_interface_by_name(intf.name) int_stats = int.get_statistics() r_bytes=int_stats.get_param(RX_BYTES) if r_bytes > 0: print "Interface",intf.name,"RX_BYTES",r_bytes except: continue ne.disconnect();
else: print "Please set-up a valid transport type: TIPC or TLS" exit(0) #Get a routing instance associated with a network element routing = Routing.get_instance(ne) #Get RIB information #rib = routing.rib approutetable=routing.app_route_table scope = L3UnicastScope("", L3UnicastScope.AFIType.IPV4, L3UnicastScope.SAFIType.UNICAST, "base") prefix = NetworkPrefix(prefix_addr, prefix_mask) intf = ne.get_interface_by_name(next_hop_intf) nexthop_list = list() nexthop_list.append(L3UnicastNextHop(intf, next_hop_addr,scope)) route1 = L3UnicastRoute(prefix,nexthop_list,7,None,2,16) routeop1 = L3UnicastRouteOperation(RouteOperation.RouteOperationType.ADD,route1) oplist1 = list() oplist1.append(routeop1) #update routing table added_routes = approutetable.update_routes(scope,oplist1) #print the added route for route_op in added_routes: print route_op.route
if transport == 'TLS': session_config = SessionConfig(SessionConfig.SessionTransportMode.TLS) session_config.ca_certs = cert ne.connect(user, pswd, session_config) elif transport == 'TIPC': session_config = SessionConfig(SessionConfig.SessionTransportMode.TIPC) ne.connect(user, pswd, session_config) else: print "Please set-up a valid transport type: TIPC or TLS" exit(0) RX_BYTES = InterfaceStatistics.InterfaceStatisticsParameter.ONEP_IF_STAT_RX_BYTES FILTER = InterfaceFilter(None, NetworkInterface.InterfaceTypes.ONEP_IF_TYPE_ETHERNET) print "Getting Interface Statistics on", switchIP intf_list_ne = ne.get_interface_list(FILTER) for intf in intf_list_ne: try: int = ne.get_interface_by_name(intf.name) int_stats = int.get_statistics() r_bytes = int_stats.get_param(RX_BYTES) if r_bytes > 0: print "Interface", intf.name, "RX_BYTES", r_bytes except: continue ne.disconnect()
config.transportMode = SessionConfig.SessionTransportMode.TLS ne = NetworkElement('192.168.1.110', 'HelloWorld') ne.connect('cisco', 'cisco', config) # Print some info around the NetworkElement print ne print "System Name: ", ne.properties.sys_name print "System Uptime: ", ne.properties.sys_uptime print "Total System Memory: ", ne.total_system_memory print "Free System Memory: ", ne.free_system_memory print "System CPU Utilization: ", ne.system_cpu_utilization, "%" print "System Connect Time: ", ne.get_connect_time() print "System Disconnect Time: ", ne.get_disconnect_time() GigabitEthernet1 = ne.get_interface_by_name('GigabitEthernet1') GigabitEthernet1_Statistics = GigabitEthernet1.get_statistics() print ne.properties.product_id print ne.properties.udi print ne.properties.SerialNo print ne.host_address print ne.get_interface_list # Disconnect the Network Element ne.disconnect()
else: print "Please set-up a valid transport type: TIPC or TLS" exit(0) #Get a routing instance associated with a network element routing = Routing.get_instance(ne) #Get RIB information #rib = routing.rib approutetable = routing.app_route_table scope = L3UnicastScope("", L3UnicastScope.AFIType.IPV4, L3UnicastScope.SAFIType.UNICAST, "base") prefix = NetworkPrefix(prefix_addr, prefix_mask) intf = ne.get_interface_by_name(next_hop_intf) nexthop_list = list() nexthop_list.append(L3UnicastNextHop(intf, next_hop_addr, scope)) route1 = L3UnicastRoute(prefix, nexthop_list, 7, None, 2, 16) routeop1 = L3UnicastRouteOperation(RouteOperation.RouteOperationType.ADD, route1) oplist1 = list() oplist1.append(routeop1) #update routing table added_routes = approutetable.update_routes(scope, oplist1) #print the added route for route_op in added_routes: