I don’t think there is a /renew
endpoint for the REST API. There is a RenewClientLeaseDhcp
in the GraphQL endpoint, but you may have to make a change to the op mode script since it requires raw
as a parameter in the function, but raw isn’t allowed as an input.
curl -k --raw 'https://10.0.101.245/graphql' -H 'Content-Type: application/json' -d \
'{"query":"mutation { RenewClientLeaseDhcp (data: {key: \"test123\", family: inet, interface: \"eth1\"}) {\n success\n errors\n op_mode_error {name, message, vyos_code}\n data {\n result\n }\n}\n}\n"}'|jq
{
"data": {
"RenewClientLeaseDhcp": {
"success": false,
"errors": [
"TypeError(\"renew_client_lease() missing 1 required positional argument: 'raw'\")"
],
"op_mode_error": null,
"data": null
}
}
}
Add raw:
curl -k --raw 'https://10.0.101.245/graphql' -H 'Content-Type: application/json' -d \
'{"query":"mutation { RenewClientLeaseDhcp (data: {key: \"test123\", raw: false,family: inet, interface: \"eth1\"}) {\n success\n errors\n op_mode_error {name, message, vyos_code}\n data {\n result\n }\n}\n}\n"}'|jq
{
"errors": [
{
"message": "Field 'raw' is not defined by type 'RenewClientLeaseDhcpInput'.",
"locations": [
{
"line": 1,
"column": 57
}
],
"extensions": {
"exception": null
}
}
]
}
The solution (someone may have a better one) would be to modify line 539 (may be slightly different in different versions) in /usr/libexec/vyos/op_mode/dhcp.py
from:
def renew_client_lease(raw: bool, family: ArgFamily, interface: str):
to
def renew_client_lease(family: ArgFamily, interface: str, raw: bool = False):
Then you’re able to run this:
curl -k --raw 'https://10.0.101.245/graphql' -H 'Content-Type: application/json' -d \
'{"query":"mutation { RenewClientLeaseDhcp (data: {key: \"test123\", family: inet, interface: \"eth1\"}) {\n success\n errors\n op_mode_error {name, message, vyos_code}\n data {\n result\n }\n}\n}\n"}'|jq
{
"data": {
"RenewClientLeaseDhcp": {
"success": true,
"errors": null,
"op_mode_error": null,
"data": {
"result": null
}
}
}
}
VyOS log:
Apr 24 00:29:48 dhclient[51062]: bound to 10.0.101.245 -- renewal in 35634 seconds.
Feel fre to submit a bug report at https://vyos.dev. Maybe even submit a PR to fix the issue.