ExtremeCloud IQ- Site Engine & Extreme Management Center

  • 1.  XMC Scripting Port based Script how to insert user input

    Posted 11-10-2018 15:03
    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


    [/code]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 ??



  • 2.  RE: XMC Scripting Port based Script how to insert user input

    Posted 11-10-2018 16:22
    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



  • 3.  RE: XMC Scripting Port based Script how to insert user input

    Posted 11-10-2018 16:41
    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"] [/code]With the last line the info from the input field is assigned to the variable portname.

    Regards
    Stephan



  • 4.  RE: XMC Scripting Port based Script how to insert user input

    Posted 11-11-2018 17:44
    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[/code]