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

XMC Scripting Port based Script how to insert user input

XMC Scripting Port based Script how to insert user input

M_Nees
Contributor III
i want to use a port based XMC (TCL) Script in Device View for setting Port Alias on an EXOS Switch

771304116ab94775ac9b5cd15f487970_RackMultipart20181110-122925-fh8rzi-XMC-Device-View_inline.png



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

771304116ab94775ac9b5cd15f487970_RackMultipart20181110-60988-jzao8p-Script0_inline.png


But unfortunately the script does not request the input for variable $PortAlias.

771304116ab94775ac9b5cd15f487970_RackMultipart20181110-38360-geh7aa-Script1_inline.png



it runs into an error because variable $PortAlias is empty.

771304116ab94775ac9b5cd15f487970_RackMultipart20181110-97241-6hbf66-Script2_inline.png



How can i trigger that the input was retrieved and can be set via CLI successfully ??

3 REPLIES 3

M_Nees
Contributor III
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

StephanH
Valued Contributor III
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

Regards Stephan

StephanH
Valued Contributor III
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

Regards Stephan
GTM-P2G8KFN