def add_network_name(df, api_key): networkIdList = [] networkIdList.extend(df['Network ID'].tolist( )) #take all NetworkIDs from dataframe column and turn into a list networkIdList = set(networkIdList) #remove duplicates networkNameList = [] #create a nested list of [network id, network names] for id in networkIdList: network = meraki.getnetworkdetail(api_key, id, suppressprint=True) if 'name' in network: networkNameList.append([id, network['name']]) #loop through all rows of data #for each row, loop through and check all network ids #when network id(network[0]) is identified, add to a new column the associated network name for i in df.index: for network in networkNameList: if network[0] in df.ix[i, 'Network ID']: df.ix[i, 'Network Name'] = network[1] break return df
def pod_status(d): ret = "" netinfo = meraki.getnetworkdetail(merakiapikey, d["role"], suppressprint=True) if netinfo: networkname = netinfo["name"] netid = d["role"] ret += "Network Name: " + networkname + "\nNetwork ID: " + netid + "\n" orgdevinv = meraki.getorginventory(merakiapikey, merakiorgnum, suppressprint=True) devlist = [] for d in devdict: devlist.append(devdict[d]) for d in orgdevinv: if d["serial"] in devlist: if d["networkId"] == netid: ret += "<li>" + d["serial"] + " - Present In Network\n" else: ret += "<li>" + d["serial"] + " - Missing From Network\n" return ret else: return "This Network Does Not Exist\n" + str(d)
selectedOrg = explore_next(apikey, apidata, ['id', 'name'], "Organization", "id") print( "please select:\n1: Get List of Networks\n2: Get Licenses\n3: Get Inventory\n4: Get Templates\n5: Get SNMP Settings" ) user_input = input("##: ") if user_input == '1': apidata = m.getnetworklist(apikey, selectedOrg, suppressprint=True) #configTemplateId|id|name|organizationId|tags|timeZone|type selectedNetwork = explore_next( apikey, apidata, ['name', 'id', 'tags', 'timeZone', 'type'], "Network", "id") apidata = m.getnetworkdetail(apikey, selectedNetwork, suppressprint=True) dummy = explore_next(apikey, apidata, ['name', 'id', 'tags', 'timeZone', 'type'], justPrint=True) print("please select:\n1: Get Network Devices\n2: Update Network") user_input = input("##: ") if user_input == "1": apidata = m.getnetworkdevices(apikey, selectedNetwork, suppressprint=True) # Selection │ address│lanIp│lat│lng│mac │ model│ name│ networkId│serial│tags│wan1Ip│wan2Ip selectedDevice = explore_next( apikey, apidata,
def getnetworkname(self, networkId): """Gets the details about the networkId that was passed. Then returns them the calling function""" network = meraki.getnetworkdetail(apikey, networkId) return network['name']
# Bind a network to a template. # https://dashboard.meraki.com/api_docs#bind-a-network-to-a-template #newnetwork = mer.bindtotemplate(apikey, networkid, templateid, autobind=False, suppressprint=False) print(bcolors.HEADER, "\nNow that the network is set up, let's bind it to a template. Select the template you wish to use.", bcolors.ENDC) #List Templates templatelist = mer.gettemplates(apikey, selectedOrg, suppressprint=True) selectedTemplate = explore_next(apikey,templatelist,['id','name'],"Template","id") #Choose Template to be Assinged #assignedtemplateid = input(bcolors.QUESTION + 'What is your TemplateID? ' + bcolors.ENDC) while True: apidata = mer.getnetworkdetail(apikey,newnetworkid,suppressprint=True) result = explore_next(apikey,apidata,['name','id','tags','timeZone','type'],justPrint=True) if result != "empty": break print("Initializing Network: adding 5 seconds") time.sleep(5) print(bcolors.ACTION,'We will now autobind to the Standard Template', bcolors.ENDC) #Notifiy of action taken and take it print(bcolors.ACTION,'We will now autobind to the Standard Template', bcolors.ENDC) bindtempate = mer.bindtotemplate(apikey, newnetworkid, selectedTemplate, autobind=False, suppressprint=False) #Print result from API