cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
917
Views
0
Helpful
2
Comments
cobedien
Cisco Employee
Cisco Employee

Nexus

Problem Statement

  • N6001 boot up sequence was causing ESX host to lose connectivity
  • N6001 brings the uplink ports up 2-3 minutes after the host ports
  • NX-OS Software is not able to change the boot up sequence because this is part of the second module (non-removable)

EEM script to trigger Python Policy

event manager applet link_reboot

  event syslog pattern "Module 1 current-status is"

  action 1 syslog priority critical msg Running linkchange4 down

  action 2 cli python bootflash:linkchange4.py down

event manager applet link_up

  event track 30 state up

  action 1 syslog priority critical msg Running linkchange4 up

  action 2 cli python bootflash:linkchange4.py up

 

 

Python Script to collect port state, bring them down and bring them up

#!/usr/bin/python

 

import sys

import os

import re

from cisco import cli

 

hostlistfile = "hostlist"

 

try:

    sys.argv[1]

except IndexError:

    print "Error: Missing argument, need either 'up' or 'down'"

    exit()

 

if sys.argv[1] == "up":

   # At this point we should have a file containing ports to bring up.

   if os.path.isfile(hostlistfile) == False:

       print "No hostlist found, exiting"

       exit()

 

   file = open(hostlistfile, "r")

   line = file.readline()

   while line != "":

       stripped = line.rstrip('\n')

       cli("config terminal ; interface %s ; no shutdown" % stripped)

       line = file.readline()

 

   #We are now done with the hostlist file, lets delete.

   os.remove(hostlistfile)

 

if sys.argv[1] == "down":

    # Uplinks are not yet up, lets see which hosts are active, bring those

    # down and save to a file.

 

    f = open(hostlistfile, "w")

    print "Generating host list dynamically."

    result = cli("show interface")

    for rline in result[1].split('\n'):

        match = re.match(r'^(Ethernet[\S]+).*', rline)

        if match:

            #Check name against Ethenert2/ we will skip these uplinks.

            match2 = re.match(r'Ethernet2/.*', match.group(1))

            if match2:

                continue

 

            # If we made it this far, check state then adjust

            match3 = re.match(r'Ethernet1/.*', match.group(1))

            if match3:

                match4 = re.match(r'.*(Administratively down|SFP not inserted).*', rline)

                if match4 == None:

                    f.write(match.group(1))

                    f.write('\n')

                    #Change state

                    cli("config t ; interface %s ; shutdown" % match.group(1))

    f.close()

 

Comments
silemire
Level 1
Level 1

Thanks, I'm having the same issue with a Nexus 6001 in my network causing packet loss after a switch reboot. FYI, the script works fine with NX-OS 6.0(2) but Python is broken in NX-OS version 7.0(x): there is no way to launch a script from the CLI, it starts the interpreter but does not launch the script.

cobedien
Cisco Employee
Cisco Employee

Silemire,

Can you please send me the output of what you are seeing with the show output to co@cisco.com

 

Thanks


Cesar

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: