<?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: Python script to get every devices Hostname *.dynamic-m.com in Network Platform API</title>
    <link>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405065#M1180</link>
    <description>&lt;P&gt;I tried the script yesterday, it works like a charm!! I had a hard time finding the ORG ID but it was so simple, it was at the very bottom of the Meraki Dashboard page lol.&lt;/P&gt;&lt;P&gt;Thanks again for your tremendous help!&lt;/P&gt;&lt;P&gt;G.&lt;/P&gt;</description>
    <pubDate>Wed, 04 May 2022 12:36:08 GMT</pubDate>
    <dc:creator>GH31</dc:creator>
    <dc:date>2022-05-04T12:36:08Z</dc:date>
    <item>
      <title>Python script to get every devices Hostname *.dynamic-m.com</title>
      <link>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405058#M1173</link>
      <description>&lt;P&gt;Hey there,&lt;/P&gt;&lt;P&gt;I have barely no experience with Python and I am looking for a script that would allow me to get every devices Hostname *.dynamic-m.com from every single device in my Meraki network.&lt;/P&gt;&lt;P&gt;Does anybody have something handy to share please?&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 20:56:22 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405058#M1173</guid>
      <dc:creator>GH31</dc:creator>
      <dc:date>2022-04-14T20:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to get every devices Hostname *.dynamic-m.com</title>
      <link>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405059#M1174</link>
      <description>&lt;P&gt;That would be easy ! &lt;/P&gt;&lt;P&gt;Loop through all your devices that are MXs : &lt;SPAN&gt;/organizations/&lt;/SPAN&gt;&lt;STRONG&gt;{organizationId}&lt;/STRONG&gt;&lt;SPAN&gt;/devices ( ref : &lt;A href="https://developer.cisco.com/meraki/api-v1/#!get-organization-devices" target="_blank" rel="nofollow noopener noreferrer"&gt;https://developer.cisco.com/meraki/api-v1/#!get-organization-devices &lt;/A&gt;) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;     Then Retrieve the management interfaces for each device ( includes DDNS infos ) : /devices/&lt;STRONG&gt;{serial}&lt;/STRONG&gt;/managementInterface   (ref : &lt;A href="https://developer.cisco.com/meraki/api-v1/#!get-device-management-interface" target="_blank" rel="nofollow noopener noreferrer"&gt;https://developer.cisco.com/meraki/api-v1/#!get-device-management-interface&lt;/A&gt; ) &lt;/P&gt;&lt;P&gt;I can write the script for you if you want ! &lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 22:15:56 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405059#M1174</guid>
      <dc:creator>Raphael_L</dc:creator>
      <dc:date>2022-04-14T22:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to get every devices Hostname *.dynamic-m.com</title>
      <link>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405060#M1175</link>
      <description>&lt;P&gt;Hey Raphael!&lt;/P&gt;&lt;P&gt;If you could write the script it would be so appreciated and I'm sure it will help a lot of people, I've been struggling to find time for months to learn how to develop on Python but it's not my core thing I do not develop.&lt;/P&gt;&lt;P&gt;Thanks a lot in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 22:23:26 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405060#M1175</guid>
      <dc:creator>GH31</dc:creator>
      <dc:date>2022-04-14T22:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to get every devices Hostname *.dynamic-m.com</title>
      <link>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405061#M1176</link>
      <description>&lt;P&gt;It can help you:&lt;/P&gt;&lt;P&gt;&lt;A href="https://rowelldionicio.com/listing-meraki-network-devices-using-the-api-devnet/" target="_blank" rel="nofollow noopener noreferrer"&gt;https://rowelldionicio.com/listing-meraki-network-devices-using-the-api-devnet/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 22:53:58 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405061#M1176</guid>
      <dc:creator>aleabrahao</dc:creator>
      <dc:date>2022-04-14T22:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to get every devices Hostname *.dynamic-m.com</title>
      <link>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405062#M1177</link>
      <description>&lt;PRE class="lia-code-sample language-python"&gt;&lt;CODE&gt;import json
import requests
import codecs

requests.packages.urllib3.disable_warnings()

base_url_v1 = 'https://api.meraki.com/api/v1'

apikey = "XXXXXXXXXX" #YOUR_API_KEY
orgid = "XXXXXXXXXXX" #YOUR_ORG_ID
headers = {
	'x-cisco-meraki-api-key': format(str(apikey)),
	'Content-Type': 'application/json'
}

def __returnhandler(statuscode, returntext):
	if str(statuscode) == '200':
		return returntext
	else:
		print('HTTP Status Code: {0}\n'.format(statuscode))
def getorgdevices():
	results = []
	geturl = '{0}/organizations/{1}/devices?model=MX'.format(str(base_url_v1), str(orgid))
	dashboard = requests.get(geturl, headers=headers,verify=False)
	if dashboard.status_code == 200:
		raw = dashboard.json()
		for i in raw:  
			results.append(i)
		while 'next' in dashboard.links :
			dashboard = requests.get(dashboard.links['next']['url'],headers=headers,verify=False)
			raw = dashboard.json()
			for i in raw:  
				results.append(i)
	return (results)  
def getManagementInterface(serialnum):
	geturl = '{0}/devices/{1}/managementInterface'.format(str(base_url_v1), str(serialnum))
	dashboard = requests.get(geturl, headers=headers,verify=False)
	result = __returnhandler(dashboard.status_code, dashboard.text)
	return result
	
devices = getorgdevices()
f = codecs.open("DDNS.txt", "a","utf-8")
f.write("DeviceName,activeDdnsHostname,ddnsHostnameWan1,ddnsHostnameWan2\n")
f.close()

for device in devices:
	ManagementInterface = json.loads(getManagementInterface(device['serial']))
	ActiveDDNSHostname = ManagementInterface['ddnsHostnames']['activeDdnsHostname']
	DDNSHostnameWan1 = ManagementInterface['ddnsHostnames']['ddnsHostnameWan1']
	DDNSHostnameWan2 = ManagementInterface['ddnsHostnames']['ddnsHostnameWan2']
	f = codecs.open("DDNS.txt", "a","utf-8")
	message = "{},{},{},{}\n".format(device['name'],ActiveDDNSHostname,DDNSHostnameWan1,DDNSHostnameWan2)
	f.write(message)
	f.close()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It is not the prettiest code ! but I was able to get that running in under 5 minutes and I have get going for the night. &lt;/P&gt;&lt;P&gt;I will create a textfile named DDNS.txt which you can then import into excel as a CSV with a ',' delimiter. &lt;/P&gt;&lt;P&gt;I tried it on 60 MX and it was giving me the right info. You will need to supply your API key and your ORG ID. &lt;/P&gt;&lt;P&gt;Have fun !&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 22:58:29 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405062#M1177</guid>
      <dc:creator>Raphael_L</dc:creator>
      <dc:date>2022-04-14T22:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to get every devices Hostname *.dynamic-m.com</title>
      <link>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405063#M1178</link>
      <description>&lt;P&gt;Thanks a lot, I will definitely look into that, I glanced at it real quick and I am certain it will help me learn!!&lt;/P&gt;</description>
      <pubDate>Mon, 18 Apr 2022 14:14:22 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405063#M1178</guid>
      <dc:creator>GH31</dc:creator>
      <dc:date>2022-04-18T14:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to get every devices Hostname *.dynamic-m.com</title>
      <link>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405064#M1179</link>
      <description>&lt;P&gt;Thank you so much Raphael!!&lt;/P&gt;&lt;P&gt;I will test it soon and will let you know if it worked!!&lt;/P&gt;</description>
      <pubDate>Mon, 18 Apr 2022 14:16:45 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405064#M1179</guid>
      <dc:creator>GH31</dc:creator>
      <dc:date>2022-04-18T14:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to get every devices Hostname *.dynamic-m.com</title>
      <link>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405065#M1180</link>
      <description>&lt;P&gt;I tried the script yesterday, it works like a charm!! I had a hard time finding the ORG ID but it was so simple, it was at the very bottom of the Meraki Dashboard page lol.&lt;/P&gt;&lt;P&gt;Thanks again for your tremendous help!&lt;/P&gt;&lt;P&gt;G.&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 12:36:08 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405065#M1180</guid>
      <dc:creator>GH31</dc:creator>
      <dc:date>2022-05-04T12:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to get every devices Hostname *.dynamic-m.com</title>
      <link>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405066#M1181</link>
      <description>&lt;P&gt;My pleasure !  &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Yes it can be found at the bottom of your dashboard or via the API endpoint : getOrganizations ( &lt;A href="https://developer.cisco.com/meraki/api-latest/#!get-organizations" target="_blank" rel="nofollow noopener noreferrer"&gt;https://developer.cisco.com/meraki/api-latest/#!get-organizations&lt;/A&gt; )  &lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt; &lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2022 12:37:46 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405066#M1181</guid>
      <dc:creator>Raphael_L</dc:creator>
      <dc:date>2022-05-04T12:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to get every devices Hostname *.dynamic-m.com</title>
      <link>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405067#M1182</link>
      <description>&lt;P&gt;I tried using this and out of my 115 devices, it only output 5 of them to the ddns.txt file. Run it again, and I get a different set of values.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 23:56:13 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405067#M1182</guid>
      <dc:creator>iscs-mark</dc:creator>
      <dc:date>2022-07-01T23:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: Python script to get every devices Hostname *.dynamic-m.com</title>
      <link>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405068#M1183</link>
      <description>&lt;P&gt;Were you able to find a solution to this?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 17:06:36 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/python-script-to-get-every-devices-hostname-dynamic-m-com/m-p/5405068#M1183</guid>
      <dc:creator>ZaidAmla</dc:creator>
      <dc:date>2022-07-20T17:06:36Z</dc:date>
    </item>
  </channel>
</rss>

