Hey there,

i'm trying to control the kea server by using the control agent.

I already implemented a web-frontend to the database (mysql) to show all the 
leases and reservations.
Now I'm trying to get the running configuration by requesting the control agent.

$msg = array("command" => "config-get", "service" => "[ dhcp4 ]");
$message = json_encode($msg);

//$message = '{ "command": "config-get", "service": "dhcp4" }';
$len = strlen($message);

echo print_r($message, true), "\n";

$ch = curl_init('http://127.0.0.1:8080/');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $message);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
     'Content-type: application/json',
     'Content-Length: '. $len)
);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);

$ret = curl_exec($ch);
if($ret === false)
{
    echo 'Curl error: ' . curl_error($ch);
}
else
{
     echo print_r($ret, true);
    echo 'Operation completed without any errors';
}

All I receive is the following:
{"command":"config-get","service":"[ dhcp4 ]"}
{ "result": 400, "text": "Bad Request" }
Operation completed without any errors


I tried a lot of things:

-       dhcp4 with or without brackets

-       using the documented string 
(http://kea.isc.org/docs/kea-guide.html#ctrl-channel-client)

-       with and without timeouts

-       different HTTPHEADER (with, and without Content-Length like in the 
documentation)

The service is up and running, if i'm using the shell and curl the example 
works.
I also tried to get a clue by reading the log (DEBUG, Level 99) but there is 
just a lousy message "HTTP_DATA_RECEIVED received 152 bytes from 127.0.0.1" and 
"DEBUG [kea-ctrl-agent.http] HTTP_RESPONSE_SEND sending HTTP response HTTP/1.1 
400 Bad Request#015#012 to 127.0.0.1"

Does anybody have a clue how to successfully connect and receive a proper 
message?


Thanks in advance

Sebastian
_______________________________________________
Kea-users mailing list
Kea-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/kea-users

Reply via email to