<?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: Differentiate switch ports in Network Platform API</title>
    <link>https://community.cisco.com/t5/network-platform-api/differentiate-switch-ports/m-p/5399786#M398</link>
    <description>&lt;P&gt;You will have to parse the data and only include Ethernet and SPF Ports ..&lt;/P&gt;&lt;P&gt;If you don't mind, can you please post the API call get request response here, i will try to write code for you&lt;/P&gt;</description>
    <pubDate>Tue, 02 Jan 2024 10:49:03 GMT</pubDate>
    <dc:creator>amitpalsingh</dc:creator>
    <dc:date>2024-01-02T10:49:03Z</dc:date>
    <item>
      <title>Differentiate switch ports</title>
      <link>https://community.cisco.com/t5/network-platform-api/differentiate-switch-ports/m-p/5399785#M397</link>
      <description>&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I need to collect information on all switch ports in my organization (divided into several networks).&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Based on this &lt;/SPAN&gt;&lt;SPAN&gt;&lt;A href="https://api.meraki.com/api/v1" target="_blank" rel="nofollow noopener noreferrer"&gt;https://api.meraki.com/api/v1&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN&gt;/devices/&lt;/SPAN&gt;&lt;SPAN&gt;${&lt;/SPAN&gt;&lt;SPAN&gt;deviceSerial&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;/switch/ports, I ran a test script against my 24-port switch.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;However, it returns 30 data of ports, which to my understanding are the 24 ethernet ports, 4 SFP ports, and 2 stack ports.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;But I'm stuck on finding out how to differentiate between the ethernet ports, SFP ports, and the stack ports as my requirements exclude the stack ports.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Anyone can help me with this?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 02 Jan 2024 10:24:22 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/differentiate-switch-ports/m-p/5399785#M397</guid>
      <dc:creator>wellyhartanto</dc:creator>
      <dc:date>2024-01-02T10:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: Differentiate switch ports</title>
      <link>https://community.cisco.com/t5/network-platform-api/differentiate-switch-ports/m-p/5399786#M398</link>
      <description>&lt;P&gt;You will have to parse the data and only include Ethernet and SPF Ports ..&lt;/P&gt;&lt;P&gt;If you don't mind, can you please post the API call get request response here, i will try to write code for you&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 10:49:03 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/differentiate-switch-ports/m-p/5399786#M398</guid>
      <dc:creator>amitpalsingh</dc:creator>
      <dc:date>2024-01-02T10:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: Differentiate switch ports</title>
      <link>https://community.cisco.com/t5/network-platform-api/differentiate-switch-ports/m-p/5399787#M399</link>
      <description>&lt;P&gt;Hi Amit,&lt;/P&gt;&lt;P&gt;I can show you this with a very basic python script.&lt;/P&gt;&lt;PRE class="lia-code-sample language-python"&gt;&lt;CODE&gt;import meraki

# Defining your API key as a variable in source code is discouraged.
# This API key is for a read-only docs-specific environment.
# In your own code, use an environment variable as shown under the Usage section
# @ https://github.com/meraki/dashboard-api-python/

API_KEY = 'abcdasdasdsadasdasda12333333'

dashboard = meraki.DashboardAPI(API_KEY)

serial = 'Q2GW-XXXX-XXXX'

ports = dashboard.switch.getDeviceSwitchPorts(
    serial
)

print(len(ports)) #This will return 30 if we run it against a 24-port switch

for port in ports:
    print(port)
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The port 29 and 30 information that fetched from above script is as simple as:&lt;/P&gt;&lt;PRE class="lia-code-sample language-javascript"&gt;&lt;CODE&gt;{'portId': '30', 'name': None, 'tags': ['sp_all'], 'enabled': True, 'poeEnabled': False, 'type': 'trunk', 'vlan': 1, 'voiceVlan': None, 'allowedVlans': 'all', 'isolationEnabled': False, 'rstpEnabled': True, 'stpGuard': 'disabled', 'linkNegotiation': 'Auto negotiate', 'portScheduleId': None, 'udld': 'Alert only', 'linkNegotiationCapabilities': ['Auto negotiate'], 'accessPolicyType': 'Open', 'daiTrusted': False, 'profile': {'enabled': False, 'id': '', 'iname': None}, 'stormControlEnabled': True}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there anything I can use if I want only ethernet and SFP ports?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 11:01:00 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/differentiate-switch-ports/m-p/5399787#M399</guid>
      <dc:creator>wellyhartanto</dc:creator>
      <dc:date>2024-01-02T11:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: Differentiate switch ports</title>
      <link>https://community.cisco.com/t5/network-platform-api/differentiate-switch-ports/m-p/5399788#M400</link>
      <description>&lt;PRE&gt;&lt;SPAN&gt;for &lt;/SPAN&gt;Port &lt;SPAN&gt;in &lt;/SPAN&gt;Ports:&lt;BR /&gt;    Count = &lt;SPAN&gt;1&lt;BR /&gt;&lt;/SPAN&gt;    &lt;SPAN&gt;while &lt;/SPAN&gt;Count &amp;lt; &lt;SPAN&gt;len&lt;/SPAN&gt;(Ports)-&lt;SPAN&gt;1&lt;/SPAN&gt;:&lt;BR /&gt;        &lt;SPAN&gt;print&lt;/SPAN&gt;(Port)&lt;BR /&gt;        Count+=&lt;SPAN&gt;1&lt;BR /&gt;&lt;BR /&gt;See if this works , if not please share get response for all 30 ports &lt;BR /&gt;&lt;/SPAN&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Jan 2024 11:37:35 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/differentiate-switch-ports/m-p/5399788#M400</guid>
      <dc:creator>amitpalsingh</dc:creator>
      <dc:date>2024-01-02T11:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: Differentiate switch ports</title>
      <link>https://community.cisco.com/t5/network-platform-api/differentiate-switch-ports/m-p/5399789#M401</link>
      <description>&lt;P&gt;In some scripts I use a look-up table of switch-specific parameters that aren't accessible via the API (or weren't when the script was written) such as PoE capacity, you could do the same for ports, it only needs updating when a new switch model comes out.&lt;/P&gt;&lt;P&gt;The ports are returned with normal first, then trunk ports, then stack ports, if you only have MS1xx/2xx family switches (it can be more complicated for other MS series), you could use a rule...&lt;/P&gt;&lt;P&gt;If port count is 30 (24+4+2) or 54 (48+4+2), you know the last two are stack ports. The ones without stack ports will not have 30 or 54 ports.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 14:56:05 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/differentiate-switch-ports/m-p/5399789#M401</guid>
      <dc:creator>sungod</dc:creator>
      <dc:date>2024-01-02T14:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: Differentiate switch ports</title>
      <link>https://community.cisco.com/t5/network-platform-api/differentiate-switch-ports/m-p/5399790#M402</link>
      <description>&lt;P&gt;Hi &lt;A href="https://community.meraki.com/t5/user/viewprofilepage/user-id/1069"&gt;@jscorb&lt;/A&gt; &lt;/P&gt;&lt;P&gt;Indeed, the workaround will suffice my requirements, thank you!&lt;/P&gt;&lt;P&gt;But I still believe that somehow the API should provide the ability for us to differentiate the port types; there may be some scenarios on the usage.&lt;/P&gt;&lt;P&gt;Btw, could you please share your lookup table? I and the others may find it useful.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2024 00:51:43 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/differentiate-switch-ports/m-p/5399790#M402</guid>
      <dc:creator>wellyhartanto</dc:creator>
      <dc:date>2024-01-03T00:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: Differentiate switch ports</title>
      <link>https://community.cisco.com/t5/network-platform-api/differentiate-switch-ports/m-p/5399791#M403</link>
      <description>&lt;P&gt;Here's one, the LUT is wrapped in a simple function, so calling poeb(model) returns the PoE budget.&lt;/P&gt;&lt;P&gt;Note in this script I want the PoE budget as a string, it's trivial to tweak to return a number instead.&lt;/P&gt;&lt;PRE class="lia-code-sample language-python"&gt;&lt;CODE&gt;def poeb(model):
    poebudgets = {
        "MS22P": 380,
        "MS42P": 380,
        "MS120-8LP": 67,
        "MS120-8FP": 124,
        "MS120-24P": 370,
        "MS120-48LP": 370,
        "MS120-48FP": 740,
        "MS125-24P": 370,
        "MS125-48LP": 370,
        "MS125-48FP": 740,
        "MS130-8P": 120,
        "MS130-8X": 120,
        "MS130-12X": 240,
        "MS130-24P": 370,
        "MS130-24X": 370,
        "MS130-48P": 740,
        "MS130-48X": 740,
        "MS130R-8P": 240,
        "MS210-24P": 370,
        "MS210-48LP": 370,
        "MS210-48FP": 740,
        "MS220-8P": 124,
        "MS220-24P": 370,
        "MS220-48LP": 370,
        "MS220-48FP": 740,
        "MS225-24P": 370,
        "MS225-48LP": 370,
        "MS225-48FP": 740,
        "MS250-24P": 370,
        "MS250-48LP": 370,
        "MS250-48FP": 740,
        "MS320-24P": 370,
        "MS320-48LP": 370,
        "MS320-48FP": 740,
        "MS350-24P": 370,
        "MS350-48LP": 370,
        "MS350-48FP": 740,
        "MS350-24X": 740,
        "MS355-24X": 740,
        "MS355-48X": 740,
        "MS355-24X2": 740,
        # the MS390 budget is based on the default primary PSU only, so assumes worst case scenario for estimating PoE headroom
        "MS390-24P": 445,
        "MS390-24U": 830,
        "MS390-24UX": 560,
        "MS390-48P": 437,
        "MS355-48U": 822,
        "MS390-48UX": 490,
        "MS390-48UX2": 645,
        # the C9300 budget is based on the default primary PSU only, so assumes worst case scenario for estimating PoE headroom
        "C9300-24P-M": 445,
        "C9300-24U-M": 830,
        "C9300-24UX-M": 560,
        "C9300-48P-M": 437,
        "C9300-48U-M": 822,
        "C9300-48UXM-M": 490,
        "C9300-48UN-M": 645,

    }
    if model in poebudgets:
        return str(poebudgets[model])
    else:
        return "0"&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Jan 2024 09:47:35 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/differentiate-switch-ports/m-p/5399791#M403</guid>
      <dc:creator>sungod</dc:creator>
      <dc:date>2024-01-03T09:47:35Z</dc:date>
    </item>
  </channel>
</rss>

