Checking if device is up-to-date

Solved
Jason-907
Getting noticed

Checking if device is up-to-date

I'm currently having an issue where I need to reboot a PoE device. As we don't have access to the "cycle power" button via the API, I am disabling and re-enabling PoE on the device. The problem I'm having is that if I don't wait long enough, between turning off the PoE and turning it back on, then nothing happens. Is there a way to check if a change has been pushed to the device? Since these are security cameras, I don't want them all going down at the same time.

for myport in myswitch:
    print(myport['number'])
    if((myport['tags'] == tag) and (myport['enabled'] == True) ):
        print("Cycling port tagged " + myport['tags'] + " on " + mydevice['name'] + " port: ", myport['number'])
        meraki.updateswitchport(apikey, serialnum, myport['number'], name=None, tags=None, enabled=None, porttype=None, vlan=None,voicevlan=None, allowedvlans=None, poe=False, isolation=None, rstp=None, stpguard=None, accesspolicynum=None, suppressprint=True)
        print("\tTuring off")
        status=meraki.getswitchportdetail(apikey, serialnum, myport['number'], suppressprint=True)
        time.sleep(pause) # because loop below doesn't work as intended
        while (meraki.getswitchportdetail(apikey, serialnum, myport['number'], suppressprint=True))['poeEnabled']:
            print(".", end = '') # visual queue that script hasn't hung
            time.sleep(pause)
        meraki.updateswitchport(apikey, serialnum, myport['number'], name=None, tags=None, enabled=None, porttype=None, vlan=None,voicevlan=None, allowedvlans=None, poe=True, isolation=None, rstp=None, stpguard=None, accesspolicynum=None, suppressprint=True)
        print("\n\tTurning back on")
        time.sleep(pause * 2) # because loop below doesn't work as intended
        while (meraki.getswitchportdetail(apikey, serialnum, portnum, suppressprint=True))['poeEnabled'] == False:
            time.sleep(pause)
            print(".", end = '') # visual queue that script hasn't hung

 

As you can see, I tried to have the wait time based on checking if the status had changed via the API, but as this is just checking what the config in Meraki Dashboard says, it immediately reports that the criteria is met, so I had to throw pauses in before the loop. Is there a way to see how long ago the last change was pushed to the device or if config changes are still in queue? It's something the dashboard reports, so I'm hopeful its in the API and I just overlooked it.

I'm trying to minimize downtime, but it;s starting to look like I might have deal with a fixed amount of downtime. Not the end of the world, but I figured if any of you had solved this issue, it'd be good to know how you did it.

1 Accepted Solution
TonyC
Meraki Employee
Meraki Employee

A 10s pause timer between PUT disable > PUT enable should be plenty of time for the config to get pushed. If you really want to get clever you can use ICMP to check that the camera actually dropped but that feels like overkill.

We are planning on adding support for the cycle port tool via API for this exact use case, so it's good to hear that would be of use to you.

View solution in original post

6 Replies 6
PhilipDAth
Kind of a big deal
Kind of a big deal

I don't know of anyway to do that.  You could try querying the port status and waiting until you see it becomes disabled.

https://dashboard.meraki.com/api_docs#return-a-switch-port 

Jason-907
Getting noticed

Unfortunately, the API just queries the status that the dashboard is reporting as what the config should be rather than reporting the cached status until a successfully sync has been reported. That's why I was hoping there was an API call to check if the "CONFIG" on the appliance status is reporting "Up to date" or not.

I've yank the loops and set pause=60 until I figure out a better way to do this. It just means the script will take longer to complete, but as I'll be doing it at night, that shouldn't be too big of an issue since we have several cameras covering the same area and with the delays, we shouldn't have more than one camera offline at a time.

 

TonyC
Meraki Employee
Meraki Employee

A 10s pause timer between PUT disable > PUT enable should be plenty of time for the config to get pushed. If you really want to get clever you can use ICMP to check that the camera actually dropped but that feels like overkill.

We are planning on adding support for the cycle port tool via API for this exact use case, so it's good to hear that would be of use to you.
Jason-907
Getting noticed

I found that anything less than a 30 second delay was sketchy. It might toggle the PoE or it might not. I think it depends on timing and latency. The ping idea is clever and I'm disappointed in myself for not thinking of it myself.

 

I guess I'll need to make a get-client type call to grab the IP address, but that should be easy enough. This should speed up the script considerably. Thanks for the idea!

PhilipDAth
Kind of a big deal
Kind of a big deal

ps. If it was me, I'd just go for a fixed 60s.  Give the camera enough time to really power down.

Nash
Kind of a big deal

These aren't Meraki devices? Too bad. @NolanHerring has a bit on how to use the API to do this with Meraki stuff.

 

I think Phillip's got it right with just adding delay into your loop to allow changes to download to the Meraki device and camera to power off. The famous Meraki 1-2 minute "go get some water" break. 😕

Get notified when there are additional replies to this discussion.