<?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: Remove port from vlan in Scripting</title>
    <link>https://community.extremenetworks.com/t5/scripting/remove-port-from-vlan/m-p/60746#M361</link>
    <description>&lt;P&gt;Hello Chuck,&lt;/P&gt;&lt;P&gt;maybe it’t easiert to use “show port &amp;lt;port number&amp;gt; vid”. Here the output is smaller.&lt;/P&gt;&lt;P&gt;Yes the result from cli in the variable port_info is a string.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can do the following. Please be aware that “Untagged” matches two times. First in the header of the cli output and second in the line where the vlan is shown. But that’s not a problem because of the for loop overwrites the first output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;import re&lt;/P&gt;&lt;P&gt;cli_result = emc_cli.send("show port &amp;lt;port number&amp;gt; vid")&lt;BR /&gt;vlanInfo = cli_result.getOutput()&lt;/P&gt;&lt;P&gt;vlanInfoLines = vlanInfo.split("\n")&amp;nbsp; #receive a list containing the lines from output&lt;/P&gt;&lt;P&gt;for line in vlanInfoLines:&amp;nbsp; #loop through the lines&lt;BR /&gt;&amp;nbsp; &amp;nbsp; print line&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if "Untagged" in line: #check if you can see the word Untagged&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; vlanId = line.split() #split the line&amp;nbsp; by white spaces&lt;BR /&gt;print ("Untagged vlan id is: " + vlanId[1]) #take the second element from the list&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#If you more like regex (maybe more flexible)&lt;/P&gt;&lt;P&gt;for line in vlanInfoLines:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; untaggedLine = re.search("Untagged\s*(\d*)", line)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if untaggedLine:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; vlanByReg = untaggedLine.group(1)&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;print ("Untagged vlan id is: " + vlanByReg)&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Stephan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Oct 2020 12:01:23 GMT</pubDate>
    <dc:creator>StephanH</dc:creator>
    <dc:date>2020-10-08T12:01:23Z</dc:date>
    <item>
      <title>Remove port from vlan</title>
      <link>https://community.extremenetworks.com/t5/scripting/remove-port-from-vlan/m-p/60743#M358</link>
      <description>&lt;P&gt;I’m using a python script to configure a switchport, but I need to find the current untagged vlan, then use the value of the untagged vlan to remove the associated port.&lt;/P&gt;&lt;P&gt;&amp;nbsp;get_port_info = emc_cli.send("show port " + ports + " info detail | grep Internal")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The above command generates this output:&lt;/P&gt;&lt;P&gt;Name: Auth-RSTP-VLAN, Internal Tag = 4090, MAC-limit = No-limit, Virtual router: &amp;nbsp; VR-Default&lt;/P&gt;&lt;P&gt;So, in this case, I want to create a variable for “4090”&amp;nbsp;&lt;BR /&gt;configure vlan 4090&amp;nbsp;delete port &amp;lt;oort number&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone point me in the right direction?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 03:23:56 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/scripting/remove-port-from-vlan/m-p/60743#M358</guid>
      <dc:creator>cslayton</dc:creator>
      <dc:date>2020-10-08T03:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: Remove port from vlan</title>
      <link>https://community.extremenetworks.com/t5/scripting/remove-port-from-vlan/m-p/60744#M359</link>
      <description>&lt;P&gt;Hello Cslayton,&lt;/P&gt;&lt;P&gt;I am not sure&amp;nbsp;where exactly you get stuck. But below you can see how to get the output into a variable&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; get_port_info= emc_cli.send("show port " + ports +&amp;nbsp;" info detailconfigure vlan 4090&amp;nbsp;delete port &amp;lt;oort number&amp;gt; | grep Internal"&amp;nbsp;)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;port_info&amp;nbsp;= get_port_info.getOutput()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;get_port_change= emc_cli.send("configure vlan 4090&amp;nbsp;delete port &amp;lt;oort number&amp;gt;"&amp;nbsp;)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Stephan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 03:44:21 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/scripting/remove-port-from-vlan/m-p/60744#M359</guid>
      <dc:creator>StephanH</dc:creator>
      <dc:date>2020-10-08T03:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: Remove port from vlan</title>
      <link>https://community.extremenetworks.com/t5/scripting/remove-port-from-vlan/m-p/60745#M360</link>
      <description>&lt;P&gt;Thanks StephanH!&amp;nbsp; I’m almost there.&amp;nbsp; I need to search the output (maybe using regex?) to get the Vlan ID (4090) so that I can send this command:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;get_port_change= emc_cli.send("configure vlan &amp;lt;vlan id var&amp;gt;&amp;nbsp;delete port &amp;lt;oort number&amp;gt;"&amp;nbsp;)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Is port_info a string?&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Chuck&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 07:50:01 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/scripting/remove-port-from-vlan/m-p/60745#M360</guid>
      <dc:creator>cslayton</dc:creator>
      <dc:date>2020-10-08T07:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: Remove port from vlan</title>
      <link>https://community.extremenetworks.com/t5/scripting/remove-port-from-vlan/m-p/60746#M361</link>
      <description>&lt;P&gt;Hello Chuck,&lt;/P&gt;&lt;P&gt;maybe it’t easiert to use “show port &amp;lt;port number&amp;gt; vid”. Here the output is smaller.&lt;/P&gt;&lt;P&gt;Yes the result from cli in the variable port_info is a string.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can do the following. Please be aware that “Untagged” matches two times. First in the header of the cli output and second in the line where the vlan is shown. But that’s not a problem because of the for loop overwrites the first output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;import re&lt;/P&gt;&lt;P&gt;cli_result = emc_cli.send("show port &amp;lt;port number&amp;gt; vid")&lt;BR /&gt;vlanInfo = cli_result.getOutput()&lt;/P&gt;&lt;P&gt;vlanInfoLines = vlanInfo.split("\n")&amp;nbsp; #receive a list containing the lines from output&lt;/P&gt;&lt;P&gt;for line in vlanInfoLines:&amp;nbsp; #loop through the lines&lt;BR /&gt;&amp;nbsp; &amp;nbsp; print line&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if "Untagged" in line: #check if you can see the word Untagged&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; vlanId = line.split() #split the line&amp;nbsp; by white spaces&lt;BR /&gt;print ("Untagged vlan id is: " + vlanId[1]) #take the second element from the list&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;#If you more like regex (maybe more flexible)&lt;/P&gt;&lt;P&gt;for line in vlanInfoLines:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; untaggedLine = re.search("Untagged\s*(\d*)", line)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if untaggedLine:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; vlanByReg = untaggedLine.group(1)&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;print ("Untagged vlan id is: " + vlanByReg)&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Stephan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 12:01:23 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/scripting/remove-port-from-vlan/m-p/60746#M361</guid>
      <dc:creator>StephanH</dc:creator>
      <dc:date>2020-10-08T12:01:23Z</dc:date>
    </item>
  </channel>
</rss>

