コード例 #1
0
 def useCLI(self, command):
     vty_session = VtyService(self._device)
     vty_session.open()
     parsed_show = vty_session.write(command)
     # print parsed_showd
     vty_session.close()
     return parsed_show
コード例 #2
0
 def getReasonforReboot(self):
     reason = 'Unknown'
     vty_session = VtyService(self._device)
     vty_session.open()
     parsed_show_version = vty_session.write('show version').split('\n')
     for line in parsed_show_version:
         if line.startswith('Last reload'):
             parsed_line = line.split(':')
             reason = parsed_line[1].strip()
             return reason
     vty_session.close()
コード例 #3
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()