Merge pull request 'develop' (#12) from develop into main
testing/ogcore-api/pipeline/head This commit looks good Details

Reviewed-on: #12
jenkins-provision 0.5
Manuel Aranda Rosales 2024-10-25 11:05:19 +02:00
commit 3ee70ef7e6
244 changed files with 12000 additions and 717 deletions

14
.env
View File

@ -24,7 +24,7 @@ APP_SECRET=e95c7f17da15ce1b03d77ad655379c34
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8.0.32&charset=utf8mb4"
#DATABASE_URL="mysql://root:root@127.0.0.1:3336/dimio?serverVersion=8.0.32&charset=utf8mb4"
DATABASE_URL="mysql://root:root@ogcore-database:3306/ogcore?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
OG_1_DATABASE_URL="mysql://root:root@ogcore-database:3306/ogcore_old_og?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
@ -32,7 +32,7 @@ OG_1_DATABASE_URL="mysql://root:root@ogcore-database:3306/ogcore_old_og?serverVe
###< doctrine/doctrine-bundle ###
###> nelmio/cors-bundle ###
CORS_ALLOW_ORIGIN='^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$'
CORS_ALLOW_ORIGIN='*'
###< nelmio/cors-bundle ###
###> lexik/jwt-authentication-bundle ###
@ -40,3 +40,13 @@ JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem
JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem
JWT_PASSPHRASE=8b9154df37ffa91ef9186ce095324e39e50ff3b023bb1ed34383abd019ba4515
###< lexik/jwt-authentication-bundle ###
OGBOOT_API_URL=http://localhost:8085
OGDHCP_API_URL=http://localhost:8085
###> UDS ###
UDS_AUTH_LOGIN="Usuarios locales"
UDS_AUTH_USERNAME="natiqindel"
UDS_AUTH_PASSWORD="correct horse battery staple"
UDS_URL=https://localhost:8087/uds/rest/
###< UDS ###

95
Jenkinsfile vendored
View File

@ -1,46 +1,109 @@
pipeline {
agent {
node {
label 'jenkins-slave'
}
}
environment {
DOCKER_REPO = "opengnsys"
DOCKER_TAG = "${env.BUILD_NUMBER}"
DOCKER_IMAGE_NAME = "ogcore"
BRANCH_NAME = "${env.BRANCH_NAME}"
DOCKER_IDENTITY = "${DOCKER_REPO}/${DOCKER_IMAGE_NAME}-php:${BRANCH_NAME}-${DOCKER_TAG}"
DOCKER_IDENTITY_NGINX = "${DOCKER_REPO}/${DOCKER_IMAGE_NAME}-nginx:${BRANCH_NAME}-${DOCKER_TAG}"
DOCKER_COMPOSE_TEMPLATE = 'docker-compose-ci-template.yaml'
DOCKER_COMPOSE_FILE = 'docker-compose-ci-tmp.yaml'
}
stages {
stage('Build Environmen') {
stage ("Checkout") {
steps {
//Build environment
sh 'docker compose -f docker-compose-ci.yaml up --build -d'
checkout scm
}
}
stage('Build Environment') {
steps {
script {
docker.build("${DOCKER_IDENTITY}", '-f docker/Dockerfile-jenkins-php .')
docker.build("${DOCKER_IDENTITY_NGINX}", '-f docker/Dockerfile-nginx .')
}
}
}
stage(('Prepare Docker Composer')) {
steps {
sh """
sed 's|ogcore-php:static|${DOCKER_IDENTITY}|g; s|ogcore-nginx:static|${DOCKER_IDENTITY_NGINX}|g' ${DOCKER_COMPOSE_TEMPLATE} > ${DOCKER_COMPOSE_FILE}
cat ${DOCKER_COMPOSE_FILE}
"""
}
}
stage('Run containers') {
steps {
sh "docker compose -f ${DOCKER_COMPOSE_FILE} up -d"
}
}
stage('Install dependencies') {
steps {
// Install dependencies
sh 'docker exec ogcore-php composer install'
sh 'docker exec ogcore-php php bin/console lexik:jwt:generate-keypair --overwrite'
sh 'docker exec ogcore-php php bin/console doctrine:migrations:migrate --no-interaction'
sh 'docker exec ogcore-php php bin/console doctrine:fixtures:load --no-interaction'
// Create report directory
sh 'docker exec ogcore-php mkdir -p /report'
sh """
docker compose exec php mkdir -p /report
docker compose exec php composer install
docker compose exec php php bin/console lexik:jwt:generate-keypair --overwrite
docker compose exec php php bin/console doctrine:migrations:migrate --no-interaction
docker compose exec php php bin/console doctrine:fixtures:load --no-interaction
"""
}
}
stage('Tests') {
steps {
// Run tests
sh 'docker compose exec php bin/phpunit --log-junit /report/phpunit.xml'
sh 'docker cp ogcore-php:/report/phpunit.xml .'
sh """
docker compose exec php bin/phpunit --log-junit /report/phpunit.xml
"""
}
}
}
stage ("Publish Image") {
steps {
script {
docker.withRegistry('https://index.docker.io/v1/', 'docker-hub-credentials') {
docker.image("${DOCKER_IDENTITY}").push()
docker.image("${DOCKER_IDENTITY_NGINX}").push()
}
}
}
}
}
post {
always {
sh "docker compose -f ${DOCKER_COMPOSE_FILE} cp php:/report/phpunit.xml phpunit.xml"
// Publish JUnit test results
xunit (
thresholds: [ skipped(failureThreshold: '0') , failed(failureThreshold: '0') ],
tools: [ PHPUnit(pattern: 'phpunit.xml') ]
)
// Remove containers
sh 'docker compose -f docker-compose-ci.yaml down'
sh 'docker compose -f docker-compose-ci.yaml rm -f'
sh "docker compose -f ${DOCKER_COMPOSE_FILE} down"
sh "docker compose -f ${DOCKER_COMPOSE_FILE} rm -f"
sh "docker rmi ${DOCKER_IDENTITY}"
sh "docker rmi ${DOCKER_IDENTITY_NGINX}"
script {
def committerEmail = sh (
script: "git show -s --pretty=%ae",
returnStdout: true
).trim()
def buildResult = currentBuild.currentResult
mail to: committerEmail,
subject: "Opengnsys CI Build ${env.JOB_NAME} - ${env.BRANCH_NAME} - ${buildResult}",
body: """
<h1>Opengnsys CI Build ${JOB_NAME} - ${BRANCH_NAME} - ${buildResult}</h1>
<p>Build Number: ${BUILD_NUMBER}</p>
<p>Build URL: ${BUILD_URL}</p>º
Saludos cordiales,
Opengnsys CI
"""
}
}
}
}

View File

@ -69,6 +69,7 @@ docker exec ogcore-php php bin/console doctrine:migrations:migrate --no-interact
```sh
docker exec ogcore-php php bin/console doctrine:fixtures:load --no-interaction
docker exec ogcore-php php bin/console app:load-default-user-groups #cargamos los grupos por defecto
docker exec ogcore-php php bin/console app:load-default-commands #cargamos los commands por defecto
```
## UX Api Platform
@ -129,12 +130,11 @@ Una vez tengamos la base de datos cargada, podremos ejecutar las migraciones de
```sh
--- Migraciones de OpenGnsys. ---
docker exec ogcore-php php bin/console opengnsys:migration:organizational-unit #cargamos las unidades organizativas
docker exec ogcore-php php bin/console opengnsys:migration:hardware-profiles #cargamos los perfiles de hardware
docker exec ogcore-php php bin/console opengnsys:migration:hardware-profile #cargamos los perfiles de hardware
docker exec ogcore-php php bin/console opengnsys:migration:clients #cargamos los clientes
docker exec ogcore-php php bin/console opengnsys:migration:os #cargamos los sistemas operativos
docker exec ogcore-php php bin/console opengnsys:migration:partition #cargamos las particiones
docker exec ogcore-php php bin/console opengnsys:migration:image #cargamos las imagenes
docker exec ogcore-php php bin/console opengnsys:migration:software-profile #cargamos los software profiles
```
## Objetos de interés

View File

@ -2,12 +2,13 @@
"type": "project",
"license": "proprietary",
"minimum-stability": "stable",
"version": "0.5.0",
"prefer-stable": true,
"require": {
"php": ">=8.1",
"ext-ctype": "*",
"ext-iconv": "*",
"api-platform/core": "^3.3",
"api-platform/core": "^3.2",
"doctrine/dbal": "^3",
"doctrine/doctrine-bundle": "^2.12",
"doctrine/doctrine-migrations-bundle": "^3.3",
@ -25,6 +26,7 @@
"symfony/expression-language": "6.4.*",
"symfony/flex": "^2",
"symfony/framework-bundle": "6.4.*",
"symfony/http-client": "6.4.*",
"symfony/property-access": "6.4.*",
"symfony/property-info": "6.4.*",
"symfony/runtime": "6.4.*",
@ -89,7 +91,6 @@
"phpunit/phpunit": "^9.5",
"symfony/browser-kit": "6.4.*",
"symfony/css-selector": "6.4.*",
"symfony/http-client": "6.4.*",
"symfony/maker-bundle": "^1.59",
"symfony/phpunit-bridge": "^7.0",
"symfony/web-profiler-bundle": "^6.4",

970
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,8 @@ resources:
filters:
- 'api_platform.filter.client.order'
- 'api_platform.filter.client.search'
- 'api_platform.filter.client.boolean'
- 'api_platform.filter.client.exist'
ApiPlatform\Metadata\Get:
provider: App\State\Provider\ClientProvider
ApiPlatform\Metadata\Put:
@ -33,6 +34,21 @@ resources:
uriTemplate: /clients/change-organizational-units
controller: App\Controller\ChangeOrganizationalUnitAction
agent_status:
class: ApiPlatform\Metadata\Post
method: POST
input: false
uriTemplate: /clients/{uuid}/agent/status
controller: App\Controller\OgAgent\StatusAction
get_pxe:
class: ApiPlatform\Metadata\Post
method: POST
input: false
uriTemplate: /clients/server/{uuid}/get-pxe
controller: App\Controller\OgBoot\PxeBootFile\GetAction
properties:
App\Entity\Client:
id:

View File

@ -0,0 +1,39 @@
resources:
App\Entity\Command:
processor: App\State\Processor\CommandProcessor
input: App\Dto\Input\CommandInput
output: App\Dto\Output\CommandOutput
normalizationContext:
groups: ['default', 'command:read']
denormalizationContext:
groups: ['command:write']
operations:
ApiPlatform\Metadata\GetCollection:
provider: App\State\Provider\CommandProvider
filters:
- 'api_platform.filter.command.order'
- 'api_platform.filter.command.search'
- 'api_platform.filter.command.boolean'
ApiPlatform\Metadata\Get:
provider: App\State\Provider\CommandProvider
ApiPlatform\Metadata\Put:
provider: App\State\Provider\CommandProvider
ApiPlatform\Metadata\Patch:
provider: App\State\Provider\CommandProvider
ApiPlatform\Metadata\Post: ~
ApiPlatform\Metadata\Delete: ~
command_execute:
class: ApiPlatform\Metadata\Post
method: POST
input: App\Dto\Input\CommandExecuteInput
uriTemplate: /commands/{uuid}/execute
controller: App\Controller\CommandExecuteAction
properties:
App\Entity\Command:
id:
identifier: false
uuid:
identifier: true

View File

@ -0,0 +1,46 @@
resources:
App\Entity\CommandGroup:
processor: App\State\Processor\CommandGroupProcessor
input: App\Dto\Input\CommandGroupInput
output: App\Dto\Output\CommandGroupOutput
normalizationContext:
groups: ['default', 'command-group:read']
denormalizationContext:
groups: ['command-group:write']
operations:
ApiPlatform\Metadata\GetCollection:
provider: App\State\Provider\CommandGroupProvider
filters:
- 'api_platform.filter.command.order'
- 'api_platform.filter.command.search'
- 'api_platform.filter.command.boolean'
ApiPlatform\Metadata\Get:
provider: App\State\Provider\CommandGroupProvider
ApiPlatform\Metadata\Put:
provider: App\State\Provider\CommandGroupProvider
ApiPlatform\Metadata\Patch:
provider: App\State\Provider\CommandGroupProvider
ApiPlatform\Metadata\Post: ~
ApiPlatform\Metadata\Delete: ~
add_commands:
class: ApiPlatform\Metadata\Post
method: POST
input: App\Dto\Input\CommandGroupAddCommandsInput
uriTemplate: /command-groups/{uuid}/add-commands
controller: App\Controller\CommandGroupAddCommandsAction
command_group_execute:
class: ApiPlatform\Metadata\Post
method: POST
input: App\Dto\Input\CommandGroupExecuteInput
uriTemplate: /command-groups/{uuid}/execute
controller: App\Controller\CommandGroupExecuteAction
properties:
App\Entity\CommandGroup:
id:
identifier: false
uuid:
identifier: true

View File

@ -0,0 +1,32 @@
resources:
App\Entity\CommandTask:
processor: App\State\Processor\CommandTaskProcessor
input: App\Dto\Input\CommandTaskInput
output: App\Dto\Output\CommandTaskOutput
normalizationContext:
groups: ['default', 'command-task:read']
denormalizationContext:
groups: ['command-task:write']
operations:
ApiPlatform\Metadata\GetCollection:
provider: App\State\Provider\CommandTaskProvider
filters:
- 'api_platform.filter.command_task.order'
- 'api_platform.filter.command_task.search'
- 'api_platform.filter.command_task.boolean'
ApiPlatform\Metadata\Get:
provider: App\State\Provider\CommandTaskProvider
ApiPlatform\Metadata\Put:
provider: App\State\Provider\CommandTaskProvider
ApiPlatform\Metadata\Patch:
provider: App\State\Provider\CommandTaskProvider
ApiPlatform\Metadata\Post: ~
ApiPlatform\Metadata\Delete: ~
properties:
App\Entity\CommandTask:
id:
identifier: false
uuid:
identifier: true

View File

@ -0,0 +1,102 @@
resources:
App\Entity\OgLive:
processor: App\State\Processor\OgLiveProcessor
input: App\Dto\Input\OgLiveInput
output: App\Dto\Output\OgLiveOutput
normalizationContext:
groups: ['default', 'og-live:read']
denormalizationContext:
groups: ['og-live:write']
operations:
ApiPlatform\Metadata\GetCollection:
provider: App\State\Provider\OgLiveProvider
filters:
- 'api_platform.filter.og_live.order'
- 'api_platform.filter.og_live.search'
- 'api_platform.filter.og_live.boolean'
ApiPlatform\Metadata\Get:
provider: App\State\Provider\OgLiveProvider
ApiPlatform\Metadata\Put:
provider: App\State\Provider\OgLiveProvider
ApiPlatform\Metadata\Patch:
provider: App\State\Provider\OgLiveProvider
ApiPlatform\Metadata\Post: ~
ApiPlatform\Metadata\Delete: ~
oglives_sync:
class: ApiPlatform\Metadata\Post
method: POST
input: false
uriTemplate: /og-lives/sync
controller: App\Controller\OgBoot\OgLive\SyncAction
get_collection_oglives:
shortName: OgLive Server
description: Get collection of OgLive
class: ApiPlatform\Metadata\GetCollection
method: GET
input: false
uriTemplate: /og-lives/server/get-collection
controller: App\Controller\OgBoot\OgLive\GetCollectionAction
get_oglive:
shortName: OgLive Server
description: Get OgLive
class: ApiPlatform\Metadata\Get
method: GET
input: false
uriTemplate: /og-lives/server/{uuid}/get
controller: App\Controller\OgBoot\OgLive\GetAction
get_isos:
shortName: OgLive Server
description: Get Isos of OgLive
class: ApiPlatform\Metadata\GetCollection
method: GET
input: false
uriTemplate: /og-lives/server/get-isos
controller: App\Controller\OgBoot\OgLive\GetIsosAction
get_default:
shortName: OgLive Server
description: Get default OgLive
class: ApiPlatform\Metadata\GetCollection
method: GET
input: false
uriTemplate: /og-lives/server/get-default
controller: App\Controller\OgBoot\OgLive\GetDefaultAction
set_default:
shortName: OgLive Server
description: Set default OgLive
class: ApiPlatform\Metadata\Post
method: POST
input: false
uriTemplate: /og-lives/server/{uuid}/set-default
controller: App\Controller\OgBoot\OgLive\SetDefaultAction
install:
shortName: OgLive Server
description: Install OgLive
class: ApiPlatform\Metadata\Post
method: POST
input: false
uriTemplate: /og-lives/server/{uuid}/install
controller: App\Controller\OgBoot\OgLive\InstallAction
uninstall:
shortName: OgLive Server
description: Uninstall OgLive
class: ApiPlatform\Metadata\Post
method: POST
input: false
uriTemplate: /og-lives/server/{uuid}/uninstall
controller: App\Controller\OgBoot\OgLive\UninstallAction
properties:
App\Entity\OgLive:
id:
identifier: false
uuid:
identifier: true

View File

@ -13,6 +13,8 @@ resources:
filters:
- 'api_platform.filter.organizational_unit.order'
- 'api_platform.filter.organizational_unit.search'
- 'api_platform.filter.organizational_unit.group_filter'
ApiPlatform\Metadata\Get:
security: 'is_granted("ORGANIZATIONAL_UNIT_VIEW", object)'
provider: App\State\Provider\OrganizationalUnitProvider

View File

@ -0,0 +1,103 @@
resources:
App\Entity\PxeTemplate:
processor: App\State\Processor\PxeTemplateProcessor
input: App\Dto\Input\PxeTemplateInput
output: App\Dto\Output\PxeTemplateOutput
normalizationContext:
groups: ['default', 'pxe-template:read']
denormalizationContext:
groups: ['pxe-template:write']
operations:
ApiPlatform\Metadata\GetCollection:
provider: App\State\Provider\PxeTemplateProvider
filters:
- 'api_platform.filter.pxe_template.order'
- 'api_platform.filter.pxe_template.search'
- 'api_platform.filter.pxe_template.boolean'
ApiPlatform\Metadata\Get:
provider: App\State\Provider\PxeTemplateProvider
ApiPlatform\Metadata\Put:
provider: App\State\Provider\PxeTemplateProvider
ApiPlatform\Metadata\Patch:
provider: App\State\Provider\PxeTemplateProvider
ApiPlatform\Metadata\Post: ~
ApiPlatform\Metadata\Delete: ~
pxe_template_sync:
class: ApiPlatform\Metadata\Post
method: POST
input: false
uriTemplate: /pxe-templates/sync
controller: App\Controller\OgBoot\PxeTemplate\SyncAction
get_collection_templates:
shortName: PxeTemplate Server
description: Get collection of PxeTemplate
class: ApiPlatform\Metadata\GetCollection
method: GET
input: false
uriTemplate: /pxe-templates/server/get-collection
controller: App\Controller\OgBoot\PxeTemplate\GetCollectionAction
get_template:
shortName: PxeTemplate Server
description: Get PxeTemplate
class: ApiPlatform\Metadata\Get
method: GET
input: false
uriTemplate: /pxe-templates/server/{uuid}/get
controller: App\Controller\OgBoot\PxeTemplate\GetAction
post_template:
shortName: PxeTemplate Server
description: Create PxeTemplate
class: ApiPlatform\Metadata\Post
method: POST
input: false
uriTemplate: /pxe-templates/server/{uuid}/post
controller: App\Controller\OgBoot\PxeTemplate\PostAction
delete_template:
shortName: PxeTemplate Server
description: Delete PxeTemplate
class: ApiPlatform\Metadata\Post
method: POST
input: false
uriTemplate: /pxe-templates/server/{uuid}/delete
controller: App\Controller\OgBoot\PxeTemplate\DeleteAction
template_add_clients:
shortName: PxeTemplate Server
description: Add Client to PxeTemplate
class: ApiPlatform\Metadata\Post
method: POST
input: App\Dto\Input\PxeTemplateAddClientsInput
uriTemplate: /pxe-templates/{uuid}/add-clients
controller: App\Controller\OgBoot\PxeTemplate\AddClientAction
template_sync_client:
shortName: PxeTemplate Server
description: Sync Client to PxeTemplate
class: ApiPlatform\Metadata\Post
method: POST
input: App\Dto\Input\PxeTemplateSyncClientInput
uriTemplate: /pxe-templates/{uuid}/sync-client
controller: App\Controller\OgBoot\PxeBootFile\PostAction
template_delete_client:
shortName: PxeTemplate Server
description: Add Client to PxeTemplate
class: ApiPlatform\Metadata\Post
method: POST
input: App\Dto\Input\PxeTemplateDeleteClientInput
uriTemplate: /pxe-templates/{uuid}/delete-client
controller: App\Controller\OgBoot\PxeTemplate\DeleteClientAction
properties:
App\Entity\PxeTemplate:
id:
identifier: false
uuid:
identifier: true

View File

@ -0,0 +1,37 @@
resources:
App\Entity\RemoteCalendar:
processor: App\State\Processor\RemoteCalendarProcessor
input: App\Dto\Input\RemoteCalendarInput
output: App\Dto\Output\RemoteCalendarOutput
normalizationContext:
groups: ['default', 'remote-calendar:read']
denormalizationContext:
groups: ['remote-calendar:write']
operations:
ApiPlatform\Metadata\GetCollection:
provider: App\State\Provider\RemoteCalendarProvider
filters:
- 'api_platform.filter.remote_calendar.order'
- 'api_platform.filter.remote_calendar.search'
ApiPlatform\Metadata\Get:
provider: App\State\Provider\RemoteCalendarProvider
ApiPlatform\Metadata\Put:
provider: App\State\Provider\RemoteCalendarProvider
ApiPlatform\Metadata\Patch:
provider: App\State\Provider\RemoteCalendarProvider
ApiPlatform\Metadata\Post: ~
ApiPlatform\Metadata\Delete: ~
sync_uds:
class: ApiPlatform\Metadata\Post
method: POST
uriTemplate: /remote-calendars/{uuid}/sync-uds
controller: App\Controller\UDS\RemoteCalendarSyncUdsAction
properties:
App\Entity\RemoteCalendar:
id:
identifier: false
uuid:
identifier: true

View File

@ -0,0 +1,31 @@
resources:
App\Entity\RemoteCalendarRule:
processor: App\State\Processor\RemoteCalendarRuleProcessor
input: App\Dto\Input\RemoteCalendarRuleInput
output: App\Dto\Output\RemoteCalendarRuleOutput
normalizationContext:
groups: ['default', 'remote-calendar-rule:read']
denormalizationContext:
groups: ['remote-calendar-rule:write']
operations:
ApiPlatform\Metadata\GetCollection:
provider: App\State\Provider\RemoteCalendarRuleProvider
filters:
- 'api_platform.filter.remote_calendar_rule.order'
- 'api_platform.filter.remote_calendar_rule.search'
ApiPlatform\Metadata\Get:
provider: App\State\Provider\RemoteCalendarRuleProvider
ApiPlatform\Metadata\Put:
provider: App\State\Provider\RemoteCalendarRuleProvider
ApiPlatform\Metadata\Patch:
provider: App\State\Provider\RemoteCalendarRuleProvider
ApiPlatform\Metadata\Post: ~
ApiPlatform\Metadata\Delete: ~
properties:
App\Entity\RemoteCalendarRule:
id:
identifier: false
uuid:
identifier: true

View File

@ -11,10 +11,13 @@ resources:
ApiPlatform\Metadata\GetCollection:
provider: App\State\Provider\SoftwareProfileProvider
filters:
- 'api_platform.filter.software.order'
- 'api_platform.filter.software.search'
- 'api_platform.filter.software_profile.order'
- 'api_platform.filter.software_profile.search'
ApiPlatform\Metadata\Get:
provider: App\State\Provider\SoftwareProfileProvider
normalizationContext:
groups: ['software-profile:item:get', 'software-profile:read:collection:short']
ApiPlatform\Metadata\Put:
provider: App\State\Provider\SoftwareProfileProvider
ApiPlatform\Metadata\Patch:

View File

@ -0,0 +1,121 @@
resources:
App\Entity\Subnet:
processor: App\State\Processor\SubnetProcessor
input: App\Dto\Input\SubnetInput
output: App\Dto\Output\SubnetOutput
normalizationContext:
groups: ['default', 'subnet:read']
denormalizationContext:
groups: ['subnet:write']
operations:
ApiPlatform\Metadata\GetCollection:
provider: App\State\Provider\SubnetProvider
filters:
- 'api_platform.filter.subnet.order'
- 'api_platform.filter.subnet.search'
ApiPlatform\Metadata\Get:
provider: App\State\Provider\SubnetProvider
ApiPlatform\Metadata\Put:
provider: App\State\Provider\SubnetProvider
ApiPlatform\Metadata\Patch:
provider: App\State\Provider\SubnetProvider
ApiPlatform\Metadata\Post: ~
ApiPlatform\Metadata\Delete: ~
subnet_sync:
class: ApiPlatform\Metadata\Post
method: POST
input: false
uriTemplate: /subnets/sync
controller: App\Controller\OgDhcp\Subnet\SyncAction
get_collection_subnets:
shortName: Subnet Server
description: Get collection of Subnet
class: ApiPlatform\Metadata\GetCollection
method: GET
input: false
uriTemplate: /og-dhcp/server/get-collection
controller: App\Controller\OgDhcp\Subnet\GetCollectionAction
get_subnet:
shortName: Subnet Server
description: Get Subnet
class: ApiPlatform\Metadata\Get
method: GET
input: false
uriTemplate: /og-dhcp/server/{uuid}/get
controller: App\Controller\OgDhcp\Subnet\GetAction
post_subnet:
shortName: Subnet Server
description: Create Subnet
class: ApiPlatform\Metadata\Post
method: POST
input: false
uriTemplate: /og-dhcp/server/{uuid}/post
controller: App\Controller\OgDhcp\Subnet\PostAction
put_subnet:
shortName: Subnet Server
description: Create Subnet
class: ApiPlatform\Metadata\Put
method: PUT
input: false
uriTemplate: /og-dhcp/server/{uuid}/put
controller: App\Controller\OgDhcp\Subnet\PutAction
delete_subnet:
shortName: Subnet Server
description: Delete Subnet
class: ApiPlatform\Metadata\Delete
method: DELETE
input: false
uriTemplate: /og-dhcp/server/{uuid}/delete
controller: App\Controller\OgDhcp\Subnet\DeleteAction
post_host:
shortName: Subnet Server Hosts
description: Post Host to Subnet
class: ApiPlatform\Metadata\Post
method: POST
input: App\Dto\Input\SubnetAddHostInput
uriTemplate: /og-dhcp/server/{uuid}/post-host
controller: App\Controller\OgDhcp\Subnet\PostHostAction
get_hosts:
shortName: Subnet Server Hosts
description: Get Hosts of Subnet
class: ApiPlatform\Metadata\Get
method: GET
input: false
uriTemplate: /og-dhcp/server/{uuid}/get-hosts
controller: App\Controller\OgDhcp\Subnet\GetHostsAction
put_host:
shortName: Subnet Server Hosts
description: Put Host of Subnet
class: ApiPlatform\Metadata\Put
method: PUT
input: false
uriTemplate: /og-dhcp/server/{uuid}/put-host
controller: App\Controller\OgDhcp\Subnet\PutHostAction
delete_host:
shortName: Subnet Server Hosts
description: Delete Host of Subnet
class: ApiPlatform\Metadata\Delete
method: DELETE
input: false
read: false
uriTemplate: /og-dhcp/server/{uuid}/delete-host/{clientUuid}
controller: App\Controller\OgDhcp\Subnet\DeleteHostAction
properties:
App\Entity\Subnet:
id:
identifier: false
uuid:
identifier: true

View File

@ -0,0 +1,23 @@
resources:
App\Entity\Trace:
output: App\Dto\Output\TraceOutput
normalizationContext:
groups: ['default', 'trace:read']
operations:
ApiPlatform\Metadata\GetCollection:
provider: App\State\Provider\TraceProvider
filters:
- 'api_platform.filter.trace.order'
- 'api_platform.filter.trace.search'
ApiPlatform\Metadata\Get:
provider: App\State\Provider\TraceProvider
order:
createdAt: DESC
properties:
App\Entity\Trace:
id:
identifier: false
uuid:
identifier: true

View File

@ -1,43 +1,26 @@
api_platform:
title: 'OgCore Api'
description: 'Api Documentation for OgCore'
version: 1.0.0
path_segment_name_generator: 'api_platform.path_segment_name_generator.dash'
version: 0.5.0
path_segment_name_generator: api_platform.path_segment_name_generator.dash
defaults:
pagination_client_items_per_page: true
collection:
pagination:
items_per_page_parameter_name: 'itemsPerPage'
formats:
jsonld: [ 'application/ld+json' ]
jsonhal: [ 'application/hal+json' ]
jsonapi: [ 'application/vnd.api+json' ]
json: [ 'application/json' ]
xml: [ 'application/xml', 'text/xml' ]
yaml: [ 'application/x-yaml' ]
csv: [ 'text/csv' ]
html: [ 'text/html' ]
json: [ 'application/json' ]
csv: [ 'text/csv' ]
patch_formats:
jsonld: ['application/ld+json', 'application/json']
mapping:
paths: ['%kernel.project_dir%/config/api_platform', '%kernel.project_dir%/src/Dto']
use_symfony_listeners: true
collection:
pagination:
items_per_page_parameter_name: 'itemsPerPage'
defaults:
pagination_client_items_per_page: true
denormalization_context:
allow_extra_attributes: false
cache_headers:
vary: [ 'Content-Type', 'Authorization', 'Origin' ]
extra_properties:
standard_put: true
rfc_7807_compliant_errors: true
event_listeners_backward_compatibility_layer: false
keep_legacy_inflector: true
docs_formats:
jsonld: ['application/ld+json']
jsonopenapi: ['application/vnd.openapi+json']
html: ['text/html']
swagger:
versions: [3]
api_keys:
apiKey:
name: Authorization
type: header
type: header
exception_to_status:
Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException: 409

View File

@ -18,6 +18,11 @@ framework:
php_errors:
log: true
http_client:
default_options:
verify_host: false
verify_peer: false
when@test:
framework:
test: true

View File

@ -29,7 +29,8 @@ security:
- { path: ^/$, roles: PUBLIC_ACCESS } # Allows accessing the Swagger UI
- { path: ^/docs, roles: PUBLIC_ACCESS } # Allows accessing the Swagger UI docs
- { path: ^/auth/login, roles: PUBLIC_ACCESS }
- { path: ^/opengnsys/rest/, roles: PUBLIC_ACCESS }
- { path: ^/opengnsys/rest, roles: PUBLIC_ACCESS }
- { path: ^/og-lives/install/webhook, roles: PUBLIC_ACCESS }
- { path: ^/auth/refresh, roles: PUBLIC_ACCESS }
- { path: ^/, roles: IS_AUTHENTICATED_FULLY }

View File

@ -4,11 +4,18 @@ imports:
parameters:
services:
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
bind:
$ogBootApiUrl: '%env(OGBOOT_API_URL)%'
$ogDhcpApiUrl: '%env(OGDHCP_API_URL)%'
$udsAPIurl: '%env(UDS_URL)%'
$udsAuthLogin: '%env(UDS_AUTH_LOGIN)%'
$udsAuthUsername: '%env(UDS_AUTH_USERNAME)%'
$udsAuthPassword: '%env(UDS_AUTH_PASSWORD)%'
App\:
resource: '../src/'
exclude:
@ -101,3 +108,47 @@ services:
bind:
$collectionProvider: '@api_platform.doctrine.orm.state.collection_provider'
$itemProvider: '@api_platform.doctrine.orm.state.item_provider'
App\State\Provider\OgLiveProvider:
bind:
$collectionProvider: '@api_platform.doctrine.orm.state.collection_provider'
$itemProvider: '@api_platform.doctrine.orm.state.item_provider'
App\State\Provider\RemoteCalendarProvider:
bind:
$collectionProvider: '@api_platform.doctrine.orm.state.collection_provider'
$itemProvider: '@api_platform.doctrine.orm.state.item_provider'
App\State\Provider\CommandProvider:
bind:
$collectionProvider: '@api_platform.doctrine.orm.state.collection_provider'
$itemProvider: '@api_platform.doctrine.orm.state.item_provider'
App\State\Provider\PxeTemplateProvider:
bind:
$collectionProvider: '@api_platform.doctrine.orm.state.collection_provider'
$itemProvider: '@api_platform.doctrine.orm.state.item_provider'
App\State\Provider\CommandGroupProvider:
bind:
$collectionProvider: '@api_platform.doctrine.orm.state.collection_provider'
$itemProvider: '@api_platform.doctrine.orm.state.item_provider'
App\State\Provider\CommandTaskProvider:
bind:
$collectionProvider: '@api_platform.doctrine.orm.state.collection_provider'
$itemProvider: '@api_platform.doctrine.orm.state.item_provider'
App\State\Provider\SubnetProvider:
bind:
$collectionProvider: '@api_platform.doctrine.orm.state.collection_provider'
$itemProvider: '@api_platform.doctrine.orm.state.item_provider'
App\State\Provider\TraceProvider:
bind:
$collectionProvider: '@api_platform.doctrine.orm.state.collection_provider'
$itemProvider: '@api_platform.doctrine.orm.state.item_provider'
App\State\Provider\RemoteCalendarRuleProvider:
bind:
$collectionProvider: '@api_platform.doctrine.orm.state.collection_provider'
$itemProvider: '@api_platform.doctrine.orm.state.item_provider'

View File

@ -1,4 +1,16 @@
services:
api_platform.filter.calendar.order:
parent: 'api_platform.doctrine.orm.order_filter'
arguments:
$properties: { 'id': ~, 'name': ~,}
$orderParameterName: 'order'
tags: [ 'api_platform.filter' ]
api_platform.filter.calendar.search:
parent: 'api_platform.doctrine.orm.search_filter'
arguments: [ { 'id': 'exact', 'name': 'exact'} ]
tags: [ 'api_platform.filter' ]
api_platform.filter.client.order:
parent: 'api_platform.doctrine.orm.order_filter'
arguments:
@ -8,7 +20,29 @@ services:
api_platform.filter.client.search:
parent: 'api_platform.doctrine.orm.search_filter'
arguments: [ { 'id': 'exact', 'name': 'partial', 'serialNumber': 'exact', organizationalUnit.id: 'exact' } ]
arguments: [ { 'id': 'exact', 'name': 'partial', 'serialNumber': 'exact', 'template.id': 'exact', organizationalUnit.id: 'exact', mac: 'exact', ip: 'exact' } ]
tags: [ 'api_platform.filter' ]
api_platform.filter.client.exist:
parent: 'api_platform.doctrine.orm.exists_filter'
arguments: [{'subnet': ~, 'template': ~ }]
tags: [ 'api_platform.filter' ]
api_platform.filter.command.order:
parent: 'api_platform.doctrine.orm.order_filter'
arguments:
$properties: { 'id': ~, 'name': ~ }
$orderParameterName: 'order'
tags: [ 'api_platform.filter' ]
api_platform.filter.command.search:
parent: 'api_platform.doctrine.orm.search_filter'
arguments: [ { 'id': 'exact', 'name': 'partial'} ]
tags: [ 'api_platform.filter' ]
api_platform.filter.command.boolean:
parent: 'api_platform.doctrine.orm.boolean_filter'
arguments: [ { 'enabled': ~ } ]
tags: [ 'api_platform.filter' ]
api_platform.filter.hardware.order:
@ -18,6 +52,35 @@ services:
$orderParameterName: 'order'
tags: [ 'api_platform.filter' ]
api_platform.filter.image.order:
parent: 'api_platform.doctrine.orm.order_filter'
arguments:
$properties: { 'id': ~, 'name': ~ }
$orderParameterName: 'order'
tags: [ 'api_platform.filter' ]
api_platform.filter.image.search:
parent: 'api_platform.doctrine.orm.search_filter'
arguments: [ { 'id': 'exact', 'name': 'partial', } ]
tags: [ 'api_platform.filter' ]
api_platform.filter.og_live.order:
parent: 'api_platform.doctrine.orm.order_filter'
arguments:
$properties: { 'id': ~, 'name': ~ }
$orderParameterName: 'order'
tags: [ 'api_platform.filter' ]
api_platform.filter.og_live.search:
parent: 'api_platform.doctrine.orm.search_filter'
arguments: [ { 'id': 'exact', 'name': 'partial', } ]
tags: [ 'api_platform.filter' ]
api_platform.filter.og_live.boolean:
parent: 'api_platform.doctrine.orm.boolean_filter'
arguments: [ { 'isDefault': ~, 'installed': ~ } ]
tags: [ 'api_platform.filter' ]
api_platform.filter.hardware.search:
parent: 'api_platform.doctrine.orm.search_filter'
arguments: [ { 'id': 'exact', 'name': 'partial' } ]
@ -35,6 +98,18 @@ services:
arguments: [ { 'id': 'exact', 'name': 'exact', 'title': 'exact' } ]
tags: [ 'api_platform.filter' ]
api_platform.filter.operative_system.order:
parent: 'api_platform.doctrine.orm.order_filter'
arguments:
$properties: { 'id': ~, 'name': ~ }
$orderParameterName: 'order'
tags: [ 'api_platform.filter' ]
api_platform.filter.operative_system.search:
parent: 'api_platform.doctrine.orm.search_filter'
arguments: [ { 'id': 'exact', 'name': 'partial' } ]
tags: [ 'api_platform.filter' ]
api_platform.filter.organizational_unit.order:
parent: 'api_platform.doctrine.orm.order_filter'
arguments:
@ -47,6 +122,11 @@ services:
arguments: [ { id: 'exact', name: 'partial', type: 'exact', parent.id: 'exact'} ]
tags: [ 'api_platform.filter' ]
api_platform.filter.organizational_unit.group_filter:
parent: 'api_platform.serializer.group_filter'
arguments: [ 'groups', true, ['organizational-unit:read:collection:short'] ]
tags: [ 'api_platform.filter' ]
api_platform.filter.partition.order:
parent: 'api_platform.doctrine.orm.order_filter'
arguments:
@ -56,7 +136,89 @@ services:
api_platform.filter.partition.search:
parent: 'api_platform.doctrine.orm.search_filter'
arguments: [ { 'id': 'exact', 'usage': 'exact', 'diskNumber': 'exact' } ]
arguments: [ { 'id': 'exact', 'usage': 'exact', 'diskNumber': 'exact', 'client.id': 'exact' } ]
tags: [ 'api_platform.filter' ]
api_platform.filter.pxe_template.order:
parent: 'api_platform.doctrine.orm.order_filter'
arguments:
$properties: { 'id': ~, 'name': ~ }
$orderParameterName: 'order'
tags: [ 'api_platform.filter' ]
api_platform.filter.pxe_boot_file.search:
parent: 'api_platform.doctrine.orm.search_filter'
arguments: [ { 'id': 'exact', 'template': exact } ]
tags: [ 'api_platform.filter' ]
api_platform.filter.pxe_template.search:
parent: 'api_platform.doctrine.orm.search_filter'
arguments: [ { 'id': 'exact', 'name': 'partial', } ]
tags: [ 'api_platform.filter' ]
api_platform.filter.pxe_template.boolean:
parent: 'api_platform.doctrine.orm.boolean_filter'
arguments: [ { 'synchronized': ~ } ]
tags: [ 'api_platform.filter' ]
api_platform.filter.remote_calendar.order:
parent: 'api_platform.doctrine.orm.order_filter'
arguments:
$properties: { 'id': ~, 'name': ~ }
$orderParameterName: 'order'
tags: [ 'api_platform.filter' ]
api_platform.filter.remote_calendar.search:
parent: 'api_platform.doctrine.orm.search_filter'
arguments: [ { 'id': 'exact', 'name': 'partial', } ]
tags: [ 'api_platform.filter' ]
api_platform.filter.software.order:
parent: 'api_platform.doctrine.orm.order_filter'
arguments:
$properties: { 'id': ~, 'name': ~ }
$orderParameterName: 'order'
tags: [ 'api_platform.filter' ]
api_platform.filter.software.search:
parent: 'api_platform.doctrine.orm.search_filter'
arguments: [ { 'id': 'exact', 'name': 'partial', type: 'exact'} ]
tags: [ 'api_platform.filter' ]
api_platform.filter.software_profile.order:
parent: 'api_platform.doctrine.orm.order_filter'
arguments:
$properties: { 'id': ~, 'description': ~ }
$orderParameterName: 'order'
tags: [ 'api_platform.filter' ]
api_platform.filter.software_profile.search:
parent: 'api_platform.doctrine.orm.search_filter'
arguments: [ { 'id': 'exact', 'description': 'partial' } ]
tags: [ 'api_platform.filter' ]
api_platform.filter.subnet.order:
parent: 'api_platform.doctrine.orm.order_filter'
arguments:
$properties: { 'id': ~, 'name': ~ }
$orderParameterName: 'order'
tags: [ 'api_platform.filter' ]
api_platform.filter.subnet.search:
parent: 'api_platform.doctrine.orm.search_filter'
arguments: [ { 'id': 'exact', 'name': 'partial', ip: 'exact', nextServer: 'exact', netmask: 'exact', bootFileName: 'partial'} ]
tags: [ 'api_platform.filter' ]
api_platform.filter.trace.search:
parent: 'api_platform.doctrine.orm.search_filter'
arguments: [ { 'id': 'exact', 'command.id': 'exact', 'client.id': 'exact' } ]
tags: [ 'api_platform.filter' ]
api_platform.filter.trace.order:
parent: 'api_platform.doctrine.orm.order_filter'
arguments:
$properties: { 'id': ~, 'command': ~ }
$orderParameterName: 'order'
tags: [ 'api_platform.filter' ]
api_platform.filter.user.order:

View File

@ -0,0 +1,51 @@
services:
database:
container_name: ogcore-database
image: mariadb:10.11
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: ogcore
MYSQL_PASSWORD: root
MYSQL_USER: admin
ports:
- 3336:3306
volumes:
- database_data:/var/lib/mysql
networks:
- ogcore-network
nginx:
container_name: ogcore-nginx
build:
context: .
dockerfile: ./docker/Dockerfile-nginx
depends_on:
- php
ports:
- 8080:80
volumes:
- ./public:/var/www/html/public:cached
networks:
- ogcore-network
image: ogcore-nginx:static
php:
container_name: ogcore-php
build:
context: .
dockerfile: ./docker/Dockerfile-jenkins-php
depends_on:
- database
environment:
XDEBUG_CLIENT_HOST: 127.17.0.1
XDEBUG_CLIENT_PORT: 9003
PHP_IDE_CONFIG: serverName=ogcore
networks:
- ogcore-network
image: ogcore-php:static
volumes:
database_data:
networks:
ogcore-network:

View File

@ -23,8 +23,10 @@ services:
- php
ports:
- 8080:80
- 8443:443 # Añadir el puerto 443
volumes:
- ./public:/var/www/html/public:cached
- ./docker/certs:/etc/nginx/certs # Montar certificados en Nginx
networks:
- ogcore-network

View File

@ -1,2 +1,7 @@
FROM nginx:latest
COPY ./docker/default.conf /etc/nginx/conf.d/default.conf
# Copiar el archivo de configuración de Nginx
COPY ./docker/default.conf /etc/nginx/conf.d/default.conf
# Copiar los certificados SSL
COPY ./docker/certs /etc/nginx/certs

View File

@ -28,3 +28,14 @@ RUN apk del -f .build-deps
COPY ./docker/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
# Generate SSH keys
RUN ssh-keygen -t rsa -b 4096 -f /root/.ssh/id_rsa -N ""
# Optionally, copy public key to a specific location
RUN cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys
# Expose any ports you may need
EXPOSE 9000
# Command to run the PHP-FPM server
CMD ["php-fpm"]

View File

@ -0,0 +1,28 @@
-----BEGIN CERTIFICATE-----
MIIExTCCAq2gAwIBAgICEAEwDQYJKoZIhvcNAQELBQAwSTELMAkGA1UEBhMCRVMx
DzANBgNVBAgMBk1hZHJpZDEPMA0GA1UEBwwGTWFkcmlkMRgwFgYDVQQDDA9jYS51
ZHMtdGVzdC5uZXQwHhcNMjQxMDA5MTQyODM3WhcNMjUxMDE5MTQyODM3WjBNMQsw
CQYDVQQGEwJFUzEPMA0GA1UECAwGTWFkcmlkMQ8wDQYDVQQHDAZNYWRyaWQxHDAa
BgNVBAMME29nY29yZS51ZHMtdGVzdC5uZXQwggEiMA0GCSqGSIb3DQEBAQUAA4IB
DwAwggEKAoIBAQDaT0uiHcCwxUtRiJAhMI1VBuUohIzQgBQ1pwOa8gfwJZGn+p5p
T6qVrDb2RGWL8kJyR0tohQ6BxwVirAYTs0Az2EzZrh26gAlMhEsmQdWjQuWeHiRk
tp+6ELfATSd97LwMe5KgJl80JYQDVHxryPxPTgbxB3tjmp8ErcrhQ58Omq2D6bnd
xrKCbgfSoZP+ZyqKY3sNbHIX3632zSwHnu8on2ltZiYbbs1I29onysM4Zj2eAjZP
ot3pTzt4uIYV+i0fyY3+STvBda10bgUsoFWAVcdG310oVsginkFbpnhZPPueUklw
YtsXPq/yPJwn/tIcbEZ7TO7Pvtlh9RqTne9VAgMBAAGjgbIwga8wHgYDVR0RBBcw
FYITb2djb3JlLnVkcy10ZXN0Lm5ldDAdBgNVHQ4EFgQUS+4OUtWxVvTVc1odUFUO
UR3dURswbgYDVR0jBGcwZaFNpEswSTELMAkGA1UEBhMCRVMxDzANBgNVBAgMBk1h
ZHJpZDEPMA0GA1UEBwwGTWFkcmlkMRgwFgYDVQQDDA9jYS51ZHMtdGVzdC5uZXSC
FECd/NYwzaJTHtQ002YnOD3ZKLs0MA0GCSqGSIb3DQEBCwUAA4ICAQAeHA6/lJIv
hQTySWOOLhnuWcej1DmQhbDzyrylLUfJe86qV7QCLpasXabDpOQzTK5yBkjCWtV2
YiXNx6eT1iGbs70+5fITjj2vhAT9bxi4WH49xU4q+vfxlfxTkA4/ZXTEEmb+B91Q
BVEF/7f13UiGV2yu4xbDptr98v/55OeycBgwLdNN7uw7EP6WK8ryLxlxvF+nqt1n
YHof/QqRJze3FKHlGhGvx1I3SEE+VwWW5hVbde3HkwlORf5ABr4fxbvudL+kwtMi
HmYV2oYvkYQZK0Vfcua0WAn9vKVBgnF6tXdqJTPG7p91dVe7bIbUdFgNBVBdh/md
SdESFWCghPQ6WYoB7/1WfPKVQ/0IBe7l8Yx+piNNl4WW2M7lOGf8mbBWUHNAgJjD
2u3440PfsPJgBniUuV4ILNhRNGbAjdk86oU8w2Vg6WR7xsQIBcukrHEm5wEW2RkW
bZMclPyUOzHh1l4dQZTyOp2LxYNqtfYXQuPDT6tvZV5hLuLMqQfdLVxuoi3KOgo2
GfaolX2sW/sA4fx1FAvEvEq7zEvchpocL3EYa/aUNySxMrgjKMc3AtyLYF48D8M7
1LZMj61TaPWUUalM/u32fEHhqOXJ1o0VX3gCY7c+hKhGFee8Aiyk/hrB2ED/Q/vR
cssM+sHHNwSYI/L+bjEkJDQtVZEztcQODQ==
-----END CERTIFICATE-----

View File

@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDaT0uiHcCwxUtR
iJAhMI1VBuUohIzQgBQ1pwOa8gfwJZGn+p5pT6qVrDb2RGWL8kJyR0tohQ6BxwVi
rAYTs0Az2EzZrh26gAlMhEsmQdWjQuWeHiRktp+6ELfATSd97LwMe5KgJl80JYQD
VHxryPxPTgbxB3tjmp8ErcrhQ58Omq2D6bndxrKCbgfSoZP+ZyqKY3sNbHIX3632
zSwHnu8on2ltZiYbbs1I29onysM4Zj2eAjZPot3pTzt4uIYV+i0fyY3+STvBda10
bgUsoFWAVcdG310oVsginkFbpnhZPPueUklwYtsXPq/yPJwn/tIcbEZ7TO7Pvtlh
9RqTne9VAgMBAAECggEADthSi9EbH8oiv4YaSu96xNvlrFYrHyh+d1GGmLw5lvZv
C62qpP2iW3AtAp0PDK+qHgxED/TwUhne/2E0PpWzWXMtcqX45ow7VaUvWQgkB2iO
paxmDCUxAl2NqTl15IW7GdwzUcmaMrkUW4ecuFWf9qKXLT+1f8XtZ0uMHrpS8BKr
bDM5oeushD6/ES32ecBIG3eJafSMESUux1fq/frzHEajS0fkYqFxi2uLYJdPLXC/
YdVan7sIxOU3gxRROFDYLJ1uaksvUMM31oIujuxngdLTrf/K61RJGBFMeu1UIfrO
v6/9tqZgLIPTaC1nYMxjD+AtkwlY4C5vsPa8+jKtcQKBgQDz16/d/YSPxoa1QyPD
Ae/z+l13DGdk2+PdDavoyb1j11qwl4pgSGIA2uR3XeXg/dtmZaFk+KXUC+mHPsiM
TvxjoqjzP8LMXPJkRRzzTAwMjYzI8/ZAmCW+4q4Sxv3Dw4UQd0tCYi9ruMtXhnqp
agMKT2CNAikmbWdIu4S5uR6GDQKBgQDlMbfB5yJQsanW29VEJkUv+JBKZvxC7v59
2EmZEbW1hqYHR7PA2qvSnNXvsQKRIcJtmrzf3koDhXN3mw59deBgT5FsUQCGxoK8
ALMYMKiYcCNLp1rpxoz63lFnSzpD+f2dLBj0sac5Ufw17O6Fjs5+ZqND32UaEXFW
CLrjBpPEaQKBgAjXIQEjV9L+l5Oqw3kmcNSflxPh1z3I2xIAlOLzrXIZNKiCVfn3
pdXyGaZaOSNXEMU9mgRXH2v4opbMp+iuVGgoVYe8IAvYstD/0HThpO4vk5MVhTAC
VBv/i+ASZtDaHdDjAk99z8pQAM9DiN7rgQC2sAFsuqEyBjSU19MD6x9hAoGAOSW1
cObF2qMB+y3jNlPoinaK29Jj8fiPgids6nrM+Q8y1LvfKSYdE63BdjuHrVJinVuo
3pUZlVkwGlGSQlwi70DHvN9Rp0lWDbSK82wmjaPgWRvIgmPcgSzv1Taft5Vc1FTL
gC/Px24W2gdSzgB2onPLH8BTADX7MX2Jw9O/AokCgYBK7kvg1/cmikj176JFn1AM
MBCwVKS1fvUyh0bctadVyM+RA22cVvLB5PEbPB+LbyK1PnHB3jivEa954bOuYo39
frRrRYZW4iP+oTqx8arcioaMW2K5urFtsqNrYVgkE5KDBAqFGSAyuKTAjftMxGqy
tORwgZ9jzgbBC0V8td6fqg==
-----END PRIVATE KEY-----

View File

@ -1,26 +1,45 @@
server {
listen 80;
server_name localhost;
root /var/www/html/public;
location / {
try_files $uri /index.php?$is_args$args;
# Redirigir todo el tráfico HTTP a HTTPS
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name localhost;
root /var/www/html/public;
index index.html index.php;
ssl_certificate /etc/nginx/certs/ogcore.uds-test.net.crt.pem;
ssl_certificate_key /etc/nginx/certs/ogcore.uds-test.net.key.pem;
location /opengnsys/rest/ous// {
rewrite ^/opengnsys/rest/ous//([0-9]+)/images /opengnsys/rest/ous/$1/images;
rewrite ^/opengnsys/rest/ous//([0-9]+)/labs /opengnsys/rest/ous/$1/labs;
}
location ~ ^/index.php(/|$) {
# Bloque principal para archivos
location / {
try_files $uri $uri/ /index.php?$args;
}
# Manejo de PHP
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass php:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param DOCUMENT_ROOT $document_root;
internal;
fastcgi_param PATH_INFO $request_uri;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
}
# Bloque para errores PHP
location ~ \.php$ {
return 404;
}
error_log /var/log/nginx/error.log;
error_log /var/log/nginx/error.log debug;
access_log /var/log/nginx/access.log;
}
}

6
entrypoint.sh 100644
View File

@ -0,0 +1,6 @@
#!/bin/sh
# Instalar certificados CA de Symfony si no existen
if [ ! -f /root/.symfony*/cacert.pem ]; then
symfony server:ca:install
fi

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240808140716 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE og_live (id INT AUTO_INCREMENT NOT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, download_url VARCHAR(255) DEFAULT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_3D6B7739D17F50A6 (uuid), UNIQUE INDEX UNIQ_IDENTIFIER_NAME (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE og_live');
}
}

View File

@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240812095940 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE pxe_boot_file (id INT AUTO_INCREMENT NOT NULL, template_id INT DEFAULT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_7FD1F34BD17F50A6 (uuid), INDEX IDX_7FD1F34B5DA0FB8 (template_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE pxe_template (id INT AUTO_INCREMENT NOT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, template_content VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_73197554D17F50A6 (uuid), UNIQUE INDEX UNIQ_IDENTIFIER_NAME (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE pxe_boot_file ADD CONSTRAINT FK_7FD1F34B5DA0FB8 FOREIGN KEY (template_id) REFERENCES pxe_template (id)');
$this->addSql('ALTER TABLE client ADD pxe_boot_file_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455D4CBF752 FOREIGN KEY (pxe_boot_file_id) REFERENCES pxe_boot_file (id)');
$this->addSql('CREATE INDEX IDX_C7440455D4CBF752 ON client (pxe_boot_file_id)');
$this->addSql('ALTER TABLE og_live ADD checksum VARCHAR(255) DEFAULT NULL, ADD distribution VARCHAR(255) DEFAULT NULL, ADD kernel VARCHAR(255) DEFAULT NULL, ADD architecture VARCHAR(255) DEFAULT NULL, ADD revision VARCHAR(255) DEFAULT NULL, ADD directory VARCHAR(255) DEFAULT NULL, ADD filename VARCHAR(255) DEFAULT NULL, ADD installed TINYINT(1) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455D4CBF752');
$this->addSql('ALTER TABLE pxe_boot_file DROP FOREIGN KEY FK_7FD1F34B5DA0FB8');
$this->addSql('DROP TABLE pxe_boot_file');
$this->addSql('DROP TABLE pxe_template');
$this->addSql('ALTER TABLE og_live DROP checksum, DROP distribution, DROP kernel, DROP architecture, DROP revision, DROP directory, DROP filename, DROP installed');
$this->addSql('DROP INDEX IDX_C7440455D4CBF752 ON client');
$this->addSql('ALTER TABLE client DROP pxe_boot_file_id');
}
}

View File

@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240812135824 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE og_repository (id INT AUTO_INCREMENT NOT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, ip_address VARCHAR(255) NOT NULL, description VARCHAR(255) DEFAULT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_2E0FDA37D17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE client ADD repository_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C744045550C9D4F7 FOREIGN KEY (repository_id) REFERENCES og_repository (id)');
$this->addSql('CREATE INDEX IDX_C744045550C9D4F7 ON client (repository_id)');
$this->addSql('ALTER TABLE network_settings ADD repository_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE network_settings ADD CONSTRAINT FK_48869B5450C9D4F7 FOREIGN KEY (repository_id) REFERENCES og_repository (id)');
$this->addSql('CREATE INDEX IDX_48869B5450C9D4F7 ON network_settings (repository_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C744045550C9D4F7');
$this->addSql('ALTER TABLE network_settings DROP FOREIGN KEY FK_48869B5450C9D4F7');
$this->addSql('DROP TABLE og_repository');
$this->addSql('DROP INDEX IDX_48869B5450C9D4F7 ON network_settings');
$this->addSql('ALTER TABLE network_settings DROP repository_id');
$this->addSql('DROP INDEX IDX_C744045550C9D4F7 ON client');
$this->addSql('ALTER TABLE client DROP repository_id');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240814130427 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE pxe_template CHANGE template_content template_content TINYTEXT NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE pxe_template CHANGE template_content template_content VARCHAR(255) NOT NULL');
}
}

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240819062421 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE og_live ADD synchronized TINYINT(1) DEFAULT NULL');
$this->addSql('ALTER TABLE pxe_template ADD synchronized TINYINT(1) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE og_live DROP synchronized');
$this->addSql('ALTER TABLE pxe_template DROP synchronized');
}
}

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240819140045 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE og_live ADD `default` TINYINT(1) DEFAULT NULL');
$this->addSql('ALTER TABLE pxe_boot_file ADD synchronized TINYINT(1) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE og_live DROP `default`');
$this->addSql('ALTER TABLE pxe_boot_file DROP synchronized');
}
}

View File

@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240820063513 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE client ADD og_live_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455F7E54CF3 FOREIGN KEY (og_live_id) REFERENCES og_live (id)');
$this->addSql('CREATE INDEX IDX_C7440455F7E54CF3 ON client (og_live_id)');
$this->addSql('ALTER TABLE network_settings ADD og_live_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE network_settings ADD CONSTRAINT FK_48869B54F7E54CF3 FOREIGN KEY (og_live_id) REFERENCES og_live (id)');
$this->addSql('CREATE INDEX IDX_48869B54F7E54CF3 ON network_settings (og_live_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE network_settings DROP FOREIGN KEY FK_48869B54F7E54CF3');
$this->addSql('DROP INDEX IDX_48869B54F7E54CF3 ON network_settings');
$this->addSql('ALTER TABLE network_settings DROP og_live_id');
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455F7E54CF3');
$this->addSql('DROP INDEX IDX_C7440455F7E54CF3 ON client');
$this->addSql('ALTER TABLE client DROP og_live_id');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240820064106 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE og_live CHANGE `default` is_default TINYINT(1) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE og_live CHANGE is_default `default` TINYINT(1) DEFAULT NULL');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240821065158 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE pxe_template CHANGE template_content template_content LONGTEXT NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE pxe_template CHANGE template_content template_content TINYTEXT NOT NULL');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240827102833 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE subnet (id INT AUTO_INCREMENT NOT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, netmask VARCHAR(255) NOT NULL, ip_address VARCHAR(255) NOT NULL, next_server VARCHAR(255) NOT NULL, boot_file_name VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_91C24216D17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE subnet');
}
}

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240902124157 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE network_settings ADD next_server VARCHAR(255) DEFAULT NULL, ADD boot_file_name VARCHAR(255) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE network_settings ADD og_live_id INT DEFAULT NULL, DROP next_server, DROP boot_file_name');
$this->addSql('ALTER TABLE network_settings ADD CONSTRAINT FK_48869B54F7E54CF3 FOREIGN KEY (og_live_id) REFERENCES og_live (id)');
}
}

View File

@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240903081001 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE organizational_unit ADD subnet_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE organizational_unit ADD CONSTRAINT FK_749AEB2DC9CF9478 FOREIGN KEY (subnet_id) REFERENCES subnet (id)');
$this->addSql('CREATE INDEX IDX_749AEB2DC9CF9478 ON organizational_unit (subnet_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE organizational_unit DROP FOREIGN KEY FK_749AEB2DC9CF9478');
$this->addSql('DROP INDEX IDX_749AEB2DC9CF9478 ON organizational_unit');
$this->addSql('ALTER TABLE organizational_unit DROP subnet_id');
}
}

View File

@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240904134540 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE client CHANGE og_live_id subnet_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455C9CF9478 FOREIGN KEY (subnet_id) REFERENCES subnet (id)');
$this->addSql('CREATE INDEX IDX_C7440455C9CF9478 ON client (subnet_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455C9CF9478');
$this->addSql('DROP INDEX IDX_C7440455C9CF9478 ON client');
$this->addSql('ALTER TABLE client CHANGE subnet_id og_live_id INT DEFAULT NULL');
}
}

View File

@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240905080435 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE og_live ADD status VARCHAR(255) NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE og_live DROP status');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240916073039 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE command (id INT AUTO_INCREMENT NOT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, script VARCHAR(255) NOT NULL, comments VARCHAR(255) DEFAULT NULL, read_only TINYINT(1) NOT NULL, name VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_8ECAEAD4D17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE command');
}
}

View File

@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240916091601 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE command_group (id INT AUTO_INCREMENT NOT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, position INT NOT NULL, name VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_FE6811F6D17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE command_group_command (command_group_id INT NOT NULL, command_id INT NOT NULL, INDEX IDX_118CE215C7B800D6 (command_group_id), INDEX IDX_118CE21533E1689A (command_id), PRIMARY KEY(command_group_id, command_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE command_group_command ADD CONSTRAINT FK_118CE215C7B800D6 FOREIGN KEY (command_group_id) REFERENCES command_group (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE command_group_command ADD CONSTRAINT FK_118CE21533E1689A FOREIGN KEY (command_id) REFERENCES command (id) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE command_group_command DROP FOREIGN KEY FK_118CE215C7B800D6');
$this->addSql('ALTER TABLE command_group_command DROP FOREIGN KEY FK_118CE21533E1689A');
$this->addSql('DROP TABLE command_group');
$this->addSql('DROP TABLE command_group_command');
}
}

View File

@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240917064754 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE command_task (id INT AUTO_INCREMENT NOT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, datetime DATETIME NOT NULL, notes VARCHAR(255) DEFAULT NULL, status VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_F3D475A8D17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE command_task_command (command_task_id INT NOT NULL, command_id INT NOT NULL, INDEX IDX_BB417CA862DC5265 (command_task_id), INDEX IDX_BB417CA833E1689A (command_id), PRIMARY KEY(command_task_id, command_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE command_task_command_group (command_task_id INT NOT NULL, command_group_id INT NOT NULL, INDEX IDX_C43618BD62DC5265 (command_task_id), INDEX IDX_C43618BDC7B800D6 (command_group_id), PRIMARY KEY(command_task_id, command_group_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE command_task_command ADD CONSTRAINT FK_BB417CA862DC5265 FOREIGN KEY (command_task_id) REFERENCES command_task (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE command_task_command ADD CONSTRAINT FK_BB417CA833E1689A FOREIGN KEY (command_id) REFERENCES command (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE command_task_command_group ADD CONSTRAINT FK_C43618BD62DC5265 FOREIGN KEY (command_task_id) REFERENCES command_task (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE command_task_command_group ADD CONSTRAINT FK_C43618BDC7B800D6 FOREIGN KEY (command_group_id) REFERENCES command_group (id) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE command_task_command DROP FOREIGN KEY FK_BB417CA862DC5265');
$this->addSql('ALTER TABLE command_task_command DROP FOREIGN KEY FK_BB417CA833E1689A');
$this->addSql('ALTER TABLE command_task_command_group DROP FOREIGN KEY FK_C43618BD62DC5265');
$this->addSql('ALTER TABLE command_task_command_group DROP FOREIGN KEY FK_C43618BDC7B800D6');
$this->addSql('DROP TABLE command_task');
$this->addSql('DROP TABLE command_task_command');
$this->addSql('DROP TABLE command_task_command_group');
}
}

View File

@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240917091950 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE trace (id INT AUTO_INCREMENT NOT NULL, client_id INT NOT NULL, command_id INT NOT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, status VARCHAR(255) NOT NULL, output VARCHAR(255) DEFAULT NULL, executed_at DATETIME NOT NULL, finished_at DATETIME NOT NULL, UNIQUE INDEX UNIQ_315BD5A1D17F50A6 (uuid), INDEX IDX_315BD5A119EB6921 (client_id), INDEX IDX_315BD5A133E1689A (command_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE trace ADD CONSTRAINT FK_315BD5A119EB6921 FOREIGN KEY (client_id) REFERENCES client (id)');
$this->addSql('ALTER TABLE trace ADD CONSTRAINT FK_315BD5A133E1689A FOREIGN KEY (command_id) REFERENCES command (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE trace DROP FOREIGN KEY FK_315BD5A119EB6921');
$this->addSql('ALTER TABLE trace DROP FOREIGN KEY FK_315BD5A133E1689A');
$this->addSql('DROP TABLE trace');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240917092207 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE trace CHANGE finished_at finished_at DATETIME DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE trace CHANGE finished_at finished_at DATETIME NOT NULL');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240924071858 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE command CHANGE script script LONGTEXT NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE command CHANGE script script VARCHAR(255) NOT NULL');
}
}

View File

@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240924090429 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE remote_calendar (id INT AUTO_INCREMENT NOT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_BD3BDE0AD17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE remote_calendar_rule (id INT AUTO_INCREMENT NOT NULL, remote_calendar_id INT DEFAULT NULL, uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) DEFAULT NULL, updated_by VARCHAR(255) DEFAULT NULL, busy_weekdays JSON NOT NULL COMMENT \'(DC2Type:json)\', busy_from_hour DATETIME NOT NULL, busy_to_hour DATETIME NOT NULL, is_remote_available TINYINT(1) NOT NULL, available_from_date DATE NOT NULL, available_to_date DATE NOT NULL, available_reason VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_EE93D058D17F50A6 (uuid), INDEX IDX_EE93D058C56641EE (remote_calendar_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE remote_calendar_rule ADD CONSTRAINT FK_EE93D058C56641EE FOREIGN KEY (remote_calendar_id) REFERENCES remote_calendar (id)');
$this->addSql('ALTER TABLE organizational_unit ADD remote_calendar_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE organizational_unit ADD CONSTRAINT FK_749AEB2DC56641EE FOREIGN KEY (remote_calendar_id) REFERENCES remote_calendar (id)');
$this->addSql('CREATE INDEX IDX_749AEB2DC56641EE ON organizational_unit (remote_calendar_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE organizational_unit DROP FOREIGN KEY FK_749AEB2DC56641EE');
$this->addSql('ALTER TABLE remote_calendar_rule DROP FOREIGN KEY FK_EE93D058C56641EE');
$this->addSql('DROP TABLE remote_calendar');
$this->addSql('DROP TABLE remote_calendar_rule');
$this->addSql('DROP INDEX IDX_749AEB2DC56641EE ON organizational_unit');
$this->addSql('ALTER TABLE organizational_unit DROP remote_calendar_id');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240924095558 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE remote_calendar_rule CHANGE busy_from_hour busy_from_hour TIME NOT NULL, CHANGE busy_to_hour busy_to_hour TIME NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE remote_calendar_rule CHANGE busy_from_hour busy_from_hour DATETIME NOT NULL, CHANGE busy_to_hour busy_to_hour DATETIME NOT NULL');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240924100335 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_NAME ON remote_calendar (name)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP INDEX UNIQ_IDENTIFIER_NAME ON remote_calendar');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240924102357 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE remote_calendar_rule CHANGE busy_weekdays busy_weekdays JSON DEFAULT NULL COMMENT \'(DC2Type:json)\', CHANGE busy_from_hour busy_from_hour TIME DEFAULT NULL, CHANGE busy_to_hour busy_to_hour TIME DEFAULT NULL, CHANGE available_from_date available_from_date DATE DEFAULT NULL, CHANGE available_to_date available_to_date DATE DEFAULT NULL, CHANGE available_reason available_reason VARCHAR(255) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE remote_calendar_rule CHANGE busy_weekdays busy_weekdays JSON NOT NULL COMMENT \'(DC2Type:json)\', CHANGE busy_from_hour busy_from_hour TIME NOT NULL, CHANGE busy_to_hour busy_to_hour TIME NOT NULL, CHANGE available_from_date available_from_date DATE NOT NULL, CHANGE available_to_date available_to_date DATE NOT NULL, CHANGE available_reason available_reason VARCHAR(255) NOT NULL');
}
}

View File

@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240926085224 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE remote_calendar_rule DROP FOREIGN KEY FK_EE93D058C56641EE');
$this->addSql('ALTER TABLE remote_calendar_rule CHANGE remote_calendar_id remote_calendar_id INT NOT NULL');
$this->addSql('ALTER TABLE remote_calendar_rule ADD CONSTRAINT FK_EE93D058C56641EE FOREIGN KEY (remote_calendar_id) REFERENCES remote_calendar (id) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE remote_calendar_rule DROP FOREIGN KEY FK_EE93D058C56641EE');
$this->addSql('ALTER TABLE remote_calendar_rule CHANGE remote_calendar_id remote_calendar_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE remote_calendar_rule ADD CONSTRAINT FK_EE93D058C56641EE FOREIGN KEY (remote_calendar_id) REFERENCES remote_calendar (id)');
}
}

View File

@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240926104532 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE command_group DROP position');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE organizational_unit ADD FK_749AEB2DC56641EE FOREIGN KEY (remote_calendar_id) REFERENCES remote_calendar (id)');
$this->addSql('ALTER TABLE command_group ADD position INT NOT NULL');
}
}

View File

@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240930131003 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE command_task_client (command_task_id INT NOT NULL, client_id INT NOT NULL, INDEX IDX_F97A827D62DC5265 (command_task_id), INDEX IDX_F97A827D19EB6921 (client_id), PRIMARY KEY(command_task_id, client_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE command_task_client ADD CONSTRAINT FK_F97A827D62DC5265 FOREIGN KEY (command_task_id) REFERENCES command_task (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE command_task_client ADD CONSTRAINT FK_F97A827D19EB6921 FOREIGN KEY (client_id) REFERENCES client (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455F7E54CF3');
$this->addSql('DROP INDEX IDX_C7440455F7E54CF3 ON client');
$this->addSql('ALTER TABLE client ADD og_live_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455F7E54CF3 FOREIGN KEY (og_live_id) REFERENCES og_live (id)');
$this->addSql('CREATE INDEX IDX_C7440455F7E54CF3 ON client (og_live_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE command_task_client DROP FOREIGN KEY FK_F97A827D62DC5265');
$this->addSql('ALTER TABLE command_task_client DROP FOREIGN KEY FK_F97A827D19EB6921');
$this->addSql('DROP TABLE command_task_client');
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455F7E54CF3');
$this->addSql('DROP INDEX IDX_C7440455F7E54CF3 ON client');
$this->addSql('ALTER TABLE client DROP og_live_id');
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455F7E54CF3 FOREIGN KEY (subnet_id) REFERENCES og_live (id)');
$this->addSql('CREATE INDEX IDX_C7440455F7E54CF3 ON client (subnet_id)');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241002062742 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE organizational_unit ADD remote_pc TINYINT(1) NOT NULL, ADD reserved TINYINT(1) NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE organizational_unit DROP remote_pc, DROP reserved');
}
}

View File

@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241008080902 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE `partition` ADD image_id INT NOT NULL');
$this->addSql('ALTER TABLE `partition` ADD CONSTRAINT FK_9EB910E43DA5256D FOREIGN KEY (image_id) REFERENCES image (id)');
$this->addSql('CREATE INDEX IDX_9EB910E43DA5256D ON `partition` (image_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE `partition` DROP FOREIGN KEY FK_9EB910E43DA5256D');
$this->addSql('DROP INDEX IDX_9EB910E43DA5256D ON `partition`');
$this->addSql('ALTER TABLE `partition` DROP image_id');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241008081013 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE client ADD maintenance TINYINT(1) NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE client DROP maintenance');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241008092247 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE image CHANGE software_profile_id software_profile_id INT DEFAULT NULL, CHANGE path path VARCHAR(255) DEFAULT NULL, CHANGE type type VARCHAR(255) DEFAULT NULL, CHANGE size size INT DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE image CHANGE software_profile_id software_profile_id INT NOT NULL, CHANGE path path VARCHAR(255) NOT NULL, CHANGE type type VARCHAR(255) NOT NULL, CHANGE size size INT NOT NULL');
}
}

View File

@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241008092849 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE image ADD organizational_unit_id INT NOT NULL');
$this->addSql('ALTER TABLE image ADD CONSTRAINT FK_C53D045FFB84408A FOREIGN KEY (organizational_unit_id) REFERENCES organizational_unit (id)');
$this->addSql('CREATE INDEX IDX_C53D045FFB84408A ON image (organizational_unit_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE image DROP FOREIGN KEY FK_C53D045FFB84408A');
$this->addSql('DROP INDEX IDX_C53D045FFB84408A ON image');
$this->addSql('ALTER TABLE image DROP organizational_unit_id');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241014053130 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE subnet ADD server_id INT DEFAULT NULL, ADD synchronized TINYINT(1) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE subnet DROP server_id, DROP synchronized');
}
}

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241014082029 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455C9CF9478');
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455C9CF9478 FOREIGN KEY (subnet_id) REFERENCES subnet (id) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455C9CF9478');
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455C9CF9478 FOREIGN KEY (subnet_id) REFERENCES subnet (id)');
}
}

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241014102105 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455C9CF9478');
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455C9CF9478 FOREIGN KEY (subnet_id) REFERENCES subnet (id) ON DELETE SET NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455C9CF9478');
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455C9CF9478 FOREIGN KEY (subnet_id) REFERENCES subnet (id) ON DELETE CASCADE');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241015154123 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE `partition` CHANGE image_id image_id INT DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE `partition` CHANGE image_id image_id INT NOT NULL');
}
}

View File

@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241016063657 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE software ADD type VARCHAR(255) NOT NULL');
$this->addSql('ALTER TABLE software_profile ADD operative_system_id INT NOT NULL');
$this->addSql('ALTER TABLE software_profile ADD CONSTRAINT FK_B70C3C9BF1E9F66E FOREIGN KEY (operative_system_id) REFERENCES operative_system (id)');
$this->addSql('CREATE INDEX IDX_B70C3C9BF1E9F66E ON software_profile (operative_system_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE software DROP type');
$this->addSql('ALTER TABLE software_profile DROP FOREIGN KEY FK_B70C3C9BF1E9F66E');
$this->addSql('DROP INDEX IDX_B70C3C9BF1E9F66E ON software_profile');
$this->addSql('ALTER TABLE software_profile DROP operative_system_id');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241016065729 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE software_profile CHANGE operative_system_id operative_system_id INT DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE software_profile CHANGE operative_system_id operative_system_id INT NOT NULL');
}
}

View File

@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241018055534 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE image DROP FOREIGN KEY FK_C53D045FFB84408A');
$this->addSql('ALTER TABLE image DROP FOREIGN KEY FK_C53D045F19EB6921');
$this->addSql('DROP INDEX IDX_C53D045F19EB6921 ON image');
$this->addSql('DROP INDEX IDX_C53D045FFB84408A ON image');
$this->addSql('ALTER TABLE image DROP client_id, DROP organizational_unit_id');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE image ADD client_id INT NOT NULL, ADD organizational_unit_id INT NOT NULL');
$this->addSql('ALTER TABLE image ADD CONSTRAINT FK_C53D045FFB84408A FOREIGN KEY (organizational_unit_id) REFERENCES organizational_unit (id)');
$this->addSql('ALTER TABLE image ADD CONSTRAINT FK_C53D045F19EB6921 FOREIGN KEY (client_id) REFERENCES client (id)');
$this->addSql('CREATE INDEX IDX_C53D045F19EB6921 ON image (client_id)');
$this->addSql('CREATE INDEX IDX_C53D045FFB84408A ON image (organizational_unit_id)');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241018060155 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE image ADD remote_pc TINYINT(1) NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE image DROP remote_pc');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241019073142 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE client ADD agent_job_id VARCHAR(255) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE client DROP agent_job_id');
}
}

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241021061008 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455F7E54CF3');
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455F7E54CF3 FOREIGN KEY (og_live_id) REFERENCES og_live (id) ON DELETE SET NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455F7E54CF3');
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455F7E54CF3 FOREIGN KEY (og_live_id) REFERENCES og_live (id)');
}
}

View File

@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241021071250 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455D4CBF752');
$this->addSql('ALTER TABLE pxe_boot_file DROP FOREIGN KEY FK_7FD1F34B5DA0FB8');
$this->addSql('DROP TABLE pxe_boot_file');
$this->addSql('DROP INDEX IDX_C7440455D4CBF752 ON client');
$this->addSql('ALTER TABLE client CHANGE pxe_boot_file_id template_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C74404555DA0FB8 FOREIGN KEY (template_id) REFERENCES pxe_template (id)');
$this->addSql('CREATE INDEX IDX_C74404555DA0FB8 ON client (template_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE pxe_boot_file (id INT AUTO_INCREMENT NOT NULL, template_id INT DEFAULT NULL, uuid CHAR(36) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci` COMMENT \'(DC2Type:uuid)\', migration_id VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, created_by VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, updated_by VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, synchronized TINYINT(1) DEFAULT NULL, INDEX IDX_7FD1F34B5DA0FB8 (template_id), UNIQUE INDEX UNIQ_7FD1F34BD17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
$this->addSql('ALTER TABLE pxe_boot_file ADD CONSTRAINT FK_7FD1F34B5DA0FB8 FOREIGN KEY (template_id) REFERENCES pxe_template (id)');
$this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C74404555DA0FB8');
$this->addSql('DROP INDEX IDX_C74404555DA0FB8 ON client');
$this->addSql('ALTER TABLE client CHANGE template_id pxe_boot_file_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455D4CBF752 FOREIGN KEY (pxe_boot_file_id) REFERENCES pxe_boot_file (id)');
$this->addSql('CREATE INDEX IDX_C7440455D4CBF752 ON client (pxe_boot_file_id)');
}
}

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241021201438 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE client ADD pxe_sync TINYINT(1) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE client DROP pxe_sync');
}
}

View File

@ -0,0 +1,95 @@
<?php
namespace App\Command;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class LoadDefaultCommandsCommand extends Command
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
)
{
parent::__construct('app:load-default-commands');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$commands = [
[
'name' => 'Encender',
'enabled' => true,
'readOnly' => true,
],
[
'name' => 'Apagar',
'enabled' => true,
'readOnly' => true,
],
[
'name' => 'Restaurar Imagen',
'enabled' => true,
'readOnly' => true,
],
[
'name' => 'Crear Imagen',
'enabled' => true,
'readOnly' => true,
],
[
'name' => 'Reiniciar',
'enabled' => true,
'readOnly' => true,
],
[
'name' => 'Inventario Hardware',
'enabled' => true,
'readOnly' => true,
],
[
'name' => 'Inventario Software',
'enabled' => true,
'readOnly' => true,
],
[
'name' => 'Ejecutar Script',
'enabled' => true,
'readOnly' => true,
],
[
'name' => 'Iniciar Sesion',
'enabled' => true,
'readOnly' => true,
],
[
'name' => 'Particionar y Formatear',
'enabled' => true,
'readOnly' => true,
],
[
'name' => 'Eliminar Imagen Cache',
'enabled' => true,
'readOnly' => true,
],
];
foreach ($commands as $command) {
$entity = new \App\Entity\Command();
$entity->setName($command['name']);
$entity->setScript('');
$entity->setEnabled($command['enabled']);
$entity->setReadOnly($command['readOnly']);
$this->entityManager->persist($entity);
}
$this->entityManager->flush();
return 1;
}
}

View File

@ -0,0 +1,172 @@
<?php
declare(strict_types=1);
namespace App\Command;
use App\Entity\Client;
use App\Entity\Image;
use App\Entity\OrganizationalUnit;
use App\Model\OrganizationalUnitTypes;
use App\Model\UserGroupPermissions;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class LoadOrganizationalUnitDefaultCommand extends Command
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
)
{
parent::__construct('app:load-default-ous');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$organizationalUnits = [
[
'name' => 'Universidad Test',
'type' => OrganizationalUnitTypes::ORGANIZATIONAL_UNIT
]
];
$classrooms = [
[
'name' => 'Aula Test 1',
'type' => OrganizationalUnitTypes::CLASSROOM
],
[
'name' => 'Aula Test 2',
'type' => OrganizationalUnitTypes::CLASSROOM
],
[
'name' => 'Aula Test 3',
'type' => OrganizationalUnitTypes::CLASSROOM
]
];
$clientsA = [
[
'name' => 'Cliente Test 1a',
'ip' => '1.1.1.1',
'mac' => '00:1A:2B:3C:4D:5E',
],
[
'name' => 'Cliente Test 1b',
'ip' => '2.2.2.2',
'mac' => '00:1B:3C:4D:5E:6F'
],
[
'name' => 'Cliente Test 1c',
'ip' => '3.3.3.3',
'mac' => '00:1C:4D:5E:6F:7A'
]
];
$clientsB = [
[
'name' => 'Cliente Test 2a',
'ip' => '4.4.4.4',
'mac' => '00:1D:5E:6F:7A:8B'
],
[
'name' => 'Cliente Test 2b',
'ip' => '5.5.5.5',
'mac' => '00:1E:6F:7A:8B:9C'
],
[
'name' => 'Cliente Test 2c',
'ip' => '6.6.6.6',
'mac' => '00:1F:7A:8B:9C:AD'
],
];
$clientsC = [
[
'name' => 'Cliente Test 3a',
'ip' => '7.7.7.7.',
'mac' => '00:2A:8B:9C:AD:BE'
],
[
'name' => 'Cliente Test 3b',
'ip' => '8.8.8.8',
'mac' => '00:2B:9C:AD:BE:CF'
],
[
'name' => 'Cliente Test 3c',
'ip' => '9.9.9.9',
'mac' => '00:2C:AD:BE:CF:D0'
]
];
$images = [
[
'name' => 'Imagen Test 1',
'type' => 'ISO',
'path' => '/path/to/imagen1.iso'
],
[
'name' => 'Imagen Test 2',
'type' => 'ISO',
'path' => '/path/to/imagen2.iso'
],
[
'name' => 'Imagen Test 3',
'type' => 'ISO',
'path' => '/path/to/imagen3.iso'
]
];
foreach ($organizationalUnits as $organizationalUnit) {
$organizationalUnitEntity = new OrganizationalUnit();
$organizationalUnitEntity->setName($organizationalUnit['name']);
$organizationalUnitEntity->setType($organizationalUnit['type']);
$this->entityManager->persist($organizationalUnitEntity);
foreach ($classrooms as $classroom) {
$classroomEntity = new OrganizationalUnit();
$classroomEntity->setName($classroom['name']);
$classroomEntity->setType($classroom['type']);
$classroomEntity->setParent($organizationalUnitEntity);
$this->entityManager->persist($classroomEntity);
if ($classroomEntity->getName() === 'Aula Test 1') {
$clients = $clientsA;
} elseif ($classroomEntity->getName() === 'Aula Test 2') {
$clients = $clientsB;
} elseif ($classroomEntity->getName() === 'Aula Test 3') {
$clients = $clientsC;
}
foreach ($clients as $client) {
$clientEntity = new Client();
$clientEntity->setName($client['name']);
$clientEntity->setIp($client['ip']);
$clientEntity->setMac($client['mac']);
$clientEntity->setMaintenance(false);
$clientEntity->setOrganizationalUnit($classroomEntity);
$this->entityManager->persist($clientEntity);
foreach ($images as $image) {
$imageEntity = new Image();
$imageEntity->setName($image['name']);
$imageEntity->setType($image['type']);
$imageEntity->setPath($image['path']);
$imageEntity->setOrganizationalUnit($organizationalUnitEntity);
$imageEntity->setClient($clientEntity);
$this->entityManager->persist($imageEntity);
}
}
}
$this->entityManager->flush();
}
return Command::SUCCESS;
}
}

View File

@ -63,6 +63,7 @@ class MigrateClientsCommand extends Command
$clientEntity->setNetdriver($client['netdriver']);
$clientEntity->setMac($client['mac']);
$clientEntity->setIp($client['ip']);
$clientEntity->setMaintenance(false);
$clientEntity->setPosition(['x' => 0, 'y' => 0]);
}

View File

@ -6,6 +6,7 @@ use App\Entity\Hardware;
use App\Entity\HardwareProfile;
use App\Entity\HardwareType;
use App\Entity\OrganizationalUnit;
use App\Model\OrganizationalUnitTypes;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\Persistence\ManagerRegistry;
@ -118,7 +119,11 @@ class MigrateHardwareAndHardwareProfileCommand extends Command
$hardwareProfileEntity->setComments($hardwareProfile['perfilhard.comentarios']);
}
$migrationId = $hardwareProfile['perfilhard.grupoid'] === 0 ? $hardwareProfile['perfilhard.idcentro'] : $hardwareProfile['perfilhard.grupoid'];
$migrationId = match ($hardwareProfile['perfilhard.grupoid']) {
0 => OrganizationalUnitTypes::ORGANIZATIONAL_UNIT . '-' . $hardwareProfile['perfilhard.idcentro'],
default => OrganizationalUnitTypes::CLASSROOMS_GROUP . '-' . $hardwareProfile['perfilhard.grupoid'],
};
$organizationalUnit = $organizationalUnitRepository->findOneBy(['migrationId' => $migrationId]);
if ($organizationalUnit){

View File

@ -0,0 +1,91 @@
<?php
declare(strict_types=1);
namespace App\Command\Migration;
use App\Entity\Client;
use App\Entity\Image;
use App\Entity\OrganizationalUnit;
use App\Model\OrganizationalUnitTypes;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
#[AsCommand(name: 'opengnsys:migration:images', description: 'Migrate images data')]
class MigrateImagesCommand extends Command
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly ManagerRegistry $doctrine
)
{
parent::__construct();
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
/** @var EntityManagerInterface $oldDatabaseEntityManager */
$oldDatabaseEntityManager = $this->doctrine->getManager('og_1');
$imagesRepository = $this->entityManager->getRepository(Image::class);
$clientRepository = $this->entityManager->getRepository(Client::class);
$ouRepository = $this->entityManager->getRepository(OrganizationalUnit::class);
/** Obtener las imágenes de la base de datos antigua **/
$rsmOperativeSystems = new ResultSetMapping();
$rsmOperativeSystems->addScalarResult('idimagen', 'idimagen');
$rsmOperativeSystems->addScalarResult('nombreca', 'nombreca');
$rsmOperativeSystems->addScalarResult('idcentro', 'centros.idcentro');
$rsmOperativeSystems->addScalarResult('idordenador', 'ordenadores.idordenador');
$rsmOperativeSystems->addScalarResult('numdisk', 'numdisk');
$rsmOperativeSystems->addScalarResult('ruta', 'ruta');
$rsmOperativeSystems->addScalarResult('numpar', 'numpar');
$rsmOperativeSystems->addScalarResult('revision', 'revision');
$rsmOperativeSystems->addScalarResult('descripcion', 'descripcion');
$rsmOperativeSystems->addScalarResult('comentarios', 'comentarios');
$imagesQuery = $oldDatabaseEntityManager->createNativeQuery('SELECT idimagen, nombreca, ruta, ordenadores.idordenador, centros.idcentro, numdisk, numpar, revision, descripcion, imagenes.comentarios FROM imagenes LEFT JOIN ordenadores ON imagenes.idordenador = ordenadores.idordenador LEFT JOIN centros ON imagenes.idcentro = imagenes.idcentro', $rsmOperativeSystems);
$images = $imagesQuery->getResult();
/** Imágenes **/
$output->writeln("IMÁGENES TOTAL: ". count($images));
foreach ($images as $image){
$ouEntity = $ouRepository->findOneBy(['migrationId' => OrganizationalUnitTypes::ORGANIZATIONAL_UNIT.'-'.$image['centros.idcentro']]);
if (!$ouEntity) {
$output->writeln("No se ha encontrado la OU con id: ". $image['centros.idcentro']);
continue;
}
$clientEntity = $clientRepository->findOneBy(['migrationId' => $image['ordenadores.idordenador']]);
if(!$clientEntity){
$output->writeln("No se ha encontrado el cliente con id: ". $image['ordenadores.idordenador']);
continue;
}
$imageEntity = $imagesRepository->findOneBy(['migrationId' => $image['idimagen']]);
if(!$imageEntity) {
$imageEntity = new Image();
$imageEntity->setMigrationId((string) $image['idimagen']);
$imageEntity->setName($image['nombreca']);
$imageEntity->setClient($clientEntity);
$imageEntity->setOrganizationalUnit($ouEntity);
$imageEntity->setRevision((string) $image['revision']);
$imageEntity->setDescription($image['descripcion']);
$imageEntity->setComments($image['comentarios']);
}
$this->entityManager->persist($imageEntity);
}
$this->entityManager->flush();
return Command::SUCCESS;
}
}

View File

@ -2,9 +2,12 @@
namespace App\Command\Migration;
use App\Entity\OperativeSystem;
use App\Entity\OrganizationalUnit;
use App\Entity\Software;
use App\Entity\SoftwareProfile;
use App\Model\OrganizationalUnitTypes;
use App\Model\SoftwareTypes;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\Persistence\ManagerRegistry;
@ -24,34 +27,131 @@ class MigrateSoftwareAndSoftwareProfileCommand extends Command
parent::__construct();
}
protected function execute(InputInterface $input, OutputInterface $output): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
ini_set('memory_limit', '-1');
/** @var EntityManagerInterface $oldDatabaseEntityManager */
$oldDatabaseEntityManager = $this->doctrine->getManager('og_1');
$organizationalUnitRepository = $this->entityManager->getRepository(OrganizationalUnit::class);
$operativeSystemRepository = $this->entityManager->getRepository(OperativeSystem::class);
$softwareProfileRepository = $this->entityManager->getRepository(SoftwareProfile::class);
$softwareRepository = $this->entityManager->getRepository(Software::class);
/** Obtener los perfiles software de la base de datos antigua **/
/** Obtener los software de la base de datos antigua **/
$rsmSoftware = new ResultSetMapping();
$rsmSoftware->addScalarResult('idtiposoftware', 'idtiposoftware');
$rsmSoftware->addScalarResult('idsoftware', 'idsoftware');
$rsmSoftware->addScalarResult('descripcion', 'descripcion');
$rsmSoftware->addScalarResult('grupoid', 'softwares.grupoid');
$rsmSoftware->addScalarResult('idcentro', 'softwares.idcentro');
$rsmSoftware->addScalarResult('idtiposoftware', 'softwares.idtiposoftware');
$softwareQuery = $oldDatabaseEntityManager->createNativeQuery('SELECT idtiposoftware, descripcion FROM softwares', $rsmSoftware);
$softwareQuery = $oldDatabaseEntityManager->createNativeQuery('SELECT idsoftware, softwares.idtiposoftware, softwares.descripcion, softwares.grupoid, softwares.idcentro FROM softwares ', $rsmSoftware);
$softwareCollection = $softwareQuery->getResult();
foreach ($softwareCollection as $software) {
$output->writeln("SOFTWARE TOTAL: ". count($softwareCollection));
foreach ($softwareCollection as $software){
$softwareEntity = null;
$softwareEntity = $softwareRepository->findOneBy(['migrationId' => $software['idtiposoftware']]);
if (!$softwareEntity) {
$softwareEntity = $softwareRepository->findOneBy(['migrationId' => $software['idsoftware']]);
if(!$softwareEntity){
$type = match ($software['softwares.idtiposoftware']) {
1 => SoftwareTypes::OPERATIVE_SYSTEM,
2 => SoftwareTypes::APPLICATION,
3 => SoftwareTypes::FILE,
default => SoftwareTypes::APPLICATION,
};
$softwareEntity = new Software();
$softwareEntity->setMigrationId($software['idtiposoftware']);
$softwareEntity->setName($software['descripcion']);
$softwareEntity->setMigrationId($software['idsoftware']);
$softwareEntity->setDescription($software['descripcion']);
$softwareEntity->setName($software['descripcion']);
$softwareEntity->setType($type);
}
$migrationId = match ($software['softwares.grupoid']) {
0 => OrganizationalUnitTypes::ORGANIZATIONAL_UNIT . '-' . $software['softwares.idcentro'],
default => OrganizationalUnitTypes::CLASSROOMS_GROUP . '-' . $software['softwares.grupoid'],
};
$organizationalUnit = $organizationalUnitRepository->findOneBy(['migrationId' => $migrationId]);
/*
if ($organizationalUnit){
$softwareEntity->setOrganizationalUnit($organizationalUnit);
}*/
$this->entityManager->persist($softwareEntity);
}
/** Obtener los perfiles software de la base de datos antigua **/
$rsmSoftwareProfiles = new ResultSetMapping();
$rsmSoftwareProfiles->addScalarResult('idperfilsoft', 'idperfilsoft');
$rsmSoftwareProfiles->addScalarResult('descripcion', 'descripcion');
$rsmSoftwareProfiles->addScalarResult('comentarios', 'perfilessoft.comentarios');
$rsmSoftwareProfiles->addScalarResult('grupoid', 'perfilessoft.grupoid');
$rsmSoftwareProfiles->addScalarResult('idcentro', 'perfilessoft.idcentro');
$rsmSoftwareProfiles->addScalarResult('idnombreso', 'perfilessoft.idnombreso');
$softwareProfilesQuery = $oldDatabaseEntityManager->createNativeQuery('SELECT idperfilsoft, descripcion, grupos.comentarios, perfilessoft.grupoid, perfilessoft.idcentro, perfilessoft.idnombreso FROM perfilessoft LEFT JOIN grupos ON perfilessoft.grupoid = grupos.idgrupo', $rsmSoftwareProfiles);
$softwareProfiles = $softwareProfilesQuery->getResult();
/** Perfiles software **/
$output->writeln("PERFILES SOFTWARE TOTAL: ". count($softwareProfiles));
foreach ($softwareProfiles as $softwareProfile){
$softwareProfileEntity = null;
$softwareProfileEntity = $softwareProfileRepository->findOneBy(['migrationId' => $softwareProfile['idperfilsoft']]);
if(!$softwareProfileEntity){
$softwareProfileEntity = new SoftwareProfile();
$softwareProfileEntity->setMigrationId($softwareProfile['idperfilsoft']);
$softwareProfileEntity->setDescription($softwareProfile['descripcion']);
$softwareProfileEntity->setComments($softwareProfile['perfilessoft.comentarios']);
}
$migrationId = match ($softwareProfile['perfilessoft.grupoid']) {
0 => OrganizationalUnitTypes::ORGANIZATIONAL_UNIT . '-' . $softwareProfile['perfilessoft.idcentro'],
default => OrganizationalUnitTypes::CLASSROOMS_GROUP . '-' . $softwareProfile['perfilessoft.grupoid'],
};
$organizationalUnit = $organizationalUnitRepository->findOneBy(['migrationId' => $migrationId]);
if ($organizationalUnit){
$softwareProfileEntity->setOrganizationalUnit($organizationalUnit);
}
$operativeSystem = $operativeSystemRepository->findOneBy(['migrationId' => $softwareProfile['perfilessoft.idnombreso']]);
if ($operativeSystem){
$softwareProfileEntity->setOperativeSystem($operativeSystem);
}
$this->entityManager->persist($softwareProfileEntity);
}
/** Obtener los software, y asignarselos a los perfiles software **/
$rsmSoftwareProfilesRelation = new ResultSetMapping();
$rsmSoftwareProfilesRelation->addScalarResult('idperfilsoft', 'idperfilsoft');
$rsmSoftwareProfilesRelation->addScalarResult('idsoftware', 'idsoftware');
$softwareProfilesQuery = $oldDatabaseEntityManager->createNativeQuery('SELECT idperfilsoft, idsoftware FROM perfilessoft_softwares', $rsmSoftwareProfilesRelation);
$softwareProfileRelations = $softwareProfilesQuery->getResult();
$output->writeln("PERFILES SOFTWARE RELACIONES TOTAL: ". count($softwareProfileRelations));
foreach ($softwareProfileRelations as $softwareProfileRelation){
$softwareProfileEntity = $softwareProfileRepository->findOneBy(['migrationId' => $softwareProfileRelation['idperfilsoft']]);
$softwareEntity = $softwareRepository->findOneBy(['migrationId' => $softwareProfileRelation['idsoftware']]);
if ($softwareProfileEntity && $softwareEntity){
$softwareProfileEntity->addSoftwareCollection($softwareEntity);
$this->entityManager->persist($softwareProfileEntity);
}
}
$this->entityManager->flush();
return Command::SUCCESS;
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace App\Controller;
use App\Dto\Input\CommandExecuteInput;
use App\Dto\Input\CommandGroupAddCommandsInput;
use App\Entity\Client;
use App\Entity\Command;
use App\Entity\CommandGroup;
use App\Entity\Trace;
use App\Model\TraceStatus;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
class CommandExecuteAction extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager
)
{
}
public function __invoke(CommandExecuteInput $input, Command $command): JsonResponse
{
$clients = $input->clients;
/** @var Client $client */
foreach ($clients as $client) {
$trace = new Trace();
$trace->setClient($client->getEntity());
$trace->setCommand($command);
$trace->setStatus(TraceStatus::IN_PROGRESS);
$trace->setExecutedAt(new \DateTimeImmutable());
$this->entityManager->persist($trace);
}
$this->entityManager->flush();
return new JsonResponse(data: 'Command executed successfully', status: Response::HTTP_OK);
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace App\Controller;
use App\Dto\Input\CommandGroupAddCommandsInput;
use App\Entity\Command;
use App\Entity\CommandGroup;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
class CommandGroupAddCommandsAction extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager
)
{
}
public function __invoke(CommandGroupAddCommandsInput $input, CommandGroup $commandGroup): JsonResponse
{
$commands = $input->commands;
/** @var Command $command */
foreach ($commands as $command) {
$commandGroup->addCommand($command->getEntity());
}
$this->entityManager->persist($commandGroup);
$this->entityManager->flush();
return new JsonResponse(data: 'Commands added to command group successfully', status: Response::HTTP_OK);
}
}

View File

@ -0,0 +1,46 @@
<?php
namespace App\Controller;
use App\Dto\Input\CommandGroupAddCommandsInput;
use App\Dto\Input\CommandGroupExecuteInput;
use App\Entity\Client;
use App\Entity\Command;
use App\Entity\CommandGroup;
use App\Entity\Trace;
use App\Model\TraceStatus;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
class CommandGroupExecuteAction extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager
)
{
}
public function __invoke(CommandGroupExecuteInput $input, CommandGroup $commandGroup): JsonResponse
{
$clients = $input->clients;
foreach ($commandGroup->getCommands() as $command) {
/** @var Client $client */
foreach ($clients as $client) {
$trace = new Trace();
$trace->setClient($client->getEntity());
$trace->setCommand($command);
$trace->setStatus(TraceStatus::IN_PROGRESS);
$trace->setExecutedAt(new \DateTimeImmutable());
$this->entityManager->persist($trace);
}
}
$this->entityManager->flush();
return new JsonResponse(data: 'Command group executed successfully', status: Response::HTTP_OK);
}
}

View File

@ -4,6 +4,11 @@ declare(strict_types=1);
namespace App\Controller\OgAgent;
use App\Entity\Client;
use App\Entity\OrganizationalUnit;
use App\Entity\Partition;
use App\Model\OrganizationalUnitTypes;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
@ -14,8 +19,14 @@ use Symfony\Component\Routing\Attribute\Route;
#[AsController]
class OgAdmClientController extends AbstractController
{
#[Route('/opengnsys/rest/__ogAdmClient/InclusionCliente', methods: ['POST'])]
public function inclusionCliente(Request $request): JsonResponse
public function __construct(
protected readonly EntityManagerInterface $entityManager
)
{
}
#[Route('/opengnsys/rest/ogAdmClient/InclusionCliente', methods: ['POST'])]
public function processClient(Request $request): JsonResponse
{
$data = $request->toArray();
$requiredFields = ['iph', 'cfg'];
@ -26,21 +37,52 @@ class OgAdmClientController extends AbstractController
}
}
$clientEntity = $this->entityManager->getRepository(Client::class)->findOneBy(['ip' => $data['iph']]);
if (!$clientEntity) {
return new JsonResponse(['message' => 'Client not found'], Response::HTTP_NOT_FOUND);
}
foreach ($data['cfg'] as $cfg) {
if (isset($cfg['disk']) && isset($cfg['par'])) {
$partitionEntity = $this->entityManager->getRepository(Partition::class)
->findOneBy(['client' => $clientEntity, 'diskNumber' => $cfg['disk'], 'partitionNumber' => $cfg['par']]);
if (!$partitionEntity) {
$partitionEntity = new Partition();
}
$partitionEntity->setClient($clientEntity);
$partitionEntity->setDiskNumber((int)$cfg['disk']);
$partitionEntity->setPartitionNumber((int) $cfg['par']);
$partitionEntity->setSize((int) $cfg['tam'] ?? null);
$partitionEntity->setMemoryUsage((int) $cfg['uso'] * 100 ?? null);
$partitionEntity->setFileSystem($cfg['fsi'] ?? null);
$this->entityManager->persist($partitionEntity);
}
}
$this->entityManager->flush();
$center = $this->entityManager->getRepository(OrganizationalUnit::class)->find($clientEntity->getOrganizationalUnit()->getId());
$root = $this->entityManager->getRepository(OrganizationalUnit::class)->getRootNodes();
$responseData = [
'res' => 1,
'ido' => $data['ido'] ?? 42,
'npc' => $data['npc'] ?? 42,
'che' => 42,
'ido' => $clientEntity->getId(),
'npc' => $clientEntity->getName(),
'che' => 1,
'exe' => 42,
'ida' => $data['ida'] ?? 42,
'idc' => $data['idc'] ?? 42,
'ida' => $clientEntity->getOrganizationalUnit()?->getId(),
'idc' => $root[0]->getId(),
];
return new JsonResponse($responseData, Response::HTTP_OK);
}
#[Route('/opengnsys/rest/__ogAdmClient/AutoexecCliente', methods: ['POST'])]
#[Route('/opengnsys/rest/ogAdmClient/AutoexecCliente', methods: ['POST'])]
public function autoexecCliente(Request $request): JsonResponse
{
$data = $request->toArray();
@ -71,7 +113,7 @@ class OgAdmClientController extends AbstractController
return new JsonResponse($responseData, Response::HTTP_OK);
}
#[Route('/opengnsys/rest/__ogAdmClient/enviaArchivo', methods: ['POST'])]
#[Route('/opengnsys/rest/ogAdmClient/enviaArchivo', methods: ['POST'])]
public function enviaArchivo(Request $request): JsonResponse
{
$data = $request->toArray();
@ -95,7 +137,7 @@ class OgAdmClientController extends AbstractController
return new JsonResponse(['contents' => base64_encode($contents)], Response::HTTP_OK);
}
#[Route('/opengnsys/rest/__ogAdmClient/ComandosPendientes', methods: ['POST'])]
#[Route('/opengnsys/rest/ogAdmClient/ComandosPendientes', methods: ['POST'])]
public function comandosPendientes(Request $request): JsonResponse
{
$data = $request->toArray();
@ -122,7 +164,7 @@ class OgAdmClientController extends AbstractController
return new JsonResponse($param, Response::HTTP_OK);
}
#[Route('/opengnsys/rest/__ogAdmClient/DisponibilidadComandos', methods: ['POST'])]
#[Route('/opengnsys/rest/ogAdmClient/DisponibilidadComandos', methods: ['POST'])]
public function disponibilidadComandos(Request $request): JsonResponse
{
$data = $request->toArray();

View File

@ -0,0 +1,89 @@
<?php
namespace App\Controller\OgAgent;
use App\Entity\Client;
use App\Entity\Partition;
use App\Model\OgLiveStatus;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Component\HttpClient\Internal\ClientState;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Validator\Exception\ValidatorException;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
#[AsController]
class StatusAction extends AbstractController
{
public function __construct(
protected readonly EntityManagerInterface $entityManager,
protected readonly HttpClientInterface $httpClient
) {}
/**
* @throws TransportExceptionInterface
* @throws ServerExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface
*/
public function __invoke(Client $client): JsonResponse
{
if (!$client->getIp()) {
throw new ValidatorException('IP is required');
}
try {
$response = $this->httpClient->request('POST', 'https://' . $client->getIp() . ':8000/ogAdmClient/status', [
'verify_peer' => false, // Desactivar verificación del certificado
'verify_host' => false, // Desactivar verificación del nombre del host
'timeout' => 10, // Tiempo máximo de espera
'headers' => [
'Content-Type' => 'application/json', // Cabecera de tipo de contenido
],
'json' => [], // Cuerpo de la solicitud como JSON
]);
$statusCode = $response->getStatusCode();
$client->setStatus($statusCode === Response::HTTP_OK ? 'active' : 'off');
} catch (TransportExceptionInterface $e) {
$client->setStatus('off');
return new JsonResponse(
data: ['error' => $e->getMessage()],
status: Response::HTTP_INTERNAL_SERVER_ERROR
);
}
$data = json_decode($response->getContent(), true);
if (isset($data['cfg'])) {
foreach ($data['cfg'] as $cfg) {
$partitionEntity = $this->entityManager->getRepository(Partition::class)
->findOneBy(['client' => $client, 'diskNumber' => $cfg['disk'], 'partitionNumber' => $cfg['par']]);
if (!$partitionEntity) {
$partitionEntity = new Partition();
}
$partitionEntity->setClient($client);
$partitionEntity->setDiskNumber($cfg['disk']);
$partitionEntity->setPartitionNumber($cfg['par']);
$partitionEntity->setSize($cfg['tam']);
$partitionEntity->setMemoryUsage($cfg['uso']);
$this->entityManager->persist($partitionEntity);
}
}
$this->entityManager->persist($client);
$this->entityManager->flush();
return new JsonResponse(status: Response::HTTP_OK);
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace App\Controller\OgAgent\Webhook;
use App\Controller\OgBoot\AbstractOgBootController;
use App\Entity\OgLive;
use App\Model\OgLiveStatus;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Validator\Exception\ValidatorException;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
#[AsController]
class GetStatusAction extends AbstractController
{
public function __construct(
protected readonly EntityManagerInterface $entityManager
)
{
}
#[Route('/clients/status/webhook', name: 'status', methods: ['POST'])]
public function installWebhook(Request $request): JsonResponse
{
$data = json_decode($request->getContent(), true);
if (!is_array($data)) {
return new JsonResponse(['error' => 'Invalid JSON data'], Response::HTTP_BAD_REQUEST);
}
return new JsonResponse(data: $data, status: Response::HTTP_OK);
}
}

View File

@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
namespace App\Controller\OgBoot;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
#[AsController]
abstract class AbstractOgBootController extends AbstractController
{
public function __construct(
protected readonly string $ogBootApiUrl,
protected readonly EntityManagerInterface $entityManager
)
{
}
/**
* @throws TransportExceptionInterface
* @throws ServerExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface
*/
public function createRequest (HttpClientInterface $httpClient, string $method, string $url, array $params = []): JsonResponse|array
{
$params = array_merge($params, [
'headers' => [
'accept' => 'application/json',
'Content-Type' => 'application/json'
],
]);
try {
$response = $httpClient->request($method, $url, $params);
return json_decode($response->getContent(), true);
} catch (ClientExceptionInterface | ServerExceptionInterface $e) {
$response = $e->getResponse();
$content = json_decode($response->getContent(false), true);
throw new HttpException($response->getStatusCode(), $content['error'] ?? 'An error occurred');
} catch (TransportExceptionInterface $e) {
throw new HttpException(Response::HTTP_INTERNAL_SERVER_ERROR, $e->getMessage());
}
}
}

View File

@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace App\Controller\OgBoot;
use App\Service\OgBoot\StatusService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
#[Route('/og-boot')]
#[AsController]
class OgBootController extends AbstractController
{
public function __construct(
private readonly StatusService $ogbootStatusService,
)
{
}
/**
* @throws TransportExceptionInterface
* @throws ServerExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface
*/
#[Route('/status', name: 'ogboot_status', methods: ['GET'])]
public function status(): JsonResponse
{
$data = $this->ogbootStatusService->__invoke();
return new JsonResponse( data: $data, status: Response::HTTP_OK);
}
}

View File

@ -0,0 +1,36 @@
<?php
namespace App\Controller\OgBoot\OgLive;
use App\Controller\OgBoot\AbstractOgBootController;
use App\Entity\OgLive;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Validator\Exception\ValidatorException;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
#[AsController]
class GetAction extends AbstractOgBootController
{
/**
* @throws TransportExceptionInterface
* @throws ServerExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface
*/
public function __invoke(OgLive $data, HttpClientInterface $httpClient): JsonResponse
{
if (!$data->getChecksum()) {
throw new ValidatorException('Checksum is required');
}
$content = $this->createRequest($httpClient, 'GET', $this->ogBootApiUrl.'/ogboot/v1/oglives/'.$data->getChecksum());
return new JsonResponse(data: $content, status: Response::HTTP_OK);
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace App\Controller\OgBoot\OgLive;
use App\Controller\OgBoot\AbstractOgBootController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Validator\Exception\ValidatorException;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
#[AsController]
class GetCollectionAction extends AbstractOgBootController
{
/**
* @throws TransportExceptionInterface
* @throws ServerExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface
*/
public function __invoke(HttpClientInterface $httpClient): JsonResponse
{
$content = $this->createRequest($httpClient, 'GET', $this->ogBootApiUrl.'/ogboot/v1/oglives');
return new JsonResponse(data: $content, status: Response::HTTP_OK);
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Controller\OgBoot\OgLive;
use App\Controller\OgBoot\AbstractOgBootController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
#[AsController]
class GetDefaultAction extends AbstractOgBootController
{
/**
* @throws TransportExceptionInterface
* @throws ServerExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface
*/
public function __invoke(HttpClientInterface $httpClient): JsonResponse
{
$content = $this->createRequest($httpClient, 'GET', $this->ogBootApiUrl.'/ogboot/v1/oglives/default');
return new JsonResponse(status: Response::HTTP_OK);
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace App\Controller\OgBoot\OgLive;
use App\Controller\OgBoot\AbstractOgBootController;
use App\Entity\OgLive;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
#[AsController]
class GetIsosAction extends AbstractOgBootController
{
/**
* @throws TransportExceptionInterface
* @throws ServerExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface
*/
public function __invoke(HttpClientInterface $httpClient): JsonResponse
{
$content = $this->createRequest($httpClient, 'GET', $this->ogBootApiUrl.'/ogboot/v1/oglives/isos');
return new JsonResponse(data: $content, status: Response::HTTP_OK);
}
}

View File

@ -0,0 +1,49 @@
<?php
namespace App\Controller\OgBoot\OgLive;
use App\Controller\OgBoot\AbstractOgBootController;
use App\Entity\OgLive;
use App\Model\OgLiveStatus;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Validator\Exception\ValidatorException;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
#[AsController]
class InstallAction extends AbstractOgBootController
{
/**
* @throws TransportExceptionInterface
* @throws ServerExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface
*/
public function __invoke(OgLive $data, HttpClientInterface $httpClient, EntityManagerInterface $entityManager): JsonResponse
{
if (!$data->getDownloadUrl()) {
throw new ValidatorException('Download URL is required');
}
$params = [
'json' => [
'url' => $data->getDownloadUrl(),
'id' => $data->getUuid()
]
];
$content = $this->createRequest($httpClient, 'POST', $this->ogBootApiUrl.'/ogboot/v1/oglives/install', $params);
$data->setStatus(OgLiveStatus::PENDING);
$entityManager->persist($data);
$entityManager->flush();
return new JsonResponse(data: $content, status: Response::HTTP_OK);
}
}

View File

@ -0,0 +1,54 @@
<?php
namespace App\Controller\OgBoot\OgLive;
use App\Controller\OgBoot\AbstractOgBootController;
use App\Entity\OgLive;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Validator\Exception\ValidatorException;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
#[AsController]
class SetDefaultAction extends AbstractOgBootController
{
/**
* @throws TransportExceptionInterface
* @throws ServerExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface
*/
public function __invoke(OgLive $data, HttpClientInterface $httpClient, EntityManagerInterface $entityManager): JsonResponse
{
if (!$data->getChecksum()) {
throw new ValidatorException('Checksum URL is required');
}
$params = [
'json' => [
'checksum' => $data->getChecksum()
]
];
$content = $this->createRequest($httpClient, 'PUT', $this->ogBootApiUrl.'/ogboot/v1/oglives/default', $params);
$oldDefaultOgLive = $this->entityManager->getRepository(OgLive::class)->findBy(['isDefault' => true]);
foreach ($oldDefaultOgLive as $oldOgLive) {
$oldOgLive->setIsDefault(false);
$this->entityManager->persist($oldOgLive);
}
$data->setIsDefault(true);
$entityManager->persist($data);
$entityManager->flush();
return new JsonResponse(status: Response::HTTP_OK);
}
}

View File

@ -0,0 +1,80 @@
<?php
namespace App\Controller\OgBoot\OgLive;
use App\Controller\OgBoot\AbstractOgBootController;
use App\Entity\OgLive;
use App\Model\OgLiveStatus;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Validator\Exception\ValidatorException;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
#[AsController]
class SyncAction extends AbstractOgBootController
{
/**
* @throws TransportExceptionInterface
* @throws ServerExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface
*/
public function __invoke(HttpClientInterface $httpClient, EntityManagerInterface $entityManager): JsonResponse
{
$content = $this->createRequest($httpClient, 'GET', $this->ogBootApiUrl . '/ogboot/v1/oglives');
foreach ($content['message']['installed_ogLives'] as $ogLive) {
$ogLiveEntity = $this->entityManager->getRepository(OgLive::class)->findOneBy(['checksum' => $ogLive['id']]);
if ($ogLiveEntity) {
$this->extracted($ogLiveEntity, $ogLive);
$this->entityManager->persist($ogLiveEntity);
} else {
$ogLiveEntity = new OgLive();
$this->extracted($ogLiveEntity, $ogLive);
}
$this->entityManager->persist($ogLiveEntity);
}
$this->entityManager->flush();
//$this->serDefaultOgLive($content['default_oglive']);
return new JsonResponse(data: $content, status: Response::HTTP_OK);
}
/**
* @param OgLive|null $ogLiveEntity
* @param mixed $ogLive
* @return void
*/
private function extracted(OgLive|null $ogLiveEntity, mixed $ogLive): void
{
$ogLiveEntity->setName($ogLive['directory']);
$ogLiveEntity->setInstalled(true);
$ogLiveEntity->setArchitecture($ogLive['architecture']);
$ogLiveEntity->setDistribution($ogLive['distribution']);
$ogLiveEntity->setFilename($ogLive['directory']);
$ogLiveEntity->setKernel($ogLive['kernel']);
$ogLiveEntity->setRevision($ogLive['revision']);
$ogLiveEntity->setDirectory($ogLive['directory']);
$ogLiveEntity->setChecksum($ogLive['id']);
$ogLiveEntity->setStatus(OgLiveStatus::ACTIVE);
}
private function serDefaultOgLive(string $defaultOgLive): void
{
$ogLiveEntity = $this->entityManager->getRepository(OgLive::class)->findOneBy(['name' => $defaultOgLive]);
if (!$ogLiveEntity) {
return;
}
$ogLiveEntity->setIsDefault(true);
$this->entityManager->persist($ogLiveEntity);
$this->entityManager->flush();
}
}

View File

@ -0,0 +1,41 @@
<?php
namespace App\Controller\OgBoot\OgLive;
use App\Controller\OgBoot\AbstractOgBootController;
use App\Entity\OgLive;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\Validator\Exception\ValidatorException;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
#[AsController]
class UninstallAction extends AbstractOgBootController
{
/**
* @throws ServerExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface
* @throws TransportExceptionInterface
*/
public function __invoke(OgLive $data, HttpClientInterface $httpClient, EntityManagerInterface $entityManager): JsonResponse
{
if (!$data->getChecksum()) {
throw new ValidatorException('Checksum is required');
}
$content = $this->createRequest($httpClient, 'DELETE', $this->ogBootApiUrl.'/ogboot/v1/oglives/'.$data->getChecksum());
$entityManager->remove($data);
$entityManager->flush();
return new JsonResponse(status: Response::HTTP_OK);
}
}

View File

@ -0,0 +1,98 @@
<?php
namespace App\Controller\OgBoot\OgLive\Webhook;
use App\Controller\OgBoot\AbstractOgBootController;
use App\Entity\OgLive;
use App\Model\OgLiveStatus;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Validator\Exception\ValidatorException;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
#[AsController]
class InstallOgLiveResponseAction extends AbstractController
{
public CONST string OG_LIVE_INSTALL_SUCCESS = 'success';
public CONST string OG_LIVE_INSTALL_FAILED = 'failure';
public function __construct(
protected readonly EntityManagerInterface $entityManager
)
{
}
#[Route('/og-lives/install/webhook', name: 'install_webhook', methods: ['POST'])]
public function installWebhook(Request $request): JsonResponse
{
$data = json_decode($request->getContent(), true);
if (!is_array($data)) {
return new JsonResponse(['error' => 'Invalid JSON data'], Response::HTTP_BAD_REQUEST);
}
$data = $data['webhookData'];
if ($data === null || !isset($data['message'], $data['ogCoreId'], $data['status'])) {
return new JsonResponse(['error' => 'Invalid or incomplete JSON data'], Response::HTTP_BAD_REQUEST);
}
$message = $data['message'];
$ogCoreId = $data['ogCoreId'];
$status = $data['status'];
$ogLive = $this->entityManager->getRepository(OgLive::class)->findOneBy(['uuid' => $ogCoreId]);
if (!$ogLive) {
return new JsonResponse(['error' => 'OgLive not found'], Response::HTTP_NOT_FOUND);
}
if ($ogLive->getStatus() === OgLiveStatus::ACTIVE) {
return new JsonResponse(['error' => 'OgLive is already active'], Response::HTTP_BAD_REQUEST);
}
$this->updateOgLive($ogLive, $message, $status);
return new JsonResponse(data: sprintf('OgLive %s updated successfully', $ogLive->getChecksum()), status: Response::HTTP_OK);
}
private function updateOgLive (OgLive $ogLive, array $details, string $status): void
{
if ($status === self::OG_LIVE_INSTALL_SUCCESS) {
$ogLive->setInstalled(true);
$ogLive->setSynchronized(true);
$ogLive->setChecksum($details['id']);
$ogLive->setDistribution($details['distribution']);
$ogLive->setKernel($details['kernel']);
$ogLive->setArchitecture($details['architecture']);
$ogLive->setRevision($details['revision']);
$ogLive->setDirectory($details['directory']);
}
$ogLive->setStatus($status === self::OG_LIVE_INSTALL_SUCCESS ? OgLiveStatus::ACTIVE : OgLiveStatus::FAILED);
$ogLive->setInstalled($status === self::OG_LIVE_INSTALL_SUCCESS);
$oldDefaultOgLive = $this->entityManager->getRepository(OgLive::class)->findBy(['isDefault' => true]);
foreach ($oldDefaultOgLive as $oldOgLive) {
$oldOgLive->setIsDefault(false);
$this->entityManager->persist($oldOgLive);
}
$ogLive->setIsDefault(true);
$this->entityManager->persist($ogLive);
$this->entityManager->flush();
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace App\Controller\OgBoot\PxeBootFile;
use App\Controller\OgBoot\AbstractOgBootController;
use App\Entity\Client;
use App\Entity\PxeTemplate;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
#[AsController]
class GetAction extends AbstractOgBootController
{
/**
* @throws TransportExceptionInterface
* @throws ServerExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface
*/
public function __invoke(Client $client, HttpClientInterface $httpClient): JsonResponse
{
try {
$response = $httpClient->request('GET', $this->ogBootApiUrl.'/ogboot/v1/pxes/'.$client->getMac(), [
'headers' => [
'accept' => 'application/json',
],
]);
} catch (TransportExceptionInterface $e) {
return new JsonResponse( data: 'An error occurred', status: Response::HTTP_INTERNAL_SERVER_ERROR);
}
$data = json_decode($response->getContent(), true);
return new JsonResponse( data: $data, status: Response::HTTP_OK);
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\Controller\OgBoot\PxeBootFile;
use App\Controller\OgBoot\AbstractOgBootController;
use App\Entity\PxeBootFile;
use App\Entity\PxeTemplate;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
#[AsController]
class GetCollectionAction extends AbstractOgBootController
{
/**
* @throws TransportExceptionInterface
* @throws ServerExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface
*/
public function __invoke(HttpClientInterface $httpClient): JsonResponse
{
$content = $this->createRequest($httpClient, 'GET', $this->ogBootApiUrl.'/ogboot/v1/pxes');
return new JsonResponse(data: $content, status: Response::HTTP_OK);
}
}

View File

@ -0,0 +1,80 @@
<?php
namespace App\Controller\OgBoot\PxeBootFile;
use App\Controller\OgBoot\AbstractOgBootController;
use App\Dto\Input\PxeTemplateSyncClientInput;
use App\Entity\Client;
use App\Entity\PxeTemplate;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
#[AsController]
class PostAction extends AbstractOgBootController
{
/**
* @throws TransportExceptionInterface
* @throws ServerExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ClientExceptionInterface
*/
public function __invoke(PxeTemplateSyncClientInput $input, PxeTemplate $pxeTemplate, HttpClientInterface $httpClient): JsonResponse
{
/** @var Client $client */
$client = $input->client->getEntity();
$data = [
'template_name' => $pxeTemplate->getName(),
'mac' => strtolower($client->getMac()),
'lang' => 'es_ES.UTF_8',
'ip' => $client->getIp(),
'server_ip' => '192.168.2.4',
'router' => $client->getOrganizationalUnit()->getNetworkSettings()->getRouter(),
'netmask' => $client->getOrganizationalUnit()->getNetworkSettings() ? $client->getOrganizationalUnit()->getNetworkSettings()->getNetmask() : '255.255.255.0',
'computer_name' => $client->getName(),
'netiface' => $client->getNetiface(),
'group' => $client->getOrganizationalUnit()->getName(),
'ogrepo' => $client->getRepository() ? $client->getRepository()->getIpAddress() : '192.168.2.4',
'oglive' => '192.168.2.4',
'oglog' => '192.168.2.4',
'ogshare' => '192.168.2.4',
'oglivedir' => 'ogLive',
'ogprof' => 'false',
'hardprofile' => $client->getHardwareProfile() ? $client->getHardwareProfile()->getDescription() : 'default',
'ogntp' => $client->getOrganizationalUnit()->getNetworkSettings()?->getNtp(),
'ogdns' => $client->getOrganizationalUnit()->getNetworkSettings()?->getDns(),
'ogProxy' => $client->getOrganizationalUnit()->getNetworkSettings()?->getProxy(),
'ogunit' => '',
'resolution' => '788'
];
try {
$response = $httpClient->request('POST', $this->ogBootApiUrl.'/ogboot/v1/pxes', [
'headers' => [
'accept' => 'application/json',
'Content-Type' => 'application/json',
],
'json' => $data
]);
} catch (TransportExceptionInterface $e) {
$client->setPxeSync(false);
$this->entityManager->persist($client);
$this->entityManager->flush();
return new JsonResponse( data: $e->getMessage(), status: Response::HTTP_INTERNAL_SERVER_ERROR);
}
$client->setPxeSync(true);
$this->entityManager->persist($client);
$this->entityManager->flush();
return new JsonResponse(data: json_decode($response->getContent(), true), status: Response::HTTP_OK);
}
}

Some files were not shown because too many files have changed in this diff Show More