Ejemplo n.º 1
0
def scaleNotification():

    for switch in switches:
        switchIP = switch[0]
        appName = switch[1]
        user = switch[2]
        pswd = switch[3]

        #
        # Set up session connection configuration and connect to the switch
        #
        ne = NetworkElement(switchIP, appName)
        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)

        vty = VtyService(ne)
        vty.open()
        vlan_summary = vty.write("sh vlan summary")
        vty.close()

        vlan_sum = re.search('(?<=vlansum-all-vlan\t)(.*)', vlan_summary)

        if int(vlan_sum.group(0)) > int(scale_limits["max_vlans"]):
            string_print = "Vlan scale exceeded. Max vlan recommended:", scale_limits[
                "max_vlans"], "vlan being used :", vlan_sum.group(0)
            print string_print
            ne.create_syslog_message(
                ne.OnepSyslogSeverity.ONEP_SYSLOG_CRITICAL, str(string_print))
        print "Disconnecting from NE: ", switchIP
        ne.disconnect()
Ejemplo n.º 2
0
def scaleNotification():

    for switch in switches:
        switchIP = switch[0]
        appName  = switch[1]
        user     = switch[2]
        pswd     = switch[3]

        #
        # Set up session connection configuration and connect to the switch
        #
        ne = NetworkElement(switchIP, appName)
        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)

        vty = VtyService(ne)
        vty.open()
        vlan_summary = vty.write("sh vlan summary")
        vty.close()

        vlan_sum = re.search('(?<=vlansum-all-vlan\t)(.*)',vlan_summary)

        if int(vlan_sum.group(0)) > int(scale_limits["max_vlans"]):
            string_print = "Vlan scale exceeded. Max vlan recommended:",scale_limits["max_vlans"],"vlan being used :", vlan_sum.group(0)
            print string_print
            ne.create_syslog_message (ne.OnepSyslogSeverity.ONEP_SYSLOG_CRITICAL,
                                      str(string_print));
        print "Disconnecting from NE: ",switchIP
        ne.disconnect()
Ejemplo n.º 3
0
# user     - switch userID
pswd = "<pswd>"

logMsg = "syslog generated by onePK"
#####################################################################

#
# Set up session connection configuration and connect to the switch
#
ne = NetworkElement(switchIP, appName)
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)
else:
    print "Please set-up a valid transport type: TIPC or TLS"
    exit(0)

#
# Create the syslog messange and disconnect from the device
#
print "Generating Syslog message."
ne.create_syslog_message(ne.OnepSyslogSeverity.ONEP_SYSLOG_CRITICAL, logMsg)
print "Check on switch logs using \"sh log log duration 00:05:00\" cli"

print "Disconnecting from device: ", switchIP
ne.disconnect()
Ejemplo n.º 4
0
filter =  InterfaceFilter(None, NetworkInterface.InterfaceTypes.ONEP_IF_TYPE_ETHERNET)
intf_list_ne = ne.get_interface_list(filter)
#
# For every Interface, check the CRC errors
#
for intf_ne in intf_list_ne:
    try:
        int = ne.get_interface_by_name(intf_ne.name)
        int_stats =  int.get_statistics()
        rx_CRC_pkts=int_stats.get_param(rx_CRC)
        print "CRC_pkts: ", rx_CRC_pkts,"on int", intf_ne.name
        #
        # If CRC error are greater than the threshold, generate a syslog message,
        # print the values and shut down the interface
        #
        if rx_CRC_pkts > crcThreshold:
            string_print = "CRC threshold of ",crcThreshold," exceeded. Shutting down interface ",intf_ne.name
            ne.create_syslog_message (ne.OnepSyslogSeverity.ONEP_SYSLOG_CRITICAL,
                                      str(string_print));

            #print locally
            print "Interface: ",intf_ne.name,"RX_PKTS_CRC",rx_CRC_pkts
            print "Shutting interface", intf_ne.name

            #shut interface
            int.shut_down(1)
    except:
        continue

ne.disconnect();
Ejemplo n.º 5
0
# user     - switch userID
pswd     = "<pswd>"

logMsg   = "syslog generated by onePK"
#####################################################################

#
# Set up session connection configuration and connect to the switch
#
ne = NetworkElement(switchIP, appName)
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)
else:
    print "Please set-up a valid transport type: TIPC or TLS"
    exit(0)

#
# Create the syslog messange and disconnect from the device
#
print "Generating Syslog message."
ne.create_syslog_message(ne.OnepSyslogSeverity.ONEP_SYSLOG_CRITICAL, logMsg);
print "Check on switch logs using \"sh log log duration 00:05:00\" cli"

print "Disconnecting from device: ", switchIP
ne.disconnect()
Ejemplo n.º 6
0
                         NetworkInterface.InterfaceTypes.ONEP_IF_TYPE_ETHERNET)
intf_list_ne = ne.get_interface_list(filter)
#
# For every Interface, check the CRC errors
#
for intf_ne in intf_list_ne:
    try:
        int = ne.get_interface_by_name(intf_ne.name)
        int_stats = int.get_statistics()
        rx_CRC_pkts = int_stats.get_param(rx_CRC)
        print "CRC_pkts: ", rx_CRC_pkts, "on int", intf_ne.name
        #
        # If CRC error are greater than the threshold, generate a syslog message,
        # print the values and shut down the interface
        #
        if rx_CRC_pkts > crcThreshold:
            string_print = "CRC threshold of ", crcThreshold, " exceeded. Shutting down interface ", intf_ne.name
            ne.create_syslog_message(
                ne.OnepSyslogSeverity.ONEP_SYSLOG_CRITICAL, str(string_print))

            #print locally
            print "Interface: ", intf_ne.name, "RX_PKTS_CRC", rx_CRC_pkts
            print "Shutting interface", intf_ne.name

            #shut interface
            int.shut_down(1)
    except:
        continue

ne.disconnect()