Search code examples
pythonapiansibleip-addressovh

Why does my API call to OVH not work on my allocated ipBlock?


Problem

I'm been stuck on how to use this OVH's call call to obtain the MAC that has been assigned for the task. The problem is, I can't seem to successfully guess what the required "ip" parameter of type "ipBlock" is.

My addressing

193.xx.x.115: My dedicated server running many containers
151.zz.z.192/27: The IP address block that we have purchased from OVH to assign a public IP address to each container
151.zz.z.219: An existing container that has recently had a vMAC allocation task complete (source of taskId)

What I've tried to use with client.get(URL)

URL = "/ip/" + 151.zz.z.192/27 + "/task/" + taskID

throws ovh.exceptions.ResourceNotFoundError: Got an invalid (or empty) URL

URL = "/ip/" + 151.zz.z.192 + "/task/" + taskID

throws ovh.exceptions.ResourceNotFoundError: The requested object (ip = 151.80.6.192) does not exist

URL = "/ip/" + 151.zz.z.219 + "/task/" + taskID

throws ovh.exceptions.ResourceNotFoundError: The requested object (ip = 151.80.6.211) does not exist

URL = "/ip/" + 193.xx.x.115 + "/task/" + taskID

throws ovh.exceptions.ResourceNotFoundError: The requested object (taskId = 127250060) does not exist

Overall

I am starting to wonder whether this API call works with vMACs at all. The only time it finds the URL and resource valid is when I point it directly at the dedicated server and not the IP block that's allocated for the containers or a CT address.

At the same time though, this seems less likely when we consider that I've successfully used another API call just before that to assign a vMac to the same container IP address.

Is there any advice you can offer? Thanks in advance.


Solution

  • The valid format of ipBlock is the kind you get returned from the /ip/ call. In your case: 151.zz.z.192/27.

    From my experiments, it does not look like the tasks under /ip/... include the vmac creation tasks. I tried creating several vmacs, and the associated tasks show up at: /dedicated/server/{serviceName}/task (function=addVirtualMac).

    You can get the done status from there, (/dedicated/server/{serviceName}/task/{taskId}, specifically), but that does not include the generated MAC.

    There is one endpoint that shows all virtual MACs. Maybe you can use that one for your purposes: /dedicated/server/{serviceName}/virtualMac