cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 

Python Scripts Executing from Netsight - Clarification Needed

Python Scripts Executing from Netsight - Clarification Needed

Ed_McGuigan1
New Contributor III
I got my python book and started learning python at the beginning of the week.

I want to write a script that can be executed from Netsight ( EMC 8.04 ). What I actually want to do is locate ports on switches to which PoE powered wireless access points are connected and cycle the PoE power in order to reboot hung access points.

There is no documentation that I can find specific to Python scripts as opposed to TCL scripts on Netsight and my assumption was that I would just write a script that was suitable to be loaded directly onto a switch and that the Netsight interface would take care of uploading the script and executing it.

I noticed that there didn't seem to be any information about adding the same kind of metadata for the definition of script arguments.

I have a script that I can manually upload onto a switch and execute but if I try to execute it from Netsight by selecting the Run option and picking a switch to run it on, it fails with a complaint that the exsh module couldn't be found.

I have realized that a python script in Netsight is not uploaded to the switch but rather executed on the server. I guess that would be workable but there is no documented method for providing arguments to the scripts.

Is this a feature that hasn't been completed yet?
I am trying to work out a method of being able to upload and execute a python script on a switch such that it can be leveraged from Netsight, or understand how others are leveraging python on XOS and getting scripts out onto devices on as needed basis.

Do I need to use a generic python server script to push out my XOS python scripts, run them at the switch and then delete them?
20 REPLIES 20

Hi Dave,

I'd be interested in an example as well.

Did you allude to the JSON-RPC interface to EXOS?

Edit: I've been reading the thread from the top down, the example has been provided and my question answered (yes, it is JSON-RPC) below. Thanks. šŸ™‚

Thanks,
Erik

Stay tuned, more to come... even better! šŸ™‚

I am definitely interested Dave - just depends on how much work it is for you.

We need some more resources so that this tremendously powerful toolset gets better utilized ( and it's also a lot more fun than endless typing ).

Ed_McGuigan1
New Contributor III
Ok Stephane, I had a little play with this.

I just did a basic script to walks the keys in emc_vars dictionary and copied in some lines from a real script with custom variables defined. Seems a little weird to have a TCL style "set var" command at the top of some python but "whatever!".

I am still thinking about using the server scripts to load switch scripts and execute them but I guess for now I will see where I get with pure server scripts.

Regardless, you have cured me of TCLishness - pure python for me from here on.

Thanks for your help.

Ed.
#@MetaDataStart
#@DetailDescriptionStart
#############################################################################
# Extreme Networks(R) CLI Scripting Library
#
# Script : Trap Suppression
# Revision : 1.0
# Last Updated : October 16 2017
#
# Used to disable certain trap OIDs in a mib-view in order to suppress specific traps
# usually because they are endemic or we just don't care about them or don't want to
# overload the Alarm systems.
#
# Current relevant traps are:
# 1.3.6.1.4.1.1916.0.6 extremeOverheat
# 1.3.6.1.4.1.1916.0.7 extremeFanFailed
# 1.3.6.1.4.1.1916.0.8 extremeFanOK
# 1.3.6.1.4.1.1916.1.4.13.2.0.1 extremePortMauChangeTrap
#
#####################################################################
#@DetailDescriptionEnd
#############################################################################################
# Define identity management configuration parameters in this section.
#############################################################################################
#@SectionStart (description = Script configuration properties)
#@VariableFieldLabel ( description = "Trap OID List",
# type = String,
# scope = global,
# required = yes,
# readonly = no
#)
set var trapOidList 1.3.6.1.4.1.1916.0.7:exclude,1.3.6.1.4.1.1916.0.8:exclude
#@VariableFieldLabel (description = "Target MIB View"
# type = String,
# scope = global
# )
set var targetMibView AccessSwitchTraps
#@SectionEnd
#@MetaDataEnd
import os
print('Hello world! ' + os.getcwd())
for key, value in emc_vars.items() :
print (key, value)
print("trapOidList is " + emc_vars["trapOidList"])
print("targetMibView is " + emc_vars["targetMibView"])=====================================================================

Script output was as follows:
Date and Time: 2017-11-06T10:31:43.730
EMC User: 1101286
EMC User Domain:
IP: 10.130.254.20
Hello world! /usr/local/Extreme_Networks/NetSight/wildfly/bin
(u'date', u'2017-11-06')
(u'log4j.configuration', u'file:./log4j.properties')
(u'serverVersion', u'8.0.3')
(u'isExos', u'true')
(u'devicePwd', u'blindmickeymcgrew')
(u'USE_NETSNMP', u'true')
(u'enterasys.tomcat.http.port', u'8080')
(u'enterasys.tomcat.https.port', u'8443')
(u'javax.script.name', u'Python')
(u'managementPorts', u'')
(u'deviceName', u'Highland ES IDF1.20')
(u'deviceId', 297)
(u'javax.script.engine_version', u'2.7.0')
(u'deviceVR', u'VR-Default')
(u'javax.script.language', u'python')
(u'STATUS', 1)
(u'serverIP', u'10.254.231.12')
(u'scriptOwner', u'')
(u'auditLogEnabled', u'')
(u'deviceType', u'EXOS Stack-V80')
(u'interSwitchPorts', u'1:25,1:32,1:38,1:45,4:6,3:16,3:19,3:22,3:26,2:2,3:27,2:5,3:34,2:25,2:32')
(u'WmInfoHistory.ProcessEndSystemEvents', u'true')
(u'enterasys.mysqlrealm.rpt.password', u'enterasys')
(u'enterasys.tomcat.ciphers', u'TLS_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-GCM-SHA384,ECDHE-ECDSA-AES128-GCM-SHA256,ECDHE-RSA-AES128-GCM-SHA256,ECDHE-ECDSA-AES256-SHA384,ECDHE-RSA-AES256-SHA384,ECDHE-ECDSA-AES128-SHA256,ECDHE-RSA-AES128-SHA256')
(u'targetMibView', u'AccessSwitchTraps')
(u'accessPorts', u'1:24,2:48,1:26,1:27,1:28,1:29,1:30,1:31,1:33,1:34,1:35,1:36,1:37,1:39,1:40,1:41,1:42,1:43,1:44,1:46,1:47,1:48,4:1,4:2,4:3,4:4,4:5,4:7,4:8,4:9,4:10,4:11,4:12,4:13,4:14,4:15,4:16,4:17,4:18,4:19,4:20,4:21,4:22,4:23,4:24,3:1,4:25,3:2,4:26,3:3,4:27,3:4,4:28,3:5,4:29,3:6,4:30,3:7,4:31,3:8,4:32,3:9,4:33,3:10,4:34,3:11,4:35,3:12,4:36,3:13,4:37,3:14,4:38,3:15,4:39,4:40,3:17,4:41,3:18,4:42,4:43,3:20,4:44,3:21,4:45,4:46,3:23,4:47,3:24,4:48,3:25,2:1,2:3,3:28,2:4,3:29,3:30,2:6,3:31,2:7,3:32,2:8,3:33,2:9,2:10,3:35,2:11,3:36,2:12,3:37,2:13,3:38,2:14,3:39,2:15,3:40,2:16,3:41,2:17,3:42,2:18,3:43,2:19,3:44,2:20,3:45,2:21,3:46,2:22,3:47,2:23,3:48,2:24,1:1,1:2,2:26,1:3,2:27,1:4,2:28,1:5,2:29,1:6,2:30,1:7,2:31,1:8,1:9,2:33,1:10,2:34,1:11,2:35,1:12,2:36,1:13,2:37,1:14,2:38,1:15,2:39,1:16,2:40,1:17,2:41,1:18,2:42,1:19,2:43,1:20,2:44,1:21,2:45,1:22,2:46,1:23,2:47')
(u'enterasys.jboss.log4j.logfile', u'../../appdata/logs/server.log')
(u'domain', u'')
(u'enterasys.embeddednac.enable', u'false')
(u'nmsMobile.demoMode', u'false')
(u'enterasys.mysqlrealm.password', u'enterasys')
(u'endsystem.detail.mapping', u'moref=custom1,uuid=custom1')
(u'enterasys.webservices.queryendsystems', u'true')
(u'trapOidList', u'1.3.6.1.4.1.1916.0.7:exclude,1.3.6.1.4.1.1916.0.8:exclude')
(u'enterasys.mysqlrealm.rpt.username', u'netsight')
(u'enterasys.mysqlrealm.username', u'netsight')
(u'deviceASN', u'4269997588')
(u'deviceSysOid', u'1.3.6.1.4.1.1916.2.93')
(u'enterasys.datasource.connectionurl', u'jdbc:mysql://127.0.0.1:4589/netsight?jdbcCompliantTruncation=false&useUnicode=true&characterEncoding=UTF-8&useSSL=false')
(u'java.security.manager', u'')
(u'deviceLogin', u'netsight')
(u'serverName', u'10.254.18.218')
(u'deviceSoftwareVer', u'15.6.3.1')
(u'ports', u'1:24,2:48,1:25,1:26,1:27,1:28,1:29,1:30,1:31,1:32,1:33,1:34,1:35,1:36,1:37,1:38,1:39,1:40,1:41,1:42,1:43,1:44,1:45,1:46,1:47,1:48,4:1,4:2,4:3,4:4,4:5,4:6,4:7,4:8,4:9,4:10,4:11,4:12,4:13,4:14,4:15,4:16,4:17,4:18,4:19,4:20,4:21,4:22,4:23,4:24,3:1,4:25,3:2,4:26,3:3,4:27,3:4,4:28,3:5,4:29,3:6,4:30,3:7,4:31,3:8,4:32,3:9,4:33,3:10,4:34,3:11,4:35,3:12,4:36,3:13,4:37,3:14,4:38,3:15,4:39,3:16,4:40,3:17,4:41,3:18,4:42,3:19,4:43,3:20,4:44,3:21,4:45,3:22,4:46,3:23,4:47,3:24,4:48,3:25,2:1,3:26,2:2,3:27,2:3,3:28,2:4,3:29,2:5,3:30,2:6,3:31,2:7,3:32,2:8,3:33,2:9,3:34,2:10,3:35,2:11,3:36,2:12,3:37,2:13,3:38,2:14,3:39,2:15,3:40,2:16,3:41,2:17,3:42,2:18,3:43,2:19,3:44,2:20,3:45,2:21,3:46,2:22,3:47,2:23,3:48,2:24,1:1,2:25,1:2,2:26,1:3,2:27,1:4,2:28,1:5,2:29,1:6,2:30,1:7,2:31,1:8,2:32,1:9,2:33,1:10,2:34,1:11,2:35,1:12,2:36,1:13,2:37,1:14,2:38,1:15,2:39,1:16,2:40,1:17,2:41,1:18,2:42,1:19,2:43,1:20,2:44,1:21,2:45,1:22,2:46,1:23,2:47')
(u'java.security.policy', u'../server/default/conf/server.policy')
(u'oneView.responsetime.app.redline', u'1000')
(u'oneView.responsetime.tcp.redline', u'1000')
(u'vendor', u'Extreme')
(u'USE_IPV6', u'true')
(u'enterasys.datasource.rpt.connectionurl', u'jdbc:mysql://127.0.0.1:4589/netsightrpt?jdbcCompliantTruncation=false&useUnicode=true&characterEncoding=UTF-8&useSSL=false')
(u'javax.script.filename', u'/usr/local/Extreme_Networks/NetSight/appdata/scripting/overrides/hworld.py')
(u'dashboard.cache.time', u'2')
(u'javax.script.engine', u'python')
(u'deviceIP', u'10.130.254.20')
(u'jboss.bind.address', u'10.254.231.12')
(u'userDomain', u'')
(u'OneView.DisplayNacConfigurationTab', u'true')
(u'userName', u'1101286')
(u'scriptTimeout', u'60')
(u'time', u'10:31:43 EST')
(u'family', u'Summit Series')
(u'username', u'root')
trapOidList is 1.3.6.1.4.1.1916.0.7:exclude,1.3.6.1.4.1.1916.0.8:exclude
targetMibView is AccessSwitchTraps

Regarding "Seems a little weird to have a TCL style "set var" command at the top of some python but "whatever!"."

Yes. That should be changed in a future release.

nice password šŸ™‚

GTM-P2G8KFN