<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: B-Series with multiple ports in Scripting</title>
    <link>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72258#M430</link>
    <description>&lt;P&gt;Once again, you nailed it!&lt;/P&gt;</description>
    <pubDate>Sat, 05 Dec 2020 00:06:08 GMT</pubDate>
    <dc:creator>cslayton</dc:creator>
    <dc:date>2020-12-05T00:06:08Z</dc:date>
    <item>
      <title>B-Series with multiple ports</title>
      <link>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72243#M415</link>
      <description>&lt;P&gt;I have a python script that I’m using for B-series switches to configure multiple ports at the same time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#@METADATASTART&lt;BR /&gt;#@ScriptDescription "Change port from static to NAC".&lt;BR /&gt;#@DetailDescriptionStart&lt;BR /&gt;##############################################################################&lt;BR /&gt;#&lt;BR /&gt;#Purpose: "Change port from static to NAC".&lt;BR /&gt;#&lt;BR /&gt;# Version : 1.0&lt;BR /&gt;#&lt;BR /&gt;# This script deletes selected ports from all vlans, sets "display-string" and&lt;BR /&gt;# "description-string" to "NAC_Port". &amp;nbsp;Finally, the configuration is saved.&lt;BR /&gt;##############################################################################&lt;BR /&gt;#@DetailDescriptionEnd&lt;BR /&gt;#&lt;BR /&gt;#@MetaDataEnd&lt;BR /&gt;import re&lt;BR /&gt;import commands&lt;/P&gt;&lt;P&gt;def main():&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if "port" in emc_vars:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ports = emc_vars["port"]&lt;BR /&gt;&amp;nbsp; &amp;nbsp; else:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print "Please select at least one PORT if you start the script"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return 0&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; cli_result = emc_cli.send("clear port vlan " + ports) &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;main()&lt;/P&gt;&lt;P&gt;However, I get the following output:&lt;/P&gt;&lt;P&gt;deerl1sw006(su)-&amp;gt;clear port vlan ge.1.7,ge.1.8&lt;BR /&gt;Invalid Port in [port-string].&amp;nbsp;&lt;/P&gt;&lt;P&gt;The B-Series switch needs to use ; instead of , to separate interfaces.&amp;nbsp; Is there anyway to fix this?&lt;/P&gt;&lt;P&gt;Chuck&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 04:25:37 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72243#M415</guid>
      <dc:creator>cslayton</dc:creator>
      <dc:date>2020-12-04T04:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: B-Series with multiple ports</title>
      <link>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72244#M416</link>
      <description>&lt;P&gt;I tried to change ports (string) to a list using this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ports_list = ports.split()&lt;BR /&gt;&amp;nbsp; &amp;nbsp; for x in ports_list:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cli_result = emc_cli.send("clear port vlan " + x) &amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the same error.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 04:48:37 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72244#M416</guid>
      <dc:creator>cslayton</dc:creator>
      <dc:date>2020-12-04T04:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: B-Series with multiple ports</title>
      <link>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72245#M417</link>
      <description>&lt;P&gt;Hello Chuck,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class="language-python"&gt;#@METADATASTART&lt;BR /&gt;#@ScriptDescription "Change port from static to NAC".&lt;BR /&gt;#@DetailDescriptionStart&lt;BR /&gt;##############################################################################&lt;BR /&gt;#&lt;BR /&gt;#Purpose: "Change port from static to NAC".&lt;BR /&gt;#&lt;BR /&gt;# Version : 1.0&lt;BR /&gt;#&lt;BR /&gt;# This script deletes selected ports from all vlans, sets "display-string" and&lt;BR /&gt;# "description-string" to "NAC_Port".  Finally, the configuration is saved.&lt;BR /&gt;##############################################################################&lt;BR /&gt;#@DetailDescriptionEnd&lt;BR /&gt;#&lt;BR /&gt;#@MetaDataEnd&lt;BR /&gt;import re&lt;BR /&gt;import commands&lt;BR /&gt;&lt;BR /&gt;def main():&lt;BR /&gt;&lt;BR /&gt;    if "port" in emc_vars:&lt;BR /&gt;        ports = emc_vars["port"].split(",") #create a list with all ports&lt;BR /&gt;    else:&lt;BR /&gt;        print "Please select at least one PORT if you start the script"&lt;BR /&gt;        return 0&lt;BR /&gt;&lt;BR /&gt;    portcounter = 0&lt;BR /&gt;    for port in ports: #walk through the list&lt;BR /&gt;        if portcounter == 0:&lt;BR /&gt;            portstring = port&lt;BR /&gt;        else:&lt;BR /&gt;            portstring = portstring + ";" + port #fill in the separator you need&lt;BR /&gt;        portcounter += 1&lt;BR /&gt;&lt;BR /&gt;    cli_result = emc_cli.send("clear port vlan " + portstring)  &lt;BR /&gt;&lt;BR /&gt;main()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 07:23:31 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72245#M417</guid>
      <dc:creator>StephanH</dc:creator>
      <dc:date>2020-12-04T07:23:31Z</dc:date>
    </item>
    <item>
      <title>Re: B-Series with multiple ports</title>
      <link>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72246#M418</link>
      <description>&lt;P&gt;Thanks so Much!&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 07:42:56 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72246#M418</guid>
      <dc:creator>cslayton</dc:creator>
      <dc:date>2020-12-04T07:42:56Z</dc:date>
    </item>
    <item>
      <title>Re: B-Series with multiple ports</title>
      <link>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72247#M419</link>
      <description>&lt;P&gt;Trying to further refine this by creating functions, but the below doesn’t work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import re&lt;BR /&gt;import commands&lt;/P&gt;&lt;P&gt;def(port_list):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if "port" in emc_vars:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ports = emc_vars["port"].split(",") #create a list with all ports&lt;BR /&gt;&amp;nbsp; &amp;nbsp; else:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print "Please select at least one PORT if you start the script"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return 0&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; portcounter = 0&lt;BR /&gt;&amp;nbsp; &amp;nbsp; for port in ports: #walk through the list&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if portcounter == 0:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; portstring = port&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; portstring = portstring + ";" + port #fill in the separator you need&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; portcounter += 1&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;def main():&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; cli_result = emc_cli.send("clear port vlan " + portstring) &amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; cli_result = emc_cli.send("set port alias " + portstring + " NAC")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; cli_result = emc_cli.send("set macauthentication port enable " + portstring)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; cli_result = emc_cli.send("set multiauth port mode auth-reqd " + portstring)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; cli_result = emc_cli.send("set multiauth port numusers 4 " + portstring)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; cli_result = emc_cli.send("set pwa portcontrol enable " + portstring)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; cli_result = emc_cli.send("save config")&lt;/P&gt;&lt;P&gt;port_list()&amp;nbsp;&lt;BR /&gt;main()&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 22:18:45 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72247#M419</guid>
      <dc:creator>cslayton</dc:creator>
      <dc:date>2020-12-04T22:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: B-Series with multiple ports</title>
      <link>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72248#M420</link>
      <description>&lt;P&gt;Hello Cuck,&lt;/P&gt;&lt;P&gt;what isn’t working?&lt;/P&gt;&lt;P&gt;Error message?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 22:24:21 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72248#M420</guid>
      <dc:creator>StephanH</dc:creator>
      <dc:date>2020-12-04T22:24:21Z</dc:date>
    </item>
    <item>
      <title>Re: B-Series with multiple ports</title>
      <link>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72249#M421</link>
      <description>&lt;P&gt;The code you posted is working fine.&amp;nbsp; I am trying to create a function out of the section that creates a list of all ports and then call that function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error:&amp;nbsp;&amp;nbsp;SyntaxError: ("no viable alternative at input '('", ('&amp;lt;string&amp;gt;', 19, 3, 'def(port_list):\n'))&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 22:34:38 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72249#M421</guid>
      <dc:creator>cslayton</dc:creator>
      <dc:date>2020-12-04T22:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: B-Series with multiple ports</title>
      <link>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72250#M422</link>
      <description>&lt;P&gt;Here is the error:&lt;/P&gt;&lt;P&gt;“def(port_list)”&amp;nbsp; should be:&amp;nbsp; “def port_list():”&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 22:52:47 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72250#M422</guid>
      <dc:creator>StephanH</dc:creator>
      <dc:date>2020-12-04T22:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: B-Series with multiple ports</title>
      <link>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72251#M423</link>
      <description>&lt;P&gt;Thanks!&amp;nbsp; A bit embarrassed I missed something so easy.&amp;nbsp; However, now I’m getting this:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Traceback (most recent call last):&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 45, in &amp;lt;module&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 36, in main&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NameError: global name 'portstring' is not defined&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 23:12:27 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72251#M423</guid>
      <dc:creator>cslayton</dc:creator>
      <dc:date>2020-12-04T23:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: B-Series with multiple ports</title>
      <link>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72252#M424</link>
      <description>&lt;P&gt;Hello Chuck,&lt;/P&gt;&lt;P&gt;post your complete code, or post with line numbers, please. So we can see what lines are the problem.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 23:17:00 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72252#M424</guid>
      <dc:creator>StephanH</dc:creator>
      <dc:date>2020-12-04T23:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: B-Series with multiple ports</title>
      <link>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72253#M425</link>
      <description>&lt;FIGURE&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="cf13e5dba07740a397c0ef9ccd7de603_fef11e2f-4290-417d-b710-54fc163c42f7.png"&gt;&lt;img src="https://community.extremenetworks.com/t5/image/serverpage/image-id/3314iD8BF21E8546F3A5F/image-size/large?v=v2&amp;amp;px=999" role="button" title="cf13e5dba07740a397c0ef9ccd7de603_fef11e2f-4290-417d-b710-54fc163c42f7.png" alt="cf13e5dba07740a397c0ef9ccd7de603_fef11e2f-4290-417d-b710-54fc163c42f7.png" /&gt;&lt;/span&gt;&lt;/FIGURE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 23:21:53 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72253#M425</guid>
      <dc:creator>cslayton</dc:creator>
      <dc:date>2020-12-04T23:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: B-Series with multiple ports</title>
      <link>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72254#M426</link>
      <description>&lt;P&gt;Not nice (and not tested) but only to show you how functions and variables works together:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class="language-python"&gt;import re&lt;BR /&gt;import commands&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;def writeConfig(my_portstring):&lt;BR /&gt;&lt;BR /&gt;    cli_result = emc_cli.send("clear port vlan " + my_portstring)  &lt;BR /&gt;    cli_result = emc_cli.send("set port alias " + my_portstring + " NAC")&lt;BR /&gt;    cli_result = emc_cli.send("set macauthentication port enable " + my_portstring)&lt;BR /&gt;    cli_result = emc_cli.send("set multiauth port mode auth-reqd " + my_portstring)&lt;BR /&gt;    cli_result = emc_cli.send("set multiauth port numusers 4 " + my_portstring)&lt;BR /&gt;    cli_result = emc_cli.send("set pwa portcontrol enable " + my_portstring)&lt;BR /&gt;    cli_result = emc_cli.send("save config")&lt;BR /&gt;&lt;BR /&gt;def port_list():&lt;BR /&gt;    if "port" in emc_vars:&lt;BR /&gt;        ports = emc_vars["port"].split(",") #create a list with all ports&lt;BR /&gt;    else:&lt;BR /&gt;        print "Please select at least one PORT if you start the script"&lt;BR /&gt;        return 0&lt;BR /&gt;&lt;BR /&gt;    portcounter = 0&lt;BR /&gt;    for port in ports: #walk through the list&lt;BR /&gt;        if portcounter == 0:&lt;BR /&gt;            portstring = port&lt;BR /&gt;        else:&lt;BR /&gt;            portstring = portstring + ";" + port #fill in the separator you need&lt;BR /&gt;        portcounter += 1&lt;BR /&gt;&lt;BR /&gt;	return portstring&lt;BR /&gt;&lt;BR /&gt;def main():&lt;BR /&gt;&lt;BR /&gt;	my_portstring = port_list()&lt;BR /&gt;	writeConfig(my_portstring)&lt;BR /&gt;&lt;BR /&gt;main()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 23:33:48 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72254#M426</guid>
      <dc:creator>StephanH</dc:creator>
      <dc:date>2020-12-04T23:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: B-Series with multiple ports</title>
      <link>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72255#M427</link>
      <description>&lt;P&gt;Ah, got it!&amp;nbsp; This works!&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 23:39:30 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72255#M427</guid>
      <dc:creator>cslayton</dc:creator>
      <dc:date>2020-12-04T23:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: B-Series with multiple ports</title>
      <link>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72256#M428</link>
      <description>&lt;P&gt;Stephan, sorry to bother again, but this only uses the first port (if I selected multiple ports).&lt;/P&gt;&lt;P&gt;Chuck&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 23:48:57 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72256#M428</guid>
      <dc:creator>cslayton</dc:creator>
      <dc:date>2020-12-04T23:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: B-Series with multiple ports</title>
      <link>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72257#M429</link>
      <description>&lt;P&gt;Ah yes I see it. Change the insert for the line “return portsting” in that way that it is inline with word for.&lt;/P&gt;&lt;P&gt;The line insertion has to be the same. In the moment the return ends after the for loops run once.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 23:58:41 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72257#M429</guid>
      <dc:creator>StephanH</dc:creator>
      <dc:date>2020-12-04T23:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: B-Series with multiple ports</title>
      <link>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72258#M430</link>
      <description>&lt;P&gt;Once again, you nailed it!&lt;/P&gt;</description>
      <pubDate>Sat, 05 Dec 2020 00:06:08 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/scripting/b-series-with-multiple-ports/m-p/72258#M430</guid>
      <dc:creator>cslayton</dc:creator>
      <dc:date>2020-12-05T00:06:08Z</dc:date>
    </item>
  </channel>
</rss>

