Describe the bug
The edit_rate_limits and disable_rate_limits methods of the pyvcloud.vcd.gateway.Gateway() class call the put_linked_resource method of the vcd.Client class.
The calls look like this:
return self.client.put_linked_resource(
self.resource, RelationType.EDIT, EntityType.EDGE_GATEWAY.value,
gateway)
The RelationType.EDIT is incorrect, the proper RelationType is RelationType.GATEWAY_UPDATE_PROPERTIES.
Currently any request to edit or remove rate limits on the Edge Gateway, is accepted with a 202 (queued) but then fails as the request is invalid.
Reproduction steps
- Instantiate a Gateway object.
- Attempt to disable or edit a rate limit on one of the external networks.
- Log that the task was queued (Return code: 202).
- Wait.
- Notice that the updates you requested were not made.
- Log in to the UI to see that the task failed almost instantly.
- Compare the API call to that of the same request from the UI.
- Notice that the RelationType is incorrect.
- Subclass a Gateway object and override the rate_limits methods to use
RelationType.GATEWAY_UPDATE_PROPERTIES.
- Use the Subclassed Gateway object to confirm that the changes to rate limits are now working.
- Cry inconsolably because a simple integration test would have caught this bug. ;-)
- Cheer up because the folks a VMWare are gonna fix this quickly, right?
Expected behavior
The calls to Client.put_linked_resource() should use RelationType.GATEWAY_UPDATE_PROPERTIES.
Additional context
It's probable that a broader review needs to be done on all the methods of the Gateway class.
RelationType.GATEWAY_UPDATE_PROPERTIES is only used twice in the class definition and I suspect that it ought to be used for most of the modification tasks. Unfortunately, I don't have a suitable lab environment nor the time to check every method in this class. :-(