diff --git a/Jenkinsfile b/Jenkinsfile index c0e936e..64117be 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,8 +22,19 @@ pipeline { } stage('Build Environment') { steps { + sh ''' + # Detener todos los contenedores si hay alguno ejecutándose + if [ $(docker ps -q | wc -l) -gt 0 ]; then + docker stop $(docker ps -q) + fi + + # Eliminar todos los contenedores si hay alguno detenido + if [ $(docker ps -a -q | wc -l) -gt 0 ]; then + docker rm $(docker ps -a -q) + fi + ''' script { - + docker.build("${DOCKER_IDENTITY}", '-f docker/Dockerfile-jenkins-php .') docker.build("${DOCKER_IDENTITY_NGINX}", '-f docker/Dockerfile-nginx .') } @@ -72,6 +83,10 @@ pipeline { docker.image("${DOCKER_IDENTITY}").push("latest") docker.image("${DOCKER_IDENTITY_NGINX}").push("latest") } + if (env.TAG_NAME) { + docker.image("${DOCKER_IDENTITY}").push("${env.TAG_NAME}") + docker.image("${DOCKER_IDENTITY_NGINX}").push("${env.TAG_NAME}") + } } } } @@ -79,19 +94,7 @@ pipeline { } 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_FILE} down" - sh "docker compose -f ${DOCKER_COMPOSE_FILE} rm -f" - sh "docker rmi ${DOCKER_IDENTITY}" - sh "docker rmi ${DOCKER_IDENTITY_NGINX}" + always { script { def committerEmail = sh ( script: "git show -s --pretty=%ae", @@ -109,6 +112,17 @@ pipeline { Opengnsys CI """ } + 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_FILE} down" + sh "docker compose -f ${DOCKER_COMPOSE_FILE} rm -f" + sh "docker rmi ${DOCKER_IDENTITY}" + sh "docker rmi ${DOCKER_IDENTITY_NGINX}" } } } diff --git a/composer.lock b/composer.lock index e2c3c61..2bfe6d3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "696433794f1d706f6d16af7589d2c1ea", + "content-hash": "aaa904068da3e39927da2e6658330011", "packages": [ { "name": "api-platform/core", @@ -3768,16 +3768,16 @@ }, { "name": "symfony/dotenv", - "version": "v6.4.10", + "version": "v6.4.13", "source": { "type": "git", "url": "https://github.com/symfony/dotenv.git", - "reference": "2ae0c84cc9be0dc1eeb86016970b63c764d8472e" + "reference": "436ae2dd89360fea8c7d5ff3f48ecf523c80bfb4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dotenv/zipball/2ae0c84cc9be0dc1eeb86016970b63c764d8472e", - "reference": "2ae0c84cc9be0dc1eeb86016970b63c764d8472e", + "url": "https://api.github.com/repos/symfony/dotenv/zipball/436ae2dd89360fea8c7d5ff3f48ecf523c80bfb4", + "reference": "436ae2dd89360fea8c7d5ff3f48ecf523c80bfb4", "shasum": "" }, "require": { @@ -3822,7 +3822,7 @@ "environment" ], "support": { - "source": "https://github.com/symfony/dotenv/tree/v6.4.10" + "source": "https://github.com/symfony/dotenv/tree/v6.4.13" }, "funding": [ { @@ -3838,7 +3838,7 @@ "type": "tidelift" } ], - "time": "2024-07-09T18:29:35+00:00" + "time": "2024-09-28T07:43:51+00:00" }, { "name": "symfony/error-handler", diff --git a/config/api_platform/Client.yaml b/config/api_platform/Client.yaml index d1e1d84..33a92c3 100644 --- a/config/api_platform/Client.yaml +++ b/config/api_platform/Client.yaml @@ -38,6 +38,7 @@ resources: class: ApiPlatform\Metadata\Post method: POST input: false + output: false uriTemplate: /clients/{uuid}/agent/status controller: App\Controller\OgAgent\StatusAction diff --git a/config/api_platform/Image.yaml b/config/api_platform/Image.yaml index 37ab891..8aea897 100644 --- a/config/api_platform/Image.yaml +++ b/config/api_platform/Image.yaml @@ -13,6 +13,7 @@ resources: filters: - 'api_platform.filter.image.order' - 'api_platform.filter.image.search' + - 'api_platform.filter.image.boolean' ApiPlatform\Metadata\Get: provider: App\State\Provider\ImageProvider ApiPlatform\Metadata\Put: @@ -22,6 +23,58 @@ resources: ApiPlatform\Metadata\Post: ~ ApiPlatform\Metadata\Delete: ~ + get_image_ogrepository: + shortName: OgRepository Server + description: Get image in OgRepository + class: ApiPlatform\Metadata\Get + method: GET + input: false + uriTemplate: /images/server/{uuid}/get + controller: App\Controller\OgRepository\Image\GetAction + + create_aux_files_image_ogrepository: + shortName: OgRepository Server + class: ApiPlatform\Metadata\Post + method: POST + input: false + uriTemplate: /images/server/{uuid}/create-aux-files + controller: App\Controller\OgRepository\Image\CreateAuxFilesAction + + deploy_image_ogrepository: + shortName: OgRepository Server + class: ApiPlatform\Metadata\Post + method: POST + input: App\Dto\Input\DeployImageInput + uriTemplate: /images/{uuid}/deploy-image + controller: App\Controller\DeployImageAction + + trash_delete_image_ogrepository: + shortName: OgRepository Server + description: Delete Image in OgRepository + class: ApiPlatform\Metadata\Post + method: POST + input: false + uriTemplate: /images/server/{uuid}/delete-trash + controller: App\Controller\OgRepository\Image\DeleteTrashAction + + permanent_delete_image_ogrepository: + shortName: OgRepository Server + description: Delete Image in OgRepository + class: ApiPlatform\Metadata\Post + method: POST + input: false + uriTemplate: /images/server/{uuid}/delete-permanent + controller: App\Controller\OgRepository\Image\DeletePermanentAction + + recover_image_ogrepository: + shortName: OgRepository Server + description: Recover Image in OgRepository + class: ApiPlatform\Metadata\Post + method: POST + input: false + uriTemplate: /images/server/{uuid}/recover + controller: App\Controller\OgRepository\Image\RecoverAction + properties: App\Entity\Image: id: diff --git a/config/api_platform/ImageRepository.yaml b/config/api_platform/ImageRepository.yaml new file mode 100644 index 0000000..7ff7d33 --- /dev/null +++ b/config/api_platform/ImageRepository.yaml @@ -0,0 +1,56 @@ +resources: + App\Entity\ImageRepository: + processor: App\State\Processor\ImageRepositoryProcessor + input: App\Dto\Input\ImageRepositoryInput + output: App\Dto\Output\ImageRepositoryOutput + normalizationContext: + groups: ['default', 'repository:read'] + denormalizationContext: + groups: ['repository:write'] + operations: + ApiPlatform\Metadata\GetCollection: + provider: App\State\Provider\ImageRepositoryProvider + filters: + - 'api_platform.filter.repository.order' + - 'api_platform.filter.repository.search' + ApiPlatform\Metadata\Get: + provider: App\State\Provider\ImageRepositoryProvider + ApiPlatform\Metadata\Put: + provider: App\State\Provider\ImageRepositoryProvider + ApiPlatform\Metadata\Patch: + provider: App\State\Provider\ImageRepositoryProvider + ApiPlatform\Metadata\Post: ~ + ApiPlatform\Metadata\Delete: ~ + + image_ogrepository_sync: + shortName: OgRepository Server + class: ApiPlatform\Metadata\Get + method: GET + input: false + uriTemplate: /image-repositories/server/sync + controller: App\Controller\OgRepository\SyncAction + + get_collection_images_ogrepository: + shortName: OgRepository Server + description: Get collection of image in OgRepository + class: ApiPlatform\Metadata\Get + method: GET + input: false + uriTemplate: /image-repositories/server/get-collection + controller: App\Controller\OgRepository\GetCollectionAction + + images_ogrepository_status: + shortName: OgRepository Server + description: Get status of OgRepository + class: ApiPlatform\Metadata\Get + method: GET + input: false + uriTemplate: /image-repositories/server/{uuid}/status + controller: App\Controller\OgRepository\StatusAction + +properties: + App\Entity\ImageRepository: + id: + identifier: false + uuid: + identifier: true \ No newline at end of file diff --git a/config/api_platform/Partition.yaml b/config/api_platform/Partition.yaml index 7d09114..3103413 100644 --- a/config/api_platform/Partition.yaml +++ b/config/api_platform/Partition.yaml @@ -3,6 +3,8 @@ resources: processor: App\State\Processor\PartitionProcessor input: App\Dto\Input\PartitionInput output: App\Dto\Output\PartitionOutput + orderBy: + partitionNumber: 'ASC' normalizationContext: groups: ['default', 'partition:read'] denormalizationContext: diff --git a/config/api_platform/SoftwareProfile.yaml b/config/api_platform/SoftwareProfile.yaml index 899cad8..ff08333 100644 --- a/config/api_platform/SoftwareProfile.yaml +++ b/config/api_platform/SoftwareProfile.yaml @@ -17,7 +17,7 @@ resources: ApiPlatform\Metadata\Get: provider: App\State\Provider\SoftwareProfileProvider normalizationContext: - groups: ['software-profile:item:get', 'software-profile:read:collection:short'] + groups: ['software-profile:read', 'software-profile:item:get', 'software-profile:read:collection:short'] ApiPlatform\Metadata\Put: provider: App\State\Provider\SoftwareProfileProvider ApiPlatform\Metadata\Patch: diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 568ba93..ac8c830 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -30,6 +30,7 @@ security: - { path: ^/docs, roles: PUBLIC_ACCESS } # Allows accessing the Swagger UI docs - { path: ^/auth/login, roles: PUBLIC_ACCESS } - { path: ^/opengnsys/rest, roles: PUBLIC_ACCESS } + - { path: ^/og-repository/webhook, roles: PUBLIC_ACCESS } - { path: ^/og-lives/install/webhook, roles: PUBLIC_ACCESS } - { path: ^/auth/refresh, roles: PUBLIC_ACCESS } - { path: ^/, roles: IS_AUTHENTICATED_FULLY } diff --git a/config/services.yaml b/config/services.yaml index 294e4b8..0987229 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -4,22 +4,16 @@ imports: parameters: services: + App\DependencyInjection\JsonEnvVarLoader: + tags: ['container.env_var_loader'] + _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: - - '../src/DependencyInjection/' - '../src/Entity/' - '../src/Kernel.php' @@ -152,3 +146,8 @@ services: bind: $collectionProvider: '@api_platform.doctrine.orm.state.collection_provider' $itemProvider: '@api_platform.doctrine.orm.state.item_provider' + + App\State\Provider\ImageRepositoryProvider: + bind: + $collectionProvider: '@api_platform.doctrine.orm.state.collection_provider' + $itemProvider: '@api_platform.doctrine.orm.state.item_provider' diff --git a/config/services/api_platform.yaml b/config/services/api_platform.yaml index b5f7b49..5987770 100644 --- a/config/services/api_platform.yaml +++ b/config/services/api_platform.yaml @@ -61,7 +61,12 @@ services: api_platform.filter.image.search: parent: 'api_platform.doctrine.orm.search_filter' - arguments: [ { 'id': 'exact', 'name': 'partial', } ] + arguments: [ { 'id': 'exact', 'name': 'partial', 'repository.id': 'exact'} ] + tags: [ 'api_platform.filter' ] + + api_platform.filter.image.boolean: + parent: 'api_platform.doctrine.orm.boolean_filter' + arguments: [ { 'created': ~ } ] tags: [ 'api_platform.filter' ] api_platform.filter.og_live.order: @@ -211,7 +216,7 @@ services: api_platform.filter.trace.search: parent: 'api_platform.doctrine.orm.search_filter' - arguments: [ { 'id': 'exact', 'command.id': 'exact', 'client.id': 'exact' } ] + arguments: [ { 'id': 'exact', 'command.id': 'exact', 'client.id': 'exact', status: 'exact' } ] tags: [ 'api_platform.filter' ] api_platform.filter.trace.order: diff --git a/docker-compose-ci-template.yaml b/docker-compose-ci-template.yaml index b407aa8..3daf1ae 100644 --- a/docker-compose-ci-template.yaml +++ b/docker-compose-ci-template.yaml @@ -36,10 +36,6 @@ services: 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 diff --git a/docker-compose-ci.yaml b/docker-compose-ci.yaml index d6442f7..897d8c5 100644 --- a/docker-compose-ci.yaml +++ b/docker-compose-ci.yaml @@ -35,10 +35,6 @@ services: 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 diff --git a/docker-compose-deploy.yml b/docker-compose-deploy.yml index 36f1181..acf0ce8 100644 --- a/docker-compose-deploy.yml +++ b/docker-compose-deploy.yml @@ -36,12 +36,12 @@ services: 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 volumes: - ogpublic:/var/www/html/public + - /opt/opengnsys/ogCore/etc/.env:/var/www/html/.env + - /opt/opengnsys/ogCore/etc/env.json://var/www/html/env.json + +>>>>>>> develop networks: - ogcore-network image: opengnsys/ogcore-php:static @@ -50,5 +50,6 @@ volumes: database_data: ogpublic: + networks: ogcore-network: diff --git a/docker-compose.yaml b/docker-compose.yaml index 8a5bd62..b6c7909 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -39,10 +39,6 @@ services: - ./:/var/www/html depends_on: - database - environment: - XDEBUG_CLIENT_HOST: 127.17.0.1 - XDEBUG_CLIENT_PORT: 9003 - PHP_IDE_CONFIG: serverName=ogcore networks: - ogcore-network diff --git a/docker/Dockerfile-jenkins-php b/docker/Dockerfile-jenkins-php index 370b3c2..2702ee7 100644 --- a/docker/Dockerfile-jenkins-php +++ b/docker/Dockerfile-jenkins-php @@ -19,13 +19,6 @@ ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/do RUN chmod +x /usr/local/bin/install-php-extensions RUN install-php-extensions sockets -# Add xdebug -RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS -RUN apk add --update linux-headers -RUN pecl install xdebug -RUN docker-php-ext-enable xdebug -RUN apk del -f .build-deps -COPY ./docker/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini COPY . /var/www/html diff --git a/docker/Dockerfile-php b/docker/Dockerfile-php index a4cdcb8..e8be930 100644 --- a/docker/Dockerfile-php +++ b/docker/Dockerfile-php @@ -19,15 +19,6 @@ ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/do RUN chmod +x /usr/local/bin/install-php-extensions RUN install-php-extensions sockets -# Add xdebug -RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS -RUN apk add --update linux-headers -RUN pecl install xdebug -RUN docker-php-ext-enable xdebug -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 "" diff --git a/docker/xdebug.ini b/docker/xdebug.ini deleted file mode 100644 index af39592..0000000 --- a/docker/xdebug.ini +++ /dev/null @@ -1,5 +0,0 @@ -xdebug.mode=debug -xdebug.start_with_request=trigger -xdebug.discover_client_host = 1 -xdebug.client_host=${XDEBUG_CLIENT_HOST} -xdebug.client_port=${XDEBUG_CLIENT_PORT} \ No newline at end of file diff --git a/env.json b/env.json new file mode 100644 index 0000000..d5d8034 --- /dev/null +++ b/env.json @@ -0,0 +1,11 @@ +{ + "vars": { + "OG_BOOT_API_URL": "192.168.68.58", + "OG_DHCP_API_URL": "192.168.68.58:81", + "OG_CORE_IP": "192.168.68.62", + "UDS_AUTH_LOGIN": "Usuarios locales", + "UDS_AUTH_USERNAME": "natiqindel", + "UDS_AUTH_PASSWORD": "correct horse battery staple", + "UDS_URL": "https:\/\/localhost:8087\/uds\/rest\/" + } +} \ No newline at end of file diff --git a/migrations/Version20240617113606.php b/migrations/Version20240617113606.php deleted file mode 100644 index 3c98a3c..0000000 --- a/migrations/Version20240617113606.php +++ /dev/null @@ -1,81 +0,0 @@ -addSql('CREATE TABLE client (id INT AUTO_INCREMENT NOT NULL, organizational_unit_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, serial_number VARCHAR(255) DEFAULT NULL, netiface VARCHAR(255) DEFAULT NULL, net_driver VARCHAR(255) DEFAULT NULL, mac VARCHAR(255) DEFAULT NULL, ip VARCHAR(255) DEFAULT NULL, status VARCHAR(255) DEFAULT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_C7440455D17F50A6 (uuid), INDEX IDX_C7440455FB84408A (organizational_unit_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE hardware (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, description VARCHAR(255) DEFAULT NULL, type VARCHAR(255) DEFAULT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_FE99E9E0D17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE hardware_profile (id INT AUTO_INCREMENT NOT NULL, organizational_unit_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, description VARCHAR(255) DEFAULT NULL, comments VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_2D9A2460D17F50A6 (uuid), INDEX IDX_2D9A2460FB84408A (organizational_unit_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE hardware_profile_hardware (hardware_profile_id INT NOT NULL, hardware_id INT NOT NULL, INDEX IDX_18C7E12CFA495C1 (hardware_profile_id), INDEX IDX_18C7E12C9CC762B (hardware_id), PRIMARY KEY(hardware_profile_id, hardware_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE menu (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, title VARCHAR(255) NOT NULL, resolution VARCHAR(255) NOT NULL, comments VARCHAR(255) DEFAULT NULL, public_url VARCHAR(255) DEFAULT NULL, private_url VARCHAR(255) DEFAULT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_7D053A93D17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE network_settings (id INT AUTO_INCREMENT NOT NULL, menu_id INT DEFAULT NULL, hardware_profile_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, proxy VARCHAR(255) DEFAULT NULL, dns VARCHAR(255) DEFAULT NULL, netmask VARCHAR(255) DEFAULT NULL, router VARCHAR(255) DEFAULT NULL, ntp VARCHAR(255) DEFAULT NULL, p2p_time INT DEFAULT NULL, p2p_mode VARCHAR(255) DEFAULT NULL, mcast_ip VARCHAR(255) DEFAULT NULL, mcast_speed INT DEFAULT NULL, mcast_mode VARCHAR(255) DEFAULT NULL, mcast_port INT DEFAULT NULL, validation TINYINT(1) DEFAULT NULL, UNIQUE INDEX UNIQ_48869B54D17F50A6 (uuid), INDEX IDX_48869B54CCD7E912 (menu_id), INDEX IDX_48869B54CFA495C1 (hardware_profile_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE organizational_unit (id INT AUTO_INCREMENT NOT NULL, parent_id INT DEFAULT NULL, network_settings_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, description VARCHAR(255) DEFAULT NULL, comments VARCHAR(255) DEFAULT NULL, path VARCHAR(255) DEFAULT NULL, level INT DEFAULT NULL, slug VARCHAR(255) DEFAULT NULL, type VARCHAR(255) NOT NULL, location VARCHAR(255) DEFAULT NULL, projector TINYINT(1) DEFAULT NULL, board TINYINT(1) DEFAULT NULL, capacity INT DEFAULT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_749AEB2DD17F50A6 (uuid), INDEX IDX_749AEB2D727ACA70 (parent_id), INDEX IDX_749AEB2D9B9A36D0 (network_settings_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE `partition` (id INT AUTO_INCREMENT NOT NULL, client_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, disk_number INT DEFAULT NULL, partition_number INT DEFAULT NULL, partition_code VARCHAR(255) DEFAULT NULL, size INT NOT NULL, cache_content VARCHAR(255) DEFAULT NULL, filesystem VARCHAR(255) DEFAULT NULL, os_name VARCHAR(255) NOT NULL, memory_usage INT NOT NULL, UNIQUE INDEX UNIQ_9EB910E4D17F50A6 (uuid), INDEX IDX_9EB910E419EB6921 (client_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE refresh_tokens (id INT AUTO_INCREMENT NOT NULL, refresh_token VARCHAR(128) NOT NULL, username VARCHAR(255) NOT NULL, valid DATETIME NOT NULL, UNIQUE INDEX UNIQ_9BACE7E1C74F2195 (refresh_token), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE user (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, username VARCHAR(180) NOT NULL, roles JSON NOT NULL COMMENT \'(DC2Type:json)\', password VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_8D93D649D17F50A6 (uuid), UNIQUE INDEX UNIQ_IDENTIFIER_USERNAME (username), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE user_organizational_unit (user_id INT NOT NULL, organizational_unit_id INT NOT NULL, INDEX IDX_5E59845FA76ED395 (user_id), INDEX IDX_5E59845FFB84408A (organizational_unit_id), PRIMARY KEY(user_id, organizational_unit_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE user_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, permissions JSON NOT NULL COMMENT \'(DC2Type:json)\', name VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_8F02BF9DD17F50A6 (uuid), UNIQUE INDEX UNIQ_IDENTIFIER_NAME (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE user_group_user (user_group_id INT NOT NULL, user_id INT NOT NULL, INDEX IDX_3AE4BD51ED93D47 (user_group_id), INDEX IDX_3AE4BD5A76ED395 (user_id), PRIMARY KEY(user_group_id, user_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455FB84408A FOREIGN KEY (organizational_unit_id) REFERENCES organizational_unit (id)'); - $this->addSql('ALTER TABLE hardware_profile ADD CONSTRAINT FK_2D9A2460FB84408A FOREIGN KEY (organizational_unit_id) REFERENCES organizational_unit (id)'); - $this->addSql('ALTER TABLE hardware_profile_hardware ADD CONSTRAINT FK_18C7E12CFA495C1 FOREIGN KEY (hardware_profile_id) REFERENCES hardware_profile (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE hardware_profile_hardware ADD CONSTRAINT FK_18C7E12C9CC762B FOREIGN KEY (hardware_id) REFERENCES hardware (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE network_settings ADD CONSTRAINT FK_48869B54CCD7E912 FOREIGN KEY (menu_id) REFERENCES menu (id)'); - $this->addSql('ALTER TABLE network_settings ADD CONSTRAINT FK_48869B54CFA495C1 FOREIGN KEY (hardware_profile_id) REFERENCES hardware_profile (id)'); - $this->addSql('ALTER TABLE organizational_unit ADD CONSTRAINT FK_749AEB2D727ACA70 FOREIGN KEY (parent_id) REFERENCES organizational_unit (id) ON DELETE SET NULL'); - $this->addSql('ALTER TABLE organizational_unit ADD CONSTRAINT FK_749AEB2D9B9A36D0 FOREIGN KEY (network_settings_id) REFERENCES network_settings (id)'); - $this->addSql('ALTER TABLE `partition` ADD CONSTRAINT FK_9EB910E419EB6921 FOREIGN KEY (client_id) REFERENCES client (id)'); - $this->addSql('ALTER TABLE user_organizational_unit ADD CONSTRAINT FK_5E59845FA76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE user_organizational_unit ADD CONSTRAINT FK_5E59845FFB84408A FOREIGN KEY (organizational_unit_id) REFERENCES organizational_unit (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE user_group_user ADD CONSTRAINT FK_3AE4BD51ED93D47 FOREIGN KEY (user_group_id) REFERENCES user_group (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE user_group_user ADD CONSTRAINT FK_3AE4BD5A76ED395 FOREIGN KEY (user_id) REFERENCES user (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_C7440455FB84408A'); - $this->addSql('ALTER TABLE hardware_profile DROP FOREIGN KEY FK_2D9A2460FB84408A'); - $this->addSql('ALTER TABLE hardware_profile_hardware DROP FOREIGN KEY FK_18C7E12CFA495C1'); - $this->addSql('ALTER TABLE hardware_profile_hardware DROP FOREIGN KEY FK_18C7E12C9CC762B'); - $this->addSql('ALTER TABLE network_settings DROP FOREIGN KEY FK_48869B54CCD7E912'); - $this->addSql('ALTER TABLE network_settings DROP FOREIGN KEY FK_48869B54CFA495C1'); - $this->addSql('ALTER TABLE organizational_unit DROP FOREIGN KEY FK_749AEB2D727ACA70'); - $this->addSql('ALTER TABLE organizational_unit DROP FOREIGN KEY FK_749AEB2D9B9A36D0'); - $this->addSql('ALTER TABLE `partition` DROP FOREIGN KEY FK_9EB910E419EB6921'); - $this->addSql('ALTER TABLE user_organizational_unit DROP FOREIGN KEY FK_5E59845FA76ED395'); - $this->addSql('ALTER TABLE user_organizational_unit DROP FOREIGN KEY FK_5E59845FFB84408A'); - $this->addSql('ALTER TABLE user_group_user DROP FOREIGN KEY FK_3AE4BD51ED93D47'); - $this->addSql('ALTER TABLE user_group_user DROP FOREIGN KEY FK_3AE4BD5A76ED395'); - $this->addSql('DROP TABLE client'); - $this->addSql('DROP TABLE hardware'); - $this->addSql('DROP TABLE hardware_profile'); - $this->addSql('DROP TABLE hardware_profile_hardware'); - $this->addSql('DROP TABLE menu'); - $this->addSql('DROP TABLE network_settings'); - $this->addSql('DROP TABLE organizational_unit'); - $this->addSql('DROP TABLE `partition`'); - $this->addSql('DROP TABLE refresh_tokens'); - $this->addSql('DROP TABLE user'); - $this->addSql('DROP TABLE user_organizational_unit'); - $this->addSql('DROP TABLE user_group'); - $this->addSql('DROP TABLE user_group_user'); - } -} diff --git a/migrations/Version20240618062825.php b/migrations/Version20240618062825.php deleted file mode 100644 index 7cb73fe..0000000 --- a/migrations/Version20240618062825.php +++ /dev/null @@ -1,39 +0,0 @@ -addSql('ALTER TABLE client ADD menu_id INT DEFAULT NULL, ADD hardware_profile_id INT DEFAULT NULL'); - $this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455CCD7E912 FOREIGN KEY (menu_id) REFERENCES menu (id)'); - $this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455CFA495C1 FOREIGN KEY (hardware_profile_id) REFERENCES hardware_profile (id)'); - $this->addSql('CREATE INDEX IDX_C7440455CCD7E912 ON client (menu_id)'); - $this->addSql('CREATE INDEX IDX_C7440455CFA495C1 ON client (hardware_profile_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_C7440455CCD7E912'); - $this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455CFA495C1'); - $this->addSql('DROP INDEX IDX_C7440455CCD7E912 ON client'); - $this->addSql('DROP INDEX IDX_C7440455CFA495C1 ON client'); - $this->addSql('ALTER TABLE client DROP menu_id, DROP hardware_profile_id'); - } -} diff --git a/migrations/Version20240618083013.php b/migrations/Version20240618083013.php deleted file mode 100644 index df541b8..0000000 --- a/migrations/Version20240618083013.php +++ /dev/null @@ -1,41 +0,0 @@ -addSql('CREATE TABLE hardware_type (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_2AA5A113D17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE operative_system (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_E9C44095D17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE operative_system_type (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_4A13A156D17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('ALTER TABLE hardware ADD type_id INT DEFAULT NULL, DROP type'); - $this->addSql('ALTER TABLE hardware ADD CONSTRAINT FK_FE99E9E0C54C8C93 FOREIGN KEY (type_id) REFERENCES hardware_type (id)'); - $this->addSql('CREATE INDEX IDX_FE99E9E0C54C8C93 ON hardware (type_id)'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE hardware DROP FOREIGN KEY FK_FE99E9E0C54C8C93'); - $this->addSql('DROP TABLE hardware_type'); - $this->addSql('DROP TABLE operative_system'); - $this->addSql('DROP TABLE operative_system_type'); - $this->addSql('DROP INDEX IDX_FE99E9E0C54C8C93 ON hardware'); - $this->addSql('ALTER TABLE hardware ADD type VARCHAR(255) DEFAULT NULL, DROP type_id'); - } -} diff --git a/migrations/Version20240618113629.php b/migrations/Version20240618113629.php deleted file mode 100644 index c9e1d5a..0000000 --- a/migrations/Version20240618113629.php +++ /dev/null @@ -1,31 +0,0 @@ -addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_NAME ON organizational_unit (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 organizational_unit'); - } -} diff --git a/migrations/Version20240619083230.php b/migrations/Version20240619083230.php deleted file mode 100644 index ea1e30b..0000000 --- a/migrations/Version20240619083230.php +++ /dev/null @@ -1,33 +0,0 @@ -addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_IP ON client (ip)'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_MAC ON client (mac)'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('DROP INDEX UNIQ_IDENTIFIER_IP ON client'); - $this->addSql('DROP INDEX UNIQ_IDENTIFIER_MAC ON client'); - } -} diff --git a/migrations/Version20240619084701.php b/migrations/Version20240619084701.php deleted file mode 100644 index 22e781b..0000000 --- a/migrations/Version20240619084701.php +++ /dev/null @@ -1,31 +0,0 @@ -addSql('ALTER TABLE client ADD validation 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 validation'); - } -} diff --git a/migrations/Version20240619104206.php b/migrations/Version20240619104206.php deleted file mode 100644 index d4654c9..0000000 --- a/migrations/Version20240619104206.php +++ /dev/null @@ -1,35 +0,0 @@ -addSql('ALTER TABLE `partition` ADD operative_system_id INT DEFAULT NULL, DROP os_name'); - $this->addSql('ALTER TABLE `partition` ADD CONSTRAINT FK_9EB910E4F1E9F66E FOREIGN KEY (operative_system_id) REFERENCES operative_system (id)'); - $this->addSql('CREATE INDEX IDX_9EB910E4F1E9F66E ON `partition` (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 `partition` DROP FOREIGN KEY FK_9EB910E4F1E9F66E'); - $this->addSql('DROP INDEX IDX_9EB910E4F1E9F66E ON `partition`'); - $this->addSql('ALTER TABLE `partition` ADD os_name VARCHAR(255) NOT NULL, DROP operative_system_id'); - } -} diff --git a/migrations/Version20240620095914.php b/migrations/Version20240620095914.php deleted file mode 100644 index 5e4d7f2..0000000 --- a/migrations/Version20240620095914.php +++ /dev/null @@ -1,33 +0,0 @@ -addSql('ALTER TABLE `partition` DROP FOREIGN KEY FK_9EB910E419EB6921'); - $this->addSql('ALTER TABLE `partition` ADD CONSTRAINT FK_9EB910E419EB6921 FOREIGN KEY (client_id) REFERENCES client (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 `partition` DROP FOREIGN KEY FK_9EB910E419EB6921'); - $this->addSql('ALTER TABLE `partition` ADD CONSTRAINT FK_9EB910E419EB6921 FOREIGN KEY (client_id) REFERENCES client (id)'); - } -} diff --git a/migrations/Version20240620100039.php b/migrations/Version20240620100039.php deleted file mode 100644 index 7aa27c5..0000000 --- a/migrations/Version20240620100039.php +++ /dev/null @@ -1,33 +0,0 @@ -addSql('ALTER TABLE `partition` DROP FOREIGN KEY FK_9EB910E419EB6921'); - $this->addSql('ALTER TABLE `partition` ADD CONSTRAINT FK_9EB910E419EB6921 FOREIGN KEY (client_id) REFERENCES client (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 `partition` DROP FOREIGN KEY FK_9EB910E419EB6921'); - $this->addSql('ALTER TABLE `partition` ADD CONSTRAINT FK_9EB910E419EB6921 FOREIGN KEY (client_id) REFERENCES client (id) ON DELETE SET NULL'); - } -} diff --git a/migrations/Version20240621085144.php b/migrations/Version20240621085144.php deleted file mode 100644 index 8286ec6..0000000 --- a/migrations/Version20240621085144.php +++ /dev/null @@ -1,33 +0,0 @@ -addSql('DROP INDEX UNIQ_IDENTIFIER_NAME ON organizational_unit'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_NAME ON organizational_unit (name, parent_id)'); - } - - 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 organizational_unit'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_NAME ON organizational_unit (name)'); - } -} diff --git a/migrations/Version20240701123613.php b/migrations/Version20240701123613.php deleted file mode 100644 index e83b75e..0000000 --- a/migrations/Version20240701123613.php +++ /dev/null @@ -1,33 +0,0 @@ -addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455FB84408A'); - $this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455FB84408A FOREIGN KEY (organizational_unit_id) REFERENCES organizational_unit (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_C7440455FB84408A'); - $this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455FB84408A FOREIGN KEY (organizational_unit_id) REFERENCES organizational_unit (id)'); - } -} diff --git a/migrations/Version20240702132742.php b/migrations/Version20240702132742.php deleted file mode 100644 index 91069d5..0000000 --- a/migrations/Version20240702132742.php +++ /dev/null @@ -1,41 +0,0 @@ -addSql('CREATE TABLE software (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, description VARCHAR(255) DEFAULT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_77D068CFD17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE software_profile (id INT AUTO_INCREMENT NOT NULL, organizational_unit_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, description VARCHAR(255) DEFAULT NULL, comments VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_B70C3C9BD17F50A6 (uuid), INDEX IDX_B70C3C9BFB84408A (organizational_unit_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE software_profile_software (software_profile_id INT NOT NULL, software_id INT NOT NULL, INDEX IDX_3DDFEC7ED42A742 (software_profile_id), INDEX IDX_3DDFEC7D7452741 (software_id), PRIMARY KEY(software_profile_id, software_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('ALTER TABLE software_profile ADD CONSTRAINT FK_B70C3C9BFB84408A FOREIGN KEY (organizational_unit_id) REFERENCES organizational_unit (id)'); - $this->addSql('ALTER TABLE software_profile_software ADD CONSTRAINT FK_3DDFEC7ED42A742 FOREIGN KEY (software_profile_id) REFERENCES software_profile (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE software_profile_software ADD CONSTRAINT FK_3DDFEC7D7452741 FOREIGN KEY (software_id) REFERENCES software (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 software_profile DROP FOREIGN KEY FK_B70C3C9BFB84408A'); - $this->addSql('ALTER TABLE software_profile_software DROP FOREIGN KEY FK_3DDFEC7ED42A742'); - $this->addSql('ALTER TABLE software_profile_software DROP FOREIGN KEY FK_3DDFEC7D7452741'); - $this->addSql('DROP TABLE software'); - $this->addSql('DROP TABLE software_profile'); - $this->addSql('DROP TABLE software_profile_software'); - } -} diff --git a/migrations/Version20240703090301.php b/migrations/Version20240703090301.php deleted file mode 100644 index 9a7588b..0000000 --- a/migrations/Version20240703090301.php +++ /dev/null @@ -1,35 +0,0 @@ -addSql('CREATE TABLE image (id INT AUTO_INCREMENT NOT NULL, client_id INT NOT NULL, software_profile_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, description VARCHAR(255) DEFAULT NULL, comments VARCHAR(255) DEFAULT NULL, path VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, revision VARCHAR(255) DEFAULT NULL, info VARCHAR(255) DEFAULT NULL, size INT NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_C53D045FD17F50A6 (uuid), INDEX IDX_C53D045F19EB6921 (client_id), INDEX IDX_C53D045FED42A742 (software_profile_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('ALTER TABLE image ADD CONSTRAINT FK_C53D045F19EB6921 FOREIGN KEY (client_id) REFERENCES client (id)'); - $this->addSql('ALTER TABLE image ADD CONSTRAINT FK_C53D045FED42A742 FOREIGN KEY (software_profile_id) REFERENCES software_profile (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_C53D045F19EB6921'); - $this->addSql('ALTER TABLE image DROP FOREIGN KEY FK_C53D045FED42A742'); - $this->addSql('DROP TABLE image'); - } -} diff --git a/migrations/Version20240715084147.php b/migrations/Version20240715084147.php deleted file mode 100644 index 0db212c..0000000 --- a/migrations/Version20240715084147.php +++ /dev/null @@ -1,43 +0,0 @@ -addSql('CREATE TABLE user_user_group (user_id INT NOT NULL, user_group_id INT NOT NULL, INDEX IDX_28657971A76ED395 (user_id), INDEX IDX_286579711ED93D47 (user_group_id), PRIMARY KEY(user_id, user_group_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('ALTER TABLE user_user_group ADD CONSTRAINT FK_28657971A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE user_user_group ADD CONSTRAINT FK_286579711ED93D47 FOREIGN KEY (user_group_id) REFERENCES user_group (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE user_group_user DROP FOREIGN KEY FK_3AE4BD51ED93D47'); - $this->addSql('ALTER TABLE user_group_user DROP FOREIGN KEY FK_3AE4BD5A76ED395'); - $this->addSql('DROP TABLE user_group_user'); - $this->addSql('ALTER TABLE hardware_profile CHANGE organizational_unit_id organizational_unit_id INT NOT NULL'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE TABLE user_group_user (user_group_id INT NOT NULL, user_id INT NOT NULL, INDEX IDX_3AE4BD5A76ED395 (user_id), INDEX IDX_3AE4BD51ED93D47 (user_group_id), PRIMARY KEY(user_group_id, user_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' '); - $this->addSql('ALTER TABLE user_group_user ADD CONSTRAINT FK_3AE4BD51ED93D47 FOREIGN KEY (user_group_id) REFERENCES user_group (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE user_group_user ADD CONSTRAINT FK_3AE4BD5A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE user_user_group DROP FOREIGN KEY FK_28657971A76ED395'); - $this->addSql('ALTER TABLE user_user_group DROP FOREIGN KEY FK_286579711ED93D47'); - $this->addSql('DROP TABLE user_user_group'); - $this->addSql('ALTER TABLE hardware_profile CHANGE organizational_unit_id organizational_unit_id INT DEFAULT NULL'); - } -} diff --git a/migrations/Version20240717094811.php b/migrations/Version20240717094811.php deleted file mode 100644 index c1eb1f2..0000000 --- a/migrations/Version20240717094811.php +++ /dev/null @@ -1,31 +0,0 @@ -addSql('CREATE TABLE view (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, favourite TINYINT(1) NOT NULL, filters JSON DEFAULT NULL COMMENT \'(DC2Type:json)\', name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_FEFDAB8ED17F50A6 (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 view'); - } -} diff --git a/migrations/Version20240718064611.php b/migrations/Version20240718064611.php deleted file mode 100644 index fedb106..0000000 --- a/migrations/Version20240718064611.php +++ /dev/null @@ -1,31 +0,0 @@ -addSql('ALTER TABLE client ADD position JSON DEFAULT NULL COMMENT \'(DC2Type:json)\''); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE client DROP position'); - } -} diff --git a/migrations/Version20240801130155.php b/migrations/Version20240801130155.php deleted file mode 100644 index 5c389bf..0000000 --- a/migrations/Version20240801130155.php +++ /dev/null @@ -1,35 +0,0 @@ -addSql('ALTER TABLE view ADD user_id INT DEFAULT NULL'); - $this->addSql('ALTER TABLE view ADD CONSTRAINT FK_FEFDAB8EA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)'); - $this->addSql('CREATE INDEX IDX_FEFDAB8EA76ED395 ON view (user_id)'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE view DROP FOREIGN KEY FK_FEFDAB8EA76ED395'); - $this->addSql('DROP INDEX IDX_FEFDAB8EA76ED395 ON view'); - $this->addSql('ALTER TABLE view DROP user_id'); - } -} diff --git a/migrations/Version20240808140716.php b/migrations/Version20240808140716.php deleted file mode 100644 index b61c4df..0000000 --- a/migrations/Version20240808140716.php +++ /dev/null @@ -1,31 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240812095940.php b/migrations/Version20240812095940.php deleted file mode 100644 index 448e24e..0000000 --- a/migrations/Version20240812095940.php +++ /dev/null @@ -1,43 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240812135824.php b/migrations/Version20240812135824.php deleted file mode 100644 index 5bd9784..0000000 --- a/migrations/Version20240812135824.php +++ /dev/null @@ -1,43 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240814130427.php b/migrations/Version20240814130427.php deleted file mode 100644 index 8e2cabc..0000000 --- a/migrations/Version20240814130427.php +++ /dev/null @@ -1,31 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240819062421.php b/migrations/Version20240819062421.php deleted file mode 100644 index 79b21f8..0000000 --- a/migrations/Version20240819062421.php +++ /dev/null @@ -1,33 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240819140045.php b/migrations/Version20240819140045.php deleted file mode 100644 index 01a67ef..0000000 --- a/migrations/Version20240819140045.php +++ /dev/null @@ -1,33 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240820063513.php b/migrations/Version20240820063513.php deleted file mode 100644 index 42803dd..0000000 --- a/migrations/Version20240820063513.php +++ /dev/null @@ -1,41 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240820064106.php b/migrations/Version20240820064106.php deleted file mode 100644 index 2e387f6..0000000 --- a/migrations/Version20240820064106.php +++ /dev/null @@ -1,31 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240821065158.php b/migrations/Version20240821065158.php deleted file mode 100644 index dfcd85a..0000000 --- a/migrations/Version20240821065158.php +++ /dev/null @@ -1,31 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240827102833.php b/migrations/Version20240827102833.php deleted file mode 100644 index 00ab457..0000000 --- a/migrations/Version20240827102833.php +++ /dev/null @@ -1,31 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240902124157.php b/migrations/Version20240902124157.php deleted file mode 100644 index 5c320b9..0000000 --- a/migrations/Version20240902124157.php +++ /dev/null @@ -1,33 +0,0 @@ -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)'); - - } -} diff --git a/migrations/Version20240903081001.php b/migrations/Version20240903081001.php deleted file mode 100644 index 9202867..0000000 --- a/migrations/Version20240903081001.php +++ /dev/null @@ -1,35 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240904134540.php b/migrations/Version20240904134540.php deleted file mode 100644 index df9dd35..0000000 --- a/migrations/Version20240904134540.php +++ /dev/null @@ -1,35 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240905080435.php b/migrations/Version20240905080435.php deleted file mode 100644 index 82c72f8..0000000 --- a/migrations/Version20240905080435.php +++ /dev/null @@ -1,32 +0,0 @@ -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'); - - } -} diff --git a/migrations/Version20240916073039.php b/migrations/Version20240916073039.php deleted file mode 100644 index ba99c0b..0000000 --- a/migrations/Version20240916073039.php +++ /dev/null @@ -1,31 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240916091601.php b/migrations/Version20240916091601.php deleted file mode 100644 index 9f3304d..0000000 --- a/migrations/Version20240916091601.php +++ /dev/null @@ -1,37 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240917064754.php b/migrations/Version20240917064754.php deleted file mode 100644 index 64f1f9b..0000000 --- a/migrations/Version20240917064754.php +++ /dev/null @@ -1,43 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240917091950.php b/migrations/Version20240917091950.php deleted file mode 100644 index 7645fa2..0000000 --- a/migrations/Version20240917091950.php +++ /dev/null @@ -1,35 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240917092207.php b/migrations/Version20240917092207.php deleted file mode 100644 index f291bd8..0000000 --- a/migrations/Version20240917092207.php +++ /dev/null @@ -1,31 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240924071858.php b/migrations/Version20240924071858.php deleted file mode 100644 index d758402..0000000 --- a/migrations/Version20240924071858.php +++ /dev/null @@ -1,31 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240924090429.php b/migrations/Version20240924090429.php deleted file mode 100644 index ba9563c..0000000 --- a/migrations/Version20240924090429.php +++ /dev/null @@ -1,41 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240924095558.php b/migrations/Version20240924095558.php deleted file mode 100644 index b8b2d3b..0000000 --- a/migrations/Version20240924095558.php +++ /dev/null @@ -1,31 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240924100335.php b/migrations/Version20240924100335.php deleted file mode 100644 index 9edf05f..0000000 --- a/migrations/Version20240924100335.php +++ /dev/null @@ -1,31 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240924102357.php b/migrations/Version20240924102357.php deleted file mode 100644 index 069d3d3..0000000 --- a/migrations/Version20240924102357.php +++ /dev/null @@ -1,31 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240926085224.php b/migrations/Version20240926085224.php deleted file mode 100644 index b05ce37..0000000 --- a/migrations/Version20240926085224.php +++ /dev/null @@ -1,35 +0,0 @@ -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)'); - } -} diff --git a/migrations/Version20240926104532.php b/migrations/Version20240926104532.php deleted file mode 100644 index 125bc93..0000000 --- a/migrations/Version20240926104532.php +++ /dev/null @@ -1,32 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20240930131003.php b/migrations/Version20240930131003.php deleted file mode 100644 index 68b2308..0000000 --- a/migrations/Version20240930131003.php +++ /dev/null @@ -1,45 +0,0 @@ -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)'); - } -} diff --git a/migrations/Version20241002062742.php b/migrations/Version20241002062742.php deleted file mode 100644 index d867007..0000000 --- a/migrations/Version20241002062742.php +++ /dev/null @@ -1,31 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20241008080902.php b/migrations/Version20241008080902.php deleted file mode 100644 index dc61c00..0000000 --- a/migrations/Version20241008080902.php +++ /dev/null @@ -1,35 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20241008081013.php b/migrations/Version20241008081013.php deleted file mode 100644 index 87b726c..0000000 --- a/migrations/Version20241008081013.php +++ /dev/null @@ -1,31 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20241008092247.php b/migrations/Version20241008092247.php deleted file mode 100644 index 033c6bc..0000000 --- a/migrations/Version20241008092247.php +++ /dev/null @@ -1,31 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20241008092849.php b/migrations/Version20241008092849.php deleted file mode 100644 index 5c39be2..0000000 --- a/migrations/Version20241008092849.php +++ /dev/null @@ -1,35 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20241014053130.php b/migrations/Version20241014053130.php deleted file mode 100644 index 5abd23e..0000000 --- a/migrations/Version20241014053130.php +++ /dev/null @@ -1,31 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20241014082029.php b/migrations/Version20241014082029.php deleted file mode 100644 index 7777645..0000000 --- a/migrations/Version20241014082029.php +++ /dev/null @@ -1,33 +0,0 @@ -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)'); - } -} diff --git a/migrations/Version20241014102105.php b/migrations/Version20241014102105.php deleted file mode 100644 index 6015cff..0000000 --- a/migrations/Version20241014102105.php +++ /dev/null @@ -1,33 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20241015154123.php b/migrations/Version20241015154123.php deleted file mode 100644 index 8a87c52..0000000 --- a/migrations/Version20241015154123.php +++ /dev/null @@ -1,31 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20241016063657.php b/migrations/Version20241016063657.php deleted file mode 100644 index 340af96..0000000 --- a/migrations/Version20241016063657.php +++ /dev/null @@ -1,37 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20241016065729.php b/migrations/Version20241016065729.php deleted file mode 100644 index a33c8e2..0000000 --- a/migrations/Version20241016065729.php +++ /dev/null @@ -1,31 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20241018055534.php b/migrations/Version20241018055534.php deleted file mode 100644 index 0c1d5ab..0000000 --- a/migrations/Version20241018055534.php +++ /dev/null @@ -1,39 +0,0 @@ -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)'); - } -} diff --git a/migrations/Version20241018060155.php b/migrations/Version20241018060155.php deleted file mode 100644 index 48d75fb..0000000 --- a/migrations/Version20241018060155.php +++ /dev/null @@ -1,31 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20241019073142.php b/migrations/Version20241019073142.php deleted file mode 100644 index 645dac2..0000000 --- a/migrations/Version20241019073142.php +++ /dev/null @@ -1,31 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20241021061008.php b/migrations/Version20241021061008.php deleted file mode 100644 index 84ba8f8..0000000 --- a/migrations/Version20241021061008.php +++ /dev/null @@ -1,33 +0,0 @@ -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)'); - } -} diff --git a/migrations/Version20241021071250.php b/migrations/Version20241021071250.php deleted file mode 100644 index 054ddd6..0000000 --- a/migrations/Version20241021071250.php +++ /dev/null @@ -1,43 +0,0 @@ -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)'); - } -} diff --git a/migrations/Version20241021201438.php b/migrations/Version20241021201438.php deleted file mode 100644 index 7c1dc59..0000000 --- a/migrations/Version20241021201438.php +++ /dev/null @@ -1,31 +0,0 @@ -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'); - } -} diff --git a/migrations/Version20241120160808.php b/migrations/Version20241120160808.php new file mode 100644 index 0000000..b08b321 --- /dev/null +++ b/migrations/Version20241120160808.php @@ -0,0 +1,189 @@ +addSql('CREATE TABLE client (id INT AUTO_INCREMENT NOT NULL, organizational_unit_id INT DEFAULT NULL, menu_id INT DEFAULT NULL, hardware_profile_id INT DEFAULT NULL, template_id INT DEFAULT NULL, repository_id INT DEFAULT NULL, subnet_id INT DEFAULT NULL, og_live_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, serial_number VARCHAR(255) DEFAULT NULL, netiface VARCHAR(255) DEFAULT NULL, net_driver VARCHAR(255) DEFAULT NULL, mac VARCHAR(255) DEFAULT NULL, ip VARCHAR(255) DEFAULT NULL, status VARCHAR(255) DEFAULT NULL, validation TINYINT(1) DEFAULT NULL, position JSON DEFAULT NULL COMMENT \'(DC2Type:json)\', maintenance TINYINT(1) NOT NULL, agent_job_id VARCHAR(255) DEFAULT NULL, pxe_sync TINYINT(1) DEFAULT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_C7440455D17F50A6 (uuid), INDEX IDX_C7440455FB84408A (organizational_unit_id), INDEX IDX_C7440455CCD7E912 (menu_id), INDEX IDX_C7440455CFA495C1 (hardware_profile_id), INDEX IDX_C74404555DA0FB8 (template_id), INDEX IDX_C744045550C9D4F7 (repository_id), INDEX IDX_C7440455C9CF9478 (subnet_id), INDEX IDX_C7440455F7E54CF3 (og_live_id), UNIQUE INDEX UNIQ_IDENTIFIER_IP (ip), UNIQUE INDEX UNIQ_IDENTIFIER_MAC (mac), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $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 LONGTEXT 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'); + $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, 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('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('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('CREATE TABLE hardware (id INT AUTO_INCREMENT NOT NULL, type_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, description VARCHAR(255) DEFAULT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_FE99E9E0D17F50A6 (uuid), INDEX IDX_FE99E9E0C54C8C93 (type_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE hardware_profile (id INT AUTO_INCREMENT NOT NULL, organizational_unit_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, description VARCHAR(255) DEFAULT NULL, comments VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_2D9A2460D17F50A6 (uuid), INDEX IDX_2D9A2460FB84408A (organizational_unit_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE hardware_profile_hardware (hardware_profile_id INT NOT NULL, hardware_id INT NOT NULL, INDEX IDX_18C7E12CFA495C1 (hardware_profile_id), INDEX IDX_18C7E12C9CC762B (hardware_id), PRIMARY KEY(hardware_profile_id, hardware_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE hardware_type (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_2AA5A113D17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE image (id INT AUTO_INCREMENT NOT NULL, software_profile_id INT DEFAULT NULL, repository_id INT NOT NULL, parent_id INT DEFAULT NULL, client_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, description VARCHAR(255) DEFAULT NULL, comments VARCHAR(255) DEFAULT NULL, path VARCHAR(255) DEFAULT NULL, type VARCHAR(255) DEFAULT NULL, revision VARCHAR(255) DEFAULT NULL, info VARCHAR(255) DEFAULT NULL, size INT DEFAULT NULL, remote_pc TINYINT(1) NOT NULL, partition_info VARCHAR(255) DEFAULT NULL, created TINYINT(1) DEFAULT NULL, image_fullsum VARCHAR(255) DEFAULT NULL, status VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_C53D045FD17F50A6 (uuid), INDEX IDX_C53D045FED42A742 (software_profile_id), INDEX IDX_C53D045F50C9D4F7 (repository_id), INDEX IDX_C53D045F727ACA70 (parent_id), INDEX IDX_C53D045F19EB6921 (client_id), UNIQUE INDEX UNIQ_IDENTIFIER_NAME (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE image_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 VARCHAR(255) NOT NULL, comments VARCHAR(255) DEFAULT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_302040FBD17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE menu (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, title VARCHAR(255) NOT NULL, resolution VARCHAR(255) NOT NULL, comments VARCHAR(255) DEFAULT NULL, public_url VARCHAR(255) DEFAULT NULL, private_url VARCHAR(255) DEFAULT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_7D053A93D17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE network_settings (id INT AUTO_INCREMENT NOT NULL, menu_id INT DEFAULT NULL, hardware_profile_id INT DEFAULT NULL, repository_id INT DEFAULT NULL, og_live_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, next_server VARCHAR(255) DEFAULT NULL, boot_file_name VARCHAR(255) DEFAULT NULL, proxy VARCHAR(255) DEFAULT NULL, dns VARCHAR(255) DEFAULT NULL, netmask VARCHAR(255) DEFAULT NULL, router VARCHAR(255) DEFAULT NULL, ntp VARCHAR(255) DEFAULT NULL, p2p_time INT DEFAULT NULL, p2p_mode VARCHAR(255) DEFAULT NULL, mcast_ip VARCHAR(255) DEFAULT NULL, mcast_speed INT DEFAULT NULL, mcast_mode VARCHAR(255) DEFAULT NULL, mcast_port INT DEFAULT NULL, validation TINYINT(1) DEFAULT NULL, og_log VARCHAR(255) DEFAULT NULL, og_share VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_48869B54D17F50A6 (uuid), INDEX IDX_48869B54CCD7E912 (menu_id), INDEX IDX_48869B54CFA495C1 (hardware_profile_id), INDEX IDX_48869B5450C9D4F7 (repository_id), INDEX IDX_48869B54F7E54CF3 (og_live_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $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, checksum VARCHAR(255) DEFAULT NULL, distribution VARCHAR(255) DEFAULT NULL, kernel VARCHAR(255) DEFAULT NULL, architecture VARCHAR(255) DEFAULT NULL, revision VARCHAR(255) DEFAULT NULL, directory VARCHAR(255) DEFAULT NULL, filename VARCHAR(255) DEFAULT NULL, installed TINYINT(1) DEFAULT NULL, is_default TINYINT(1) DEFAULT NULL, status VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, synchronized TINYINT(1) DEFAULT 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'); + $this->addSql('CREATE TABLE operative_system (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_E9C44095D17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE operative_system_type (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_4A13A156D17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE organizational_unit (id INT AUTO_INCREMENT NOT NULL, parent_id INT DEFAULT NULL, network_settings_id INT DEFAULT NULL, subnet_id INT DEFAULT 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, description VARCHAR(255) DEFAULT NULL, comments VARCHAR(255) DEFAULT NULL, path VARCHAR(255) DEFAULT NULL, level INT DEFAULT NULL, slug VARCHAR(255) DEFAULT NULL, type VARCHAR(255) NOT NULL, location VARCHAR(255) DEFAULT NULL, projector TINYINT(1) DEFAULT NULL, board TINYINT(1) DEFAULT NULL, capacity INT DEFAULT NULL, remote_pc TINYINT(1) NOT NULL, reserved TINYINT(1) NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_749AEB2DD17F50A6 (uuid), INDEX IDX_749AEB2D727ACA70 (parent_id), INDEX IDX_749AEB2D9B9A36D0 (network_settings_id), INDEX IDX_749AEB2DC9CF9478 (subnet_id), INDEX IDX_749AEB2DC56641EE (remote_calendar_id), UNIQUE INDEX UNIQ_IDENTIFIER_NAME (name, parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE `partition` (id INT AUTO_INCREMENT NOT NULL, client_id INT DEFAULT NULL, operative_system_id INT DEFAULT NULL, image_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, disk_number INT DEFAULT NULL, partition_number INT DEFAULT NULL, partition_code VARCHAR(255) DEFAULT NULL, size INT NOT NULL, cache_content VARCHAR(255) DEFAULT NULL, filesystem VARCHAR(255) DEFAULT NULL, memory_usage INT NOT NULL, UNIQUE INDEX UNIQ_9EB910E4D17F50A6 (uuid), INDEX IDX_9EB910E419EB6921 (client_id), INDEX IDX_9EB910E4F1E9F66E (operative_system_id), INDEX IDX_9EB910E43DA5256D (image_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 LONGTEXT NOT NULL, name VARCHAR(255) NOT NULL, synchronized TINYINT(1) DEFAULT 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('CREATE TABLE refresh_tokens (id INT AUTO_INCREMENT NOT NULL, refresh_token VARCHAR(128) NOT NULL, username VARCHAR(255) NOT NULL, valid DATETIME NOT NULL, UNIQUE INDEX UNIQ_9BACE7E1C74F2195 (refresh_token), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $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), UNIQUE INDEX UNIQ_IDENTIFIER_NAME (name), 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 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, busy_weekdays JSON DEFAULT NULL COMMENT \'(DC2Type:json)\', busy_from_hour TIME DEFAULT NULL, busy_to_hour TIME DEFAULT NULL, is_remote_available TINYINT(1) NOT NULL, available_from_date DATE DEFAULT NULL, available_to_date DATE DEFAULT NULL, available_reason VARCHAR(255) DEFAULT 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('CREATE TABLE software (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, description VARCHAR(255) DEFAULT NULL, type VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_77D068CFD17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE software_profile (id INT AUTO_INCREMENT NOT NULL, organizational_unit_id INT NOT NULL, operative_system_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, description VARCHAR(255) DEFAULT NULL, comments VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_B70C3C9BD17F50A6 (uuid), INDEX IDX_B70C3C9BFB84408A (organizational_unit_id), INDEX IDX_B70C3C9BF1E9F66E (operative_system_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE software_profile_software (software_profile_id INT NOT NULL, software_id INT NOT NULL, INDEX IDX_3DDFEC7ED42A742 (software_profile_id), INDEX IDX_3DDFEC7D7452741 (software_id), PRIMARY KEY(software_profile_id, software_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $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, server_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, synchronized TINYINT(1) DEFAULT NULL, UNIQUE INDEX UNIQ_91C24216D17F50A6 (uuid), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE trace (id INT AUTO_INCREMENT NOT NULL, client_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, command VARCHAR(255) DEFAULT NULL, status VARCHAR(255) NOT NULL, output VARCHAR(255) DEFAULT NULL, executed_at DATETIME NOT NULL, finished_at DATETIME DEFAULT NULL, job_id VARCHAR(255) DEFAULT NULL, input JSON DEFAULT NULL COMMENT \'(DC2Type:json)\', UNIQUE INDEX UNIQ_315BD5A1D17F50A6 (uuid), INDEX IDX_315BD5A119EB6921 (client_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE user (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, username VARCHAR(180) NOT NULL, roles JSON NOT NULL COMMENT \'(DC2Type:json)\', password VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_8D93D649D17F50A6 (uuid), UNIQUE INDEX UNIQ_IDENTIFIER_USERNAME (username), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE user_user_group (user_id INT NOT NULL, user_group_id INT NOT NULL, INDEX IDX_28657971A76ED395 (user_id), INDEX IDX_286579711ED93D47 (user_group_id), PRIMARY KEY(user_id, user_group_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE user_organizational_unit (user_id INT NOT NULL, organizational_unit_id INT NOT NULL, INDEX IDX_5E59845FA76ED395 (user_id), INDEX IDX_5E59845FFB84408A (organizational_unit_id), PRIMARY KEY(user_id, organizational_unit_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE user_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, permissions JSON NOT NULL COMMENT \'(DC2Type:json)\', name VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_8F02BF9DD17F50A6 (uuid), UNIQUE INDEX UNIQ_IDENTIFIER_NAME (name), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE view (id INT AUTO_INCREMENT NOT NULL, user_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, favourite TINYINT(1) NOT NULL, filters JSON DEFAULT NULL COMMENT \'(DC2Type:json)\', name VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_FEFDAB8ED17F50A6 (uuid), INDEX IDX_FEFDAB8EA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455FB84408A FOREIGN KEY (organizational_unit_id) REFERENCES organizational_unit (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455CCD7E912 FOREIGN KEY (menu_id) REFERENCES menu (id)'); + $this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455CFA495C1 FOREIGN KEY (hardware_profile_id) REFERENCES hardware_profile (id)'); + $this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C74404555DA0FB8 FOREIGN KEY (template_id) REFERENCES pxe_template (id)'); + $this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C744045550C9D4F7 FOREIGN KEY (repository_id) REFERENCES image_repository (id)'); + $this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455C9CF9478 FOREIGN KEY (subnet_id) REFERENCES subnet (id) ON DELETE SET NULL'); + $this->addSql('ALTER TABLE client ADD CONSTRAINT FK_C7440455F7E54CF3 FOREIGN KEY (og_live_id) REFERENCES og_live (id) ON DELETE SET NULL'); + $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'); + $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'); + $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 hardware ADD CONSTRAINT FK_FE99E9E0C54C8C93 FOREIGN KEY (type_id) REFERENCES hardware_type (id)'); + $this->addSql('ALTER TABLE hardware_profile ADD CONSTRAINT FK_2D9A2460FB84408A FOREIGN KEY (organizational_unit_id) REFERENCES organizational_unit (id)'); + $this->addSql('ALTER TABLE hardware_profile_hardware ADD CONSTRAINT FK_18C7E12CFA495C1 FOREIGN KEY (hardware_profile_id) REFERENCES hardware_profile (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE hardware_profile_hardware ADD CONSTRAINT FK_18C7E12C9CC762B FOREIGN KEY (hardware_id) REFERENCES hardware (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE image ADD CONSTRAINT FK_C53D045FED42A742 FOREIGN KEY (software_profile_id) REFERENCES software_profile (id)'); + $this->addSql('ALTER TABLE image ADD CONSTRAINT FK_C53D045F50C9D4F7 FOREIGN KEY (repository_id) REFERENCES image_repository (id)'); + $this->addSql('ALTER TABLE image ADD CONSTRAINT FK_C53D045F727ACA70 FOREIGN KEY (parent_id) REFERENCES image (id)'); + $this->addSql('ALTER TABLE image ADD CONSTRAINT FK_C53D045F19EB6921 FOREIGN KEY (client_id) REFERENCES client (id)'); + $this->addSql('ALTER TABLE network_settings ADD CONSTRAINT FK_48869B54CCD7E912 FOREIGN KEY (menu_id) REFERENCES menu (id)'); + $this->addSql('ALTER TABLE network_settings ADD CONSTRAINT FK_48869B54CFA495C1 FOREIGN KEY (hardware_profile_id) REFERENCES hardware_profile (id)'); + $this->addSql('ALTER TABLE network_settings ADD CONSTRAINT FK_48869B5450C9D4F7 FOREIGN KEY (repository_id) REFERENCES image_repository (id)'); + $this->addSql('ALTER TABLE network_settings ADD CONSTRAINT FK_48869B54F7E54CF3 FOREIGN KEY (og_live_id) REFERENCES og_live (id)'); + $this->addSql('ALTER TABLE organizational_unit ADD CONSTRAINT FK_749AEB2D727ACA70 FOREIGN KEY (parent_id) REFERENCES organizational_unit (id) ON DELETE SET NULL'); + $this->addSql('ALTER TABLE organizational_unit ADD CONSTRAINT FK_749AEB2D9B9A36D0 FOREIGN KEY (network_settings_id) REFERENCES network_settings (id)'); + $this->addSql('ALTER TABLE organizational_unit ADD CONSTRAINT FK_749AEB2DC9CF9478 FOREIGN KEY (subnet_id) REFERENCES subnet (id)'); + $this->addSql('ALTER TABLE organizational_unit ADD CONSTRAINT FK_749AEB2DC56641EE FOREIGN KEY (remote_calendar_id) REFERENCES remote_calendar (id)'); + $this->addSql('ALTER TABLE `partition` ADD CONSTRAINT FK_9EB910E419EB6921 FOREIGN KEY (client_id) REFERENCES client (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE `partition` ADD CONSTRAINT FK_9EB910E4F1E9F66E FOREIGN KEY (operative_system_id) REFERENCES operative_system (id)'); + $this->addSql('ALTER TABLE `partition` ADD CONSTRAINT FK_9EB910E43DA5256D FOREIGN KEY (image_id) REFERENCES image (id)'); + $this->addSql('ALTER TABLE remote_calendar_rule ADD CONSTRAINT FK_EE93D058C56641EE FOREIGN KEY (remote_calendar_id) REFERENCES remote_calendar (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE software_profile ADD CONSTRAINT FK_B70C3C9BFB84408A FOREIGN KEY (organizational_unit_id) REFERENCES organizational_unit (id)'); + $this->addSql('ALTER TABLE software_profile ADD CONSTRAINT FK_B70C3C9BF1E9F66E FOREIGN KEY (operative_system_id) REFERENCES operative_system (id)'); + $this->addSql('ALTER TABLE software_profile_software ADD CONSTRAINT FK_3DDFEC7ED42A742 FOREIGN KEY (software_profile_id) REFERENCES software_profile (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE software_profile_software ADD CONSTRAINT FK_3DDFEC7D7452741 FOREIGN KEY (software_id) REFERENCES software (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE trace ADD CONSTRAINT FK_315BD5A119EB6921 FOREIGN KEY (client_id) REFERENCES client (id)'); + $this->addSql('ALTER TABLE user_user_group ADD CONSTRAINT FK_28657971A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE user_user_group ADD CONSTRAINT FK_286579711ED93D47 FOREIGN KEY (user_group_id) REFERENCES user_group (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE user_organizational_unit ADD CONSTRAINT FK_5E59845FA76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE user_organizational_unit ADD CONSTRAINT FK_5E59845FFB84408A FOREIGN KEY (organizational_unit_id) REFERENCES organizational_unit (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE view ADD CONSTRAINT FK_FEFDAB8EA76ED395 FOREIGN KEY (user_id) REFERENCES user (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_C7440455FB84408A'); + $this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455CCD7E912'); + $this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455CFA495C1'); + $this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C74404555DA0FB8'); + $this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C744045550C9D4F7'); + $this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455C9CF9478'); + $this->addSql('ALTER TABLE client DROP FOREIGN KEY FK_C7440455F7E54CF3'); + $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('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('ALTER TABLE command_task_client DROP FOREIGN KEY FK_F97A827D62DC5265'); + $this->addSql('ALTER TABLE command_task_client DROP FOREIGN KEY FK_F97A827D19EB6921'); + $this->addSql('ALTER TABLE hardware DROP FOREIGN KEY FK_FE99E9E0C54C8C93'); + $this->addSql('ALTER TABLE hardware_profile DROP FOREIGN KEY FK_2D9A2460FB84408A'); + $this->addSql('ALTER TABLE hardware_profile_hardware DROP FOREIGN KEY FK_18C7E12CFA495C1'); + $this->addSql('ALTER TABLE hardware_profile_hardware DROP FOREIGN KEY FK_18C7E12C9CC762B'); + $this->addSql('ALTER TABLE image DROP FOREIGN KEY FK_C53D045FED42A742'); + $this->addSql('ALTER TABLE image DROP FOREIGN KEY FK_C53D045F50C9D4F7'); + $this->addSql('ALTER TABLE image DROP FOREIGN KEY FK_C53D045F727ACA70'); + $this->addSql('ALTER TABLE image DROP FOREIGN KEY FK_C53D045F19EB6921'); + $this->addSql('ALTER TABLE network_settings DROP FOREIGN KEY FK_48869B54CCD7E912'); + $this->addSql('ALTER TABLE network_settings DROP FOREIGN KEY FK_48869B54CFA495C1'); + $this->addSql('ALTER TABLE network_settings DROP FOREIGN KEY FK_48869B5450C9D4F7'); + $this->addSql('ALTER TABLE network_settings DROP FOREIGN KEY FK_48869B54F7E54CF3'); + $this->addSql('ALTER TABLE organizational_unit DROP FOREIGN KEY FK_749AEB2D727ACA70'); + $this->addSql('ALTER TABLE organizational_unit DROP FOREIGN KEY FK_749AEB2D9B9A36D0'); + $this->addSql('ALTER TABLE organizational_unit DROP FOREIGN KEY FK_749AEB2DC9CF9478'); + $this->addSql('ALTER TABLE organizational_unit DROP FOREIGN KEY FK_749AEB2DC56641EE'); + $this->addSql('ALTER TABLE `partition` DROP FOREIGN KEY FK_9EB910E419EB6921'); + $this->addSql('ALTER TABLE `partition` DROP FOREIGN KEY FK_9EB910E4F1E9F66E'); + $this->addSql('ALTER TABLE `partition` DROP FOREIGN KEY FK_9EB910E43DA5256D'); + $this->addSql('ALTER TABLE remote_calendar_rule DROP FOREIGN KEY FK_EE93D058C56641EE'); + $this->addSql('ALTER TABLE software_profile DROP FOREIGN KEY FK_B70C3C9BFB84408A'); + $this->addSql('ALTER TABLE software_profile DROP FOREIGN KEY FK_B70C3C9BF1E9F66E'); + $this->addSql('ALTER TABLE software_profile_software DROP FOREIGN KEY FK_3DDFEC7ED42A742'); + $this->addSql('ALTER TABLE software_profile_software DROP FOREIGN KEY FK_3DDFEC7D7452741'); + $this->addSql('ALTER TABLE trace DROP FOREIGN KEY FK_315BD5A119EB6921'); + $this->addSql('ALTER TABLE user_user_group DROP FOREIGN KEY FK_28657971A76ED395'); + $this->addSql('ALTER TABLE user_user_group DROP FOREIGN KEY FK_286579711ED93D47'); + $this->addSql('ALTER TABLE user_organizational_unit DROP FOREIGN KEY FK_5E59845FA76ED395'); + $this->addSql('ALTER TABLE user_organizational_unit DROP FOREIGN KEY FK_5E59845FFB84408A'); + $this->addSql('ALTER TABLE view DROP FOREIGN KEY FK_FEFDAB8EA76ED395'); + $this->addSql('DROP TABLE client'); + $this->addSql('DROP TABLE command'); + $this->addSql('DROP TABLE command_group'); + $this->addSql('DROP TABLE command_group_command'); + $this->addSql('DROP TABLE command_task'); + $this->addSql('DROP TABLE command_task_command'); + $this->addSql('DROP TABLE command_task_command_group'); + $this->addSql('DROP TABLE command_task_client'); + $this->addSql('DROP TABLE hardware'); + $this->addSql('DROP TABLE hardware_profile'); + $this->addSql('DROP TABLE hardware_profile_hardware'); + $this->addSql('DROP TABLE hardware_type'); + $this->addSql('DROP TABLE image'); + $this->addSql('DROP TABLE image_repository'); + $this->addSql('DROP TABLE menu'); + $this->addSql('DROP TABLE network_settings'); + $this->addSql('DROP TABLE og_live'); + $this->addSql('DROP TABLE operative_system'); + $this->addSql('DROP TABLE operative_system_type'); + $this->addSql('DROP TABLE organizational_unit'); + $this->addSql('DROP TABLE `partition`'); + $this->addSql('DROP TABLE pxe_template'); + $this->addSql('DROP TABLE refresh_tokens'); + $this->addSql('DROP TABLE remote_calendar'); + $this->addSql('DROP TABLE remote_calendar_rule'); + $this->addSql('DROP TABLE software'); + $this->addSql('DROP TABLE software_profile'); + $this->addSql('DROP TABLE software_profile_software'); + $this->addSql('DROP TABLE subnet'); + $this->addSql('DROP TABLE trace'); + $this->addSql('DROP TABLE user'); + $this->addSql('DROP TABLE user_user_group'); + $this->addSql('DROP TABLE user_organizational_unit'); + $this->addSql('DROP TABLE user_group'); + $this->addSql('DROP TABLE view'); + } +} diff --git a/src/Controller/DeployImageAction.php b/src/Controller/DeployImageAction.php new file mode 100644 index 0000000..7b8cf9e --- /dev/null +++ b/src/Controller/DeployImageAction.php @@ -0,0 +1,68 @@ +getPartitionInfo(), true); + + $inputData = [ + 'method' => $input->method, + 'client' => $input->client->getEntity()->getUuid(), + 'image' => $image->getUuid(), + 'p2pMode' => $input->p2pMode, + 'p2pTime' => $input->p2pTime, + 'mcastIp' => $input->mcastIp, + 'mcastPort' => $input->mcastPort, + 'mcastSpeed' => $input->mcastSpeed, + 'mcastMode' => $input->mcastMode, + 'numDisk' => (string) $partitionInfo['numDisk'], + 'numPartition' => (string) $partitionInfo['numPartition'], + ]; + + switch ($input->method){ + case DeployMethodTypes::UNICAST: + $agentJobId = $this->deployImageOgAgentAction->__invoke($image, $input, DeployMethodTypes::UNICAST); + $this->createService->__invoke($input->client->getEntity(), CommandTypes::DEPLOY_IMAGE, TraceStatus::IN_PROGRESS, $agentJobId, $inputData); + + break; + + case DeployMethodTypes::MULTICAST: + $agentJobId = $this->deployImageOgAgentAction->__invoke($image, $input, DeployMethodTypes::MULTICAST); + $this->createService->__invoke($image->getClient(), CommandTypes::DEPLOY_IMAGE, TraceStatus::IN_PROGRESS, $agentJobId, $inputData); + + break; + } + + return new JsonResponse(data: [], status: Response::HTTP_OK); + } +} diff --git a/src/Controller/EnvDataController.php b/src/Controller/EnvDataController.php new file mode 100644 index 0000000..c0a0dae --- /dev/null +++ b/src/Controller/EnvDataController.php @@ -0,0 +1,65 @@ +kernel->getProjectDir(); + + $fileName = $projectDir . DIRECTORY_SEPARATOR . self::ENV_VARS_FILE; + if (!is_file($fileName)) { + throw new \RuntimeException('File not found: '.$fileName); + } + + $content = json_decode(file_get_contents($fileName), true); + + return new JsonResponse(['vars' => $content['vars']]); + } + + #[Route('/env-vars', methods: ['POST'])] + public function updateEnvVars(Request $request): JsonResponse + { + $data = json_decode($request->getContent(), true); + $projectDir = $this->kernel->getProjectDir(); + + $fileName = $projectDir . DIRECTORY_SEPARATOR . self::ENV_VARS_FILE; + + if (!isset($data['vars']) || !is_array($data['vars'])) { + return new JsonResponse(['error' => 'Invalid payload'], Response::HTTP_BAD_REQUEST); + } + + $json = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); + + if ($json === false) { + throw new \RuntimeException('Failed to encode JSON: ' . json_last_error_msg()); + } + + if (file_put_contents($fileName, $json) === false) { + throw new \RuntimeException('Failed to write to file: ' . self::ENV_VARS_FILE); + } + + return new JsonResponse(['message' => 'Variables updated successfully']); + } +} diff --git a/src/Controller/OgAgent/CreateImageAction.php b/src/Controller/OgAgent/CreateImageAction.php new file mode 100644 index 0000000..4e01293 --- /dev/null +++ b/src/Controller/OgAgent/CreateImageAction.php @@ -0,0 +1,88 @@ +getClient()->getIp()) { + throw new ValidatorException('IP is required'); + } + + $partitionInfo = json_decode($image->getPartitionInfo(), true); + + $data = [ + 'dsk' => (string) $partitionInfo['numDisk'], + 'par' => (string) $partitionInfo['numPartition'], + 'cpt' => "83", + 'idi' => $image->getUuid(), + 'nci' => $image->getName(), + 'ipr' => $image->getRepository()->getIp(), + 'nfn' => 'CrearImagen', + 'ids' => '0' + ]; + + try { + $response = $this->httpClient->request('POST', 'https://'.$image->getClient()->getIp().':8000/CloningEngine/CrearImagen', [ + 'verify_peer' => false, + 'verify_host' => false, + 'headers' => [ + 'Content-Type' => 'application/json', + ], + 'json' => $data, + ]); + + } catch (TransportExceptionInterface $e) { + return new JsonResponse( + data: ['error' => $e->getMessage()], + status: Response::HTTP_INTERNAL_SERVER_ERROR + ); + } + + $jobId = json_decode($response->getContent(), true)['job_id']; + + $image->setStatus(ImageStatus::IN_PROGRESS); + $this->entityManager->persist($image); + + $client = $image->getClient(); + $client->setStatus(ClientStatus::BUSY); + $this->entityManager->persist($client); + $this->entityManager->flush(); + + $this->createService->__invoke($image->getClient(), CommandTypes::CREATE_IMAGE, TraceStatus::IN_PROGRESS, $jobId, []); + + return new JsonResponse(data: $image, status: Response::HTTP_OK); + } +} diff --git a/src/Controller/OgAgent/DeployImageAction.php b/src/Controller/OgAgent/DeployImageAction.php new file mode 100644 index 0000000..c8e2d01 --- /dev/null +++ b/src/Controller/OgAgent/DeployImageAction.php @@ -0,0 +1,86 @@ +getClient()->getIp()) { + throw new ValidatorException('IP is required'); + } + + $partitionInfo = json_decode($image->getPartitionInfo(), true); + + /** @var Client $client */ + $client = $input->client->getEntity(); + + $data = [ + 'dsk' => (string) $partitionInfo['numDisk'], + 'par' => (string) $partitionInfo['numPartition'], + 'ifs' => "1", + 'idi' => $image->getUuid(), + 'nci' => $image->getName(), + 'ipr' => $image->getRepository()->getIp(), + 'nfn' => 'RestaurarImagen', + 'ptc' => $method, + 'ids' => '0' + ]; + + try { + $response = $this->httpClient->request('POST', 'https://'.$client->getIp().':8000/CloningEngine/RestaurarImagen', [ + 'verify_peer' => false, + 'verify_host' => false, + 'headers' => [ + 'Content-Type' => 'application/json', + ], + 'json' => $data, + ]); + + } catch (TransportExceptionInterface $e) { + return new JsonResponse( + data: ['error' => $e->getMessage()], + status: Response::HTTP_INTERNAL_SERVER_ERROR + ); + } + + $jobId = json_decode($response->getContent(), true)['job_id']; + + $client->setStatus(ClientStatus::BUSY); + $this->entityManager->persist($client); + $this->entityManager->flush(); + + return $jobId; + } +} diff --git a/src/Controller/OgAgent/StatusAction.php b/src/Controller/OgAgent/StatusAction.php index d0ff631..d0492dc 100644 --- a/src/Controller/OgAgent/StatusAction.php +++ b/src/Controller/OgAgent/StatusAction.php @@ -3,8 +3,11 @@ namespace App\Controller\OgAgent; use App\Entity\Client; +use App\Entity\OperativeSystem; use App\Entity\Partition; +use App\Model\ClientStatus; use App\Model\OgLiveStatus; +use App\Service\CreatePartitionService; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpClient\HttpClient; @@ -24,7 +27,8 @@ class StatusAction extends AbstractController { public function __construct( protected readonly EntityManagerInterface $entityManager, - protected readonly HttpClientInterface $httpClient + protected readonly HttpClientInterface $httpClient, + protected readonly CreatePartitionService $createPartitionService ) {} /** @@ -39,51 +43,83 @@ class StatusAction extends AbstractController throw new ValidatorException('IP is required'); } + if ($client->getStatus() === ClientStatus::OG_LIVE || $client->getStatus() === ClientStatus::OFF) { + $response = $this->getOgLiveStatus($client); + } + + if ($client->getStatus() === ClientStatus::LINUX) { + $response = $this->getSOStatus($client); + } + + return new JsonResponse( + data: ['status' => $response], + status: $response === Response::HTTP_OK ? Response::HTTP_OK : Response::HTTP_INTERNAL_SERVER_ERROR + ); + } + + public function getOgLiveStatus (Client $client): JsonResponse|int + { 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 + 'verify_peer' => false, + 'verify_host' => false, + 'timeout' => 10, 'headers' => [ - 'Content-Type' => 'application/json', // Cabecera de tipo de contenido + 'Content-Type' => 'application/json', ], - 'json' => [], // Cuerpo de la solicitud como JSON + 'json' => [], ]); $statusCode = $response->getStatusCode(); - $client->setStatus($statusCode === Response::HTTP_OK ? 'active' : 'off'); + $client->setStatus($statusCode === Response::HTTP_OK ? ClientStatus::OG_LIVE : ClientStatus::OFF); } catch (TransportExceptionInterface $e) { - $client->setStatus('off'); + $client->setStatus(ClientStatus::OFF); - return new JsonResponse( - data: ['error' => $e->getMessage()], - status: Response::HTTP_INTERNAL_SERVER_ERROR - ); + return 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->createPartitionService->__invoke($data, $client); } $this->entityManager->persist($client); $this->entityManager->flush(); - return new JsonResponse(status: Response::HTTP_OK); + return Response::HTTP_OK; + } + + public function getSOStatus (Client $client): JsonResponse|int + { + try { + $response = $this->httpClient->request('POST', 'https://' . $client->getIp() . ':8000/opengnsys/status', [ + 'verify_peer' => false, + 'verify_host' => false, + 'timeout' => 10, + 'headers' => [ + 'Content-Type' => 'application/json', + ], + 'json' => [], + ]); + $statusCode = $response->getStatusCode(); + $client->setStatus($statusCode === Response::HTTP_OK ? ClientStatus::LINUX : ClientStatus::OFF); + + } catch (TransportExceptionInterface $e) { + $client->setStatus(ClientStatus::OFF); + + return Response::HTTP_INTERNAL_SERVER_ERROR; + } + + $data = json_decode($response->getContent(), true); + + if (isset($data['cfg'])) { + $this->createPartitionService->__invoke($data, $client); + } + + $this->entityManager->persist($client); + $this->entityManager->flush(); + + return Response::HTTP_OK; } } \ No newline at end of file diff --git a/src/Controller/OgAgent/OgAdmClientController.php b/src/Controller/OgAgent/Webhook/AgentController.php similarity index 84% rename from src/Controller/OgAgent/OgAdmClientController.php rename to src/Controller/OgAgent/Webhook/AgentController.php index 4ec47f4..4ed9f5d 100644 --- a/src/Controller/OgAgent/OgAdmClientController.php +++ b/src/Controller/OgAgent/Webhook/AgentController.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace App\Controller\OgAgent; +namespace App\Controller\OgAgent\Webhook; use App\Entity\Client; use App\Entity\OrganizationalUnit; use App\Entity\Partition; -use App\Model\OrganizationalUnitTypes; +use App\Service\CreatePartitionService; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; @@ -17,10 +17,11 @@ use Symfony\Component\HttpKernel\Attribute\AsController; use Symfony\Component\Routing\Attribute\Route; #[AsController] -class OgAdmClientController extends AbstractController +class AgentController extends AbstractController { public function __construct( - protected readonly EntityManagerInterface $entityManager + protected readonly EntityManagerInterface $entityManager, + protected readonly CreatePartitionService $createPartitionService ) { } @@ -43,26 +44,10 @@ class OgAdmClientController extends AbstractController 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); - } + if (isset($data['cfg'])) { + $this->createPartitionService->__invoke($data, $clientEntity); } - + $this->entityManager->flush(); $center = $this->entityManager->getRepository(OrganizationalUnit::class)->find($clientEntity->getOrganizationalUnit()->getId()); diff --git a/src/Controller/OgAgent/Webhook/ClientsController.php b/src/Controller/OgAgent/Webhook/ClientsController.php new file mode 100644 index 0000000..2ceb9ee --- /dev/null +++ b/src/Controller/OgAgent/Webhook/ClientsController.php @@ -0,0 +1,140 @@ +toArray(); + $requiredFields = ['nfn', 'idi', 'dsk', 'par', 'ids', 'res', 'der', 'job_id']; + + foreach ($requiredFields as $field) { + if (!isset($data[$field])) { + return new JsonResponse(['message' => "Missing parameter: $field"], Response::HTTP_BAD_REQUEST); + } + } + + if ($data['nfn'] === 'RESPUESTA_CrearImagen') { + $trace = $this->entityManager->getRepository(Trace::class)->findOneBy(['jobId' => $data['job_id']]); + $image = $this->entityManager->getRepository(Image::class)->findOneBy(['uuid' => $data['idi']]); + + if (!$image) { + return new JsonResponse(['message' => 'Image not found'], Response::HTTP_NOT_FOUND); + } + + if ($data['res'] === 1) { + $trace->setStatus(TraceStatus::SUCCESS); + $trace->setFinishedAt(new \DateTime()); + $image->setStatus(ImageStatus::AUX_FILES_PENDING); + $image->setCreated(true); + if (isset($data['cfg'])) { + $this->createPartitionService->__invoke($data, $image->getClient()); + } + $this->createSoftwareProfile($data['inv_sft'], $image); + $this->createAuxFilesAction->__invoke($image); + } else { + $trace->setStatus(TraceStatus::FAILED); + $trace->setFinishedAt(new \DateTime()); + $trace->setOutput($data['der']); + $image->setCreated(false); + } + $this->entityManager->persist($image); + + $client = $trace->getClient(); + $client->setStatus(ClientStatus::OG_LIVE); + + $this->entityManager->persist($trace); + $this->entityManager->flush(); + } + + if ($data['nfn'] === 'RESPUESTA_RestaurarImagen') { + $trace = $this->entityManager->getRepository(Trace::class)->findOneBy(['jobId' => $data['job_id']]); + $image = $this->entityManager->getRepository(Image::class)->findOneBy(['uuid' => $data['idi']]); + + if ($data['res'] === 1) { + $trace->setStatus(TraceStatus::SUCCESS); + $trace->setFinishedAt(new \DateTime()); + $image->setStatus(ImageStatus::PENDING); + } else { + $trace->setStatus(TraceStatus::FAILED); + $trace->setFinishedAt(new \DateTime()); + $trace->setOutput($data['der']); + } + + $this->entityManager->persist($image); + $this->entityManager->persist($trace); + $this->entityManager->flush(); + } + + return new JsonResponse([], Response::HTTP_OK); + } + + public function createSoftwareProfile (string $base64Data, Image $image): void + { + $decodedData = base64_decode($base64Data); + + $softwareList = explode("\n", $decodedData); + + $softwareProfile = new SoftwareProfile(); + $softwareProfile->setDescription('Perfil : '.$image->getName()); + $softwareProfile->setOrganizationalUnit($image->getClient()->getOrganizationalUnit()); + + foreach ($softwareList as $software) { + $software = trim($software); + $softwareEntity = $this->entityManager->getRepository(Software::class)->findOneBy(['name' => $software]); + if (!$softwareEntity) { + $softwareEntity = new Software(); + $softwareEntity->setName($software); + $softwareEntity->setType(SoftwareTypes::APPLICATION); + $this->entityManager->persist($softwareEntity); + } + + $softwareEntity->addSoftwareProfile($softwareProfile); + } + + $this->entityManager->persist($softwareProfile); + $this->entityManager->flush(); + } +} \ No newline at end of file diff --git a/src/Controller/OgAgent/Webhook/GetStatusAction.php b/src/Controller/OgAgent/Webhook/GetStatusAction.php deleted file mode 100644 index fc256f8..0000000 --- a/src/Controller/OgAgent/Webhook/GetStatusAction.php +++ /dev/null @@ -1,44 +0,0 @@ -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); - } -} \ No newline at end of file diff --git a/src/Controller/OgAgent/OgAgentController.php b/src/Controller/OgAgent/Webhook/OgAgentController.php similarity index 76% rename from src/Controller/OgAgent/OgAgentController.php rename to src/Controller/OgAgent/Webhook/OgAgentController.php index 9fc6edd..27f129b 100644 --- a/src/Controller/OgAgent/OgAgentController.php +++ b/src/Controller/OgAgent/Webhook/OgAgentController.php @@ -2,18 +2,27 @@ declare(strict_types=1); -namespace App\Controller\OgAgent; +namespace App\Controller\OgAgent\Webhook; +use App\Entity\Client; +use App\Model\ClientStatus; +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\HttpFoundation\JsonResponse; #[AsController] class OgAgentController extends AbstractController { + public function __construct( + protected readonly EntityManagerInterface $entityManager + ) + { + } + #[Route('/opengnsys/rest/ogagent/started', methods: ['POST'])] public function agentStarted(Request $request): JsonResponse { @@ -26,7 +35,22 @@ class OgAgentController extends AbstractController } } - // Procesar los datos recibidos si es necesario + $client = $this->entityManager->getRepository(Client::class)->findOneBy(['mac' => $data['mac']]); + if (!$client) { + return new JsonResponse(['message' => 'Client not found'], Response::HTTP_NOT_FOUND); + } + + switch ($data['ostype']) { + case 'Linux': + $client->setStatus(ClientStatus::LINUX); + break; + + default: + return new JsonResponse(['message' => 'Invalid status'], Response::HTTP_BAD_REQUEST); + } + + $this->entityManager->persist($client); + $this->entityManager->flush(); return new JsonResponse([], Response::HTTP_OK); } diff --git a/src/Controller/OgBoot/AbstractOgBootController.php b/src/Controller/OgBoot/AbstractOgBootController.php index 7e96b1c..ee8b178 100644 --- a/src/Controller/OgBoot/AbstractOgBootController.php +++ b/src/Controller/OgBoot/AbstractOgBootController.php @@ -6,6 +6,7 @@ namespace App\Controller\OgBoot; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Attribute\AsController; @@ -20,8 +21,11 @@ use Symfony\Contracts\HttpClient\HttpClientInterface; abstract class AbstractOgBootController extends AbstractController { public function __construct( - protected readonly string $ogBootApiUrl, - protected readonly EntityManagerInterface $entityManager + #[Autowire(env: 'OG_BOOT_API_URL')] + protected string $ogBootApiUrl, + #[Autowire(env: 'OG_CORE_IP')] + protected string $ogCoreIP, + protected readonly EntityManagerInterface $entityManager ) { } diff --git a/src/Controller/OgBoot/OgLive/GetAction.php b/src/Controller/OgBoot/OgLive/GetAction.php index 8635aee..54ebe45 100644 --- a/src/Controller/OgBoot/OgLive/GetAction.php +++ b/src/Controller/OgBoot/OgLive/GetAction.php @@ -29,7 +29,7 @@ class GetAction extends AbstractOgBootController throw new ValidatorException('Checksum is required'); } - $content = $this->createRequest($httpClient, 'GET', $this->ogBootApiUrl.'/ogboot/v1/oglives/'.$data->getChecksum()); + $content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/'.$data->getChecksum()); return new JsonResponse(data: $content, status: Response::HTTP_OK); } diff --git a/src/Controller/OgBoot/OgLive/GetCollectionAction.php b/src/Controller/OgBoot/OgLive/GetCollectionAction.php index 930b237..41cacdf 100644 --- a/src/Controller/OgBoot/OgLive/GetCollectionAction.php +++ b/src/Controller/OgBoot/OgLive/GetCollectionAction.php @@ -24,7 +24,7 @@ class GetCollectionAction extends AbstractOgBootController */ public function __invoke(HttpClientInterface $httpClient): JsonResponse { - $content = $this->createRequest($httpClient, 'GET', $this->ogBootApiUrl.'/ogboot/v1/oglives'); + $content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives'); return new JsonResponse(data: $content, status: Response::HTTP_OK); } diff --git a/src/Controller/OgBoot/OgLive/GetDefaultAction.php b/src/Controller/OgBoot/OgLive/GetDefaultAction.php index 94f3456..3c77859 100644 --- a/src/Controller/OgBoot/OgLive/GetDefaultAction.php +++ b/src/Controller/OgBoot/OgLive/GetDefaultAction.php @@ -23,7 +23,7 @@ class GetDefaultAction extends AbstractOgBootController */ public function __invoke(HttpClientInterface $httpClient): JsonResponse { - $content = $this->createRequest($httpClient, 'GET', $this->ogBootApiUrl.'/ogboot/v1/oglives/default'); + $content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/default'); return new JsonResponse(status: Response::HTTP_OK); } diff --git a/src/Controller/OgBoot/OgLive/GetIsosAction.php b/src/Controller/OgBoot/OgLive/GetIsosAction.php index 90ddb19..1acdbd2 100644 --- a/src/Controller/OgBoot/OgLive/GetIsosAction.php +++ b/src/Controller/OgBoot/OgLive/GetIsosAction.php @@ -24,7 +24,7 @@ class GetIsosAction extends AbstractOgBootController */ public function __invoke(HttpClientInterface $httpClient): JsonResponse { - $content = $this->createRequest($httpClient, 'GET', $this->ogBootApiUrl.'/ogboot/v1/oglives/isos'); + $content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/isos'); return new JsonResponse(data: $content, status: Response::HTTP_OK); } diff --git a/src/Controller/OgBoot/OgLive/InstallAction.php b/src/Controller/OgBoot/OgLive/InstallAction.php index e2bbe17..07b68ac 100644 --- a/src/Controller/OgBoot/OgLive/InstallAction.php +++ b/src/Controller/OgBoot/OgLive/InstallAction.php @@ -38,7 +38,7 @@ class InstallAction extends AbstractOgBootController ] ]; - $content = $this->createRequest($httpClient, 'POST', $this->ogBootApiUrl.'/ogboot/v1/oglives/install', $params); + $content = $this->createRequest($httpClient, 'POST', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/install', $params); $data->setStatus(OgLiveStatus::PENDING); $entityManager->persist($data); diff --git a/src/Controller/OgBoot/OgLive/SetDefaultAction.php b/src/Controller/OgBoot/OgLive/SetDefaultAction.php index 3cf7184..896ac3b 100644 --- a/src/Controller/OgBoot/OgLive/SetDefaultAction.php +++ b/src/Controller/OgBoot/OgLive/SetDefaultAction.php @@ -36,7 +36,7 @@ class SetDefaultAction extends AbstractOgBootController ] ]; - $content = $this->createRequest($httpClient, 'PUT', $this->ogBootApiUrl.'/ogboot/v1/oglives/default', $params); + $content = $this->createRequest($httpClient, 'PUT', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/default', $params); $oldDefaultOgLive = $this->entityManager->getRepository(OgLive::class)->findBy(['isDefault' => true]); diff --git a/src/Controller/OgBoot/OgLive/SyncAction.php b/src/Controller/OgBoot/OgLive/SyncAction.php index 0c036a2..9de363e 100644 --- a/src/Controller/OgBoot/OgLive/SyncAction.php +++ b/src/Controller/OgBoot/OgLive/SyncAction.php @@ -19,6 +19,7 @@ use Symfony\Contracts\HttpClient\HttpClientInterface; #[AsController] class SyncAction extends AbstractOgBootController { + const string OG_BOOT_DIRECTORY = '/opt/opengnsys/ogboot/tftpboot//'; /** * @throws TransportExceptionInterface * @throws ServerExceptionInterface @@ -27,7 +28,7 @@ class SyncAction extends AbstractOgBootController */ public function __invoke(HttpClientInterface $httpClient, EntityManagerInterface $entityManager): JsonResponse { - $content = $this->createRequest($httpClient, 'GET', $this->ogBootApiUrl . '/ogboot/v1/oglives'); + $content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogBootApiUrl . '/ogboot/v1/oglives'); foreach ($content['message']['installed_ogLives'] as $ogLive) { $ogLiveEntity = $this->entityManager->getRepository(OgLive::class)->findOneBy(['checksum' => $ogLive['id']]); @@ -53,7 +54,7 @@ class SyncAction extends AbstractOgBootController */ private function extracted(OgLive|null $ogLiveEntity, mixed $ogLive): void { - $ogLiveEntity->setName($ogLive['directory']); + $ogLiveEntity->setName(str_replace(self::OG_BOOT_DIRECTORY, '', $ogLive['directory'])); $ogLiveEntity->setInstalled(true); $ogLiveEntity->setArchitecture($ogLive['architecture']); $ogLiveEntity->setDistribution($ogLive['distribution']); diff --git a/src/Controller/OgBoot/OgLive/UninstallAction.php b/src/Controller/OgBoot/OgLive/UninstallAction.php index d0ea542..70b3c0b 100644 --- a/src/Controller/OgBoot/OgLive/UninstallAction.php +++ b/src/Controller/OgBoot/OgLive/UninstallAction.php @@ -31,7 +31,7 @@ class UninstallAction extends AbstractOgBootController throw new ValidatorException('Checksum is required'); } - $content = $this->createRequest($httpClient, 'DELETE', $this->ogBootApiUrl.'/ogboot/v1/oglives/'.$data->getChecksum()); + $content = $this->createRequest($httpClient, 'DELETE', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/oglives/'.$data->getChecksum()); $entityManager->remove($data); $entityManager->flush(); diff --git a/src/Controller/OgBoot/PxeBootFile/GetAction.php b/src/Controller/OgBoot/PxeBootFile/GetAction.php index 7f51e2b..4f4fb02 100644 --- a/src/Controller/OgBoot/PxeBootFile/GetAction.php +++ b/src/Controller/OgBoot/PxeBootFile/GetAction.php @@ -27,7 +27,7 @@ class GetAction extends AbstractOgBootController public function __invoke(Client $client, HttpClientInterface $httpClient): JsonResponse { try { - $response = $httpClient->request('GET', $this->ogBootApiUrl.'/ogboot/v1/pxes/'.$client->getMac(), [ + $response = $httpClient->request('GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/pxes/'.$client->getMac(), [ 'headers' => [ 'accept' => 'application/json', ], diff --git a/src/Controller/OgBoot/PxeBootFile/GetCollectionAction.php b/src/Controller/OgBoot/PxeBootFile/GetCollectionAction.php index f870364..3d53a9f 100644 --- a/src/Controller/OgBoot/PxeBootFile/GetCollectionAction.php +++ b/src/Controller/OgBoot/PxeBootFile/GetCollectionAction.php @@ -26,7 +26,7 @@ class GetCollectionAction extends AbstractOgBootController */ public function __invoke(HttpClientInterface $httpClient): JsonResponse { - $content = $this->createRequest($httpClient, 'GET', $this->ogBootApiUrl.'/ogboot/v1/pxes'); + $content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/pxes'); return new JsonResponse(data: $content, status: Response::HTTP_OK); } diff --git a/src/Controller/OgBoot/PxeBootFile/PostAction.php b/src/Controller/OgBoot/PxeBootFile/PostAction.php index 506b4b9..1bc03ba 100644 --- a/src/Controller/OgBoot/PxeBootFile/PostAction.php +++ b/src/Controller/OgBoot/PxeBootFile/PostAction.php @@ -36,28 +36,30 @@ class PostAction extends AbstractOgBootController 'mac' => strtolower($client->getMac()), 'lang' => 'es_ES.UTF_8', 'ip' => $client->getIp(), - 'server_ip' => '192.168.2.4', + 'server_ip' => $this->ogBootApiUrl, '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', + 'ogrepo' => $client->getRepository()->getIp() , + 'ogcore' => $this->ogCoreIP, + 'oglive' => $this->ogBootApiUrl, + 'oglog' => $client->getOrganizationalUnit()->getNetworkSettings()?->getOgLog(), + 'ogshare' => $client->getOrganizationalUnit()->getNetworkSettings()?->getOgShare() + ? $client->getOrganizationalUnit()->getNetworkSettings()?->getOgShare(): $this->ogBootApiUrl, + 'oglivedir' => $client->getOgLive()->getFilename(), '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' => '', + 'ogntp' => $client->getOrganizationalUnit()->getNetworkSettings()?->getNtp(), //optional + 'ogdns' => $client->getOrganizationalUnit()->getNetworkSettings()?->getDns(), //optional + 'ogProxy' => $client->getOrganizationalUnit()->getNetworkSettings()?->getProxy(), //optional + // 'ogunit' => '', //eliminar 'resolution' => '788' ]; try { - $response = $httpClient->request('POST', $this->ogBootApiUrl.'/ogboot/v1/pxes', [ + $response = $httpClient->request('POST', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/pxes', [ 'headers' => [ 'accept' => 'application/json', 'Content-Type' => 'application/json', diff --git a/src/Controller/OgBoot/PxeTemplate/DeleteAction.php b/src/Controller/OgBoot/PxeTemplate/DeleteAction.php index ba6c49d..eb42411 100644 --- a/src/Controller/OgBoot/PxeTemplate/DeleteAction.php +++ b/src/Controller/OgBoot/PxeTemplate/DeleteAction.php @@ -27,7 +27,7 @@ class DeleteAction extends AbstractOgBootController public function __invoke(PxeTemplate $data, HttpClientInterface $httpClient, EntityManagerInterface $entityManager): JsonResponse { try { - $response = $httpClient->request('DELETE', $this->ogBootApiUrl.'/ogboot/v1/pxe-templates/'.$data->getName(), [ + $response = $httpClient->request('DELETE', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/pxe-templates/'.$data->getName(), [ 'headers' => [ 'accept' => 'application/json', ], diff --git a/src/Controller/OgBoot/PxeTemplate/GetAction.php b/src/Controller/OgBoot/PxeTemplate/GetAction.php index 5bbc2c0..6a61c17 100644 --- a/src/Controller/OgBoot/PxeTemplate/GetAction.php +++ b/src/Controller/OgBoot/PxeTemplate/GetAction.php @@ -26,7 +26,7 @@ class GetAction extends AbstractOgBootController public function __invoke(PxeTemplate $template, HttpClientInterface $httpClient): JsonResponse { try { - $response = $httpClient->request('GET', $this->ogBootApiUrl.'/ogboot/v1/pxe-templates/'.$template->getName(), [ + $response = $httpClient->request('GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/pxe-templates/'.$template->getName(), [ 'headers' => [ 'accept' => 'application/json', ], diff --git a/src/Controller/OgBoot/PxeTemplate/GetCollectionAction.php b/src/Controller/OgBoot/PxeTemplate/GetCollectionAction.php index c294cae..623c8d3 100644 --- a/src/Controller/OgBoot/PxeTemplate/GetCollectionAction.php +++ b/src/Controller/OgBoot/PxeTemplate/GetCollectionAction.php @@ -25,7 +25,7 @@ class GetCollectionAction extends AbstractOgBootController public function __invoke(HttpClientInterface $httpClient): JsonResponse { try { - $response = $httpClient->request('GET', $this->ogBootApiUrl.'/ogboot/v1/pxe-templates', [ + $response = $httpClient->request('GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/pxe-templates', [ 'headers' => [ 'accept' => 'application/json', ], diff --git a/src/Controller/OgBoot/PxeTemplate/PostAction.php b/src/Controller/OgBoot/PxeTemplate/PostAction.php index a448bf1..e6fd198 100644 --- a/src/Controller/OgBoot/PxeTemplate/PostAction.php +++ b/src/Controller/OgBoot/PxeTemplate/PostAction.php @@ -27,7 +27,7 @@ class PostAction extends AbstractOgBootController public function __invoke(PxeTemplate $data, HttpClientInterface $httpClient, EntityManagerInterface $entityManager): JsonResponse { try { - $response = $httpClient->request('POST', $this->ogBootApiUrl.'/ogboot/v1/pxe-templates', [ + $response = $httpClient->request('POST', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/pxe-templates', [ 'headers' => [ 'accept' => 'application/json', 'Content-Type' => 'application/json', diff --git a/src/Controller/OgBoot/PxeTemplate/SyncAction.php b/src/Controller/OgBoot/PxeTemplate/SyncAction.php index 50746bd..8d85270 100644 --- a/src/Controller/OgBoot/PxeTemplate/SyncAction.php +++ b/src/Controller/OgBoot/PxeTemplate/SyncAction.php @@ -28,7 +28,7 @@ class SyncAction extends AbstractOgBootController */ public function __invoke(HttpClientInterface $httpClient, EntityManagerInterface $entityManager): JsonResponse { - $content = $this->createRequest($httpClient, 'GET', $this->ogBootApiUrl . '/ogboot/v1/pxe-templates'); + $content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogBootApiUrl . '/ogboot/v1/pxe-templates'); foreach ($content['message'] as $template) { $templateEntity = $this->entityManager->getRepository(PxeTemplate::class)->findOneBy(['name' => $template]); diff --git a/src/Controller/OgDhcp/AbstractOgDhcpController.php b/src/Controller/OgDhcp/AbstractOgDhcpController.php index 2e4e6f5..9288698 100644 --- a/src/Controller/OgDhcp/AbstractOgDhcpController.php +++ b/src/Controller/OgDhcp/AbstractOgDhcpController.php @@ -7,6 +7,7 @@ namespace App\Controller\OgDhcp; use App\Service\Utils\GetIpAddressAndNetmaskFromCIDRService; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Attribute\AsController; @@ -21,9 +22,10 @@ use Symfony\Contracts\HttpClient\HttpClientInterface; abstract class AbstractOgDhcpController extends AbstractController { public function __construct( + #[Autowire(env: 'OG_DHCP_API_URL')] protected readonly string $ogDhcpApiUrl, protected readonly EntityManagerInterface $entityManager, - protected readonly GetIpAddressAndNetmaskFromCIDRService $getIpAddressAndNetmaskFromCIDRService + protected readonly GetIpAddressAndNetmaskFromCIDRService $getIpAddressAndNetmaskFromCIDRService, ) { } diff --git a/src/Controller/OgDhcp/Subnet/DeleteAction.php b/src/Controller/OgDhcp/Subnet/DeleteAction.php index a00555a..7b9554c 100644 --- a/src/Controller/OgDhcp/Subnet/DeleteAction.php +++ b/src/Controller/OgDhcp/Subnet/DeleteAction.php @@ -29,7 +29,7 @@ class DeleteAction extends AbstractOgDhcpController throw new ValidatorException('Data Id is required'); } - $content = $this->createRequest($httpClient, 'DELETE', $this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId()); + $content = $this->createRequest($httpClient, 'DELETE', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId()); $this->entityManager->remove($data); $this->entityManager->flush(); diff --git a/src/Controller/OgDhcp/Subnet/DeleteHostAction.php b/src/Controller/OgDhcp/Subnet/DeleteHostAction.php index cf32b80..8b2c251 100644 --- a/src/Controller/OgDhcp/Subnet/DeleteHostAction.php +++ b/src/Controller/OgDhcp/Subnet/DeleteHostAction.php @@ -42,7 +42,7 @@ class DeleteHostAction extends AbstractOgDhcpController ] ]; - $content = $this->createRequest($httpClient, 'DELETE', $this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId().'/hosts', $params); + $content = $this->createRequest($httpClient, 'DELETE', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId().'/hosts', $params); $data->removeClient($client); $this->entityManager->persist($data); diff --git a/src/Controller/OgDhcp/Subnet/GetAction.php b/src/Controller/OgDhcp/Subnet/GetAction.php index 77f1bce..257e26b 100644 --- a/src/Controller/OgDhcp/Subnet/GetAction.php +++ b/src/Controller/OgDhcp/Subnet/GetAction.php @@ -29,7 +29,7 @@ class GetAction extends AbstractOgDhcpController throw new ValidatorException('Checksum is required'); } - $content = $this->createRequest($httpClient, 'GET', $this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId()); + $content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId()); return new JsonResponse(data: $content, status: Response::HTTP_OK); } diff --git a/src/Controller/OgDhcp/Subnet/GetCollectionAction.php b/src/Controller/OgDhcp/Subnet/GetCollectionAction.php index 9f9324c..95381d0 100644 --- a/src/Controller/OgDhcp/Subnet/GetCollectionAction.php +++ b/src/Controller/OgDhcp/Subnet/GetCollectionAction.php @@ -23,7 +23,7 @@ class GetCollectionAction extends AbstractOgDhcpController */ public function __invoke(HttpClientInterface $httpClient): JsonResponse { - $content = $this->createRequest($httpClient, 'GET', $this->ogDhcpApiUrl . '/ogdhcp/v1/subnets'); + $content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogDhcpApiUrl . '/ogdhcp/v1/subnets'); return new JsonResponse(data: $content, status: Response::HTTP_OK); } diff --git a/src/Controller/OgDhcp/Subnet/GetHostsAction.php b/src/Controller/OgDhcp/Subnet/GetHostsAction.php index 52ca307..8056945 100644 --- a/src/Controller/OgDhcp/Subnet/GetHostsAction.php +++ b/src/Controller/OgDhcp/Subnet/GetHostsAction.php @@ -29,7 +29,7 @@ class GetHostsAction extends AbstractOgDhcpController throw new ValidatorException('Checksum is required'); } - $content = $this->createRequest($httpClient, 'GET', $this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId().'/hosts'); + $content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId().'/hosts'); return new JsonResponse(data: $content, status: Response::HTTP_OK); } diff --git a/src/Controller/OgDhcp/Subnet/PostAction.php b/src/Controller/OgDhcp/Subnet/PostAction.php index a4824f1..8cc41d1 100644 --- a/src/Controller/OgDhcp/Subnet/PostAction.php +++ b/src/Controller/OgDhcp/Subnet/PostAction.php @@ -35,7 +35,7 @@ class PostAction extends AbstractOgDhcpController ] ]; - $content = $this->createRequest($httpClient, 'POST', $this->ogDhcpApiUrl.'/ogdhcp/v1/subnets' , $params); + $content = $this->createRequest($httpClient, 'POST', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets' , $params); $data->setServerId($content['message']['id']); $data->setSynchronized(true); diff --git a/src/Controller/OgDhcp/Subnet/PostHostAction.php b/src/Controller/OgDhcp/Subnet/PostHostAction.php index 4330f8d..c6e3872 100644 --- a/src/Controller/OgDhcp/Subnet/PostHostAction.php +++ b/src/Controller/OgDhcp/Subnet/PostHostAction.php @@ -44,7 +44,7 @@ class PostHostAction extends AbstractOgDhcpController 'json' => $data ]; - $content = $this->createRequest($httpClient, 'POST', $this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$subnet->getServerId().'/hosts', $params); + $content = $this->createRequest($httpClient, 'POST', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$subnet->getServerId().'/hosts', $params); $subnet->addClient($clientEntity); $this->entityManager->persist($subnet); diff --git a/src/Controller/OgDhcp/Subnet/PutAction.php b/src/Controller/OgDhcp/Subnet/PutAction.php index 9e3004c..080f0bc 100644 --- a/src/Controller/OgDhcp/Subnet/PutAction.php +++ b/src/Controller/OgDhcp/Subnet/PutAction.php @@ -38,7 +38,7 @@ class PutAction extends AbstractOgDhcpController ] ]; - $content = $this->createRequest($httpClient, 'PUT', $this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId(), $params); + $content = $this->createRequest($httpClient, 'PUT', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId(), $params); $this->entityManager->persist($data); $this->entityManager->flush(); diff --git a/src/Controller/OgDhcp/Subnet/PutHostAction.php b/src/Controller/OgDhcp/Subnet/PutHostAction.php index 3815ca4..5ba614a 100644 --- a/src/Controller/OgDhcp/Subnet/PutHostAction.php +++ b/src/Controller/OgDhcp/Subnet/PutHostAction.php @@ -42,7 +42,7 @@ class PutHostAction extends AbstractOgDhcpController 'json' => $data ]; - $content = $this->createRequest($httpClient, 'PUT', $this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$subnet->getId().'/hosts', $params); + $content = $this->createRequest($httpClient, 'PUT', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$subnet->getId().'/hosts', $params); } return new JsonResponse(status: Response::HTTP_OK); diff --git a/src/Controller/OgDhcp/Subnet/SyncAction.php b/src/Controller/OgDhcp/Subnet/SyncAction.php index 29c86dc..0c301d7 100644 --- a/src/Controller/OgDhcp/Subnet/SyncAction.php +++ b/src/Controller/OgDhcp/Subnet/SyncAction.php @@ -26,7 +26,7 @@ class SyncAction extends AbstractOgDhcpController */ public function __invoke(HttpClientInterface $httpClient, EntityManagerInterface $entityManager): JsonResponse { - $content = $this->createRequest($httpClient, 'GET', $this->ogDhcpApiUrl . '/ogdhcp/v1/subnets'); + $content = $this->createRequest($httpClient, 'GET', 'http://'.$this->ogDhcpApiUrl . '/ogdhcp/v1/subnets'); $arraySync = []; diff --git a/src/Controller/OgRepository/AbstractOgRepositoryController.php b/src/Controller/OgRepository/AbstractOgRepositoryController.php new file mode 100644 index 0000000..0d1f141 --- /dev/null +++ b/src/Controller/OgRepository/AbstractOgRepositoryController.php @@ -0,0 +1,58 @@ + [ + 'accept' => 'application/json', + 'Content-Type' => 'application/json' + ], + ]); + + try { + $response = $this->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()); + } + } +} diff --git a/src/Controller/OgRepository/GetCollectionAction.php b/src/Controller/OgRepository/GetCollectionAction.php new file mode 100644 index 0000000..594385a --- /dev/null +++ b/src/Controller/OgRepository/GetCollectionAction.php @@ -0,0 +1,30 @@ +createRequest('GET', 'http://'.$data->getIp(). ':8006/ogrepository/v1/images'); + + return new JsonResponse( data: $content, status: Response::HTTP_OK); + } +} \ No newline at end of file diff --git a/src/Controller/OgRepository/Image/CreateAuxFilesAction.php b/src/Controller/OgRepository/Image/CreateAuxFilesAction.php new file mode 100644 index 0000000..70c9461 --- /dev/null +++ b/src/Controller/OgRepository/Image/CreateAuxFilesAction.php @@ -0,0 +1,58 @@ +getName()) { + throw new ValidatorException('Name is required'); + } + + $params = [ + 'json' => [ + 'image' => $data->getName().'.img' + ] + ]; + + $content = $this->createRequest('POST', 'http://'.$data->getRepository()->getIp().':8006/ogrepository/v1/images/torrentsum', $params); + + $inputData = [ + 'imageName' => $data->getName(), + 'imageUuid' => $data->getUuid(), + ]; + + $this->createService->__invoke($data->getClient(), CommandTypes::CREATE_IMAGE_AUX_FILE, TraceStatus::IN_PROGRESS, $content['job_id'], $inputData); + + $data->setStatus(ImageStatus::IN_PROGRESS); + $this->entityManager->persist($data); + $this->entityManager->flush(); + + return new JsonResponse(data: $content, status: Response::HTTP_OK); + } +} \ No newline at end of file diff --git a/src/Controller/OgRepository/Image/DeletePermanentAction.php b/src/Controller/OgRepository/Image/DeletePermanentAction.php new file mode 100644 index 0000000..de36d77 --- /dev/null +++ b/src/Controller/OgRepository/Image/DeletePermanentAction.php @@ -0,0 +1,39 @@ +getImageFullsum()) { + throw new ValidatorException('Fullsum is required'); + } + + $content = $this->createRequest( 'DELETE', 'http://'.$data->getRepository()->getIp().':8006/ogrepository/v1/images/'.$data->getImageFullsum().'?method=trash'); + + $this->entityManager->remove($data); + $this->entityManager->flush(); + + return new JsonResponse(data: $content, status: Response::HTTP_OK); + } +} \ No newline at end of file diff --git a/src/Controller/OgRepository/Image/DeleteTrashAction.php b/src/Controller/OgRepository/Image/DeleteTrashAction.php new file mode 100644 index 0000000..80a5c76 --- /dev/null +++ b/src/Controller/OgRepository/Image/DeleteTrashAction.php @@ -0,0 +1,41 @@ +getImageFullsum()) { + throw new ValidatorException('Fullsum is required'); + } + + $content = $this->createRequest('DELETE', 'http://'.$data->getRepository()->getIp().':8006/ogrepository/v1/images/'.$data->getImageFullsum().'?method=trash'); + + $data->setStatus(ImageStatus::TRASH); + $this->entityManager->persist($data); + $this->entityManager->flush(); + + return new JsonResponse(data: $content, status: Response::HTTP_OK); + } +} \ No newline at end of file diff --git a/src/Controller/OgRepository/Image/DeployImageAction.php b/src/Controller/OgRepository/Image/DeployImageAction.php new file mode 100644 index 0000000..c90a6e6 --- /dev/null +++ b/src/Controller/OgRepository/Image/DeployImageAction.php @@ -0,0 +1,36 @@ +client; + + $this->createService->__invoke($data->getClient(), CommandTypes::DEPLOY_IMAGE, TraceStatus::IN_PROGRESS, null); + + return new JsonResponse(data: [], status: Response::HTTP_OK); + } +} \ No newline at end of file diff --git a/src/Controller/OgRepository/Image/GetAction.php b/src/Controller/OgRepository/Image/GetAction.php new file mode 100644 index 0000000..79df992 --- /dev/null +++ b/src/Controller/OgRepository/Image/GetAction.php @@ -0,0 +1,36 @@ +getImageFullsum()) { + throw new ValidatorException('Fullsum is required'); + } + + $content = $this->createRequest('GET', 'http://'.$data->getRepository()->getIp().':8006/ogrepository/v1/images/'.$data->getImageFullsum()); + + return new JsonResponse(data: $content, status: Response::HTTP_OK); + } +} \ No newline at end of file diff --git a/src/Controller/OgRepository/Image/RecoverAction.php b/src/Controller/OgRepository/Image/RecoverAction.php new file mode 100644 index 0000000..4e6b820 --- /dev/null +++ b/src/Controller/OgRepository/Image/RecoverAction.php @@ -0,0 +1,51 @@ +getImageFullsum()) { + throw new ValidatorException('Fullsum is required'); + } + + $params = [ + 'json' => [ + 'ID_img' => $data->getImageFullsum() + ] + ]; + + + $content = $this->createRequest('POST', 'http://'.$data->getRepository()->getIp().':8006/ogrepository/v1/trash/images', $params); + + $data->setStatus(ImageStatus::SUCCESS); + $this->entityManager->persist($data); + $this->entityManager->flush(); + + return new JsonResponse(data: $content, status: Response::HTTP_OK); + } +} \ No newline at end of file diff --git a/src/Controller/OgRepository/StatusAction.php b/src/Controller/OgRepository/StatusAction.php new file mode 100644 index 0000000..74c2654 --- /dev/null +++ b/src/Controller/OgRepository/StatusAction.php @@ -0,0 +1,30 @@ +createRequest('GET', 'http://'.$data->getIp(). ':8006/ogrepository/v1/status'); + + return new JsonResponse( data: $content, status: Response::HTTP_OK); + } +} \ No newline at end of file diff --git a/src/Controller/OgRepository/SyncAction.php b/src/Controller/OgRepository/SyncAction.php new file mode 100644 index 0000000..4fb4da5 --- /dev/null +++ b/src/Controller/OgRepository/SyncAction.php @@ -0,0 +1,50 @@ +createRequest('GET', 'http://'.$data->getIp(). ':8006/ogrepository/v1/images'); + + if (!isset($content['output']['REPOSITORY']['images'])) { + return new JsonResponse(data: 'No images found', status: Response::HTTP_NOT_FOUND); + } + + foreach ($content['output']['REPOSITORY']['images'] as $image) { + $imageEntity = $this->entityManager->getRepository(Image::class)->findOneBy(['imageFullsum' => $image['fullsum']]); + if (!$imageEntity) { + $imageEntity = new Image(); + $imageEntity->setName($image['name'].$image['type']); + $imageEntity->setStatus(ImageStatus::SUCCESS); + $imageEntity->setRepository($data); + $imageEntity->setCreated(true ); + $imageEntity->setImageFullsum($image['fullsum']); + $imageEntity->setRemotePc(false); + } + $this->entityManager->persist($imageEntity); + } + $this->entityManager->flush(); + + return new JsonResponse(data: $content, status: Response::HTTP_OK); + } +} \ No newline at end of file diff --git a/src/Controller/OgRepository/Webhook/ResponseController.php b/src/Controller/OgRepository/Webhook/ResponseController.php new file mode 100644 index 0000000..7a7d0d2 --- /dev/null +++ b/src/Controller/OgRepository/Webhook/ResponseController.php @@ -0,0 +1,59 @@ +getContent(), true); + + $trace = $this->entityManager->getRepository(Trace::class)->findOneBy(['jobId' => $data['job_id']]); + $imageUuid = $trace->getInput()['imageUuid']; + + $image = $this->entityManager->getRepository(Image::class)->findOneBy(['uuid' => $imageUuid]); + + if ($image === null) { + $trace->setStatus(TraceStatus::FAILED); + $trace->setFinishedAt(new \DateTime()); + $trace->setOutput('Image not found'); + $this->entityManager->persist($trace); + $this->entityManager->flush(); + + return new JsonResponse(['message' => 'Image not found'], Response::HTTP_NOT_FOUND); + } + + $image->setImageFullsum($data['image_id']); + $image->setStatus(ImageStatus::SUCCESS); + $this->entityManager->persist($image); + + $trace->setStatus(TraceStatus::SUCCESS); + $trace->setFinishedAt(new \DateTime()); + + $this->entityManager->persist($trace); + $this->entityManager->flush(); + + return new JsonResponse($data, Response::HTTP_OK); + + } +} \ No newline at end of file diff --git a/src/Controller/UDS/RemoteCalendarSyncUdsAction.php b/src/Controller/UDS/RemoteCalendarSyncUdsAction.php index 019534b..c5ac842 100644 --- a/src/Controller/UDS/RemoteCalendarSyncUdsAction.php +++ b/src/Controller/UDS/RemoteCalendarSyncUdsAction.php @@ -8,6 +8,7 @@ use App\Model\OrganizationalUnitTypes; use App\Service\UDS\UDSClient; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; @@ -16,6 +17,7 @@ class RemoteCalendarSyncUdsAction extends AbstractController { public function __construct( + #[Autowire(env: 'UDS_URL')] private readonly UDSClient $udsClient ) { diff --git a/src/DependencyInjection/JsonEnvVarLoader.php b/src/DependencyInjection/JsonEnvVarLoader.php new file mode 100644 index 0000000..fefa07a --- /dev/null +++ b/src/DependencyInjection/JsonEnvVarLoader.php @@ -0,0 +1,31 @@ +kernel->getProjectDir(); + + $fileName = $projectDir . DIRECTORY_SEPARATOR . self::ENV_VARS_FILE; + if (!is_file($fileName)) { + throw new \RuntimeException('File not found: '.$fileName); + } + + $content = json_decode(file_get_contents($fileName), true); + + return $content['vars']; + } +} \ No newline at end of file diff --git a/src/Dto/Input/ClientInput.php b/src/Dto/Input/ClientInput.php index 8e78aa0..3f07594 100644 --- a/src/Dto/Input/ClientInput.php +++ b/src/Dto/Input/ClientInput.php @@ -4,12 +4,14 @@ namespace App\Dto\Input; use ApiPlatform\Metadata\ApiProperty; use App\Dto\Output\HardwareProfileOutput; +use App\Dto\Output\ImageRepositoryOutput; use App\Dto\Output\MenuOutput; use App\Dto\Output\OgLiveOutput; use App\Dto\Output\OrganizationalUnitOutput; use App\Dto\Output\PxeTemplateOutput; use App\Entity\Client; -use App\Entity\OgRepository; +use App\Entity\ImageRepository; +use App\Model\ClientStatus; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; @@ -64,7 +66,7 @@ final class ClientInput description: 'El estado del cliente', example: 'active' )] - public ?string $status = 'off'; + public ?string $status = ClientStatus::OFF; #[Assert\NotNull(message: 'validators.organizational_unit.not_null')] #[Groups(['client:write', 'client:patch'])] @@ -107,7 +109,7 @@ final class ClientInput #[ApiProperty( description: 'descriptions.client.validation' )] - public ?OgRepository $repository = null; + public ?ImageRepositoryOutput $repository = null; #[Groups(['client:write'])] #[ApiProperty( @@ -147,6 +149,10 @@ final class ClientInput if ($client->getHardwareProfile()) { $this->hardwareProfile = new HardwareProfileOutput($client->getHardwareProfile()); } + + if ($client->getRepository()) { + $this->repository = new ImageRepositoryOutput($client->getRepository()); + } } public function createOrUpdateEntity(?Client $client = null): Client @@ -165,6 +171,7 @@ final class ClientInput $client->setMenu($this->menu?->getEntity()); $client->setOgLive($this->ogLive?->getEntity()); $client->setHardwareProfile($this->hardwareProfile?->getEntity()); + $client->setRepository($this->repository?->getEntity()); $client->setTemplate($this->template?->getEntity()); $client->setPosition($this->position); $client->setStatus($this->status); diff --git a/src/Dto/Input/DeployImageInput.php b/src/Dto/Input/DeployImageInput.php new file mode 100644 index 0000000..af79406 --- /dev/null +++ b/src/Dto/Input/DeployImageInput.php @@ -0,0 +1,53 @@ +description = $image->getDescription(); $this->comments = $image->getComments(); $this->type = $image->getType(); - $this->path = $image->getPath(); - $this->revision = $image->getRevision(); - $this->info = $image->getInfo(); - $this->size = $image->getSize(); $this->remotePc = $image->isRemotePc(); if ($image->getSoftwareProfile()) { $this->softwareProfile = new SoftwareProfileOutput($image->getSoftwareProfile()); } + + if ($image->getRepository()) { + $this->imageRepository = new ImageRepositoryOutput($image->getRepository()); + } + + if ($image->getClient()) { + $this->client = new ClientOutput($image->getClient()); + } + + if ($image->getParent()) { + $this->parent = new self($image->getParent()); + } } public function createOrUpdateEntity(?Image $image = null): Image @@ -84,12 +101,38 @@ final class ImageInput $image->setDescription($this->description); $image->setComments($this->comments); $image->setType($this->type); - $image->setPath($this->path); - $image->setRevision($this->revision); - $image->setInfo($this->info); - $image->setSize($this->size); - $image->setSoftwareProfile($this->softwareProfile->getEntity()); + $image->setStatus(ImageStatus::PENDING); + + if ($this->softwareProfile) { + $image->setSoftwareProfile($this->softwareProfile->getEntity()); + } + + $image->setRepository($this->imageRepository ? $this->imageRepository->getEntity() + : $this->client->getEntity()->getRepository()); + + if ($this->client) { + $image->setClient($this->client->getEntity()); + } + + if ($this->parent) { + $image->setParent($this->parent->getEntity()); + } + $image->setRemotePc($this->remotePc); + $image->setCreated(false); + + $partitionInfo = []; + + if ($this->partition) { + /** @var Partition $partition */ + $partition = $this->partition->getEntity(); + $partitionInfo["numDisk"] = $partition->getDiskNumber(); + $partitionInfo["numPartition"] = $partition->getPartitionNumber(); + $partitionInfo["partitionCode"] = $partition->getPartitionCode(); + $partitionInfo["filesystem"] = $partition->getFilesystem(); + $partitionInfo["osName"] = $partition->getOperativeSystem()?->getName(); + $image->setPartitionInfo(json_encode($partitionInfo)); + } return $image; } diff --git a/src/Dto/Input/ImageRepositoryInput.php b/src/Dto/Input/ImageRepositoryInput.php new file mode 100644 index 0000000..e2ea309 --- /dev/null +++ b/src/Dto/Input/ImageRepositoryInput.php @@ -0,0 +1,56 @@ +name = $repository->getName(); + $this->ip = $repository->getIp(); + $this->comments = $repository->getComments(); + } + + public function createOrUpdateEntity(?ImageRepository $repository = null): ImageRepository + { + if (!$repository) { + $repository = new ImageRepository(); + } + + $repository->setName($this->name); + $repository->setIp($this->ip); + $repository->setComments($this->comments); + + return $repository; + } +} \ No newline at end of file diff --git a/src/Dto/Input/NetworkSettingsInput.php b/src/Dto/Input/NetworkSettingsInput.php index e4dd125..6f33126 100644 --- a/src/Dto/Input/NetworkSettingsInput.php +++ b/src/Dto/Input/NetworkSettingsInput.php @@ -76,6 +76,12 @@ class NetworkSettingsInput #[Groups(['organizational-unit:write'])] public ?bool $validation = null; + #[Groups(['organizational-unit:write'])] + public ?string $oglog = null; + + #[Groups(['organizational-unit:write'])] + public ?string $ogshare = null; + public function __construct(?NetworkSettings $networkSettings = null) { if (!$networkSettings) { @@ -95,6 +101,8 @@ class NetworkSettingsInput $this->mcastSpeed = $networkSettings->getMcastSpeed(); $this->mcastPort = $networkSettings->getMcastPort(); $this->mcastMode = $networkSettings->getMcastMode(); + $this->oglog = $networkSettings->getOglog(); + $this->ogshare = $networkSettings->getOgshare(); if ($networkSettings->getMenu()) { $this->menu = new MenuOutput($networkSettings->getMenu()); @@ -130,6 +138,8 @@ class NetworkSettingsInput $networkSettings->setMcastSpeed($this->mcastSpeed); $networkSettings->setMcastPort($this->mcastPort); $networkSettings->setMcastMode($this->mcastMode); + $networkSettings->setOglog($this->oglog); + $networkSettings->setOgshare($this->ogshare); if ($this->menu) { $networkSettings->setMenu($this->menu->getEntity()); diff --git a/src/Dto/Input/PartitionInput.php b/src/Dto/Input/PartitionInput.php index 2e7d366..635149f 100644 --- a/src/Dto/Input/PartitionInput.php +++ b/src/Dto/Input/PartitionInput.php @@ -101,10 +101,7 @@ final class PartitionInput $partition->setOperativeSystem($this->operativeSystem->getEntity()); } $partition->setClient($this->client->getEntity()); - - if ($this->memoryUsage) { - $partition->setMemoryUsage($this->memoryUsage * 100); - } + $partition->setMemoryUsage($this->memoryUsage * 100); if ($this->image) { $partition->setImage($this->image->getEntity()); diff --git a/src/Dto/Output/ClientOutput.php b/src/Dto/Output/ClientOutput.php index 3d9399c..d751f6d 100644 --- a/src/Dto/Output/ClientOutput.php +++ b/src/Dto/Output/ClientOutput.php @@ -48,6 +48,10 @@ final class ClientOutput extends AbstractOutput #[ApiProperty(readableLink: true )] public ?HardwareProfileOutput $hardwareProfile = null; + #[Groups(['client:read'])] + #[ApiProperty(readableLink: true )] + public ?ImageRepositoryOutput $repository = null; + #[Groups(['client:read', 'organizational-unit:read'])] #[ApiProperty(readableLink: true )] public ?PxeTemplateOutput $template = null; @@ -99,6 +103,7 @@ final class ClientOutput extends AbstractOutput $this->menu = $client->getMenu() ? new MenuOutput($client->getMenu()) : null; $this->position = $client->getPosition(); $this->template = $client->getTemplate() ? new PxeTemplateOutput($client->getTemplate()) : null; + $this->repository = $client->getRepository() ? new ImageRepositoryOutput($client->getRepository()) : null; $this->hardwareProfile = $client->getHardwareProfile() ? new HardwareProfileOutput($client->getHardwareProfile()) : null; $this->subnet = $client->getSubnet()?->getIpAddress(); $this->ogLive = $client->getOgLive() ? new OgLiveOutput($client->getOgLive()) : null; diff --git a/src/Dto/Output/ImageOutput.php b/src/Dto/Output/ImageOutput.php index fe91429..235e88b 100644 --- a/src/Dto/Output/ImageOutput.php +++ b/src/Dto/Output/ImageOutput.php @@ -36,9 +36,24 @@ final class ImageOutput extends AbstractOutput #[Groups(['image:read'])] public ?bool $remotePc = null; + #[Groups(['image:read'])] + public ?bool $created = null; + #[Groups(['image:read'])] public ?SoftwareProfileOutput $softwareProfile = null; + #[Groups(['image:read'])] + public ?ImageRepositoryOutput $imageRepository = null; + + #[Groups(['image:read'])] + public ?array $partitionInfo = null; + + #[Groups(['image:read'])] + public ?string $imageFullsum = ''; + + #[Groups(['image:read'])] + public ?string $status = null; + #[Groups(['image:read'])] public \DateTime $createdAt; @@ -57,8 +72,13 @@ final class ImageOutput extends AbstractOutput $this->revision = $image->getRevision(); $this->info = $image->getInfo(); $this->size = $image->getSize(); + $this->imageFullsum = $image->getImageFullsum(); + $this->status = $image->getStatus(); $this->softwareProfile = $image->getSoftwareProfile() ? new SoftwareProfileOutput($image->getSoftwareProfile()) : null; + $this->imageRepository = $image->getRepository() ? new ImageRepositoryOutput($image->getRepository()) : null; + $this->partitionInfo = json_decode($image->getPartitionInfo(), true); $this->remotePc = $image->isRemotePc(); + $this->created = $image->isCreated(); $this->createdAt = $image->getCreatedAt(); $this->createdBy = $image->getCreatedBy(); } diff --git a/src/Dto/Output/ImageRepositoryOutput.php b/src/Dto/Output/ImageRepositoryOutput.php new file mode 100644 index 0000000..5a7faa4 --- /dev/null +++ b/src/Dto/Output/ImageRepositoryOutput.php @@ -0,0 +1,38 @@ +name = $imageRepository->getName(); + $this->ip = $imageRepository->getIp(); + $this->comments = $imageRepository->getComments(); + $this->createdAt = $imageRepository->getCreatedAt(); + $this->createdBy = $imageRepository->getCreatedBy(); + } + +} \ No newline at end of file diff --git a/src/Dto/Output/NetworkSettingsOutput.php b/src/Dto/Output/NetworkSettingsOutput.php index c85361e..b13489e 100644 --- a/src/Dto/Output/NetworkSettingsOutput.php +++ b/src/Dto/Output/NetworkSettingsOutput.php @@ -57,6 +57,12 @@ final class NetworkSettingsOutput extends AbstractOutput #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])] public ?OgLiveOutput $ogLive = null; + #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])] + public ?string $oglog = null; + + #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])] + public ?string $ogshare = null; + #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])] public ?bool $validation = null; @@ -83,6 +89,8 @@ final class NetworkSettingsOutput extends AbstractOutput $this->mcastSpeed = $networkSettings->getMcastSpeed(); $this->mcastPort = $networkSettings->getMcastPort(); $this->mcastMode = $networkSettings->getMcastMode(); + $this->oglog = $networkSettings->getOglog(); + $this->ogshare = $networkSettings->getOgshare(); if ($networkSettings->getMenu()) { $this->menu = new MenuOutput($networkSettings->getMenu()); diff --git a/src/Dto/Output/OperativeSystemOutput.php b/src/Dto/Output/OperativeSystemOutput.php index bac0169..fac3ef1 100644 --- a/src/Dto/Output/OperativeSystemOutput.php +++ b/src/Dto/Output/OperativeSystemOutput.php @@ -9,7 +9,7 @@ use Symfony\Component\Serializer\Annotation\Groups; #[Get(shortName: 'OperativeSystem')] final class OperativeSystemOutput extends AbstractOutput { - #[Groups(['operative-system:read', 'partition:read', 'software-profile:read'])] + #[Groups(['operative-system:read', 'partition:read', 'software-profile:read', 'client:read'])] public string $name; #[Groups(['operative-system:read'])] diff --git a/src/Dto/Output/OrganizationalUnitOutput.php b/src/Dto/Output/OrganizationalUnitOutput.php index 9d9ca7c..f1daa30 100644 --- a/src/Dto/Output/OrganizationalUnitOutput.php +++ b/src/Dto/Output/OrganizationalUnitOutput.php @@ -11,7 +11,7 @@ use Symfony\Component\Serializer\Annotation\Groups; #[Get(shortName: 'OrganizationalUnit')] final class OrganizationalUnitOutput extends AbstractOutput { - #[Groups(['organizational-unit:read', "client:read", "user:read", 'organizational-unit:read:collection:short'])] + #[Groups(['organizational-unit:read', "client:read", "user:read", 'organizational-unit:read:collection:short', 'software-profile:read'])] public string $name; #[Groups(['organizational-unit:read'])] diff --git a/src/Dto/Output/TraceOutput.php b/src/Dto/Output/TraceOutput.php index 265a9b2..8bbc100 100644 --- a/src/Dto/Output/TraceOutput.php +++ b/src/Dto/Output/TraceOutput.php @@ -11,7 +11,7 @@ use Symfony\Component\Serializer\Annotation\Groups; final class TraceOutput extends AbstractOutput { #[Groups(['trace:read'])] - public CommandOutput $command; + public ?string $command; #[Groups(['trace:read'])] public ClientOutput $client; @@ -19,12 +19,18 @@ final class TraceOutput extends AbstractOutput #[Groups(['trace:read'])] public string $status; + #[Groups(['trace:read'])] + public ?string $jobId = null; + #[Groups(['trace:read'])] public ?\DateTimeInterface $executedAt = null; #[Groups(['trace:read'])] public ?string $output = null; + #[Groups(['trace:read'])] + public ?array $input = null; + #[Groups(['trace:read'])] public ?\DateTimeInterface $finishedAt = null; @@ -38,11 +44,13 @@ final class TraceOutput extends AbstractOutput { parent::__construct($trace); - $this->command = new CommandOutput($trace->getCommand()); + $this->command = $trace->getCommand(); $this->client = new ClientOutput($trace->getClient()); $this->status = $trace->getStatus(); + $this->jobId = $trace->getJobId(); $this->executedAt = $trace->getExecutedAt(); $this->output = $trace->getOutput(); + $this->input = $trace->getInput(); $this->finishedAt = $trace->getFinishedAt(); $this->createdAt = $trace->getCreatedAt(); $this->createdBy = $trace->getCreatedBy(); diff --git a/src/Entity/Client.php b/src/Entity/Client.php index 37546ed..8f3ee49 100644 --- a/src/Entity/Client.php +++ b/src/Entity/Client.php @@ -15,6 +15,8 @@ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; #[UniqueEntity(fields: ['mac'], message: 'This MAC address is already in use.')] class Client extends AbstractEntity { + + // TODO nueva variable bool isTeacher use NameableTrait; #[ORM\Column(length: 255, nullable: true)] @@ -61,7 +63,7 @@ class Client extends AbstractEntity private ?PxeTemplate $template = null; #[ORM\ManyToOne(inversedBy: 'clients')] - private ?OgRepository $repository = null; + private ?ImageRepository $repository = null; #[ORM\ManyToOne(inversedBy: 'clients')] #[ORM\JoinColumn( onDelete: 'SET NULL')] @@ -260,12 +262,12 @@ class Client extends AbstractEntity } - public function getRepository(): ?OgRepository + public function getRepository(): ?ImageRepository { return $this->repository; } - public function setRepository(?OgRepository $repository): static + public function setRepository(?ImageRepository $repository): static { $this->repository = $repository; diff --git a/src/Entity/Image.php b/src/Entity/Image.php index 7dc8c05..dc2c8ba 100644 --- a/src/Entity/Image.php +++ b/src/Entity/Image.php @@ -6,8 +6,11 @@ use App\Repository\ImageRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; #[ORM\Entity(repositoryClass: ImageRepository::class)] +#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_NAME', fields: ['name'])] +#[UniqueEntity(fields: ['name'], message: 'validators.image.name.unique')] class Image extends AbstractEntity { use NameableTrait; @@ -37,19 +40,35 @@ class Image extends AbstractEntity #[ORM\JoinColumn(nullable: true)] private ?SoftwareProfile $softwareProfile = null; - /** - * @var Collection - */ - #[ORM\OneToMany(mappedBy: 'image', targetEntity: Partition::class)] - private Collection $partitions; - #[ORM\Column] private ?bool $remotePc = null; + #[ORM\ManyToOne(inversedBy: 'images')] + #[ORM\JoinColumn(nullable: false)] + private ?\App\Entity\ImageRepository $repository = null; + + #[ORM\Column(length: 255, nullable: true)] + private ?string $partitionInfo = null; + + #[ORM\ManyToOne(targetEntity: self::class)] + private ?self $parent = null; + + #[ORM\ManyToOne] + private ?Client $client = null; + + #[ORM\Column(nullable: true)] + private ?bool $created = null; + + #[ORM\Column(length: 255, nullable: true)] + private ?string $imageFullsum = null; + + #[ORM\Column(length: 255)] + private ?string $status = null; + + public function __construct() { parent::__construct(); - $this->partitions = new ArrayCollection(); } public function getDescription(): ?string @@ -148,36 +167,6 @@ class Image extends AbstractEntity return $this; } - /** - * @return Collection - */ - public function getPartitions(): Collection - { - return $this->partitions; - } - - public function addPartition(Partition $partition): static - { - if (!$this->partitions->contains($partition)) { - $this->partitions->add($partition); - $partition->setImage($this); - } - - return $this; - } - - public function removePartition(Partition $partition): static - { - if ($this->partitions->removeElement($partition)) { - // set the owning side to null (unless already changed) - if ($partition->getImage() === $this) { - $partition->setImage(null); - } - } - - return $this; - } - public function isRemotePc(): ?bool { return $this->remotePc; @@ -189,4 +178,88 @@ class Image extends AbstractEntity return $this; } + + public function getRepository(): ?\App\Entity\ImageRepository + { + return $this->repository; + } + + public function setRepository(?\App\Entity\ImageRepository $repository): static + { + $this->repository = $repository; + + return $this; + } + + public function getPartitionInfo(): ?string + { + return $this->partitionInfo; + } + + public function setPartitionInfo(?string $partitionInfo): static + { + $this->partitionInfo = $partitionInfo; + + return $this; + } + + public function getParent(): ?self + { + return $this->parent; + } + + public function setParent(?self $parent): static + { + $this->parent = $parent; + + return $this; + } + + public function getClient(): ?Client + { + return $this->client; + } + + public function setClient(?Client $client): static + { + $this->client = $client; + + return $this; + } + + public function isCreated(): ?bool + { + return $this->created; + } + + public function setCreated(?bool $created): static + { + $this->created = $created; + + return $this; + } + + public function getImageFullsum(): ?string + { + return $this->imageFullsum; + } + + public function setImageFullsum(?string $imageFullsum): static + { + $this->imageFullsum = $imageFullsum; + + return $this; + } + + public function getStatus(): ?string + { + return $this->status; + } + + public function setStatus(string $status): static + { + $this->status = $status; + + return $this; + } } diff --git a/src/Entity/ImageRepository.php b/src/Entity/ImageRepository.php new file mode 100644 index 0000000..400890e --- /dev/null +++ b/src/Entity/ImageRepository.php @@ -0,0 +1,86 @@ + + */ + #[ORM\OneToMany(mappedBy: 'repository', targetEntity: Image::class)] + private Collection $images; + + public function __construct() + { + parent::__construct(); + $this->images = new ArrayCollection(); + } + + public function getIp(): ?string + { + return $this->ip; + } + + public function setIp(string $ip): static + { + $this->ip = $ip; + + return $this; + } + + public function getComments(): ?string + { + return $this->comments; + } + + public function setComments(?string $comments): static + { + $this->comments = $comments; + + return $this; + } + + /** + * @return Collection + */ + public function getImages(): Collection + { + return $this->images; + } + + public function addImage(Image $image): static + { + if (!$this->images->contains($image)) { + $this->images->add($image); + $image->setRepository($this); + } + + return $this; + } + + public function removeImage(Image $image): static + { + if ($this->images->removeElement($image)) { + // set the owning side to null (unless already changed) + if ($image->getRepository() === $this) { + $image->setRepository(null); + } + } + + return $this; + } +} diff --git a/src/Entity/NetworkSettings.php b/src/Entity/NetworkSettings.php index bbd2080..8ba83ee 100644 --- a/src/Entity/NetworkSettings.php +++ b/src/Entity/NetworkSettings.php @@ -67,11 +67,17 @@ class NetworkSettings extends AbstractEntity private ?bool $validation = null; #[ORM\ManyToOne] - private ?OgRepository $repository = null; + private ?ImageRepository $repository = null; #[ORM\ManyToOne] private ?OgLive $ogLive = null; + #[ORM\Column(length: 255, nullable: true)] + private ?string $ogLog = null; + + #[ORM\Column(length: 255, nullable: true)] + private ?string $ogShare = null; + public function __construct() { parent::__construct(); @@ -298,12 +304,12 @@ class NetworkSettings extends AbstractEntity return $this; } - public function getRepository(): ?OgRepository + public function getRepository(): ?ImageRepository { return $this->repository; } - public function setRepository(?OgRepository $repository): static + public function setRepository(?ImageRepository $repository): static { $this->repository = $repository; @@ -321,4 +327,28 @@ class NetworkSettings extends AbstractEntity return $this; } + + public function getOgLog(): ?string + { + return $this->ogLog; + } + + public function setOgLog(?string $ogLog): static + { + $this->ogLog = $ogLog; + + return $this; + } + + public function getOgShare(): ?string + { + return $this->ogShare; + } + + public function setOgShare(?string $ogShare): static + { + $this->ogShare = $ogShare; + + return $this; + } } diff --git a/src/Entity/OgRepository.php b/src/Entity/OgRepository.php deleted file mode 100644 index 9aaaa74..0000000 --- a/src/Entity/OgRepository.php +++ /dev/null @@ -1,86 +0,0 @@ - - */ - #[ORM\OneToMany(mappedBy: 'repository', targetEntity: Client::class)] - private Collection $clients; - - public function __construct() - { - parent::__construct(); - $this->clients = new ArrayCollection(); - } - - public function getIpAddress(): ?string - { - return $this->ipAddress; - } - - public function setIpAddress(string $ipAddress): static - { - $this->ipAddress = $ipAddress; - - return $this; - } - - public function getDescription(): ?string - { - return $this->description; - } - - public function setDescription(?string $description): static - { - $this->description = $description; - - return $this; - } - - /** - * @return Collection - */ - public function getClients(): Collection - { - return $this->clients; - } - - public function addClient(Client $client): static - { - if (!$this->clients->contains($client)) { - $this->clients->add($client); - $client->setRepository($this); - } - - return $this; - } - - public function removeClient(Client $client): static - { - if ($this->clients->removeElement($client)) { - // set the owning side to null (unless already changed) - if ($client->getRepository() === $this) { - $client->setRepository(null); - } - } - - return $this; - } -} diff --git a/src/Entity/Trace.php b/src/Entity/Trace.php index 1f2f318..08bcc81 100644 --- a/src/Entity/Trace.php +++ b/src/Entity/Trace.php @@ -13,9 +13,8 @@ class Trace extends AbstractEntity #[ORM\JoinColumn(nullable: false)] private ?Client $client = null; - #[ORM\ManyToOne(inversedBy: 'traces')] - #[ORM\JoinColumn(nullable: false)] - private ?Command $command = null; + #[ORM\Column(length: 255, nullable: true)] + private ?string $command = null; #[ORM\Column(length: 255)] private ?string $status = null; @@ -29,6 +28,12 @@ class Trace extends AbstractEntity #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)] private ?\DateTimeInterface $finishedAt = null; + #[ORM\Column(length: 255, nullable: true)] + private ?string $jobId = null; + + #[ORM\Column(type: "json", nullable: true)] + private ?array $input = null; + public function getClient(): ?Client { return $this->client; @@ -41,12 +46,12 @@ class Trace extends AbstractEntity return $this; } - public function getCommand(): ?Command + public function getCommand(): ?string { return $this->command; } - public function setCommand(?Command $command): static + public function setCommand(?string $command): static { $this->command = $command; @@ -100,4 +105,28 @@ class Trace extends AbstractEntity return $this; } + + public function getJobId(): ?string + { + return $this->jobId; + } + + public function setJobId(?string $jobId): static + { + $this->jobId = $jobId; + + return $this; + } + + public function getInput(): ?array + { + return $this->input; + } + + public function setInput(?array $input): static + { + $this->input = $input; + + return $this; + } } diff --git a/src/Factory/ImageFactory.php b/src/Factory/ImageFactory.php index 52822df..80fbdcf 100644 --- a/src/Factory/ImageFactory.php +++ b/src/Factory/ImageFactory.php @@ -35,9 +35,9 @@ final class ImageFactory extends ModelFactory return [ 'createdAt' => self::faker()->dateTime(), 'name' => self::faker()->text(255), - 'path' => self::faker()->text(255), - 'size' => self::faker()->randomNumber(), + 'status' => self::faker()->randomElement(['IN_PROGRESS', 'FINISHED', 'ERROR']), 'softwareProfile' => SoftwareProfileFactory::new(), + 'repository' => ImageRepositoryFactory::new(), 'updatedAt' => self::faker()->dateTime(), 'remotePc' => self::faker()->boolean(), ]; diff --git a/src/Factory/ImageRepositoryFactory.php b/src/Factory/ImageRepositoryFactory.php new file mode 100644 index 0000000..9308fb9 --- /dev/null +++ b/src/Factory/ImageRepositoryFactory.php @@ -0,0 +1,56 @@ + + */ +final class ImageRepositoryFactory extends ModelFactory +{ + /** + * @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#factories-as-services + * + * @todo inject services if required + */ + public function __construct() + { + parent::__construct(); + } + + public static function getClass(): string + { + return ImageRepository::class; + } + + /** + * @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#model-factories + * + * @todo add your default values here + */ + protected function getDefaults(): array + { + return [ + 'createdAt' => self::faker()->dateTime(), + 'ip' => self::faker()->text(255), + 'name' => self::faker()->text(255), + 'updatedAt' => self::faker()->dateTime() + ]; + } + + /** + * @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#initialization + */ + protected function initialize(): self + { + return $this + // ->afterInstantiate(function(ImageRepository $imageRepository): void {}) + ; + } +} diff --git a/src/Model/ClientStatus.php b/src/Model/ClientStatus.php new file mode 100644 index 0000000..0ef5b22 --- /dev/null +++ b/src/Model/ClientStatus.php @@ -0,0 +1,50 @@ + 'Apagado', + self::INITIALIZING => 'Inicializando', + self::OG_LIVE => 'OG Live', + self::BUSY => 'Ocupado', + self::LINUX => 'Linux', + self::LINUX_SESSION => 'Sesión Linux', + self::MACOS => 'MacOS', + self::WINDOWS => 'Windows', + self::WINDOWS_SESSION => 'Sesión Windows', + ]; + public static function getClientStatuses(): array + { + return self::CLIENT_STATUSES; + } + + public static function getClientStatus(string $clientStatus): ?string + { + return self::CLIENT_STATUSES[$clientStatus] ?? null; + } + + public static function getClientStatusKeys(): array + { + return array_keys(self::CLIENT_STATUSES); + } +} \ No newline at end of file diff --git a/src/Model/CommandTypes.php b/src/Model/CommandTypes.php new file mode 100644 index 0000000..4744681 --- /dev/null +++ b/src/Model/CommandTypes.php @@ -0,0 +1,38 @@ + 'Deploy Image', + self::RESTORE_IMAGE => 'Update Cache', + self::CREATE_IMAGE => 'Create Image', + self::CREATE_IMAGE_AUX_FILE => 'Crear fichero auxiliar en repositorio', + self::POWER_ON => 'Encender', + self::REBOOT => 'Reiniciar', + self::SHUTDOWN => 'Apagar', + self::LOGIN => 'Login', + self::LOGOUT => 'Logout', + ]; + + public static function getCommandTypes(): array + { + return self::COMMAND_TYPES; + } + + public static function getCommandType(string $type): ?string + { + return self::COMMAND_TYPES[$type] ?? null; + } +} \ No newline at end of file diff --git a/src/Model/DeployImageTypes.php b/src/Model/DeployImageTypes.php new file mode 100644 index 0000000..4146246 --- /dev/null +++ b/src/Model/DeployImageTypes.php @@ -0,0 +1,28 @@ + 'Unidad Organizativa', + self::UPDATE_CACHE => 'Grupo de aulas', + ]; + + public static function getDeploymentImageTypes(): array + { + return self::DEPLOYMENT_IMAGE_TYPES; + } + + public static function getDeploymentImageType(string $type): ?string + { + return self::DEPLOYMENT_IMAGE_TYPES[$type] ?? null; + } + + public static function getDeploymentImageTypeKeys(): array + { + return array_keys(self::DEPLOYMENT_IMAGE_TYPES); + } +} \ No newline at end of file diff --git a/src/Model/DeployMethodTypes.php b/src/Model/DeployMethodTypes.php new file mode 100644 index 0000000..9eb464c --- /dev/null +++ b/src/Model/DeployMethodTypes.php @@ -0,0 +1,30 @@ + 'Multicast', + self::UNICAST => 'Unicast', + self::TORRENT => 'Torrent', + ]; + + public static function getDeploymentMethodTypes(): array + { + return self::DEPLOYMENT_METHOD_TYPES; + } + + public static function getDeploymentMethodType(string $type): ?string + { + return self::DEPLOYMENT_METHOD_TYPES[$type] ?? null; + } + public static function getDeploymentMethodTypeKeys(): array + { + return array_keys(self::DEPLOYMENT_METHOD_TYPES); + } +} \ No newline at end of file diff --git a/src/Model/ImageStatus.php b/src/Model/ImageStatus.php new file mode 100644 index 0000000..3ef24f1 --- /dev/null +++ b/src/Model/ImageStatus.php @@ -0,0 +1,37 @@ + 'Pendiente', + self::IN_PROGRESS => 'En progreso', + self::AUX_FILES_PENDING => 'Archivos auxiliares pendientes', + self::TRASH => 'Papelera', + self::SUCCESS => 'Completado', + self::FAILED => 'Fallido', + ]; + + public static function getStatus(): array + { + return self::STATUS; + } + + public static function getImageStatus(string $status): ?string + { + return self::STATUS[$status] ?? null; + } + + public static function getStatusKeys(): array + { + return array_keys(self::STATUS); + } +} \ No newline at end of file diff --git a/src/Model/TraceStatus.php b/src/Model/TraceStatus.php index fc790b2..d055a3f 100644 --- a/src/Model/TraceStatus.php +++ b/src/Model/TraceStatus.php @@ -6,13 +6,13 @@ final class TraceStatus { public const string PENDING = 'pending'; public const string IN_PROGRESS = 'in-progress'; - public const string COMPLETED = 'completed'; + public const string SUCCESS = 'success'; public const string FAILED = 'failed'; private const array STATUS = [ self::PENDING => 'Pendiente', self::IN_PROGRESS => 'En progreso', - self::COMPLETED => 'Completado', + self::SUCCESS => 'Finalizado con éxito', self::FAILED => 'Fallido', ]; diff --git a/src/OpenApi/OpenApiFactory.php b/src/OpenApi/OpenApiFactory.php index 2f4935e..71ce331 100644 --- a/src/OpenApi/OpenApiFactory.php +++ b/src/OpenApi/OpenApiFactory.php @@ -21,7 +21,8 @@ final readonly class OpenApiFactory implements OpenApiFactoryInterface $this->addRefreshToken($openApi); $this->addOgAgentEndpoints($openApi); $this->addUDsEndpoints($openApi); - $this->addStatusEndpoint($openApi); + $this->addOgBootStatusEndpoint($openApi); + $this->addOgRepositoryStatusEndpoint($openApi); $this->addInstallOgLiveWebhookEndpoint($openApi); return $openApi; @@ -689,7 +690,7 @@ final readonly class OpenApiFactory implements OpenApiFactoryInterface )); } - private function addStatusEndpoint(OpenApi $openApi): void + private function addOgBootStatusEndpoint(OpenApi $openApi): void { $openApi ->getPaths() @@ -738,6 +739,55 @@ final readonly class OpenApiFactory implements OpenApiFactoryInterface )); } + private function addOgRepositoryStatusEndpoint(OpenApi $openApi): void + { + $openApi + ->getPaths() + ->addPath('/og-repository/status', (new Model\PathItem())->withGet( + (new Model\Operation('getStatus')) + ->withTags(['OgRepository']) + ->withResponses([ + Response::HTTP_OK => [ + 'description' => 'Service status', + 'content' => [ + 'application/json' => [ + 'schema' => [ + 'type' => 'object', + 'properties' => [ + 'status' => [ + 'type' => 'string', + 'example' => 'ok', + ], + 'uptime' => [ + 'type' => 'integer', + 'example' => 12345, + ], + ], + ], + ], + ], + ], + Response::HTTP_SERVICE_UNAVAILABLE => [ + 'description' => 'Service unavailable', + 'content' => [ + 'application/json' => [ + 'schema' => [ + 'type' => 'object', + 'properties' => [ + 'error' => [ + 'type' => 'string', + 'example' => 'Service is down', + ], + ], + ], + ], + ], + ], + ]) + ->withSummary('Get service status') + )); + } + private function addUDsEndpoints(OpenApi $openApi): void { $openApi->getPaths()->addPath('/opengnsys/rest//ous', (new Model\PathItem())->withGet( diff --git a/src/Repository/OgRepositoryRepository.php b/src/Repository/ImageRepositoryRepository.php similarity index 52% rename from src/Repository/OgRepositoryRepository.php rename to src/Repository/ImageRepositoryRepository.php index 0db2b01..ba83114 100644 --- a/src/Repository/OgRepositoryRepository.php +++ b/src/Repository/ImageRepositoryRepository.php @@ -2,17 +2,17 @@ namespace App\Repository; -use App\Entity\OgRepository; +use App\Entity\ImageRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; /** - * @extends ServiceEntityRepository + * @extends ServiceEntityRepository */ -class OgRepositoryRepository extends AbstractRepository +class ImageRepositoryRepository extends AbstractRepository { public function __construct(ManagerRegistry $registry) { - parent::__construct($registry, self::class); + parent::__construct($registry, ImageRepository::class); } } diff --git a/src/Service/CreatePartitionService.php b/src/Service/CreatePartitionService.php new file mode 100644 index 0000000..48b903f --- /dev/null +++ b/src/Service/CreatePartitionService.php @@ -0,0 +1,50 @@ +entityManager->getRepository(Partition::class) + ->findOneBy(['client' => $clientEntity, 'diskNumber' => $cfg['disk'], 'partitionNumber' => $cfg['par']]); + + if (!$partitionEntity) { + $partitionEntity = new Partition(); + } + + if (isset($cfg['soi']) && $cfg['soi'] !== '') { + $operativeSystem = $this->entityManager->getRepository(OperativeSystem::class) + ->findOneBy(['name' => $cfg['soi']]); + + if (!$operativeSystem) { + $operativeSystem = new OperativeSystem(); + $operativeSystem->setName($cfg['soi']); + $this->entityManager->persist($operativeSystem); + } + $partitionEntity->setOperativeSystem($operativeSystem); + } + + $partitionEntity->setClient($clientEntity); + $partitionEntity->setDiskNumber($cfg['disk']); + $partitionEntity->setPartitionNumber($cfg['par']); + $partitionEntity->setSize($cfg['tam']); + $partitionEntity->setMemoryUsage(((int) $cfg['uso']) * 100); + $this->entityManager->persist($partitionEntity); + } + + $this->entityManager->flush(); + } +} \ No newline at end of file diff --git a/src/Service/OgBoot/StatusService.php b/src/Service/OgBoot/StatusService.php index c935e28..740e95e 100644 --- a/src/Service/OgBoot/StatusService.php +++ b/src/Service/OgBoot/StatusService.php @@ -2,6 +2,7 @@ namespace App\Service\OgBoot; +use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; @@ -15,7 +16,8 @@ use Symfony\Component\HttpClient\HttpClient; readonly class StatusService { public function __construct( - private string $ogBootApiUrl + #[Autowire(env: 'OG_BOOT_API_URL')] + private string $ogBootApiUrl ) { } @@ -34,7 +36,7 @@ readonly class StatusService ]); try { - $response = $httpClient->request('GET', $this->ogBootApiUrl.'/ogboot/v1/status', [ + $response = $httpClient->request('GET', 'http://'.$this->ogBootApiUrl.'/ogboot/v1/status', [ 'headers' => [ 'accept' => 'application/json', ], diff --git a/src/Service/OgDhcp/StatusService.php b/src/Service/OgDhcp/StatusService.php index 6e434bf..6c9cadf 100644 --- a/src/Service/OgDhcp/StatusService.php +++ b/src/Service/OgDhcp/StatusService.php @@ -2,6 +2,7 @@ namespace App\Service\OgDhcp; +use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\HttpClient\HttpClient; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; @@ -10,10 +11,11 @@ use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface; use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface; use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; -class StatusService +readonly class StatusService { public function __construct( - private string $ogDhcpApiUrl + #[Autowire(env: 'OG_DHCP_API_URL')] + private string $ogDhcpApiUrl ) { } @@ -32,7 +34,7 @@ class StatusService ]); try { - $response = $httpClient->request('GET', $this->ogDhcpApiUrl.'/ogdhcp/v1/status', [ + $response = $httpClient->request('GET', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/status', [ 'headers' => [ 'accept' => 'application/json', ], diff --git a/src/Service/OgRepository/StatusService.php b/src/Service/OgRepository/StatusService.php new file mode 100644 index 0000000..248021b --- /dev/null +++ b/src/Service/OgRepository/StatusService.php @@ -0,0 +1,46 @@ + false, + 'verify_host' => false, + ]); + + try { + $response = $httpClient->request('GET', ''.'/ogrepository/v1/status', [ + 'headers' => [ + 'accept' => 'application/json', + ], + ]); + } catch (TransportExceptionInterface $e) { + return new JsonResponse( data: 'An error occurred', status: Response::HTTP_INTERNAL_SERVER_ERROR); + } + + return json_decode($response->getContent(), true); + } +} \ No newline at end of file diff --git a/src/Service/Trace/CreateService.php b/src/Service/Trace/CreateService.php new file mode 100644 index 0000000..12a3459 --- /dev/null +++ b/src/Service/Trace/CreateService.php @@ -0,0 +1,33 @@ +setClient($client); + $trace->setCommand($command); + $trace->setStatus($status); + $trace->setJobId($jobId); + $trace->setExecutedAt(new \DateTime()); + $trace->setInput($input); + + $this->entityManager->persist($trace); + $this->entityManager->flush(); + + return $trace; + } +} \ No newline at end of file diff --git a/src/Service/UDS/UDSClient.php b/src/Service/UDS/UDSClient.php index 3d3f161..a8e79c4 100644 --- a/src/Service/UDS/UDSClient.php +++ b/src/Service/UDS/UDSClient.php @@ -5,6 +5,7 @@ namespace App\Service\UDS; use AllowDynamicProperties; use App\Entity\OrganizationalUnit; use Doctrine\ORM\EntityManagerInterface; +use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\HttpClient\Exception\TransportException; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; @@ -24,9 +25,13 @@ class UDSClient public function __construct( private HttpClientInterface $httpClient, private readonly EntityManagerInterface $entityManager, + #[Autowire(env: 'UDS_URL')] private string $udsAPIurl, + #[Autowire(env: 'UDS_AUTH_LOGIN')] private string $udsAuthLogin, + #[Autowire(env: 'UDS_AUTH_USERNAME')] private string $udsAuthUsername, + #[Autowire(env: 'UDS_AUTH_PASSWORD')] private string $udsAuthPassword, ) { diff --git a/src/State/Processor/ImageProcessor.php b/src/State/Processor/ImageProcessor.php index 833225d..8d79868 100644 --- a/src/State/Processor/ImageProcessor.php +++ b/src/State/Processor/ImageProcessor.php @@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\Metadata\Put; use ApiPlatform\State\ProcessorInterface; use ApiPlatform\Validator\ValidatorInterface; +use App\Controller\OgAgent\CreateImageAction; use App\Dto\Input\ImageInput; use App\Dto\Output\ImageOutput; use App\Repository\ImageRepository; @@ -17,7 +18,8 @@ readonly class ImageProcessor implements ProcessorInterface { public function __construct( private ImageRepository $imageRepository, - private ValidatorInterface $validator + private ValidatorInterface $validator, + private CreateImageAction $createImageActionController ) { } @@ -53,6 +55,11 @@ readonly class ImageProcessor implements ProcessorInterface $image = $data->createOrUpdateEntity($entity); $this->validator->validate($image); + + if ($data->source !== 'input') { + $response = $this->createImageActionController->__invoke($image); + } + $this->imageRepository->save($image); return new ImageOutput($image); diff --git a/src/State/Processor/ImageRepositoryProcessor.php b/src/State/Processor/ImageRepositoryProcessor.php new file mode 100644 index 0000000..a107ce7 --- /dev/null +++ b/src/State/Processor/ImageRepositoryProcessor.php @@ -0,0 +1,68 @@ +processCreateOrUpdate($data, $operation, $uriVariables, $context); + case $operation instanceof Delete: + return $this->processDelete($data, $operation, $uriVariables, $context); + } + } + + /** + * @throws \Exception + */ + private function processCreateOrUpdate($data, Operation $operation, array $uriVariables = [], array $context = []): ImageRepositoryOutput + { + if (!($data instanceof ImageRepositoryInput)) { + throw new \Exception(sprintf('data is not instance of %s', ImageRepositoryInput::class)); + } + + $entity = null; + if (isset($uriVariables['uuid'])) { + $entity = $this->imageRepository->findOneByUuid($uriVariables['uuid']); + } + + $repository = $data->createOrUpdateEntity($entity); + $this->validator->validate($repository); + $this->imageRepository->save($repository); + + return new ImageRepositoryOutput($repository); + } + + private function processDelete($data, Operation $operation, array $uriVariables = [], array $context = []): null + { + $user = $this->imageRepository->findOneByUuid($uriVariables['uuid']); + $this->imageRepository->delete($user); + + return null; + } +} diff --git a/src/State/Provider/ImageRepositoryProvider.php b/src/State/Provider/ImageRepositoryProvider.php new file mode 100644 index 0000000..4230b45 --- /dev/null +++ b/src/State/Provider/ImageRepositoryProvider.php @@ -0,0 +1,73 @@ +provideCollection($operation, $uriVariables, $context); + case $operation instanceof Patch: + case $operation instanceof Put: + return $this->provideInput($operation, $uriVariables, $context); + case $operation instanceof Get: + return $this->provideItem($operation, $uriVariables, $context); + } + } + + private function provideCollection(Operation $operation, array $uriVariables = [], array $context = []): object + { + $paginator = $this->collectionProvider->provide($operation, $uriVariables, $context); + + $items = new \ArrayObject(); + foreach ($paginator->getIterator() as $item){ + $items[] = new ImageRepositoryOutput($item); + } + + return new TraversablePaginator($items, $paginator->getCurrentPage(), $paginator->getItemsPerPage(), $paginator->getTotalItems()); + } + + public function provideItem(Operation $operation, array $uriVariables = [], array $context = []): object|array|null + { + $item = $this->itemProvider->provide($operation, $uriVariables, $context); + + if (!$item) { + throw new NotFoundHttpException('Image not found'); + } + + return new ImageRepositoryOutput($item); + } + + public function provideInput(Operation $operation, array $uriVariables = [], array $context = []): object|array|null + { + if (isset($uriVariables['uuid'])) { + $item = $this->itemProvider->provide($operation, $uriVariables, $context); + + return $item !== null ? new ImageRepositoryInput($item) : null; + } + + return new ImageRepositoryInput(); + } +} diff --git a/tests/Functional/ImageRepositoryTest.php b/tests/Functional/ImageRepositoryTest.php new file mode 100644 index 0000000..da616c6 --- /dev/null +++ b/tests/Functional/ImageRepositoryTest.php @@ -0,0 +1,133 @@ + self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); + + ImageRepositoryFactory::createMany(10); + + $this->createClientWithCredentials()->request('GET', '/image-repositories'); + $this->assertResponseStatusCodeSame(Response::HTTP_OK); + $this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); + $this->assertJsonContains([ + '@context' => '/contexts/ImageRepository', + '@id' => '/image-repositories', + '@type' => 'hydra:Collection', + 'hydra:totalItems' => 10, + ]); + } + + /** + * @throws RedirectionExceptionInterface + * @throws DecodingExceptionInterface + * @throws ClientExceptionInterface + * @throws TransportExceptionInterface + * @throws ServerExceptionInterface + */ + public function testCreateRepository(): void + { + UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); + + $this->createClientWithCredentials()->request('POST', '/image-repositories',['json' => [ + 'name' => self::REPOSITORY_CREATE, + 'comments' => self::REPOSITORY_CREATE, + 'ip' => '127.0.0.1' + ]]); + + $this->assertResponseStatusCodeSame(201); + $this->assertResponseHeaderSame('content-type', 'application/ld+json; charset=utf-8'); + $this->assertJsonContains([ + '@context' => '/contexts/ImageRepositoryOutput', + '@type' => 'ImageRepository', + 'name' => self::REPOSITORY_CREATE, + 'comments' => self::REPOSITORY_CREATE, + 'ip' => '127.0.0.1' + ]); + } + + /** + * @throws RedirectionExceptionInterface + * @throws DecodingExceptionInterface + * @throws ClientExceptionInterface + * @throws TransportExceptionInterface + * @throws ServerExceptionInterface + */ + public function testUpdateRepository(): void + { + UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); + + ImageRepositoryFactory::createOne(['name' => self::REPOSITORY_UPDATE, 'comments' => self::REPOSITORY_UPDATE]); + $iri = $this->findIriBy(ImageRepository::class, ['name' => self::REPOSITORY_UPDATE]); + + $this->createClientWithCredentials()->request('PUT', $iri, ['json' => [ + 'name' => self::REPOSITORY_UPDATE, + 'comments' => self::REPOSITORY_UPDATE, + 'ip' => '127.0.0.1' + ]]); + + $this->assertResponseIsSuccessful(); + $this->assertJsonContains([ + '@id' => $iri, + 'name' => self::REPOSITORY_UPDATE, + 'comments' => self::REPOSITORY_UPDATE, + 'ip' => '127.0.0.1' + ]); + } + + /** + * @throws TransportExceptionInterface + * @throws ServerExceptionInterface + * @throws RedirectionExceptionInterface + * @throws DecodingExceptionInterface + * @throws ClientExceptionInterface + */ + public function testDeleteRepository(): void + { + UserFactory::createOne(['username' => self::USER_ADMIN, 'roles'=> [UserGroupPermissions::ROLE_SUPER_ADMIN]]); + + ImageRepositoryFactory::createOne(['name' => self::REPOSITORY_DELETE, 'comments' => self::REPOSITORY_DELETE]); + $iri = $this->findIriBy(ImageRepository::class, ['name' => self::REPOSITORY_DELETE]); + $this->createClientWithCredentials()->request('DELETE', $iri); + $this->assertResponseStatusCodeSame(204); + $this->assertNull( + static::getContainer()->get('doctrine')->getRepository(ImageRepository::class)->findOneBy(['name' => self::REPOSITORY_DELETE]) + ); + } +} \ No newline at end of file diff --git a/tests/Functional/ImageTest.php b/tests/Functional/ImageTest.php index eee855f..f682a18 100644 --- a/tests/Functional/ImageTest.php +++ b/tests/Functional/ImageTest.php @@ -4,10 +4,12 @@ namespace Functional; use App\Entity\Client; use App\Entity\Image; +use App\Entity\ImageRepository; use App\Entity\OrganizationalUnit; use App\Entity\SoftwareProfile; use App\Factory\ClientFactory; use App\Factory\ImageFactory; +use App\Factory\ImageRepositoryFactory; use App\Factory\OrganizationalUnitFactory; use App\Factory\SoftwareProfileFactory; use App\Factory\UserFactory; @@ -67,11 +69,15 @@ class ImageTest extends AbstractTest SoftwareProfileFactory::createOne(['description' => self::SOFTWARE_PROFILE]); $swPIri = $this->findIriBy(SoftwareProfile::class, ['description' => self::SOFTWARE_PROFILE]); + ImageRepositoryFactory::createOne(['name' => 'repository-test']); + $irIri = $this->findIriBy(ImageRepository::class, ['name' => 'repository-test']); + $this->createClientWithCredentials()->request('POST', '/images',['json' => [ 'name' => self::IMAGE_CREATE, 'size' => 123, 'path' => '/path/to/image', 'softwareProfile' => $swPIri, + 'imageRepository' => $irIri ]]); $this->assertResponseStatusCodeSame(201); @@ -99,14 +105,12 @@ class ImageTest extends AbstractTest $this->createClientWithCredentials()->request('PUT', $iri, ['json' => [ 'name' => self::IMAGE_UPDATE, - 'size' => 123 ]]); $this->assertResponseIsSuccessful(); $this->assertJsonContains([ '@id' => $iri, 'name' => self::IMAGE_UPDATE, - 'size' => 123 ]); } diff --git a/translations/validators.en.yaml b/translations/validators.en.yaml index 7881069..2ed5bc8 100644 --- a/translations/validators.en.yaml +++ b/translations/validators.en.yaml @@ -37,6 +37,7 @@ validators: image: name: not_blank: 'The name should not be blank.' + unique: 'The name should be unique.' network_settings: ip_address: diff --git a/translations/validators.es.yaml b/translations/validators.es.yaml index 9f11c35..a6bbf00 100644 --- a/translations/validators.es.yaml +++ b/translations/validators.es.yaml @@ -37,6 +37,7 @@ validators: image: name: not_blank: 'El nombre no debería estar vacío.' + unique: 'El nombre debería ser único. Ya existe una imagen con ese nombre.' network_settings: ip_address: