Compare commits
2 Commits
c5510ac374
...
2f12fc40fe
Author | SHA1 | Date |
---|---|---|
|
2f12fc40fe | |
|
716ef20e31 |
|
@ -1,13 +1,13 @@
|
|||
{
|
||||
"openapi": "3.0.0",
|
||||
"info": {
|
||||
"title": "My API",
|
||||
"title": "Ogdhcp API",
|
||||
"version": "1.0"
|
||||
},
|
||||
"paths": {
|
||||
"/opengnsys3/rest/dhcp/subnet": {
|
||||
"/opengnsys3/rest/dhcp/subnets": {
|
||||
"get": {
|
||||
"operationId": "ece42bc4084486aedf42734bdb0b84cb",
|
||||
"operationId": "8f92a1cbcb8cd176bdc4ae272b3ad303",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Devuelve todas las subredes",
|
||||
|
@ -29,7 +29,7 @@
|
|||
},
|
||||
"post": {
|
||||
"summary": "Add a new DHCP subnet",
|
||||
"operationId": "36e86a6932056e774180d074d3d63ad0",
|
||||
"operationId": "88949bae5e7784ce2721ffafe7c88c0a",
|
||||
"requestBody": {
|
||||
"description": "JSON payload",
|
||||
"required": true,
|
||||
|
@ -97,10 +97,10 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/opengnsys3/rest/dhcp/subnet/{subnetId}": {
|
||||
"/opengnsys3/rest/dhcp/subnets/{subnetId}": {
|
||||
"put": {
|
||||
"summary": "Modify a DHCP subnet",
|
||||
"operationId": "c002afa59d07660be24fda34e1498c13",
|
||||
"operationId": "548b55fc0e1ad59ea5b5c909dfd07c71",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "subnetId",
|
||||
|
@ -172,7 +172,7 @@
|
|||
},
|
||||
"delete": {
|
||||
"summary": "Delete a DHCP subnet",
|
||||
"operationId": "299c4287d729ca98c47ef613720051f4",
|
||||
"operationId": "c1c1c34729bdd85857b22e6e2bdc41de",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "subnetId",
|
||||
|
@ -218,10 +218,10 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/opengnsys3/rest/dhcp/subnet/{subnetId}/host": {
|
||||
"/opengnsys3/rest/dhcp/subnets/{subnetId}/hosts": {
|
||||
"get": {
|
||||
"summary": "Get all hosts in a subnet",
|
||||
"operationId": "2511366de74accc3d7356814ced1cf50",
|
||||
"operationId": "0989ca622a6a7e23f5af8e3bdd6f6b05",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "subnetId",
|
||||
|
@ -281,7 +281,7 @@
|
|||
},
|
||||
"put": {
|
||||
"summary": "Update a DHCP host",
|
||||
"operationId": "6106fe2802e2f913ddb35df61b5fde35",
|
||||
"operationId": "1541441cd53685aaf6df45ab48befaa8",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "subnetId",
|
||||
|
@ -361,7 +361,7 @@
|
|||
},
|
||||
"post": {
|
||||
"summary": "Add a DHCP host to a subnet",
|
||||
"operationId": "f5d3e1de64faa4e5b14cdc7d3bd0c427",
|
||||
"operationId": "3f897dcd7c04787ac9c42ddbb57cb800",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "subnetId",
|
||||
|
@ -433,7 +433,7 @@
|
|||
},
|
||||
"delete": {
|
||||
"summary": "Delete a DHCP host from a specific subnet",
|
||||
"operationId": "542cc5fc093ff121c154504e9cad270f",
|
||||
"operationId": "f652c52b39d57d283401df66a7930b5f",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "subnetId",
|
||||
|
|
|
@ -173,8 +173,14 @@ class DhcpController
|
|||
$responseError = "Error al guardar la configuración en Kea DHCP: " . $responseSet[0]["text"];
|
||||
return new JsonResponse(['error' => $responseError], 400);
|
||||
} else {
|
||||
$responseSuccess = "Configuración cargada correctamente";
|
||||
return new JsonResponse(['success' => $responseSuccess], 200);
|
||||
$responseWrite = $this->curlKeaService->executeCurlCommand('config-write', $configuration);
|
||||
if ($responseWrite == false || $responseWrite[0]["result"] != 0) {
|
||||
$responseError = "Error al guardar la configuración en Kea DHCP: " . $responseWrite[0]["text"];
|
||||
return new JsonResponse(['error' => $responseError], 400);
|
||||
} else {
|
||||
$responseSuccess = "Configuración cargada correctamente";
|
||||
return new JsonResponse(['success' => $responseSuccess], 200);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$responseError = "Error kea configuration invalid: " . $responseTest[0]["text"];
|
||||
|
@ -253,8 +259,14 @@ class DhcpController
|
|||
$responseError = "Error al guardar la configuración en Kea DHCP: " . $responseSet[0]["text"];
|
||||
return new JsonResponse(['error' => $responseError], 400);
|
||||
} else {
|
||||
$responseSuccess = "Subred eliminada correctamente";
|
||||
return new JsonResponse(['success' => $responseSuccess], 200);
|
||||
$responseWrite = $this->curlKeaService->executeCurlCommand('config-write', $configuration);
|
||||
if ($responseWrite == false || $responseWrite[0]["result"] != 0) {
|
||||
$responseError = "Error al guardar la configuración en Kea DHCP: " . $responseWrite[0]["text"];
|
||||
return new JsonResponse(['error' => $responseError], 400);
|
||||
} else {
|
||||
$responseSuccess = "Subred eliminada correctamente";
|
||||
return new JsonResponse(['success' => $responseSuccess], 200);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$responseError = "Error kea configuration invalid: " . $responseTest[0]["text"];
|
||||
|
@ -360,8 +372,14 @@ class DhcpController
|
|||
$responseError = "Error al guardar la configuración en Kea DHCP: " . $responseSet[0]["text"];
|
||||
return new JsonResponse(['error' => $responseError], 400);
|
||||
} else {
|
||||
$responseSuccess = "Subred modificada correctamente";
|
||||
return new JsonResponse(['success' => $responseSuccess], 200);
|
||||
$responseWrite = $this->curlKeaService->executeCurlCommand('config-write', $configuration);
|
||||
if ($responseWrite == false || $responseWrite[0]["result"] != 0) {
|
||||
$responseError = "Error al guardar la configuración en Kea DHCP: " . $responseWrite[0]["text"];
|
||||
return new JsonResponse(['error' => $responseError], 400);
|
||||
} else {
|
||||
$responseSuccess = "Subred modificada correctamente";
|
||||
return new JsonResponse(['success' => $responseSuccess], 200);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$responseError = "Error kea configuration invalid: " . $responseTest[0]["text"];
|
||||
|
@ -558,8 +576,14 @@ class DhcpController
|
|||
$responseError = "Error al guardar la configuración en Kea DHCP: " . $responseSet[0]["text"];
|
||||
return new JsonResponse(['error' => $responseError], 400);
|
||||
} else {
|
||||
$responseSuccess = "Configuración cargada correctamente";
|
||||
return new JsonResponse(['success' => $responseSuccess], 200);
|
||||
$responseWrite = $this->curlKeaService->executeCurlCommand('config-write', $configuration);
|
||||
if ($responseWrite == false || $responseWrite[0]["result"] != 0) {
|
||||
$responseError = "Error al guardar la configuración en Kea DHCP: " . $responseWrite[0]["text"];
|
||||
return new JsonResponse(['error' => $responseError], 400);
|
||||
} else {
|
||||
$responseSuccess = "Configuración cargada correctamente";
|
||||
return new JsonResponse(['success' => $responseSuccess], 200);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$responseError = "Error kea configuration invalid: " . $responseTest[0]["text"];
|
||||
|
@ -652,8 +676,14 @@ class DhcpController
|
|||
$responseError = "Error al guardar la configuración en Kea DHCP: " . $responseSet[0]["text"];
|
||||
return new JsonResponse(['error' => $responseError], 400);
|
||||
} else {
|
||||
$responseSuccess = "Configuración cargada correctamente";
|
||||
return new JsonResponse(['success' => $responseSuccess], 200);
|
||||
$responseWrite = $this->curlKeaService->executeCurlCommand('config-write', $configuration);
|
||||
if ($responseWrite == false || $responseWrite[0]["result"] != 0) {
|
||||
$responseError = "Error al guardar la configuración en Kea DHCP: " . $responseWrite[0]["text"];
|
||||
return new JsonResponse(['error' => $responseError], 400);
|
||||
} else {
|
||||
$responseSuccess = "Configuración cargada correctamente";
|
||||
return new JsonResponse(['success' => $responseSuccess], 200);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$responseError = "Error al guardar la configuración en Kea DHCP: " . $responseTest[0]["text"];
|
||||
|
@ -768,8 +798,14 @@ class DhcpController
|
|||
$responseError = "Error al guardar la configuración en Kea DHCP: " . $responseSet[0]["text"];
|
||||
return new JsonResponse(['error' => $responseError], 400);
|
||||
} else {
|
||||
$responseSuccess = "Configuración cargada correctamente";
|
||||
return new JsonResponse(['success' => $responseSuccess], 200);
|
||||
$responseWrite = $this->curlKeaService->executeCurlCommand('config-write', $configuration);
|
||||
if ($responseWrite == false || $responseWrite[0]["result"] != 0) {
|
||||
$responseError = "Error al guardar la configuración en Kea DHCP: " . $responseWrite[0]["text"];
|
||||
return new JsonResponse(['error' => $responseError], 400);
|
||||
} else {
|
||||
$responseSuccess = "Configuración cargada correctamente";
|
||||
return new JsonResponse(['success' => $responseSuccess], 200);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$responseError = "Error al guardar la configuración en Kea DHCP: " . $responseTest[0]["text"];
|
||||
|
@ -806,7 +842,6 @@ class DhcpController
|
|||
$backup_file = reset($backup_files);
|
||||
$config = file_get_contents($backup_file);
|
||||
$configuration = json_decode($config);
|
||||
|
||||
$test_command = 'config-test';
|
||||
$test_output = $this->curlKeaService->executeCurlCommand($test_command, $configuration);
|
||||
if ($test_output == false || $test_output[0]["result"] != 0) {
|
||||
|
@ -817,11 +852,17 @@ class DhcpController
|
|||
$set_output = $this->curlKeaService->executeCurlCommand($set_command, $configuration, false);
|
||||
if ($set_output == false || $set_output[0]["result"] != 0) {
|
||||
$responseError = "Error al guardar la última configuración de Kea: " . $set_output[0]["text"];
|
||||
return new JsonResponse(['error' => $responseError], 400);
|
||||
return new JsonResponse(['error' => $responseError], 400);
|
||||
} else {
|
||||
unlink($backup_file);
|
||||
$responseSuccess = "última configuración cargada correctamente";
|
||||
return new JsonResponse(['success' => $responseSuccess], 200);
|
||||
$responseWrite = $this->curlKeaService->executeCurlCommand('config-write', $configuration);
|
||||
if ($responseWrite == false || $responseWrite[0]["result"] != 0) {
|
||||
$responseError = "Error al guardar la configuración en Kea DHCP: " . $responseWrite[0]["text"];
|
||||
return new JsonResponse(['error' => $responseError], 400);
|
||||
} else {
|
||||
$responseSuccess = "Configuración cargada correctamente";
|
||||
return new JsonResponse(['success' => $responseSuccess], 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue