refs #198 adds new ogbootbundle with controller functions and service to connect so stunnel4
parent
66e4e2d3cb
commit
ddc8a5faa3
|
@ -0,0 +1,107 @@
|
|||
{
|
||||
"type": "project",
|
||||
"license": "proprietary",
|
||||
"minimum-stability": "stable",
|
||||
"prefer-stable": true,
|
||||
"require": {
|
||||
"php": ">=7.2.0",
|
||||
"ext-ctype": "*",
|
||||
"ext-iconv": "*",
|
||||
"doctrine/annotations": "^1.6",
|
||||
"doctrine/doctrine-bundle": "^2.0",
|
||||
"doctrine/doctrine-migrations-bundle": "^3.0",
|
||||
"doctrine/orm": "^2.7",
|
||||
"phpdocumentor/reflection-docblock": "^5.0",
|
||||
"phpstan/phpdoc-parser": "^0.4",
|
||||
"zircote/swagger-php": "3.*",
|
||||
"symfony/runtime": "5.*",
|
||||
"symfony/asset": "5.*",
|
||||
"symfony/console": "5.*",
|
||||
"symfony/doctrine-messenger": "5.*",
|
||||
"symfony/dotenv": "5.*",
|
||||
"symfony/expression-language": "5.*",
|
||||
"symfony/flex": "^1.17",
|
||||
"symfony/form": "5.*",
|
||||
"symfony/framework-bundle": "5.*",
|
||||
"symfony/http-client": "5.*",
|
||||
"symfony/intl": "5.*",
|
||||
"symfony/mailer": "5.*",
|
||||
"symfony/mime": "5.*",
|
||||
"symfony/monolog-bundle": "^3.0",
|
||||
"symfony/notifier": "5.*",
|
||||
"symfony/process": "5.*",
|
||||
"symfony/property-access": "5.*",
|
||||
"symfony/property-info": "5.*",
|
||||
"symfony/security-bundle": "5.*",
|
||||
"symfony/serializer": "5.*",
|
||||
"symfony/string": "5.*",
|
||||
"symfony/translation": "5.*",
|
||||
"symfony/twig-bundle": "5.*",
|
||||
"symfony/validator": "5.*",
|
||||
"symfony/web-link": "5.*",
|
||||
"symfony/yaml": "5.*",
|
||||
"twig/extra-bundle": "^2.12|^3.0",
|
||||
"twig/twig": "^2.12|^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^8.5",
|
||||
"symfony/browser-kit": "5.*",
|
||||
"symfony/css-selector": "5.*",
|
||||
"symfony/debug-bundle": "5.*",
|
||||
"symfony/maker-bundle": "^1.0",
|
||||
"symfony/phpunit-bridge": "^5.0",
|
||||
"symfony/stopwatch": "5.*",
|
||||
"symfony/web-profiler-bundle": "5.*"
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "8.3"
|
||||
},
|
||||
"allow-plugins": {
|
||||
"composer/package-versions-deprecated": true,
|
||||
"symfony/flex": true,
|
||||
"symfony/runtime": true
|
||||
},
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": {
|
||||
"*": "dist"
|
||||
},
|
||||
"sort-packages": true
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"App\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"replace": {
|
||||
"symfony/polyfill-ctype": "*",
|
||||
"symfony/polyfill-iconv": "*",
|
||||
"symfony/polyfill-php72": "*"
|
||||
},
|
||||
"scripts": {
|
||||
"auto-scripts": {
|
||||
"cache:clear": "symfony-cmd",
|
||||
"assets:install %PUBLIC_DIR%": "symfony-cmd"
|
||||
},
|
||||
"post-install-cmd": [
|
||||
"@auto-scripts"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"@auto-scripts"
|
||||
]
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/symfony": "*"
|
||||
},
|
||||
"extra": {
|
||||
"symfony": {
|
||||
"allow-contrib": false,
|
||||
"require": "5.*"
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 665 B |
Binary file not shown.
After Width: | Height: | Size: 628 B |
|
@ -0,0 +1,16 @@
|
|||
html {
|
||||
box-sizing: border-box;
|
||||
overflow: -moz-scrollbars-vertical;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
*,
|
||||
*:before,
|
||||
*:after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background: #fafafa;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<!-- HTML for static distribution bundle build -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Swagger UI</title>
|
||||
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" />
|
||||
<link rel="stylesheet" type="text/css" href="index.css" />
|
||||
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
|
||||
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="swagger-ui"></div>
|
||||
<script src="./swagger-ui-bundle.js" charset="UTF-8"> </script>
|
||||
<script src="./swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
|
||||
<script src="./swagger-initializer.js" charset="UTF-8"> </script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
use App\Kernel;
|
||||
|
||||
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
|
||||
|
||||
return function (array $context) {
|
||||
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
|
||||
};
|
|
@ -0,0 +1,79 @@
|
|||
<!doctype html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<title>Swagger UI: OAuth2 Redirect</title>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
'use strict';
|
||||
function run () {
|
||||
var oauth2 = window.opener.swaggerUIRedirectOauth2;
|
||||
var sentState = oauth2.state;
|
||||
var redirectUrl = oauth2.redirectUrl;
|
||||
var isValid, qp, arr;
|
||||
|
||||
if (/code|token|error/.test(window.location.hash)) {
|
||||
qp = window.location.hash.substring(1).replace('?', '&');
|
||||
} else {
|
||||
qp = location.search.substring(1);
|
||||
}
|
||||
|
||||
arr = qp.split("&");
|
||||
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';});
|
||||
qp = qp ? JSON.parse('{' + arr.join() + '}',
|
||||
function (key, value) {
|
||||
return key === "" ? value : decodeURIComponent(value);
|
||||
}
|
||||
) : {};
|
||||
|
||||
isValid = qp.state === sentState;
|
||||
|
||||
if ((
|
||||
oauth2.auth.schema.get("flow") === "accessCode" ||
|
||||
oauth2.auth.schema.get("flow") === "authorizationCode" ||
|
||||
oauth2.auth.schema.get("flow") === "authorization_code"
|
||||
) && !oauth2.auth.code) {
|
||||
if (!isValid) {
|
||||
oauth2.errCb({
|
||||
authId: oauth2.auth.name,
|
||||
source: "auth",
|
||||
level: "warning",
|
||||
message: "Authorization may be unsafe, passed state was changed in server. The passed state wasn't returned from auth server."
|
||||
});
|
||||
}
|
||||
|
||||
if (qp.code) {
|
||||
delete oauth2.state;
|
||||
oauth2.auth.code = qp.code;
|
||||
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
|
||||
} else {
|
||||
let oauthErrorMsg;
|
||||
if (qp.error) {
|
||||
oauthErrorMsg = "["+qp.error+"]: " +
|
||||
(qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
|
||||
(qp.error_uri ? "More info: "+qp.error_uri : "");
|
||||
}
|
||||
|
||||
oauth2.errCb({
|
||||
authId: oauth2.auth.name,
|
||||
source: "auth",
|
||||
level: "error",
|
||||
message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server."
|
||||
});
|
||||
}
|
||||
} else {
|
||||
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
|
||||
}
|
||||
window.close();
|
||||
}
|
||||
|
||||
if (document.readyState !== 'loading') {
|
||||
run();
|
||||
} else {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
run();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,20 @@
|
|||
window.onload = function() {
|
||||
//<editor-fold desc="Changeable Configuration Block">
|
||||
|
||||
// the following lines will be replaced by docker/configurator, when it runs in a docker-container
|
||||
window.ui = SwaggerUIBundle({
|
||||
url: "http://192.168.0.27:8080/swagger.json",
|
||||
dom_id: '#swagger-ui',
|
||||
deepLinking: true,
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
plugins: [
|
||||
SwaggerUIBundle.plugins.DownloadUrl
|
||||
],
|
||||
layout: "StandaloneLayout"
|
||||
});
|
||||
|
||||
//</editor-fold>
|
||||
};
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,549 @@
|
|||
{
|
||||
"openapi": "3.0.0",
|
||||
"info": {
|
||||
"title": "My API",
|
||||
"version": "1.0"
|
||||
},
|
||||
"paths": {
|
||||
"/opengnsys3/rest/dhcp/subnet": {
|
||||
"get": {
|
||||
"operationId": "ece42bc4084486aedf42734bdb0b84cb",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Devuelve todas las subredes",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Subnet"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Error al obtener las subredes"
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"summary": "Add a new DHCP subnet",
|
||||
"operationId": "36e86a6932056e774180d074d3d63ad0",
|
||||
"requestBody": {
|
||||
"description": "JSON payload",
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"properties": {
|
||||
"subnetId": {
|
||||
"type": "integer",
|
||||
"example": 2
|
||||
},
|
||||
"mask": {
|
||||
"type": "string",
|
||||
"example": "255.255.255.0"
|
||||
},
|
||||
"address": {
|
||||
"type": "string",
|
||||
"example": "192.168.1.0"
|
||||
},
|
||||
"nextServer": {
|
||||
"type": "string",
|
||||
"example": "192.168.1.1"
|
||||
},
|
||||
"bootFileName": {
|
||||
"type": "string",
|
||||
"example": "pxelinux.0"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Subnet added successfully",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"properties": {
|
||||
"success": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Error occurred",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/opengnsys3/rest/dhcp/subnet/{subnetId}": {
|
||||
"put": {
|
||||
"summary": "Modify a DHCP subnet",
|
||||
"operationId": "c002afa59d07660be24fda34e1498c13",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "subnetId",
|
||||
"in": "path",
|
||||
"description": "ID of the subnet to modify",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"description": "Data to modify the subnet",
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"properties": {
|
||||
"mask": {
|
||||
"type": "string"
|
||||
},
|
||||
"address": {
|
||||
"type": "string"
|
||||
},
|
||||
"nextServer": {
|
||||
"type": "string"
|
||||
},
|
||||
"bootFileName": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Subnet modified successfully",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"properties": {
|
||||
"success": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Error occurred",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"summary": "Delete a DHCP subnet",
|
||||
"operationId": "299c4287d729ca98c47ef613720051f4",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "subnetId",
|
||||
"in": "path",
|
||||
"description": "ID of the subnet to delete",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Subnet deleted successfully",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"properties": {
|
||||
"success": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Error occurred",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/opengnsys3/rest/dhcp/subnet/{subnetId}/host": {
|
||||
"get": {
|
||||
"summary": "Get all hosts in a subnet",
|
||||
"operationId": "2511366de74accc3d7356814ced1cf50",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "subnetId",
|
||||
"in": "path",
|
||||
"description": "The ID of the subnet",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "List of hosts in the subnet",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/Host"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Error occurred",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Server error",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"summary": "Update a DHCP host",
|
||||
"operationId": "6106fe2802e2f913ddb35df61b5fde35",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "subnetId",
|
||||
"in": "path",
|
||||
"description": "The ID of the subnet",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"description": "Data for the host to update",
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"properties": {
|
||||
"host": {
|
||||
"type": "string",
|
||||
"example": "pc11"
|
||||
},
|
||||
"oldMacAddress": {
|
||||
"type": "string",
|
||||
"example": "56:6f:c7:4f:00:4f"
|
||||
},
|
||||
"oldAddress": {
|
||||
"type": "string",
|
||||
"example": "192.168.1.11"
|
||||
},
|
||||
"macAddress": {
|
||||
"type": "string",
|
||||
"example": "56:6f:c7:4f:01:01"
|
||||
},
|
||||
"address": {
|
||||
"type": "string",
|
||||
"example": "192.168.1.11"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Host updated successfully",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"properties": {
|
||||
"success": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Error occurred",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"summary": "Add a DHCP host to a subnet",
|
||||
"operationId": "f5d3e1de64faa4e5b14cdc7d3bd0c427",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "subnetId",
|
||||
"in": "path",
|
||||
"description": "ID of the subnet to add the host to",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"description": "Data for the new host",
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"properties": {
|
||||
"host": {
|
||||
"type": "string",
|
||||
"example": "pc11"
|
||||
},
|
||||
"macAddress": {
|
||||
"type": "string",
|
||||
"example": "56:6f:c7:4f:00:4f"
|
||||
},
|
||||
"address": {
|
||||
"type": "string",
|
||||
"example": "172.30.4.11"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Host added successfully",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"properties": {
|
||||
"success": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Error occurred",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"summary": "Delete a DHCP host from a specific subnet",
|
||||
"operationId": "542cc5fc093ff121c154504e9cad270f",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "subnetId",
|
||||
"in": "path",
|
||||
"description": "The ID of the subnet",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"description": "Data for the host to delete",
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"properties": {
|
||||
"host": {
|
||||
"type": "string",
|
||||
"example": "pc11"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Host deleted successfully",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"properties": {
|
||||
"success": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Error occurred",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"properties": {
|
||||
"error": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"Subnet": {
|
||||
"properties": {
|
||||
"id": {
|
||||
"description": "The ID of the subnet",
|
||||
"type": "integer"
|
||||
},
|
||||
"subnet": {
|
||||
"description": "The name of the subnet",
|
||||
"type": "string"
|
||||
},
|
||||
"next-server": {
|
||||
"description": "The next server in the subnet",
|
||||
"type": "string"
|
||||
},
|
||||
"boot-file-name": {
|
||||
"description": "The boot file name for the subnet",
|
||||
"type": "string"
|
||||
},
|
||||
"reservations": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"description": "The reservations in the subnet",
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"Host": {
|
||||
"properties": {
|
||||
"host": {
|
||||
"type": "string",
|
||||
"example": "pc11"
|
||||
},
|
||||
"macAddress": {
|
||||
"type": "string",
|
||||
"example": "56:6f:c7:4f:00:4f"
|
||||
},
|
||||
"address": {
|
||||
"type": "string",
|
||||
"example": "172.30.4.11"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,341 @@
|
|||
openapi: 3.0.0
|
||||
info:
|
||||
title: 'Ogdhcp API'
|
||||
version: '1.0'
|
||||
paths:
|
||||
/opengnsys3/rest/dhcp/subnets:
|
||||
get:
|
||||
operationId: 8f92a1cbcb8cd176bdc4ae272b3ad303
|
||||
responses:
|
||||
'200':
|
||||
description: 'Devuelve todas las subredes'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Subnet'
|
||||
'400':
|
||||
description: 'Error al obtener las subredes'
|
||||
post:
|
||||
summary: 'Add a new DHCP subnet'
|
||||
operationId: 88949bae5e7784ce2721ffafe7c88c0a
|
||||
requestBody:
|
||||
description: 'JSON payload'
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
properties:
|
||||
subnetId:
|
||||
type: integer
|
||||
example: 2
|
||||
mask:
|
||||
type: string
|
||||
example: 255.255.255.0
|
||||
address:
|
||||
type: string
|
||||
example: 192.168.1.0
|
||||
nextServer:
|
||||
type: string
|
||||
example: 192.168.1.1
|
||||
bootFileName:
|
||||
type: string
|
||||
example: pxelinux.0
|
||||
type: object
|
||||
responses:
|
||||
'200':
|
||||
description: 'Subnet added successfully'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
properties:
|
||||
success: { type: string }
|
||||
type: object
|
||||
'400':
|
||||
description: 'Error occurred'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
properties:
|
||||
error: { type: string }
|
||||
type: object
|
||||
'/opengnsys3/rest/dhcp/subnets/{subnetId}':
|
||||
put:
|
||||
summary: 'Modify a DHCP subnet'
|
||||
operationId: 548b55fc0e1ad59ea5b5c909dfd07c71
|
||||
parameters:
|
||||
-
|
||||
name: subnetId
|
||||
in: path
|
||||
description: 'ID of the subnet to modify'
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
requestBody:
|
||||
description: 'Data to modify the subnet'
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
properties:
|
||||
mask:
|
||||
type: string
|
||||
address:
|
||||
type: string
|
||||
nextServer:
|
||||
type: string
|
||||
bootFileName:
|
||||
type: string
|
||||
type: object
|
||||
responses:
|
||||
'200':
|
||||
description: 'Subnet modified successfully'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
properties:
|
||||
success: { type: string }
|
||||
type: object
|
||||
'400':
|
||||
description: 'Error occurred'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
properties:
|
||||
error: { type: string }
|
||||
type: object
|
||||
delete:
|
||||
summary: 'Delete a DHCP subnet'
|
||||
operationId: c1c1c34729bdd85857b22e6e2bdc41de
|
||||
parameters:
|
||||
-
|
||||
name: subnetId
|
||||
in: path
|
||||
description: 'ID of the subnet to delete'
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
responses:
|
||||
'200':
|
||||
description: 'Subnet deleted successfully'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
properties:
|
||||
success: { type: string }
|
||||
type: object
|
||||
'400':
|
||||
description: 'Error occurred'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
properties:
|
||||
error: { type: string }
|
||||
type: object
|
||||
'/opengnsys3/rest/dhcp/subnets/{subnetId}/hosts':
|
||||
get:
|
||||
summary: 'Get all hosts in a subnet'
|
||||
operationId: 0989ca622a6a7e23f5af8e3bdd6f6b05
|
||||
parameters:
|
||||
-
|
||||
name: subnetId
|
||||
in: path
|
||||
description: 'The ID of the subnet'
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
responses:
|
||||
'200':
|
||||
description: 'List of hosts in the subnet'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Host'
|
||||
'400':
|
||||
description: 'Error occurred'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
properties:
|
||||
error: { type: string }
|
||||
type: object
|
||||
'500':
|
||||
description: 'Server error'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
properties:
|
||||
error: { type: string }
|
||||
type: object
|
||||
put:
|
||||
summary: 'Update a DHCP host'
|
||||
operationId: 1541441cd53685aaf6df45ab48befaa8
|
||||
parameters:
|
||||
-
|
||||
name: subnetId
|
||||
in: path
|
||||
description: 'The ID of the subnet'
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
requestBody:
|
||||
description: 'Data for the host to update'
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
properties:
|
||||
host:
|
||||
type: string
|
||||
example: pc11
|
||||
oldMacAddress:
|
||||
type: string
|
||||
example: '56:6f:c7:4f:00:4f'
|
||||
oldAddress:
|
||||
type: string
|
||||
example: 192.168.1.11
|
||||
macAddress:
|
||||
type: string
|
||||
example: '56:6f:c7:4f:01:01'
|
||||
address:
|
||||
type: string
|
||||
example: 192.168.1.11
|
||||
type: object
|
||||
responses:
|
||||
'200':
|
||||
description: 'Host updated successfully'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
properties:
|
||||
success: { type: string }
|
||||
type: object
|
||||
'400':
|
||||
description: 'Error occurred'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
properties:
|
||||
error: { type: string }
|
||||
type: object
|
||||
post:
|
||||
summary: 'Add a DHCP host to a subnet'
|
||||
operationId: 3f897dcd7c04787ac9c42ddbb57cb800
|
||||
parameters:
|
||||
-
|
||||
name: subnetId
|
||||
in: path
|
||||
description: 'ID of the subnet to add the host to'
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
requestBody:
|
||||
description: 'Data for the new host'
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
properties:
|
||||
host:
|
||||
type: string
|
||||
example: pc11
|
||||
macAddress:
|
||||
type: string
|
||||
example: '56:6f:c7:4f:00:4f'
|
||||
address:
|
||||
type: string
|
||||
example: 172.30.4.11
|
||||
type: object
|
||||
responses:
|
||||
'200':
|
||||
description: 'Host added successfully'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
properties:
|
||||
success: { type: string }
|
||||
type: object
|
||||
'400':
|
||||
description: 'Error occurred'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
properties:
|
||||
error: { type: string }
|
||||
type: object
|
||||
delete:
|
||||
summary: 'Delete a DHCP host from a specific subnet'
|
||||
operationId: f652c52b39d57d283401df66a7930b5f
|
||||
parameters:
|
||||
-
|
||||
name: subnetId
|
||||
in: path
|
||||
description: 'The ID of the subnet'
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
requestBody:
|
||||
description: 'Data for the host to delete'
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
properties:
|
||||
host:
|
||||
type: string
|
||||
example: pc11
|
||||
type: object
|
||||
responses:
|
||||
'200':
|
||||
description: 'Host deleted successfully'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
properties:
|
||||
success: { type: string }
|
||||
type: object
|
||||
'400':
|
||||
description: 'Error occurred'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
properties:
|
||||
error: { type: string }
|
||||
type: object
|
||||
components:
|
||||
schemas:
|
||||
Subnet:
|
||||
properties:
|
||||
id:
|
||||
description: 'The ID of the subnet'
|
||||
type: integer
|
||||
subnet:
|
||||
description: 'The name of the subnet'
|
||||
type: string
|
||||
next-server:
|
||||
description: 'The next server in the subnet'
|
||||
type: string
|
||||
boot-file-name:
|
||||
description: 'The boot file name for the subnet'
|
||||
type: string
|
||||
reservations:
|
||||
type: array
|
||||
items:
|
||||
description: 'The reservations in the subnet'
|
||||
type: object
|
||||
type: object
|
||||
Host:
|
||||
properties:
|
||||
host:
|
||||
type: string
|
||||
example: pc11
|
||||
macAddress:
|
||||
type: string
|
||||
example: '56:6f:c7:4f:00:4f'
|
||||
address:
|
||||
type: string
|
||||
example: 172.30.4.11
|
||||
type: object
|
|
@ -0,0 +1 @@
|
|||
[]
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
||||
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
|
||||
|
||||
class Kernel extends BaseKernel
|
||||
{
|
||||
use MicroKernelTrait;
|
||||
}
|
|
@ -0,0 +1,338 @@
|
|||
<?php
|
||||
// src/OgBootBundle/Controller/OgBootController.php
|
||||
|
||||
namespace App\OgBootBundle\Controller;
|
||||
require_once __DIR__ . '/../constants.php';
|
||||
use OpenApi\Annotations as OA;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\OgBootBundle\Service\CurlRequestService;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Exception;
|
||||
|
||||
|
||||
class OgBootController
|
||||
{
|
||||
private $logger;
|
||||
/**
|
||||
* @OA\Info(title="Ogboot API", version="1.0")
|
||||
*/
|
||||
|
||||
private $curlRequestService;
|
||||
|
||||
public function __construct(CurlRequestService $curlRequestService, LoggerInterface $logger)
|
||||
{
|
||||
$this->curlRequestService = $curlRequestService;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/clients/poweroff",
|
||||
* summary="Power off a client",
|
||||
* @OA\RequestBody(
|
||||
* description="JSON payload",
|
||||
* required=true,
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* @OA\Property(property="clients", type="array", @OA\Items(type="string", example="192.168.1.1"))
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Clients powered off successfully",
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* @OA\Property(property="success", type="string")
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=400,
|
||||
* description="Error occurred",
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* @OA\Property(property="error", type="string")
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* @Route("/clients/poweroff", name="poweroff", methods={"POST"})
|
||||
*/
|
||||
public function poweroff(Request $request): Response
|
||||
{
|
||||
$data = json_decode($request->getContent(), true);
|
||||
|
||||
if (!isset($data['clients'])) {
|
||||
return new Response('Invalid data', Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
$ips = $data['clients'];
|
||||
|
||||
$result = $this->curlRequestService->common_request(OG_REST_CMD_POWEROFF, POST, [OG_REST_PARAM_CLIENTS => $ips]);
|
||||
|
||||
if ($result) {
|
||||
return new Response('Success', Response::HTTP_OK);
|
||||
} else {
|
||||
return new Response('Failed', Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/clients/reboot",
|
||||
* summary="Reboot a client",
|
||||
* @OA\RequestBody(
|
||||
* description="JSON payload",
|
||||
* required=true,
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* @OA\Property(property="clients", type="array", @OA\Items(type="string", example="192.168.1.1"))
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Clients rebooted successfully",
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* @OA\Property(property="success", type="string")
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=400,
|
||||
* description="Error occurred",
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* @OA\Property(property="error", type="string")
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* @Route("/clients/reboot", name="reboot", methods={"POST"})
|
||||
*/
|
||||
public function reboot(Request $request): Response
|
||||
{
|
||||
$data = json_decode($request->getContent(), true);
|
||||
|
||||
if (!isset($data['clients'])) {
|
||||
return new Response('Invalid data', Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
$ips = $data['clients'];
|
||||
|
||||
$result = $this->curlRequestService->common_request(OG_REST_CMD_REBOOT, POST, [OG_REST_PARAM_CLIENTS => $ips]);
|
||||
|
||||
if ($result) {
|
||||
return new Response('Success', Response::HTTP_OK);
|
||||
} else {
|
||||
return new Response('Failed', Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/clients/stop",
|
||||
* summary="Stop a client",
|
||||
* @OA\RequestBody(
|
||||
* description="JSON payload",
|
||||
* required=true,
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* @OA\Property(property="clients", type="array", @OA\Items(type="string", example="192.168.1.1"))
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Clients stopped successfully",
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* @OA\Property(property="success", type="string")
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=400,
|
||||
* description="Error occurred",
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* @OA\Property(property="error", type="string")
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* @Route("/clients/stop", name="stop", methods={"POST"})
|
||||
*/
|
||||
public function stop(Request $request): Response
|
||||
{
|
||||
$data = json_decode($request->getContent(), true);
|
||||
|
||||
if (!isset($data['clients'])) {
|
||||
return new Response('Invalid data', Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
$ips = $data['clients'];
|
||||
|
||||
$result = $this->curlRequestService->common_request(OG_REST_CMD_REBOOT, POST, [OG_REST_PARAM_CLIENTS => $ips]);
|
||||
|
||||
if ($result) {
|
||||
return new Response('Success', Response::HTTP_OK);
|
||||
} else {
|
||||
return new Response('Failed', Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/clients/refresh",
|
||||
* summary="Refresh a client",
|
||||
* @OA\RequestBody(
|
||||
* description="JSON payload",
|
||||
* required=true,
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* @OA\Property(property="clients", type="array", @OA\Items(type="string", example="192.168.1.1"))
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Clients refreshed successfully",
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* @OA\Property(property="success", type="string")
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=400,
|
||||
* description="Error occurred",
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* @OA\Property(property="error", type="string")
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* @Route("/clients/refresh", name="refresh", methods={"POST"})
|
||||
*/
|
||||
public function refresh(Request $request): Response
|
||||
{
|
||||
$data = json_decode($request->getContent(), true);
|
||||
|
||||
if (!isset($data['clients'])) {
|
||||
return new Response('Invalid data', Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
$ips = $data['clients'];
|
||||
|
||||
$result = $this->curlRequestService->common_request(OG_REST_CMD_REFRESH, POST, [OG_REST_PARAM_CLIENTS => $ips]);
|
||||
|
||||
if ($result) {
|
||||
return new Response('Success', Response::HTTP_OK);
|
||||
} else {
|
||||
return new Response('Failed', Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/clients/hardware",
|
||||
* summary="Get hardware info of a client",
|
||||
* @OA\RequestBody(
|
||||
* description="JSON payload",
|
||||
* required=true,
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* @OA\Property(property="clients", type="array", @OA\Items(type="string", example="192.168.1.1"))
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Hardware info retrieved successfully",
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* @OA\Property(property="success", type="string")
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=400,
|
||||
* description="Error occurred",
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* @OA\Property(property="error", type="string")
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* @Route("/clients/hardware", name="hardware", methods={"POST"})
|
||||
*/
|
||||
public function hardware(Request $request): Response
|
||||
{
|
||||
$data = json_decode($request->getContent(), true);
|
||||
|
||||
if (!isset($data['clients'])) {
|
||||
return new Response('Invalid data', Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
$ips = $data['clients'];
|
||||
|
||||
$result = $this->curlRequestService->common_request(OG_REST_CMD_HARDWARE, POST, [OG_REST_PARAM_CLIENTS => $ips]);
|
||||
|
||||
if ($result) {
|
||||
return new Response('Success', Response::HTTP_OK);
|
||||
} else {
|
||||
return new Response('Failed', Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/clients/software",
|
||||
* summary="Get software info of a client",
|
||||
* @OA\RequestBody(
|
||||
* description="JSON payload",
|
||||
* required=true,
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* @OA\Property(property="clients", type="array", @OA\Items(type="string", example="192.168.1.1")),
|
||||
* @OA\Property(property="disk", type="string", example="disk1"),
|
||||
* @OA\Property(property="part", type="string", example="part1")
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="Software info retrieved successfully",
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* @OA\Property(property="success", type="string")
|
||||
* )
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=400,
|
||||
* description="Error occurred",
|
||||
* @OA\JsonContent(
|
||||
* type="object",
|
||||
* @OA\Property(property="error", type="string")
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* @Route("/clients/software", name="software", methods={"POST"})
|
||||
*/
|
||||
public function software(Request $request): Response
|
||||
{
|
||||
$data = json_decode($request->getContent(), true);
|
||||
|
||||
if (!isset($data['clients']) || !isset($data['disk']) || !isset($data['part'])) {
|
||||
return new Response('Invalid data', Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
$ips = $data['clients'];
|
||||
$disk = $data['disk'];
|
||||
$part = $data['part'];
|
||||
|
||||
$result = $this->curlRequestService->common_request(OG_REST_CMD_SOFTWARE, POST, [OG_REST_PARAM_CLIENTS => $ips, OG_REST_PARAM_DISK => $disk, OG_REST_PARAM_PART => $part]);
|
||||
|
||||
if ($result) {
|
||||
return new Response('Success', Response::HTTP_OK);
|
||||
} else {
|
||||
return new Response('Failed', Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
// src/OgBootBundle/OgBootBundle.php
|
||||
|
||||
namespace App\OgBootBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class OgBootBundle extends Bundle
|
||||
{
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
// src/OgBootBundle/Service/CurlRequestService.php
|
||||
|
||||
namespace App\OgBootBundle\Service;
|
||||
require_once __DIR__ . '/../constants.php';
|
||||
use Exception;
|
||||
include_once (__DIR__ . '/../../../etc/php-vars.php');
|
||||
$conf_file = parse_ini_file(__DIR__ . '/../../../etc/ogAdmServer.cfg');
|
||||
define('OG_REST_API_TOKEN', 'Authorization: ' . $conf_file['APITOKEN']);
|
||||
|
||||
class CurlRequestService
|
||||
{
|
||||
function common_request($command, $type, $data = null) {
|
||||
|
||||
$json = json_encode($data);
|
||||
|
||||
$service_url = OG_REST_URL.$command;
|
||||
|
||||
$curl = curl_init($service_url);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
|
||||
OG_REST_API_TOKEN,
|
||||
));
|
||||
curl_setopt ($curl, CURLOPT_SSLCERT, __DIR__ . '/../../../etc/ssl/WebConsole.crt.pem');
|
||||
curl_setopt ($curl, CURLOPT_SSLKEY, __DIR__ . '/../../../etc/ssl/WebConsole.key.pem');
|
||||
|
||||
switch ($type) {
|
||||
default:
|
||||
case GET:
|
||||
break;
|
||||
case POST:
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $json);
|
||||
}
|
||||
|
||||
$curl_response = curl_exec($curl);
|
||||
$info = curl_getinfo($curl);
|
||||
|
||||
if ($curl_response === false || $info['http_code'] != 200) {
|
||||
syslog(LOG_ERR, 'error occured during curl exec. Additioanl info: ' . print_r($info, TRUE));
|
||||
return 0;
|
||||
}
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
syslog(LOG_INFO, 'response '.$command.' ok!');
|
||||
|
||||
return json_decode($curl_response, true);
|
||||
}
|
||||
|
||||
public function convertMaskToCIDR($mask)
|
||||
{
|
||||
$bits = 0;
|
||||
$mask = explode(".", $mask);
|
||||
|
||||
foreach ($mask as $octect)
|
||||
$bits += strlen(str_replace("0", "", decbin($octect)));
|
||||
|
||||
return $bits;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
define('GET', 1);
|
||||
define('POST', 2);
|
||||
define('CUSTOM', 3);
|
||||
|
||||
define('OG_REST_CMD_CLIENTS', 'clients');
|
||||
define('OG_REST_CMD_WOL', 'wol');
|
||||
define('OG_REST_CMD_SESSION', 'session');
|
||||
define('OG_REST_CMD_RUN', 'shell/run');
|
||||
define('OG_REST_CMD_OUTPUT', 'shell/output');
|
||||
define('OG_REST_CMD_POWEROFF', 'poweroff');
|
||||
define('OG_REST_CMD_REBOOT', 'reboot');
|
||||
define('OG_REST_CMD_STOP', 'stop');
|
||||
define('OG_REST_CMD_REFRESH', 'refresh');
|
||||
define('OG_REST_CMD_HARDWARE', 'hardware');
|
||||
define('OG_REST_CMD_SOFTWARE', 'software');
|
||||
define('OG_REST_CMD_CREATE_IMAGE', 'image/create');
|
||||
define('OG_REST_CMD_RESTORE_IMAGE', 'image/restore');
|
||||
define('OG_REST_CMD_SETUP', 'setup');
|
||||
define('OG_REST_CMD_CREATE_BASIC_IMAGE', 'image/create/basic');
|
||||
define('OG_REST_CMD_CREATE_INCREMENTAL_IMAGE', 'image/create/incremental');
|
||||
define('OG_REST_CMD_RESTORE_BASIC_IMAGE', 'image/restore/basic');
|
||||
define('OG_REST_CMD_RESTORE_INCREMENTAL_IMAGE', 'image/restore/incremental');
|
||||
define('OG_REST_CMD_RUN_SCHEDULE', 'run/schedule');
|
||||
|
||||
define('OG_REST_PARAM_CLIENTS', 'clients');
|
||||
define('OG_REST_PARAM_ADDR', 'addr');
|
||||
define('OG_REST_PARAM_MAC', 'mac');
|
||||
define('OG_REST_PARAM_DISK', 'disk');
|
||||
define('OG_REST_PARAM_PART', 'partition');
|
||||
define('OG_REST_PARAM_RUN', 'run');
|
||||
define('OG_REST_PARAM_TYPE', 'type');
|
||||
define('OG_REST_PARAM_STATE', 'state');
|
||||
define('OG_REST_PARAM_NAME', 'name');
|
||||
define('OG_REST_PARAM_REPOS', 'repository');
|
||||
define('OG_REST_PARAM_ID', 'id');
|
||||
define('OG_REST_PARAM_CODE', 'code');
|
||||
define('OG_REST_PARAM_PROFILE', 'profile');
|
||||
define('OG_REST_PARAM_CACHE', 'cache');
|
||||
define('OG_REST_PARAM_CACHE_SIZE', 'cache_size');
|
||||
define('OG_REST_PARAM_FILE_SYSTEM', 'filesystem');
|
||||
define('OG_REST_PARAM_SIZE', 'size');
|
||||
define('OG_REST_PARAM_FORMAT', 'format');
|
||||
define('OG_REST_PARAM_PARTITION_SETUP', 'partition_setup');
|
||||
define('OG_REST_PARAM_SYNC_PARAMS', 'sync_params');
|
||||
define('OG_REST_PARAM_SYNC', 'sync');
|
||||
define('OG_REST_PARAM_DIFF', 'diff');
|
||||
define('OG_REST_PARAM_REMOVE', 'remove');
|
||||
define('OG_REST_PARAM_COMPRESS', 'compress');
|
||||
define('OG_REST_PARAM_CLEANUP', 'cleanup');
|
||||
define('OG_REST_PARAM_CLEANUP_CACHE', 'cleanup_cache');
|
||||
define('OG_REST_PARAM_REMOVE_DST', 'remove_dst');
|
||||
define('OG_REST_PARAM_PATH', 'path');
|
||||
define('OG_REST_PARAM_DIFF_ID', 'diff_id');
|
||||
define('OG_REST_PARAM_DIFF_NAME', 'diff_name');
|
||||
define('OG_REST_PARAM_METHOD', 'method');
|
||||
define('OG_REST_PARAM_ECHO', 'echo');
|
||||
?>
|
Loading…
Reference in New Issue