How can you test to see if a Netwok is ready for devices to be claimed?

mrpackethead_
Comes here often

How can you test to see if a Netwok is ready for devices to be claimed?

I am creating a network and then attempting to claim devices for it..   

```

response = dashboard.organizations.createOrganizationNetwork(
        ORGANISATION_ID,
        props['NetworkName'],
        props['ProductTypes'],
        tags=props['Tags'],
        timeZone=props['TimeZone'],
        notes=props['Notes']
    )
```

  The networks create ok, but I get an error  ( "error: devices, updateDevice - 404 Not Found, please wait a minute if the key or org was just newly created."  when  i try to immediately claim devices...

```

dashboard.networks.claimNetworkDevices(
        props['NetworkId'],
        [props["Serial"]],
    )

```

The error suggests that the creation of the network is async... And i need to wait untill its ready.     How can i test to see if the network is in fact ready and can have devices added to it?


If i run these calls manually and allow some time between them, it works.. I dont' really want to just build in an arbitory wait...  


5 Replies 5
PhilipDAth
Kind of a big deal
Kind of a big deal

I think you are going to need that arbitrary wait.

 

I'd use a loop containing try/except and a time.sleep(1) for each iteration that fails.

 

I don't know if you can use Action Batches when creating networks - but you could look into using that approach as well.

https://developer.cisco.com/meraki/api-v1/action-batches-overview/

 

PhilipDAth
Kind of a big deal
Kind of a big deal

Perhaps @sungod might have more wisdom.

sungod
Kind of a big deal

Agree with @PhilipDAth a test-wait loop is the safest approach. Certain actions take a while to propagate.

 

I'd loop on a read endpoint like... https://developer.cisco.com/meraki/api-v1/get-network/ 

Jake-Young
Here to help

I'd try creating the Network (and maybe claiming) in action batches, see if you have better results.  In the past I noticed some behavior differences between using and not using action batches.

mrpackethead_
Comes here often

As soon as i make the get network APi call, it seems that its ready, however from the result that the API provides theres no status field, that tells you if its ready or not. 

If i get a valid response from the get network api does this mean that it is ready?   I've wrapped it in a try except, but as it turns out i'm not getting a failure..

If i go create nework, then claim device it always fails..  but  create network,  get network, claim device. well that works.


It woudl be nice if there was a status property

Get notified when there are additional replies to this discussion.