Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partner demo #19

Open
wants to merge 162 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
e1411c4
Added Initial directory for nexus scripts with sample file
gopal1cloud Jan 5, 2015
91c4ab5
nexus 9k automation first commit
Jan 7, 2015
b666f45
initialize the html files
Jan 7, 2015
df32b34
updated Readme.txt file
Jan 7, 2015
3a46b00
monitoring automation code with timestamp in the subject of email
Jan 8, 2015
a9f7df7
Automation Readme file
Jan 9, 2015
5d269af
Updated Readme file
Jan 9, 2015
40ffc98
Automation scripts
Jan 9, 2015
4c8e84c
Interface monitoring automation code with review comments
Jan 9, 2015
84dc616
monitoring systemlevel resources updated code
Jan 9, 2015
4395d23
Software upgrade and patch-managementi changes.
Jan 9, 2015
792cd38
Software and patch management changes
aci-onecloud Jan 9, 2015
aa4ba17
OS configuration and patch-management
aci-onecloud Jan 10, 2015
2277f4b
Merge branch 'master' of https://github.com/onecloud/nexus9000
aci-onecloud Jan 10, 2015
e6ac041
Updated cmd-line options
aci-onecloud Jan 14, 2015
ffacd39
L2/L3 VLAN configuration management
aci-onecloud Jan 18, 2015
3fdbea6
Delete VLAN configuration
aci-onecloud Jan 18, 2015
3f46818
monitoring code is updated with proper directory structure
Jan 19, 2015
7ad100f
Monitoring changes
Jan 19, 2015
5c61e5c
removed monitoring code
Jan 19, 2015
747c36f
removed files
Jan 19, 2015
5f042be
interface and fex configuration management code
Jan 19, 2015
9487948
updated code
Jan 19, 2015
e60f1fd
updated code
Jan 19, 2015
afb497f
fex configuration code
Jan 19, 2015
c242cbd
updated code
Jan 19, 2015
ffc5762
commit of off-box and on-box tested automation code
Jan 20, 2015
d1d1411
updated
Jan 20, 2015
537560d
Transceiver auto speed detection and configuration
Jan 21, 2015
4ee41f5
Switch Configuration Contents
Jan 21, 2015
32de064
updated code
Jan 22, 2015
362ac14
updated
Jan 20, 2015
1f57fa8
Merge branch 'master' of https://github.com/onecloud/nexus9000
aci-onecloud Jan 26, 2015
2fe2b55
L2/L3 VLAN changes
aci-onecloud Jan 26, 2015
03f78c9
in-box config-mgmt changes
aci-onecloud Jan 26, 2015
922f118
updated code
Jan 27, 2015
139c4e3
With enhancements from David
aci-onecloud Jan 29, 2015
df68350
Merge branch 'master' of https://github.com/onecloud/nexus9000
aci-onecloud Jan 29, 2015
6c3af0b
updated on-box monitoring scripts
Jan 30, 2015
003554a
updated monitoring Readme file
Jan 30, 2015
8b9f6e9
updated on-box config-mgmt scripts
Jan 30, 2015
8c34ba7
updated code
Jan 30, 2015
4c6bb17
updated code
Feb 2, 2015
8e2349e
updated code
Feb 2, 2015
3737c40
updated config management code
Feb 3, 2015
1fe7b33
updated code
Feb 3, 2015
98a42b2
updated code
Feb 3, 2015
475f8d4
updated code
Feb 3, 2015
580f76e
updated code
Feb 3, 2015
c5f59a4
updated code
Feb 3, 2015
de3945a
changes for review comments by venkat
aci-onecloud Feb 7, 2015
535f68e
Merge branch 'master' of https://github.com/onecloud/nexus9000
aci-onecloud Feb 7, 2015
a195a86
Changes for review comments by venkat
aci-onecloud Feb 7, 2015
badbc9f
updated interface monitoring code
Feb 10, 2015
1d19f9b
updated Readme file
Feb 10, 2015
dc67b4c
on-box review changes
aci-onecloud Feb 12, 2015
f80d68c
fix for review changes
aci-onecloud Feb 12, 2015
698e639
review changes
aci-onecloud Feb 12, 2015
eb25de4
review changes
aci-onecloud Feb 12, 2015
b053284
review changes
aci-onecloud Feb 12, 2015
19480dd
updated interface monitoring code
Feb 12, 2015
20e8a71
updated jinja templates
Feb 12, 2015
c30b450
updated interface monitoring on-boxcode
Feb 12, 2015
e22519f
updated interface description onbox code
Feb 12, 2015
4ea1aab
updated interface description code
Feb 12, 2015
92b58c5
updated onbox interface description code
Feb 12, 2015
a273279
fex trouble shooting code
Feb 12, 2015
d81e210
Merge branch 'master' of https://github.com/onecloud/nexus9000
aci-onecloud Feb 12, 2015
9e66b7d
updated code
Feb 13, 2015
cbc3282
review changes
aci-onecloud Feb 13, 2015
1618098
Merge branch 'master' of https://github.com/onecloud/nexus9000
aci-onecloud Feb 13, 2015
a432a57
interface description update code
Feb 13, 2015
9ac0230
fex configuration code
Feb 13, 2015
f1304ca
update interface description
Feb 13, 2015
e648f29
updated code
Feb 13, 2015
40d8633
updated interface description configuration code
Feb 13, 2015
47dfeba
updated configuration file
Feb 13, 2015
742b5e3
Update transceiver.py
darshanck Feb 17, 2015
210c10b
Update transceiver.py
darshanck Feb 17, 2015
82a90bf
updated code
sailajaonecloud Feb 18, 2015
0e9d1ad
updated code
sailajaonecloud Feb 18, 2015
14f73cb
Update transceiver.py
darshanck Feb 17, 2015
724bc82
Update transceiver.py
darshanck Feb 18, 2015
106421e
Merge branch 'master' of https://github.com/onecloud/nexus9000
aci-onecloud Feb 13, 2015
403ab13
Merge branch 'master' of https://github.com/onecloud/nexus9000
aci-onecloud Mar 3, 2015
85351d5
on-box patch-mgmt changes
aci-onecloud Mar 3, 2015
33544e2
On-Box script for Transceiver
darshanck Mar 12, 2015
fed96a7
On-Box script for Transceiver
darshanck Mar 12, 2015
9eb27bd
Delete transceiver.py
darshanck Mar 12, 2015
2763fbb
Update interface_desc_cdp.py
sailajaonecloud Mar 13, 2015
be16a4a
Update interface_desc_lldp.py
sailajaonecloud Mar 14, 2015
e97bfce
updated code
sailajaonecloud Mar 14, 2015
98ddbb5
Update interface_desc_cdp.py
sailajaonecloud Mar 14, 2015
45dceb8
Update interface_desc_lldp.py
sailajaonecloud Mar 14, 2015
2ee9521
updated fex troubleshoot code
sailajaonecloud Mar 14, 2015
c2f7e87
updated off-box fex troubleshoot code
sailajaonecloud Mar 14, 2015
3d58c25
updated configmgmt offbox code
sailajaonecloud Mar 14, 2015
5473558
updated onbox configmgmt code
sailajaonecloud Mar 14, 2015
9f0620b
Update transceiver.py
darshanck Mar 16, 2015
201d76c
Update transceiver.py
darshanck Mar 16, 2015
d0e66e3
Updated transceiver.py
darshanck Mar 16, 2015
4f61673
updated onbox fex configuration code
sailajaonecloud Mar 18, 2015
5c4b7d6
updated fex configuration off box code
sailajaonecloud Mar 18, 2015
39bbfc2
updated configuration file
sailajaonecloud Mar 18, 2015
add4d7c
updated interface description off-box code
sailajaonecloud Mar 18, 2015
e897fcd
Minor changes at mailing system and few info are added for identity o…
darshanck Mar 18, 2015
9c192c0
uppdated fex configuration off-box code
Mar 18, 2015
3167963
updated readme file
Mar 18, 2015
c80563f
updated off-box interface description code
Mar 19, 2015
49ba383
updated code
Mar 19, 2015
167ea80
HTML formatting for email contents
darshanck Mar 19, 2015
1d0c36c
Template for Transceiver auto speed configuration
darshanck Mar 19, 2015
d2291c7
HTML formatting for email contents
darshanck Mar 19, 2015
8732053
Update nx_automation.cfg
darshanck Mar 19, 2015
81815de
updtaed fex configuration code
Mar 20, 2015
8059f38
updated code
Mar 20, 2015
cb45e0a
updated code
Mar 20, 2015
5572074
Update at Print statement
darshanck Mar 21, 2015
d1a138a
Update transceiver.py
darshanck Mar 21, 2015
7ccdf5a
Update transceiver.py
darshanck Mar 21, 2015
1fa81a2
updated lldp code
Mar 22, 2015
ff3336b
Update transceiver.py
darshanck Mar 23, 2015
ef7c2f5
updated code
Mar 23, 2015
a54e5e1
updated code
Mar 24, 2015
0bcfc5d
cleanup scripts
Apr 17, 2015
7f144f7
Validation Commands
darshanck Apr 17, 2015
18acc9d
Update nexus_cleanup.py
darshanck Apr 18, 2015
7de94ff
updated code
Apr 20, 2015
2adeeb4
updated code
Apr 22, 2015
1bdfdab
updated code
Apr 22, 2015
8f69d58
Added Nexus cleanup script for bulk process
gopal1cloud May 2, 2015
159449b
Code to delete bootflash scripts
darshanck May 9, 2015
a1c3274
Formatted Script header on Off Box scripts
gopal1cloud May 28, 2015
1192bd6
Formatted Script header on On Box scripts
gopal1cloud May 28, 2015
8b686ff
Rename Readme.txt to README.md
gopal1cloud May 28, 2015
0dc40eb
Rename Readme.txt to README.md
gopal1cloud May 28, 2015
4efe49b
Rename Readme.txt to README.md
gopal1cloud May 28, 2015
aa73458
Rename Readme.txt to README.md
gopal1cloud May 28, 2015
bf25fc3
Rename Readme.txt to README.md
gopal1cloud May 28, 2015
53e9d3c
Added demo script for communityportal sync
gopal1cloud Jul 9, 2015
6dc588f
Modified title on demo script
gopal1cloud Jul 10, 2015
e8de432
deleted demo script
gopal1cloud Jul 10, 2015
888ac54
Minor change in sample script.
Jul 13, 2015
ce51a79
Changed title of fex config script.
Jul 13, 2015
22baa1a
Changed title of fex config script.
Jul 13, 2015
e6dc83c
Changed title of fex config script.
Jul 13, 2015
dbebb41
Changed title of fex config script.
Jul 13, 2015
e992f7a
Changed title of fex config script.
Jul 13, 2015
977e0be
Changed title of fex config script.
Jul 13, 2015
b36af8b
Changed long descriptiton.
Jul 13, 2015
4cff085
Modified long description on FEX Configuration
gopal1cloud Aug 13, 2015
4c6c5e2
new demo branch created
gopal1cloud Aug 18, 2015
4446deb
Update README.md
davidclin-onecloud Aug 18, 2015
b570c7a
latest working scripts
davidclin-onecloud Aug 18, 2015
68f8685
Update README.md
davidclin-onecloud Aug 18, 2015
d0d35de
Update README.md
davidclin-onecloud Aug 18, 2015
49333c5
Update README.md
davidclin-onecloud Aug 18, 2015
8b81646
Update README.md
davidclin-onecloud Aug 19, 2015
f36923c
Update README.md
davidclin-onecloud Aug 19, 2015
8df6559
Update README.md
davidclin-onecloud Aug 19, 2015
a73ec4d
added vxlan configurations
davidclin-onecloud Aug 19, 2015
15fab28
added ppt and docx files
davidclin-onecloud Aug 19, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file added demo_docs/N9K_Demo_Overview.pptx
Binary file not shown.
20 changes: 20 additions & 0 deletions demo_scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Nexus 9000 Partner Demo Scripts
===============================
Welcome to the OneCloud Consulting Nexus 9000 demo script repository.

These scripts were developed and tested on a Nexus 9000 C9372PX chassis running 7.0(3)I1(2).

Summary
========
1. __find_freeip.py__ : Pings a range of IP addresses then prints which are UP followed by a summary of addresses that are unused.
2. __sh_switch_details.py__ : Displays specific details from neighbor based on its IP address. Demonstrates use of a single programmatic Python instruction versus a series of CLI commands to obtain the same information.
3. __cdp.py__ : Configures interface descriptions based on CDP information.
4. __lldp.py__ : Configured interface descriptions based on LLDP information.
5. __ospf.py__ : Provides menu driven options to configure OSPF interface attributes (area/cost).
6. __pim.py__ : Provides menu driven options to configure PIM interface attributes.
7. __cleanup.py__ : Provides menu driven options to cleanup demo configurations.
8. __sh_version.py__ : Uses NX-API to compare expected NX-OS version against actual NX-OS versions running in the network.
9. __sh_proc_cpu_sort.py__ : Checks CPU health of switch at regular intervals with option to log output to file for TAC.
10. __sh_proc_mem.py__ : Checks memory utilization of switch at regular intervals with option to log to file for TAC.
11. __sh_int_count.py__ : Checks interface packet count at regular intervals with option to log to file for TAC.

120 changes: 120 additions & 0 deletions demo_scripts/cdp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
"""Script Cataloging Information
:Product Info:Nexus::9000::9516::NX-OS Release 6.2
:Category:Config-Mgmt
:Box Type:On-Box
:Title:Interface Description configuration
:Short Description:To dynamically configure interface descriptions
:Long Description:Check the CDP state and modify the interface description accordingly.
:Input:command to check the CDP state and based on the command output,
modify the description of the interface
:Output:interface description should be updated
"""

import os
from cli import *
import sys

"""

Class to update the interface description based on the
CDP state
"""

class Interface_Desc:

interface_message = {}

#get the nexus switch version and chassis details
def nexus_version(self):
versioncmd = "show version"
out = json.loads(clid(versioncmd))
chassis_id = out['chassis_id']
osversion = out['rr_sys_ver']
cpu_name = out['cpu_name']
memory = out['memory']
processor_board = out['proc_board_id']
device = out['host_name']
bootflash = out['bootflash_size']

print "Nexus Switch OS version is :" , osversion
print "Chassis ID is :", chassis_id
print cpu_name + "with" + str(memory) + "KB of memory"
print "Processor Board ID is " + processor_board

print "Host Name : " + device
print "Bootflash : " + str(bootflash) + ' ' + "KB"
print "\n"

def cdp_status(self):
intob = Interface_Desc()

#check CDP is enabled or not
cdp_stat = "show cdp global"
stat = json.loads(clid(cdp_stat))

if (stat['cdp_global_enabled'] == 'enabled'):
print "CDP is enabled on the Host Switch"
cdp_nei = "show cdp nei"
status = json.loads(clid(cdp_nei))
status_list = status['TABLE_cdp_neighbor_brief_info']['ROW_cdp_neighbor_brief_info']
cdp_dict = {}

if (isinstance(status_list, list)):
for i in status_list:
for key,value in i.items():
if (key == 'device_id'):
cdp_dict.update({key:value})
if (key == 'intf_id'):
cdp_dict.update({key:value})
if (key == 'port_id'):
cdp_dict.update({key:value})
if (key == 'capability'):
cdp_dict.update({key:value})
intob.updateinterface(cdp_dict)
elif (isinstance(status_list, dict)):
for key,value in status_list.items():
if (key == 'device_id'):
cdp_dict.update({key:value})
if (key == 'intf_id'):
cdp_dict.update({key:value})
if (key == 'port_id'):
cdp_dict.update({key:value})
if (key == 'capability'):
cdp_dict.update({key:value})
intob.updateinterface(cdp_dict)
else:
print "Not implemented for this response type"

else:
print "CDP is not enabled on the Host Switch.Please check the CDP manual to enable it. "
exit(1)

#update the interface description
def updateinterface(self, data):
for key,value in data.iteritems():
if (key == 'intf_id'):
cmd1 = "interface" + ' ' + value
desc = "description" + ' ' + "Connected to device" + ' ' + data['device_id'] + ' ' + "on" + ' ' + data['port_id']
msg = "Connected to device" + ' ' + data['device_id'] + ' ' + "on" + ' ' + data['port_id']

cmd = "conf t" + ' ' + " ;" + ' ' + cmd1 + ' ' + ";" + ' ' + desc
cli(cmd)
print "\n"
print "Interface" + ' ' + data['intf_id'] + ' ' + "description is updated as : " + ' ' + msg
if (data['capability']):
print "Neighbor device" + ' ' + data['device_id'] + ' ' + "is capable as : "
for i in data['capability']:
print str(i)

#print data['capability']



if __name__ == '__main__':
interfaceob = Interface_Desc()
interfaceob.nexus_version()
interfaceob.cdp_status()




225 changes: 225 additions & 0 deletions demo_scripts/cleanup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
"""
Cisco Nexus 9000 Switch On-Box script for cleaning
repetitive switch configurations such as disabling
features, removing IP addresses from all interfaces,
and so on.
"""
from cli import *
import time

class Cleanup(object):

def __init__(self):
""" No variables are required for this class. """

def print_Banner(self):
msg = '\n _ _ _ _ _ _ _'
msg += '\n / \\ / \\ / \\ / \\ / \\ / \\ / \\'
msg += '\n ( C | l | e | a | n | u | p )'
msg += '\n \\_/ \\_/ \\_/ \\_/ \\_/ \\_/ \\_/'
msg += '\n\nCisco Nexus 9000 Switch On-Box script'
msg += '\nfor cleaning repetitive switch configurations.\n'
msg += '\nDeveloped By: OneCloud Consulting\n'
msg += 'Please contact [email protected] for any queries.\n'
print msg

def print_Menu(self):
print "-"*25 + " Menu Options " + "-"*25
print "1) Remove all 'feature' CLI statements."
print "2) Remove 'ip pim sparse-mode' from all interfaces."
print "3) Remove IP addresses from all interfaces."
print "4) Remove all configured Loopback interfaces."
print "5) Remove all configured 'vrf context' except management."
print "6) Remove descriptions from all interfaces."
print "7) Run all of the above."
print "\nType any other key to exit menu."
print "-"*68

def remove_Feature(self):
# This function assumes all configured feature statements are comprised of 2 words.
# In the case of 'feature nv overlay', 3 words are used.
# To workaround this, explicitly remove 'feature nv overlay'.
cli('conf ; no feature nv overlay')
time.sleep(5) # wait 5 seconds for above command to get removed

#Now parse and iterate across output of 'show run | include feature'
show_run_feature = []
show_run_feature = cli('show run | inc feature')

feature = show_run_feature.split( )

cli_commands = "conf"

for i in xrange(1, len(feature) ,2):
cli_commands += " ; no feature " + feature[i]

if len(feature) == 0:
print "There are no features to remove."
else:
print "You are about to remove all 'feature' CLI statements."

confirm = raw_input("Are you sure? [y|n]")
if confirm == "y":
cli(cli_commands)
result = cli('show run | inc feature')
print result
print "All 'feature' CLI statements removed!\n"
return
else:
print "You chose not to commit. Script aborted."
return

def remove_Pim(self):
show_int_brief = []
show_int_brief = cli('show ip int brief | inc Eth|Lo')

interfaces = show_int_brief.split( )

cli_commands = "conf"

for i in xrange(0, len(interfaces) ,3):
cli_commands += " ; interface " + str(interfaces[i])
cli_commands += " ; no ip pim sparse-mode"

print "You are about to remove PIM sparse-mode under all interfaces."

confirm = raw_input("Are you sure? [y|n]")

if confirm == "y":
cli(cli_commands)
print "\nPIM successfully removed from all interfaces!\n"
print "Type 'show ip pim interface brief' to verify.\n"
return
else:
print "You chose not to commit. Script aborted."
return

def remove_Ipaddress(self):
show_int_brief = []
show_int_brief = cli('show ip int brief | inc Eth|Lo')

interfaces = show_int_brief.split( )

cli_commands = "conf"

for i in xrange(0, len(interfaces) ,3):
cli_commands += " ; interface " + str(interfaces[i])
cli_commands += " ; no ip address"

print "You are about to remove IP addresses from all interfaces."

confirm = raw_input("Are you sure? [y|n]")

if confirm == "y":
cli(cli_commands)
print "\nIP addresses successfully removed from all interfaces!\n"
print "Type 'show ip interface brief' to verify.\n"
return
else:
print "You chose not to commit. Script aborted."
return

def remove_Loopbacks(self):
show_int_brief = []
show_int_brief = cli('show int brief | inc Lo')

interfaces = show_int_brief.split( )

cli_commands = "conf"

for i in xrange(0, len(interfaces) ,3):
cli_commands += " ; no interface " + str(interfaces[i])

print "You are about to remove all Loopback interfaces."

confirm = raw_input("Are you sure? [y|n]")

if confirm == "y":
cli(cli_commands)
print "\nAll Loopback interfaces removed!\n"
print "Type 'show interface brief | inc Loopback' to verify.\n"
return
else:
print "You chose not to commit. Script aborted."
return

def remove_Vrf_Contexts(self):
show_run = []
show_run = cli('show run | include context | exclude management')

contexts = show_run.split( )

cli_commands = "conf"

for i in xrange(2, len(contexts) ,3):
cli_commands += " ; no vrf context " + str(contexts[i])
print "You are about to remove all vrf contexts (except management)."

confirm = raw_input("Are you sure? [y|n]")

if confirm == "y":
cli(cli_commands)
print "\nAll vrf contexts removed!\n"
print "Type 'show run | inc context' to verify.\n"
return
else:
print "You chose not to commit. Script aborted."
return

def remove_Interface_Descriptions(self):
show_int_brief = []
show_int_brief = cli('show int brief | json-pretty | inc interface | exc TABLE | exc ROW')
interfaces = show_int_brief.replace(',', '')
interfaces = interfaces.replace('"', '')

interfaces = interfaces.split( )

cli_commands = "conf"

for i in xrange(1, len(interfaces) ,2):
cli_commands += " ; interface " + str(interfaces[i] + " ; no description")

print "You are about to remove descriptions from all interfaces."

confirm = raw_input("Are you sure? [y|n]")

if confirm == "y":
cli(cli_commands)
print "\nRemoved descriptions from all interfaces!\n"
print "Type 'sh run | include description' to verify.\n"
return
else:
print "You chose not to commit. Script aborted."
return

if __name__ == '__main__':
foo = Cleanup()
foo.print_Banner()
foo.print_Menu()
option = raw_input("\nSelect option [1-7]:")

if option == "1":
print "This may take some time..."
foo.remove_Feature()
elif option == "2":
check = cli('show feature | inc pim')
check_enabled = check.split()
if check_enabled[2] == "disabled":
print "There are no interfaces with 'ip pim sparse-mode' configured."
elif check_enabled[2] == "enabled":
foo.remove_Pim()
elif option == "3":
foo.remove_Ipaddress()
elif option == "4":
foo.remove_Loopbacks()
elif option == "5":
foo.remove_Vrf_Contexts()
elif option == "6":
foo.remove_Interface_Descriptions()
elif option == "7":
print "Checking configured features. This may take some time..."
foo.remove_Feature()
foo.remove_Ipaddress()
foo.remove_Loopbacks()
foo.remove_Pim()
foo.remove_Vrf_Contexts()
Loading