XMC Scripting Port based Script how to insert user input
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎11-10-2018 03:03 PM
i want to use a port based XMC (TCL) Script in Device View for setting Port Alias on an EXOS Switch
i know there is another point within XMC to set port aliases but first i need this here (fewer windows changes in daily business) and second i wants to know how to insert user input in such kind of port specific XMC scripts.
i use this TCL script:
#@MetaDataStart
#@DetailDescriptionStart
##############################################################################
# Purpose : Example script to set port-alias on EXOS Ports
##############################################################################
#@DetailDescriptionEnd
#@MetaDataEnd
###############################################################################
#@SectionStart (description = PortAlias )
#@VariableFieldLabel ( description = "PortAlias",type = String, scope = global,)
set var PortAlias ""
CLI conf $Port dis $PortAlias
CLI conf $Port desc $PortAlias
sleep 2
CLI show port $Port desc
But unfortunately the script does not request the input for variable $PortAlias.
it runs into an error because variable $PortAlias is empty.
How can i trigger that the input was retrieved and can be set via CLI successfully ??
i know there is another point within XMC to set port aliases but first i need this here (fewer windows changes in daily business) and second i wants to know how to insert user input in such kind of port specific XMC scripts.
i use this TCL script:
#@MetaDataStart
#@DetailDescriptionStart
##############################################################################
# Purpose : Example script to set port-alias on EXOS Ports
##############################################################################
#@DetailDescriptionEnd
#@MetaDataEnd
###############################################################################
#@SectionStart (description = PortAlias )
#@VariableFieldLabel ( description = "PortAlias",type = String, scope = global,)
set var PortAlias ""
CLI conf $Port dis $PortAlias
CLI conf $Port desc $PortAlias
sleep 2
CLI show port $Port desc
But unfortunately the script does not request the input for variable $PortAlias.
it runs into an error because variable $PortAlias is empty.
How can i trigger that the input was retrieved and can be set via CLI successfully ??
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎11-11-2018 05:44 PM
With the help of Stephan i can get the script file running.
I do some mistakes in the header sections - it is important to look at the start and the end of the sections. Input fields have to be within the MetaData Section ...
Another problem is that i use $port Variable as $Port which is not the same = case sensitive
Here my simple script:
#@MetaDataStart
#@DetailDescriptionStart
##############################################################################
# Purpose : Example script to set port-alias on EXOS Ports
##############################################################################
#@DetailDescriptionEnd
#@SectionStart (description = Specify port decription)
#
#@VariableFieldLabel (description = "Enter port decription",
# type = String,
# required = yes,
# readOnly = no
# )
set var PortAlias MyPortAlias
#@SectionEnd
#@MetaDataEnd
CLI conf port $port dis $PortAlias
CLI conf port $port desc $PortAlias
sleep 1
CLI show port $port desc
sleep 1
CLI save config
I do some mistakes in the header sections - it is important to look at the start and the end of the sections. Input fields have to be within the MetaData Section ...
Another problem is that i use $port Variable as $Port which is not the same = case sensitive
Here my simple script:
#@MetaDataStart
#@DetailDescriptionStart
##############################################################################
# Purpose : Example script to set port-alias on EXOS Ports
##############################################################################
#@DetailDescriptionEnd
#@SectionStart (description = Specify port decription)
#
#@VariableFieldLabel (description = "Enter port decription",
# type = String,
# required = yes,
# readOnly = no
# )
set var PortAlias MyPortAlias
#@SectionEnd
#@MetaDataEnd
CLI conf port $port dis $PortAlias
CLI conf port $port desc $PortAlias
sleep 1
CLI show port $port desc
sleep 1
CLI save config
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎11-10-2018 04:41 PM
Hallo Matthias,
if you want a input box to define the port description add the following info to the "Meta" section:
#@SectionStart (description = Specify port description)
#
#@VariableFieldLabel (description = "Enter port description",
# type = String,
# required = yes,
# readOnly = no
# )
set var portname MyPort
#@SectionEnd
#@MetaDataEnd
portname = emc_vars["portname"] With the last line the info from the input field is assigned to the variable portname.
Regards
Stephan
if you want a input box to define the port description add the following info to the "Meta" section:
#@SectionStart (description = Specify port description)
#
#@VariableFieldLabel (description = "Enter port description",
# type = String,
# required = yes,
# readOnly = no
# )
set var portname MyPort
#@SectionEnd
#@MetaDataEnd
portname = emc_vars["portname"] With the last line the info from the input field is assigned to the variable portname.
Regards
Stephan
Regards
Stephan
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎11-10-2018 04:22 PM
Hello Matthias,
I am not sure what's going wrong. But here a working script with Python:
import string
myport = emc_vars["port"]
fromcli = emc_cli.send("show port " + myport + " des").getOutput()
print fromcli
fromcli = emc_cli.send("conf port " + myport + " des MyName")
fromcli = emc_cli.send("conf port " + myport + " dis MyName")
fromcli = emc_cli.send("show port " + myport + " des").getOutput()
print check
Regards
Stephan
I am not sure what's going wrong. But here a working script with Python:
import string
myport = emc_vars["port"]
fromcli = emc_cli.send("show port " + myport + " des").getOutput()
print fromcli
fromcli = emc_cli.send("conf port " + myport + " des MyName")
fromcli = emc_cli.send("conf port " + myport + " dis MyName")
fromcli = emc_cli.send("show port " + myport + " des").getOutput()
print check
Regards
Stephan
Regards
Stephan
