Skip to content
Snippets Groups Projects
Commit c1f7f75c authored by Karel van Klink's avatar Karel van Klink :smiley_cat: Committed by Neda Moeini
Browse files

Work around Kentik API limitation

parent ab5d259d
No related branches found
No related tags found
1 merge request!235Add a Kentik service to GSO
......@@ -114,7 +114,8 @@ class KentikClient:
plan_id = self.get_plan_by_name(self.config.billing_plans[device.site_tier])["id"]
request_body = {
"device": {
**device.model_dump(exclude=set("site_tier")),
**device.model_dump(exclude=set("device_name" "site_tier")),
"device_name": device.device_description,
"device_type": self.config.device_type,
"device_subtype": self.config.device_type,
"minimize_snmp": self.config.minimize_snmp,
......@@ -128,7 +129,14 @@ class KentikClient:
}
}
return self._send_request("POST", "v5/device", request_body).json()
new_device = self._send_request("POST", "v5/device", request_body).json()
# The name of the device has to be updated from the subscription ID to its FQDN.
# This is a limitation of the Kentik API that disallows settings device names containing a . symbol.
self.update_device(new_device["device"]["id"], {"device": {"device_name": device.device_name}})
new_device["device"]["device_name"] = device.device_name
return new_device
def update_device(self, device_id: str, updated_device: dict[str, Any]) -> dict[str, Any]:
"""Update an existing device in Kentik."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment