Skip to content
Snippets Groups Projects
Commit 65e88e3d authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

Show current license usage when updating Kentik license of a router

parent 25dd000e
No related branches found
No related tags found
1 merge request!271Show current license usage when updating Kentik license of a router
Pipeline #89244 failed
......@@ -109,7 +109,42 @@ class KentikClient:
return {}
def get_plans(self) -> list[dict[str, Any]]:
"""Get all Kentik plans available."""
"""Get all Kentik plans available.
Returns a list of ``plans`` that each have the following shape:
.. vale off
.. code-block:: json
"plan": {
"active": true,
"bgp_enabled": true,
"cdate" "1970-01-01T01:01:01.000Z",
"company_id": 111111,
"description": "A description of this plan",
"deviceTypes": [
{"device_type": "router"},
{"device_type": "host-nprobe-dns-www"}
],
"devices": [
{
"id": "111111",
"device_name": "rt0.city.tld.internal",
"device_type": "router"
},
],
"edate": "2999-01-01T09:09:09.000Z",
"fast_retention": 10,
"full_retention": 5,
"id": 11111,
"max_bigdata_fps": 100,
"max_devices": 9001,
"max_fps": 200,
"name": "KENTIK-PLAN-01",
"metadata": {},
}
.. vale on
"""
return self._send_request("GET", "v5/plans")["plans"]
def get_plan(self, plan_id: int) -> dict[str, Any]:
......
......@@ -60,6 +60,7 @@ def execute_playbook(
For example, an inventory consisting of two hosts, which each a unique host variable assigned to them looks as
follows:
.. vale off
.. code-block:: json
"inventory": {
......@@ -74,6 +75,7 @@ def execute_playbook(
}
}
}
.. vale on
.. warning::
Note the fact that the collection of all hosts is a dictionary, and not a list of strings. Ansible expects each
......
......@@ -22,7 +22,11 @@ logger = logging.getLogger()
def _initial_input_form(subscription_id: UUIDstr) -> FormGenerator:
router = Router.from_subscription(subscription_id)
active_kentik_plans = {str(plan["id"]): plan["name"] for plan in KentikClient().get_plans() if plan["active"]}
active_kentik_plans = {
str(plan["id"]): f"{plan["name"]} - ({len(plan["devices"])}/{plan["max_devices"]})"
for plan in KentikClient().get_plans()
if plan["active"]
}
available_kentik_plans = Choice(
"Select a Kentik license",
zip(active_kentik_plans.keys(), active_kentik_plans.items(), strict=True), # type: ignore[arg-type]
......
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