Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
|
9039558fad | |
|
8ebf8d2724 | |
|
0a246271e5 |
31
CHANGELOG.md
31
CHANGELOG.md
|
@ -1,35 +1,4 @@
|
|||
# Changelog
|
||||
## [0.14.2] - 2025-06-09
|
||||
### Improved
|
||||
- Cambio en el template base del menu. Ahora apunta a los script de python de manera correcta.
|
||||
|
||||
---
|
||||
## [0.14.1] - 2025-06-09
|
||||
### Fixed
|
||||
- Se han corregido los mensajes de error que se envian cuando las APIs de los modulos no estan disponibles.
|
||||
- Se ha corregido un bug en la herencia de datos entre aulas y grupos, que hacia que no se almacenaran los datos de manera correcta.
|
||||
|
||||
---
|
||||
## [0.14.0] - 2025-06-02
|
||||
### Added
|
||||
- Se ha añadido la funcionalidad de mover equipos entre aulas y grupos.
|
||||
- Se ha añadido la funcionalidad para eliminar imagen cache.
|
||||
- Se ha añadido la funcionalidad para iniciar sesion.
|
||||
|
||||
### Improved
|
||||
- Se ha cambiado la restriccion que comprobaba los puertos de MULTICAST.
|
||||
- Se ha modificado el tiempo en el script, que se encarga de comprobar el estado de los equipos. Ahora es de 1 min en lugar de 3.
|
||||
|
||||
### Fixed
|
||||
- Se ha corregido un bug que hacia que al modificar un cliente o eliminarlo, no se actualizaba su estado en la subred.
|
||||
- Se ha corregido un bug que hacia que al modificar un cliente, no se actualizara su fichero de arranque.
|
||||
|
||||
---
|
||||
## [0.13.1] - 2025-05-23
|
||||
### Fixed
|
||||
- Variable de entorno "SSl_ENABLED" desactivada por defecto.
|
||||
|
||||
---
|
||||
## [0.13.0] - 2025-05-20
|
||||
### Added
|
||||
- Se ha creado la base para la comunicacion TLS con el agente.
|
||||
|
|
|
@ -32,7 +32,7 @@ resources:
|
|||
class: ApiPlatform\Metadata\Post
|
||||
method: POST
|
||||
input: App\Dto\Input\ChangeOrganizationalUnitInput
|
||||
uriTemplate: /clients/change-organizational-unit
|
||||
uriTemplate: /clients/change-organizational-units
|
||||
controller: App\Controller\ChangeOrganizationalUnitAction
|
||||
|
||||
agent_status:
|
||||
|
@ -50,34 +50,13 @@ resources:
|
|||
uriTemplate: /clients/server/{uuid}/get-pxe
|
||||
controller: App\Controller\OgBoot\PxeBootFile\GetAction
|
||||
|
||||
boot_client:
|
||||
login_client:
|
||||
class: ApiPlatform\Metadata\Post
|
||||
method: POST
|
||||
input: App\Dto\Input\BootClientsInput
|
||||
uriTemplate: /clients/server/boot-client
|
||||
input: App\Dto\Input\MultipleClientsInput
|
||||
uriTemplate: /clients/server/login-client
|
||||
controller: App\Controller\OgAgent\LoginAction
|
||||
|
||||
remove_cache_image:
|
||||
class: ApiPlatform\Metadata\Post
|
||||
method: POST
|
||||
input: App\Dto\Input\BootClientsInput
|
||||
uriTemplate: /clients/server/remove-cache-image
|
||||
controller: App\Controller\OgAgent\RemoveCacheImageAction
|
||||
|
||||
hardware_inventory:
|
||||
class: ApiPlatform\Metadata\Post
|
||||
method: POST
|
||||
input: false
|
||||
uriTemplate: /clients/server/{uuid}/hardware-inventory
|
||||
controller: App\Controller\OgAgent\HardwareInventoryAction
|
||||
|
||||
software_inventory:
|
||||
class: ApiPlatform\Metadata\Post
|
||||
method: POST
|
||||
input: App\Dto\Input\SoftwareInventoryPartitionInput
|
||||
uriTemplate: /clients/server/{uuid}/software-inventory
|
||||
controller: App\Controller\OgAgent\SoftwareInventoryAction
|
||||
|
||||
reboot_client:
|
||||
class: ApiPlatform\Metadata\Post
|
||||
method: POST
|
||||
|
|
|
@ -4,7 +4,6 @@ resources:
|
|||
input: App\Dto\Input\PartitionPostInput
|
||||
output: App\Dto\Output\PartitionOutput
|
||||
order:
|
||||
diskNumber: 'ASC'
|
||||
partitionNumber: 'ASC'
|
||||
normalizationContext:
|
||||
groups: ['default', 'partition:read']
|
||||
|
|
|
@ -13,7 +13,6 @@ resources:
|
|||
filters:
|
||||
- 'api_platform.filter.software.order'
|
||||
- 'api_platform.filter.software.search'
|
||||
- 'software.software_profile_filter'
|
||||
|
||||
ApiPlatform\Metadata\Get:
|
||||
provider: App\State\Provider\SoftwareProvider
|
||||
|
|
|
@ -33,7 +33,6 @@ security:
|
|||
- { path: ^/og-repository/webhook, roles: PUBLIC_ACCESS }
|
||||
- { path: ^/og-lives/install/webhook, roles: PUBLIC_ACCESS }
|
||||
- { path: ^/auth/refresh, roles: PUBLIC_ACCESS }
|
||||
- { path: ^/validate, roles: PUBLIC_ACCESS }
|
||||
- { path: ^/menu-browser, roles: PUBLIC_ACCESS }
|
||||
- { path: ^/menu/, roles: PUBLIC_ACCESS }
|
||||
- { path: ^/, roles: IS_AUTHENTICATED_FULLY }
|
||||
|
|
|
@ -119,10 +119,6 @@ services:
|
|||
parent: 'App\Filter\ImageSearchRepositoryFilter'
|
||||
tags: [ 'api_platform.filter' ]
|
||||
|
||||
software.software_profile_filter:
|
||||
parent: 'App\Filter\SoftwareProfileSearchSoftwareFilter'
|
||||
tags: [ 'api_platform.filter' ]
|
||||
|
||||
api_platform.filter.og_live.order:
|
||||
parent: 'api_platform.doctrine.orm.order_filter'
|
||||
arguments:
|
||||
|
@ -281,7 +277,7 @@ services:
|
|||
|
||||
api_platform.filter.software_profile.search:
|
||||
parent: 'api_platform.doctrine.orm.search_filter'
|
||||
arguments: [ { 'id': 'exact', 'description': 'partial'} ]
|
||||
arguments: [ { 'id': 'exact', 'description': 'partial' } ]
|
||||
tags: [ 'api_platform.filter' ]
|
||||
|
||||
api_platform.filter.subnet.order:
|
||||
|
|
|
@ -8,3 +8,33 @@ Type: password
|
|||
Default: 12345678
|
||||
Description: Introduzca la contraseña
|
||||
|
||||
Template: opengnsys/ogcore_ogbootip
|
||||
Type: string
|
||||
Default: 127.0.0.1
|
||||
Description: IP del servidor de ogBoot
|
||||
|
||||
Template: opengnsys/ogcore_ogbootport
|
||||
Type: string
|
||||
Default: 8082
|
||||
Description: Puerto del endpoint del API de ogboot
|
||||
|
||||
Template: opengnsys/ogcore_ogdhcpip
|
||||
Type: string
|
||||
Default: 127.0.0.1
|
||||
Description: IP del servidor de ogdhcp
|
||||
|
||||
Template: opengnsys/ogcore_ogdhcpport
|
||||
Type: string
|
||||
Default: 8081
|
||||
Description: Puerto del endpoint del API de ogdhcp
|
||||
|
||||
Template: opengnsys/ogcore_ogrepoip
|
||||
Type: string
|
||||
Default: 127.0.0.1
|
||||
Description: IP del servidor de ogdhcp
|
||||
|
||||
Template: opengnsys/ogcore_ogrepoport
|
||||
Type: string
|
||||
Default: 8006
|
||||
Description: Puerto del endpoint del API de ogdhcp
|
||||
|
||||
|
|
5
env.json
5
env.json
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"vars": {
|
||||
"OG_BOOT_API_URL": "127.0.0.1:8082",
|
||||
"OG_DHCP_API_URL": "127.0.0.1:8081",
|
||||
"OG_CORE_IP": "127.0.0.1",
|
||||
"OG_LOG_IP": "127.0.0.1",
|
||||
|
@ -7,9 +8,9 @@
|
|||
"UDS_AUTH_USERNAME": "test",
|
||||
"UDS_AUTH_PASSWORD": "test",
|
||||
"UDS_URL": "https:\/\/localhost:8087\/uds\/rest\/",
|
||||
"SSL_ENABLED": "false",
|
||||
"SSL_ENABLED": "true",
|
||||
"OG_BOOT_IP": "127.0.0.1",
|
||||
"OG_BOOT_API_PORT": "8082",
|
||||
"OG_BOOT_PXE_PORT": "8082"
|
||||
"OG_BOOT_PXE_PORT": "8085"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
-----BEGIN CERTIFICATE-----
|
||||
MIIFrzCCA5egAwIBAgIUPmq2FSZvV2NBGIIxx5729SJN0FQwDQYJKoZIhvcNAQEL
|
||||
BQAwZzELMAkGA1UEBhMCRVMxDzANBgNVBAgMBk1hZHJpZDEPMA0GA1UEBwwGTWFk
|
||||
cmlkMRIwEAYDVQQKDAlPcGVuZ25zeXMxCzAJBgNVBAsMAkNBMRUwEwYDVQQDDAxv
|
||||
cGVuZ25zeXMtY2EwHhcNMjUwNTE2MDgzNjM4WhcNMzUwNTE0MDgzNjM4WjBnMQsw
|
||||
CQYDVQQGEwJFUzEPMA0GA1UECAwGTWFkcmlkMQ8wDQYDVQQHDAZNYWRyaWQxEjAQ
|
||||
BgNVBAoMCU9wZW5nbnN5czELMAkGA1UECwwCQ0ExFTATBgNVBAMMDG9wZW5nbnN5
|
||||
cy1jYTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANSAiJFAU7wV6hYb
|
||||
PKmjjuNFp07ITJC0vThRegIXcadAw9cblgYtD6e4KYT8LzrRpZDAazAWLSAY72W8
|
||||
i8/wWYcVIMDhtbhKy+pLFL0Z1LJpV6s6ged0wB5wQ37g1RDWeydrY9mEOr0LSC8X
|
||||
7ye7mTqtSxECglloRJw5p/9Z5yDZf2t1U6+e3WfZqKLZl9IXBb5cdR9mxUAf23/T
|
||||
ciAfTBNgltJ3noQERtjHZqxb9jrqpwaKhnZoGw4fb0poI9OQXitOzoR/b8ADMfUK
|
||||
KJ/d9iyq9h6gv4GPEJlDJK89vQlBhJAy8tHR6Qjd0nG+Be6moCndBqiHLAehMxkq
|
||||
8JS+bUOsAxq4XSsis5XQHOm/xZ4jlkerNQeeK+b0EDESjdNkKJXVy235FFJbCwGq
|
||||
IR8fdYUJenhqsHOd7WEjm5HfYo41mPG3002Wxs8oN1oNbqIzR/fxTGHWJKXX0LVt
|
||||
ZKg3s7h0MfmxMIJ5kHsh9wTO4qMIADmWPj5iCIXS15eAU3WJd4yYxTfcu1wwLBuv
|
||||
ATtZXLc/LI56PAvU1kXgdIT+OeBctVuBxKy11vrb82LF7WUZI3cP3MoRbGOLnc93
|
||||
u8pMu59l+l7pA7wjGJHSyt/H5f52ZHdbz/BMSY96/ETgAUHERM9cMoN+AGrI4Yf8
|
||||
8ZiuiAkSmukAShOfa05P8zqcXXjZAgMBAAGjUzBRMB0GA1UdDgQWBBTTPskAqxZM
|
||||
a7z7DBkb4MCspW7/bzAfBgNVHSMEGDAWgBTTPskAqxZMa7z7DBkb4MCspW7/bzAP
|
||||
BgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4ICAQC+PQBDayFqVA0BAupP
|
||||
1ksZW3rXCIPIqSqbOG8BsgnOJXt+7Isql06/3LFEdaztjAptSEqX2K7Q7Ov4ZOF5
|
||||
+lF2pSuIJwsVbzFbmrejkSZScQmXzAvQmNwMcWjpplhe0DG6hYdLek6IOo7BP2mG
|
||||
12l1mZbIkgmMbRK7Up6rQ5c9/PmcTqN5RXe3CEWPpBs5FEoD++k6wtYrZlaTCB2s
|
||||
P6taQuN1waO3jfu8KApQlcVEmlxaosrJSu8tBAE/zN9GwpR3WsdrD2iUB2d+g2rB
|
||||
RZ1P+DRnwpfIn7SEWUAezGW05Qu2gyfoZkiQ97zOYBXYCYwoNFVFtHnaRLO58cjz
|
||||
QR8+CLjs9svsrNXw+1rvUJoYyzh0vEBc+SUxKQ/7EGN6m9P7iod936Eqy6ztvUSV
|
||||
LdHxv8g0FOlmlLW1Afmiu2NopVsZqxOm1oZdurt7tYcNncu5AYwFmlP/iyDMmJBI
|
||||
hIUHmEUf0+v0K52H/ziIFovI7MVmY1RHlL5DABH+MiM6MmSl0NtW5DbEWEZN1vZI
|
||||
d3J6hsL/7o2wDYkLYkTolrBHbmvN5hoFu+b/YBAmrikJ027Lw1H04PvyW+PV1+DI
|
||||
4uTQ0NEMLhYBBY0ucg1iw6wsEbHhJwmMmen8/b18ZBytRyTzuKCyD6g6iLMEoDNG
|
||||
KOH0n1CGLevamLAYrLTwfXBTYQ==
|
||||
-----END CERTIFICATE-----
|
|
@ -0,0 +1,30 @@
|
|||
-----BEGIN CERTIFICATE-----
|
||||
MIIFDjCCAvagAwIBAgIUEcS4b1cHsVkFGWqjVqHPrYkFl0owDQYJKoZIhvcNAQEL
|
||||
BQAwZzELMAkGA1UEBhMCRVMxDzANBgNVBAgMBk1hZHJpZDEPMA0GA1UEBwwGTWFk
|
||||
cmlkMRIwEAYDVQQKDAlPcGVuZ25zeXMxCzAJBgNVBAsMAkNBMRUwEwYDVQQDDAxv
|
||||
cGVuZ25zeXMtY2EwHhcNMjUwNTE2MDkxMzA4WhcNMjcwODE5MDkxMzA4WjBrMQsw
|
||||
CQYDVQQGEwJFUzEPMA0GA1UECAwGTWFkcmlkMQ8wDQYDVQQHDAZNYWRyaWQxEjAQ
|
||||
BgNVBAoMCU9wZW5nbnN5czEPMA0GA1UECwwGb2djb3JlMRUwEwYDVQQDDAxvZ2Nv
|
||||
cmUubG9jYWwwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDEtWnQU4vW
|
||||
sNwy9jDP9ZGRMFB46xg7aXAU4KJwAlIMdth0y7TPhrPNgQOyO/fVF/qXYOAmRxuJ
|
||||
8sDjWhxSXXG1ox36yB+UjJOPf9uFBKx+jIygn77A+7nhbh423YtfetwzLKloE1MD
|
||||
BnRUSDqhohhVp98TY7kTPdckR6vZCcrzg5nijf/Nbde9NdMDl+iFpXggWS+GpP0L
|
||||
pnQhdUEWaBLupIOFFdf1C7O4/DRNs8v3+S+OWNfqZ12xmiwVGmZGywELZ/jSAZBc
|
||||
4VgeWMUekw1gbDZ3HV0FzC9L5RiR5ofyUH1O4LMfAgEQfr9wMwMBqmx49PuQLOLd
|
||||
S/iaA83b7GBFAgMBAAGjga0wgaowHwYDVR0jBBgwFoAU0z7JAKsWTGu8+wwZG+DA
|
||||
rKVu/28wCQYDVR0TBAIwADALBgNVHQ8EBAMCBaAwHQYDVR0lBBYwFAYIKwYBBQUH
|
||||
AwEGCCsGAQUFBwMCMDEGA1UdEQQqMCiCDG9nY29yZS5sb2NhbIISb3Blbmduc3lz
|
||||
Lm5hdGkuY29thwTAqAEsMB0GA1UdDgQWBBQWnCzjmnQSBYG09VTAY8sAxRolGTAN
|
||||
BgkqhkiG9w0BAQsFAAOCAgEAL8DL4gy2hAL30n0OX3VncLTCLw8C08LxoghfFNK5
|
||||
LThTLdo/SlC99fWSPayyKNCIpZHQbNsVlgGyizOagvly1BaxUA070uwSg8H7IhPA
|
||||
Pbf+MCj+QnYV6HvmkPhML87Qin4yiV2QOMC7WiEk9nFcjoRU8nDXjtShsw1zCer8
|
||||
ow+Y0lsJ1RceIgtMgzIQnDJ5cnr+BL6EdzMOWu9UZv39nG3zkHVv4RxvgNckXyVQ
|
||||
iqGiw6ZpII+M9IPcbaVLfnXWomnDRRXjs5BL/HkapTLrMw3VSjNR0Via9iXX6bft
|
||||
PXolS3ifCRwtFFm7NfaEs915vZXgGIU8Lzeve3V4udK3vQhBJsXzFRvhfAD7+vIm
|
||||
xg79N5DBi/KkRsIQ3xqgKv0FXrlJkcRBr//OBKl1QpypY+y+3FiqqntWHS19dCZW
|
||||
V9A2snjG6NxoC2BQOwqM3j3mT1jEURoQ9p+Q/h8ibL1JltM32CUZkvC/BGCU/uan
|
||||
WRefWBWd1iwVgi4ylxxW80BLG7pdgnaBsAcvWD073o8eGHle0aYJ0knUkxYilyD4
|
||||
jq9I5IPb0Vo3QUTDZAoKl3puDo0MSpznPw2fribLsjVD2GFT6I37wcvzH86dj8aT
|
||||
y5nqKbFUihcS9Pupf5GNRU+4By+vFx+AcMqoybUWgyJiBtmGAhVg7jw4QGwbw4z2
|
||||
nWE=
|
||||
-----END CERTIFICATE-----
|
|
@ -0,0 +1,10 @@
|
|||
authorityKeyIdentifier=keyid,issuer
|
||||
basicConstraints=CA:FALSE
|
||||
keyUsage = digitalSignature, keyEncipherment
|
||||
extendedKeyUsage = serverAuth, clientAuth
|
||||
subjectAltName = @alt_names
|
||||
|
||||
[alt_names]
|
||||
DNS.1 = ogcore.local
|
||||
DNS.2 = opengnsys.nati.com
|
||||
IP.1 = 192.168.1.44
|
|
@ -0,0 +1,28 @@
|
|||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDEtWnQU4vWsNwy
|
||||
9jDP9ZGRMFB46xg7aXAU4KJwAlIMdth0y7TPhrPNgQOyO/fVF/qXYOAmRxuJ8sDj
|
||||
WhxSXXG1ox36yB+UjJOPf9uFBKx+jIygn77A+7nhbh423YtfetwzLKloE1MDBnRU
|
||||
SDqhohhVp98TY7kTPdckR6vZCcrzg5nijf/Nbde9NdMDl+iFpXggWS+GpP0LpnQh
|
||||
dUEWaBLupIOFFdf1C7O4/DRNs8v3+S+OWNfqZ12xmiwVGmZGywELZ/jSAZBc4Vge
|
||||
WMUekw1gbDZ3HV0FzC9L5RiR5ofyUH1O4LMfAgEQfr9wMwMBqmx49PuQLOLdS/ia
|
||||
A83b7GBFAgMBAAECggEAHRnXkyXhALx+fx2T4Bgs1mVm6lSha5ywI66N6XM2bzif
|
||||
0juWvsLnU8Y75UDg68oV3RJMZu1LIi/jIF9i5D6FxYDhvQmhPmlDpU2djMLBwCEL
|
||||
5vFrF4LGH5caajSBW3lCHWIEl+yP8dkhGZzr66Ce6AEjS+uLZFDYRLpDrqK3vymc
|
||||
v82ixmQO2QlxfrOmumYAKV7s3JSQbn7nQmHWJE5ttybEtIwSmPECeO7orjhNRiDT
|
||||
LDJdqcgaRcdiFgALhZVA0sueGPnflkI00Kv5kW2+dgAp/rAzgsjLMXuyqT0jeJwT
|
||||
dy6EUsetc3aEthLBwsltqH5CMaYMCJQ7ycKgIJSVCwKBgQD3w4CLC3Dgp1YrnbTL
|
||||
YAAkvs10cn41vM8zG12kAJXlGAGzQ9X0pLHk5arkIUAMddUlJ9VD1Jm8qSUyfkrs
|
||||
tJcwVeNLw3R6G9lFhzk32pb9gKKCMuDzFY4IsDafyqI9e624p1A7s/QUKpnw+cFu
|
||||
Bz24XNx1I/QrRzQ2lm3K2axHEwKBgQDLP21Jj2OoQPhySFLzKdMl9NM2pjhqhdF9
|
||||
vtaovSQtFXOX/imxCk+17ZD7wbODj1cVtsf38PMOJpRs+ki4sx71ZWj7JOqEDTS4
|
||||
R1X9k9k2Lg8sV7eLKxN4JkrOWv0+0A09hnelhmHscgiolW37cBNrfNQ9ST47Eyy5
|
||||
5RrXDcvuRwKBgFRPLYWjHgUETDlJUAVIpKPcXZN7hmEI38T3UfUF0fwEIEf9FGhM
|
||||
RtCqKm24ts/GpQIgvNx5Ett0/1hgS2SiyzPCdjcIyrDmmxeivSC5fFnFFQeTAqMV
|
||||
OaDRPbVAQdcEKAhGvvGh+bOHD51Fj8G+Kw16Y/ZkhqjXcPgGVlQJoCsLAoGBAI5A
|
||||
hVAf4MNJPdpWzl/MnTEKqq2sJv4/TMFyyTDuuJwpUG9H/4weyG1vqbLa/raMo4na
|
||||
FRlu9d6ol+eyQSWskHV2lcR5MP5dc9Gqc//38+Yc1JfXiOoJqyXDv0Wwn2DQIwQ1
|
||||
0hXy+SSRJ4g+leyOo7judGm0kq6sG/i75k4wJNRPAoGAXtCh5qLEBgPp3iqBXk57
|
||||
q5Fq+kbsMZg7/YR4waKFL2pkAcWUwIpaKrxbw7/Ow2+9ZUXOygVn6Kar3I9ZfOzb
|
||||
ayxtgUZOOHzvhl9OPiq8ny00nQgojYeFfaIdohDiqEnEWCEeX6NWJ/5O+gZjFkMX
|
||||
4FV55ziMfHV4RE0S6JuvexA=
|
||||
-----END PRIVATE KEY-----
|
|
@ -4,8 +4,8 @@ server {
|
|||
root /opt/opengnsys/ogcore/api/public/;
|
||||
index index.html index.php;
|
||||
|
||||
ssl_certificate /opt/opengnsys/ogcore/etc/nginx/certs/ogcore.uds-test.net.crt.pem;
|
||||
ssl_certificate_key /opt/opengnsys/ogcore/etc/nginx/certs/ogcore.uds-test.net.key.pem;
|
||||
ssl_certificate /opt/opengnsys/ogcore/etc/certificates/ogcore.crt;
|
||||
ssl_certificate_key /opt/opengnsys/ogcore/etc/certificates/ogcore.key;
|
||||
|
||||
location /opengnsys/rest/ous// {
|
||||
rewrite ^/opengnsys/rest/ous//([0-9]+)/images /opengnsys/rest/ous/$1/images;
|
||||
|
@ -34,3 +34,93 @@ server {
|
|||
error_log /var/log/nginx/ogcore-error.log;
|
||||
access_log /var/log/nginx/ogcore-access.log;
|
||||
}
|
||||
|
||||
|
||||
server {
|
||||
listen 8444 ssl;
|
||||
server_name _;
|
||||
|
||||
root /opt/opengnsys/ogcore/api/public/;
|
||||
index index.html index.php;
|
||||
|
||||
# Certificados del servidor
|
||||
ssl_certificate /opt/opengnsys/ogcore/etc/certificates/ogcore.crt;
|
||||
ssl_certificate_key /opt/opengnsys/ogcore/etc/certificates/ogcore.key;
|
||||
|
||||
# CA para validar cliente (opcional)
|
||||
ssl_client_certificate /opt/opengnsys/ogcore/etc/certificates/ca.crt;
|
||||
ssl_verify_client optional;
|
||||
|
||||
# ================================
|
||||
# 1. RUTA ABIERTA: /auth/login
|
||||
# ================================
|
||||
location = /auth/login {
|
||||
try_files $uri $uri/ /index.php?$args;
|
||||
}
|
||||
|
||||
# ============================================
|
||||
# 2. RUTA ABIERTA: / (documentación Swagger)
|
||||
# ============================================
|
||||
location = / {
|
||||
try_files $uri $uri/ /index.php?$args;
|
||||
}
|
||||
|
||||
# ==================================================
|
||||
# 3. VALIDACIÓN DE ACCESO: Certificado o Bearer token
|
||||
# ==================================================
|
||||
location = /check-auth {
|
||||
internal;
|
||||
proxy_pass http://127.0.0.1:5001/validate;
|
||||
proxy_pass_request_body off;
|
||||
proxy_set_header Content-Length "";
|
||||
proxy_set_header SSL_CLIENT_VERIFY $ssl_client_verify;
|
||||
proxy_set_header Authorization $http_authorization;
|
||||
}
|
||||
|
||||
# ============================================
|
||||
# 4. TODAS LAS DEMÁS RUTAS → AUTENTICACIÓN
|
||||
# ============================================
|
||||
location / {
|
||||
# Permitir preflight sin autenticación
|
||||
if ($request_method = OPTIONS ) {
|
||||
add_header 'Access-Control-Allow-Origin' '*' always;
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE, PATCH' always;
|
||||
add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type' always;
|
||||
add_header 'Access-Control-Max-Age' 3600;
|
||||
return 204;
|
||||
}
|
||||
|
||||
# Para el resto de métodos, aplicar autenticación
|
||||
auth_request /check-auth;
|
||||
|
||||
# Añadir headers CORS en respuestas reales también
|
||||
add_header 'Access-Control-Allow-Origin' '*' always;
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE, PATCH' always;
|
||||
add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type' always;
|
||||
|
||||
try_files $uri $uri/ /index.php?$args;
|
||||
}
|
||||
|
||||
location ^~ /bundles/apiplatform/ {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
# ============================================
|
||||
# 5. PHP HANDLER
|
||||
# ============================================
|
||||
location ~ \.php$ {
|
||||
include fastcgi_params;
|
||||
fastcgi_pass unix:/var/run/php/php8.3-fpm-ogcore.sock;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.*)$;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param PATH_INFO $request_uri;
|
||||
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
|
||||
|
||||
# Pasa info TLS y token a PHP
|
||||
fastcgi_param SSL_CLIENT_VERIFY $ssl_client_verify;
|
||||
fastcgi_param Authorization $http_authorization;
|
||||
}
|
||||
|
||||
error_log /var/log/nginx/ogcore-error.log;
|
||||
access_log /var/log/nginx/ogcore-access.log;
|
||||
}
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20250604084222 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE `partition` DROP FOREIGN KEY FK_9EB910E43DA5256D');
|
||||
$this->addSql('ALTER TABLE `partition` ADD CONSTRAINT FK_9EB910E43DA5256D FOREIGN KEY (image_id) REFERENCES image_image_repository (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_9EB910E43DA5256D');
|
||||
$this->addSql('ALTER TABLE `partition` ADD CONSTRAINT FK_9EB910E43DA5256D FOREIGN KEY (image_id) REFERENCES image_image_repository (id)');
|
||||
}
|
||||
}
|
|
@ -20,7 +20,7 @@ use Symfony\Component\Mercure\Update;
|
|||
#[AsCommand(name: 'opengnsys:check-client-availability', description: 'Check client availability')]
|
||||
class CheckClientAvailability extends Command
|
||||
{
|
||||
const int THRESHOLD_MINUTES = 1;
|
||||
const int THRESHOLD_MINUTES = 3;
|
||||
|
||||
public function __construct(
|
||||
private readonly HubInterface $hub,
|
||||
|
@ -34,18 +34,16 @@ class CheckClientAvailability extends Command
|
|||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$threshold = (new \DateTime())->modify(' - '.self::THRESHOLD_MINUTES . ' minutes');
|
||||
$startQueryTime = microtime(true);
|
||||
|
||||
$validStatuses = [ClientStatus::OG_LIVE, ClientStatus::WINDOWS, ClientStatus::LINUX, ClientStatus::MACOS];
|
||||
$startQueryTime = microtime(true);
|
||||
|
||||
$query = $this->entityManager->createQuery(
|
||||
'UPDATE App\Entity\Client c
|
||||
SET c.status = :status
|
||||
WHERE c.status IN (:currentStatuses)
|
||||
AND c.updatedAt < :threshold'
|
||||
SET c.status = :status
|
||||
WHERE c.status = :currentStatus AND c.updatedAt < :threshold'
|
||||
);
|
||||
$query->setParameter('status', ClientStatus::DISCONNECTED);
|
||||
$query->setParameter('currentStatuses', $validStatuses);
|
||||
$query->setParameter('currentStatus', ClientStatus::OG_LIVE);
|
||||
$query->setParameter('threshold', $threshold);
|
||||
$updatedCount = $query->execute();
|
||||
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Controller\OgBoot\PxeBootFile\PostAction;
|
||||
use App\Dto\Input\ChangeOrganizationalUnitInput;
|
||||
use App\Dto\Output\ClientOutput;
|
||||
use App\Entity\Client;
|
||||
use App\Repository\ClientRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
@ -12,37 +10,29 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
|
||||
class ChangeOrganizationalUnitAction extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private PostAction $postAction,
|
||||
private readonly ClientRepository $clientRepository,
|
||||
private readonly EntityManagerInterface $entityManager
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
public function __invoke(ChangeOrganizationalUnitInput $input): JsonResponse
|
||||
{
|
||||
foreach ($input->clients as $client) {
|
||||
/** @var Client $clientEntity */
|
||||
$clientEntity = $client->getEntity();
|
||||
/** @var Client $client */
|
||||
$clientEntity = $this->clientRepository->find($client->getEntity()->getId());
|
||||
if (!$clientEntity) {
|
||||
throw new NotFoundHttpException('Client not found');
|
||||
}
|
||||
|
||||
$organizationalUnit = $input->organizationalUnit->getEntity();
|
||||
$clientEntity->setOrganizationalUnit($organizationalUnit);
|
||||
|
||||
$this->entityManager->persist($clientEntity);
|
||||
$this->postAction->__invoke($clientEntity, $clientEntity->getTemplate());
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
|
|
|
@ -79,7 +79,7 @@ abstract class AbstractOgAgentController extends AbstractController
|
|||
|
||||
return [
|
||||
'code' => Response::HTTP_INTERNAL_SERVER_ERROR,
|
||||
'error' => 'Transport error',
|
||||
'error' => 'Client/Server error',
|
||||
'details' => $e->getMessage(),
|
||||
];
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ use Psr\Log\LoggerInterface;
|
|||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
|
@ -46,7 +45,7 @@ class CreateImageAction extends AbstractOgAgentController
|
|||
public function __invoke(Image $image, ?Partition $partition = null, ?Client $client = null): JsonResponse
|
||||
{
|
||||
if (!$image->getClient()->getIp()) {
|
||||
throw new BadRequestHttpException('IP is required');
|
||||
throw new ValidatorException('IP is required');
|
||||
}
|
||||
|
||||
$partitionInfo = [];
|
||||
|
@ -152,7 +151,7 @@ class CreateImageAction extends AbstractOgAgentController
|
|||
$this->logger->info('Creating image', ['image' => $imageImageRepository->getName(), 'repository' => $repository->getIp()]);
|
||||
|
||||
if (isset($response['error']) && $response['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
throw new BadRequestHttpException('Error creating image');
|
||||
throw new ValidatorException('Error creating image');
|
||||
}
|
||||
|
||||
$jobId = $response['job_id'];
|
||||
|
|
|
@ -21,7 +21,6 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|||
use Symfony\Component\HttpClient\Exception\TransportException;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
|
@ -43,7 +42,7 @@ class DeployImageAction extends AbstractOgAgentController
|
|||
$image = $imageImageRepository->getImage();
|
||||
|
||||
if (!$client->getIp()) {
|
||||
throw new BadRequestHttpException('IP is required');
|
||||
throw new ValidatorException('IP is required');
|
||||
}
|
||||
|
||||
$method = match ($input->method) {
|
||||
|
@ -52,7 +51,7 @@ class DeployImageAction extends AbstractOgAgentController
|
|||
DeployMethodTypes::UNICAST_DIRECT => 'unicast-direct',
|
||||
DeployMethodTypes::UNICAST => 'unicast',
|
||||
DeployMethodTypes::TORRENT => 'torrent',
|
||||
default => throw new BadRequestHttpException('Invalid method'),
|
||||
default => throw new ValidatorException('Invalid method'),
|
||||
};
|
||||
|
||||
$mcastMode = $input->mcastMode.'-duplex';
|
||||
|
@ -66,7 +65,7 @@ class DeployImageAction extends AbstractOgAgentController
|
|||
DeployMethodTypes::MULTICAST, DeployMethodTypes::MULTICAST_UFTP, DeployMethodTypes::MULTICAST_UFTP_DIRECT, DeployMethodTypes::MULTICAST_UDPCAST, DeployMethodTypes::MULTICAST_UDPCAST_DIRECT => $ptcMulticastValue,
|
||||
DeployMethodTypes::UNICAST, DeployMethodTypes::UNICAST_DIRECT => $ptcUnicastValue,
|
||||
DeployMethodTypes::TORRENT => $ptcTorrentValue,
|
||||
default => throw new BadRequestHttpException('Invalid method'),
|
||||
default => throw new ValidatorException('Invalid method'),
|
||||
};
|
||||
|
||||
$repository = $imageImageRepository->getRepository();
|
||||
|
@ -95,7 +94,7 @@ class DeployImageAction extends AbstractOgAgentController
|
|||
$this->logger->info('Deploying image', [ 'image' => $imageImageRepository->getName(), 'repository' => $repository->getIp()]);
|
||||
|
||||
if (isset($response['error']) && $response['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
throw new BadRequestHttpException('Error deploying image');
|
||||
throw new ValidatorException('Error deploying image');
|
||||
}
|
||||
|
||||
$jobId = $response['job_id'];
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\OgAgent;
|
||||
|
||||
use App\Entity\Client;
|
||||
use App\Model\CommandTypes;
|
||||
use App\Model\TraceStatus;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
|
||||
class HardwareInventoryAction extends AbstractOgAgentController
|
||||
{
|
||||
/**
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
public function __invoke(Client $client): JsonResponse
|
||||
{
|
||||
$data = [
|
||||
'nfn' => 'InventarioHardware',
|
||||
'ids' => '0'
|
||||
];
|
||||
|
||||
$response = $this->createRequest(
|
||||
method: 'POST',
|
||||
url: 'https://'.$client->getIp().':8000/opengnsys/InventarioHardware',
|
||||
params: [
|
||||
'json' => $data,
|
||||
],
|
||||
token: $client->getToken(),
|
||||
);
|
||||
|
||||
if (isset($response['error']) && $response['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
throw new BadRequestHttpException('Error performing hardware inventory: '.$response['error']);
|
||||
}
|
||||
|
||||
$this->logger->info('Login client', ['client' => $client->getId()]);
|
||||
|
||||
$jobId = $response['job_id'];
|
||||
|
||||
$inputData = [
|
||||
'client' => $client->getIp(),
|
||||
];
|
||||
|
||||
$this->createService->__invoke($client, CommandTypes::HARDWARE_INVENTORY, TraceStatus::IN_PROGRESS, $jobId, $inputData);
|
||||
|
||||
return new JsonResponse(data: [], status: Response::HTTP_OK);
|
||||
}
|
||||
}
|
|
@ -4,12 +4,10 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Controller\OgAgent;
|
||||
|
||||
use App\Dto\Input\BootClientsInput;
|
||||
use App\Dto\Input\MultipleClientsInput;
|
||||
use App\Entity\Client;
|
||||
use App\Entity\Command;
|
||||
use App\Entity\Image;
|
||||
use App\Entity\Partition;
|
||||
use App\Entity\Trace;
|
||||
use App\Model\ClientStatus;
|
||||
use App\Model\CommandTypes;
|
||||
|
@ -21,7 +19,6 @@ use Psr\Log\LoggerInterface;
|
|||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
|
@ -38,42 +35,38 @@ class LoginAction extends AbstractOgAgentController
|
|||
* @throws RedirectionExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
public function __invoke(BootClientsInput $input): JsonResponse
|
||||
public function __invoke(MultipleClientsInput $input): JsonResponse
|
||||
{
|
||||
/** @var Partition $partition */
|
||||
$partition = $input->partition->getEntity();
|
||||
|
||||
foreach ($input->clients as $clientEntity) {
|
||||
/** @var Client $client */
|
||||
$client = $clientEntity->getEntity();
|
||||
|
||||
|
||||
if (!$client->getIp()) {
|
||||
throw new BadRequestHttpException('IP is required');
|
||||
throw new ValidatorException('IP is required');
|
||||
}
|
||||
|
||||
if ($client->getStatus() !== ClientStatus::OG_LIVE) {
|
||||
throw new BadRequestHttpException('Client is not in OG_LIVE status');
|
||||
throw new ValidatorException('Client is not in OG_LIVE status');
|
||||
}
|
||||
|
||||
$data = [
|
||||
'nfn' => 'IniciarSesion',
|
||||
'dsk' => (string) $partition->getDiskNumber(),
|
||||
'par' => (string) $partition->getPartitionNumber(),
|
||||
'dsk' => '1',
|
||||
'par' => '1',
|
||||
'ids' => '0'
|
||||
];
|
||||
|
||||
$response = $this->createRequest(
|
||||
method: 'POST',
|
||||
url: 'https://'.$client->getIp().':8000/opengnsys/IniciarSesion',
|
||||
url: 'http://'.$client->getIp().':8000/opengnsys/IniciarSesion',
|
||||
params: [
|
||||
'json' => $data,
|
||||
],
|
||||
token: $client->getToken(),
|
||||
]
|
||||
);
|
||||
|
||||
if (isset($response['error']) && $response['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
throw new BadRequestHttpException('Error logging in: '.$response['error']);
|
||||
throw new ValidatorException('Error logging in: '.$response['error']);
|
||||
}
|
||||
|
||||
$this->logger->info('Login client', ['client' => $client->getId()]);
|
||||
|
@ -84,7 +77,7 @@ class LoginAction extends AbstractOgAgentController
|
|||
$this->entityManager->persist($client);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->createService->__invoke($client, CommandTypes::LOGIN, TraceStatus::SUCCESS, $jobId, []);
|
||||
$this->createService->__invoke($client, CommandTypes::REBOOT, TraceStatus::SUCCESS, $jobId, []);
|
||||
}
|
||||
|
||||
return new JsonResponse(data: [], status: Response::HTTP_OK);
|
||||
|
|
|
@ -20,7 +20,6 @@ use Psr\Log\LoggerInterface;
|
|||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
|
@ -42,7 +41,7 @@ class PartitionAssistantAction extends AbstractOgAgentController
|
|||
$partitions = $input->partitions;
|
||||
|
||||
if (empty($partitions)) {
|
||||
throw new BadRequestHttpException('Partitions is required');
|
||||
throw new ValidatorException('Partitions is required');
|
||||
}
|
||||
|
||||
foreach ($input->clients as $clientInput) {
|
||||
|
@ -111,7 +110,7 @@ class PartitionAssistantAction extends AbstractOgAgentController
|
|||
$this->logger->info('Partition assistant', ['client' => $client->getId()]);
|
||||
|
||||
if (isset($response['error']) && $response['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
throw new BadRequestHttpException('Error occurred while partitioning');
|
||||
throw new ValidatorException('Error occurred while partitioning');
|
||||
}
|
||||
|
||||
$jobId = $response['job_id'];
|
||||
|
|
|
@ -20,7 +20,6 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|||
use Symfony\Component\HttpClient\Exception\TransportException;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
|
@ -44,7 +43,7 @@ class PowerOffAction extends AbstractOgAgentController
|
|||
$client = $clientEntity->getEntity();
|
||||
|
||||
if (!$client->getIp()) {
|
||||
throw new BadRequestHttpException('IP is required');
|
||||
throw new ValidatorException('IP is required');
|
||||
}
|
||||
|
||||
if ($client->getStatus() === ClientStatus::OFF) {
|
||||
|
@ -68,7 +67,7 @@ class PowerOffAction extends AbstractOgAgentController
|
|||
);
|
||||
|
||||
if (isset($response['error']) && $response['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
throw new BadRequestHttpException('Error deploying image');
|
||||
throw new ValidatorException('Error deploying image');
|
||||
}
|
||||
|
||||
$this->logger->info('Powering off client', ['client' => $client->getId()]);
|
||||
|
|
|
@ -19,7 +19,6 @@ use Psr\Log\LoggerInterface;
|
|||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
|
@ -44,7 +43,7 @@ class RebootAction extends AbstractOgAgentController
|
|||
|
||||
|
||||
if (!$client->getIp()) {
|
||||
throw new BadRequestHttpException('IP is required');
|
||||
throw new ValidatorException('IP is required');
|
||||
}
|
||||
|
||||
$endpoint = $client->getStatus() === ClientStatus::OG_LIVE ? 'opengnsys/Reiniciar' : '/opengnsys/reboot';
|
||||
|
@ -56,7 +55,7 @@ class RebootAction extends AbstractOgAgentController
|
|||
|
||||
$response = $this->createRequest(
|
||||
method: 'POST',
|
||||
url: 'https://'.$client->getIp().':8000/'.$endpoint,
|
||||
url: 'http://'.$client->getIp().':8000/'.$endpoint,
|
||||
params: [
|
||||
'json' => $data,
|
||||
],
|
||||
|
@ -64,7 +63,7 @@ class RebootAction extends AbstractOgAgentController
|
|||
);
|
||||
|
||||
if (isset($response['error']) && $response['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
throw new BadRequestHttpException('Error deploying image');
|
||||
throw new ValidatorException('Error deploying image');
|
||||
}
|
||||
|
||||
$this->logger->info('Rebooting client', ['client' => $client->getId()]);
|
||||
|
|
|
@ -1,86 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\OgAgent;
|
||||
|
||||
use App\Dto\Input\BootClientsInput;
|
||||
use App\Entity\Client;
|
||||
use App\Entity\Partition;
|
||||
use App\Model\ClientStatus;
|
||||
use App\Model\CommandTypes;
|
||||
use App\Model\TraceStatus;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
|
||||
class RemoveCacheImageAction extends AbstractOgAgentController
|
||||
{
|
||||
/**
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
public function __invoke(BootClientsInput $input): JsonResponse
|
||||
{
|
||||
/** @var Partition $partition */
|
||||
$partition = $input->partition->getEntity();
|
||||
|
||||
foreach ($input->clients as $clientEntity) {
|
||||
/** @var Client $client */
|
||||
$client = $clientEntity->getEntity();
|
||||
|
||||
if (!$partition->getImage()) {
|
||||
throw new BadRequestHttpException('Image is required');
|
||||
}
|
||||
|
||||
if (!$client->getIp()) {
|
||||
throw new BadRequestHttpException('IP is required');
|
||||
}
|
||||
|
||||
if ($client->getStatus() !== ClientStatus::OG_LIVE) {
|
||||
throw new BadRequestHttpException('Client is not in OG_LIVE status');
|
||||
}
|
||||
|
||||
$script = `rm%20-r%20/opt/opengnsys/cache/opt/opengnsys/images/{$partition->getImage()->getName()}.*@'`;
|
||||
|
||||
$data = [
|
||||
'nfn' => 'EjecutarScript',
|
||||
'scp' => base64_encode($script),
|
||||
'ids' => '0'
|
||||
];
|
||||
|
||||
$response = $this->createRequest(
|
||||
method: 'POST',
|
||||
url: 'https://'.$client->getIp().':8000/opengnsys/EjecutarScript',
|
||||
params: [
|
||||
'json' => $data,
|
||||
],
|
||||
token: $client->getToken(),
|
||||
);
|
||||
|
||||
if (isset($response['error']) && $response['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
throw new BadRequestHttpException('Error logging in: '.$response['error']);
|
||||
}
|
||||
|
||||
$this->logger->info('Login client', ['client' => $client->getId()]);
|
||||
|
||||
$jobId = $response['job_id'];
|
||||
|
||||
$this->entityManager->persist($client);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$inputData = [
|
||||
'script' => $script,
|
||||
];
|
||||
|
||||
$this->createService->__invoke($client, CommandTypes::RUN_SCRIPT, TraceStatus::SUCCESS, $jobId, $inputData);
|
||||
}
|
||||
|
||||
return new JsonResponse(data: [], status: Response::HTTP_OK);
|
||||
}
|
||||
}
|
|
@ -14,7 +14,6 @@ use Psr\Log\LoggerInterface;
|
|||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
|
@ -38,7 +37,7 @@ class RunScriptAction extends AbstractOgAgentController
|
|||
$client = $clientEntity->getEntity();
|
||||
|
||||
if (!$client->getIp()) {
|
||||
throw new BadRequestHttpException('IP is required');
|
||||
throw new ValidatorException('IP is required');
|
||||
}
|
||||
|
||||
$data = [
|
||||
|
@ -57,7 +56,7 @@ class RunScriptAction extends AbstractOgAgentController
|
|||
);
|
||||
|
||||
if (isset($response['error']) && $response['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
throw new BadRequestHttpException('Error deploying image');
|
||||
throw new ValidatorException('Error deploying image');
|
||||
}
|
||||
|
||||
$this->logger->info('Powering off client', ['client' => $client->getId()]);
|
||||
|
@ -71,7 +70,7 @@ class RunScriptAction extends AbstractOgAgentController
|
|||
'script' => $input->script,
|
||||
];
|
||||
|
||||
$this->createService->__invoke($client, CommandTypes::RUN_SCRIPT, TraceStatus::IN_PROGRESS, $jobId, $inputData);
|
||||
$this->createService->__invoke($client, CommandTypes::RUN_SCRIPT, TraceStatus::SUCCESS, $jobId, $inputData);
|
||||
}
|
||||
|
||||
return new JsonResponse(data: [], status: Response::HTTP_OK);
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\OgAgent;
|
||||
|
||||
use App\Dto\Input\SoftwareInventoryPartitionInput;
|
||||
use App\Entity\Client;
|
||||
use App\Model\CommandTypes;
|
||||
use App\Model\TraceStatus;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
|
||||
class SoftwareInventoryAction extends AbstractOgAgentController
|
||||
{
|
||||
/**
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
public function __invoke(Client $client, SoftwareInventoryPartitionInput $input): JsonResponse
|
||||
{
|
||||
$data = [
|
||||
'nfn' => 'InventarioSoftware',
|
||||
'ids' => '0',
|
||||
'dsk' => (string) $input->partition->getEntity()->getDiskNumber(),
|
||||
'par' => (string) $input->partition->getEntity()->getPartitionNumber(),
|
||||
];
|
||||
|
||||
$response = $this->createRequest(
|
||||
method: 'POST',
|
||||
url: 'https://'.$client->getIp().':8000/opengnsys/InventarioSoftware',
|
||||
params: [
|
||||
'json' => $data,
|
||||
],
|
||||
token: $client->getToken(),
|
||||
);
|
||||
|
||||
if (isset($response['error']) && $response['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
throw new BadRequestHttpException('Error performing software inventory: '.$response['error']);
|
||||
}
|
||||
|
||||
$this->logger->info('Login client', ['client' => $client->getId()]);
|
||||
|
||||
$jobId = $response['job_id'];
|
||||
|
||||
$inputData = [
|
||||
'partition' => $input->partition->getEntity()->getUuid(),
|
||||
'image' => $input->partition->getEntity()->getImage()?->getUuid(),
|
||||
'client' => $client->getIp(),
|
||||
];
|
||||
|
||||
$this->createService->__invoke($client, CommandTypes::SOFTWARE_INVENTORY, TraceStatus::IN_PROGRESS, $jobId, $inputData);
|
||||
|
||||
return new JsonResponse(data: [], status: Response::HTTP_OK);
|
||||
}
|
||||
}
|
|
@ -16,7 +16,6 @@ use Symfony\Component\HttpClient\Internal\ClientState;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
|
@ -38,7 +37,7 @@ class StatusAction extends AbstractOgAgentController
|
|||
$response = null;
|
||||
|
||||
if (!$client->getIp()) {
|
||||
throw new BadRequestHttpException('IP is required');
|
||||
throw new ValidatorException('IP is required');
|
||||
}
|
||||
|
||||
if ($client->getStatus() === ClientStatus::OG_LIVE
|
||||
|
@ -88,8 +87,7 @@ class StatusAction extends AbstractOgAgentController
|
|||
$client->setStatus(ClientStatus::OFF);
|
||||
$this->entityManager->persist($client);
|
||||
$this->entityManager->flush();
|
||||
|
||||
throw new BadRequestHttpException('Error checking client status: ' . $data['error'] . ' (' . $data['details'] . ')');
|
||||
throw new ValidatorException('Error deploying image');
|
||||
}
|
||||
|
||||
if (isset($data['cfg'])) {
|
||||
|
@ -97,7 +95,6 @@ class StatusAction extends AbstractOgAgentController
|
|||
$this->createPartitionService->__invoke($data, $client);
|
||||
}
|
||||
|
||||
$client->setStatus(ClientStatus::OG_LIVE);
|
||||
$this->entityManager->persist($client);
|
||||
$this->entityManager->flush();
|
||||
|
||||
|
|
|
@ -38,9 +38,7 @@ class StatusController extends AbstractController
|
|||
const string CREATE_IMAGE = 'RESPUESTA_CrearImagen';
|
||||
const string RESTORE_IMAGE = 'RESPUESTA_RestaurarImagen';
|
||||
const string CONFIGURE_IMAGE = 'RESPUESTA_Configurar';
|
||||
const string HARDWARE_INVENTORY = 'RESPUESTA_InventarioHardware';
|
||||
const string SOFTWARE_INVENTORY = 'RESPUESTA_InventarioSoftware';
|
||||
const string RUN_SCRIPT = 'RESPUESTA_EjecutarScript';
|
||||
|
||||
|
||||
public function __construct(
|
||||
protected readonly EntityManagerInterface $entityManager,
|
||||
|
@ -182,54 +180,10 @@ class StatusController extends AbstractController
|
|||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
if (isset($data['nfn']) && $data['nfn'] === self::RUN_SCRIPT) {
|
||||
$trace = $this->entityManager->getRepository(Trace::class)->findOneBy(['jobId' => $data['job_id']]);
|
||||
if ($trace) {
|
||||
$trace->setStatus(TraceStatus::SUCCESS);
|
||||
$trace->setFinishedAt(new \DateTime());
|
||||
$this->entityManager->persist($trace);
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['nfn']) && $data['nfn'] === self::HARDWARE_INVENTORY) {
|
||||
$trace = $this->entityManager->getRepository(Trace::class)->findOneBy(['jobId' => $data['job_id']]);
|
||||
if ($trace) {
|
||||
$client = $trace->getClient();
|
||||
|
||||
$trace->setStatus(TraceStatus::SUCCESS);
|
||||
$trace->setFinishedAt(new \DateTime());
|
||||
$this->entityManager->persist($trace);
|
||||
|
||||
//$client->setHardwareProfile();
|
||||
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($data['nfn']) && $data['nfn'] === self::SOFTWARE_INVENTORY) {
|
||||
$trace = $this->entityManager->getRepository(Trace::class)->findOneBy(['jobId' => $data['job_id']]);
|
||||
|
||||
if ($trace) {
|
||||
$client = $trace->getClient();
|
||||
$dataInput = json_decode(json_encode($trace->getInput()), true);
|
||||
$imageUuid = $dataInput['image'] ?? null;
|
||||
|
||||
$trace->setStatus(TraceStatus::SUCCESS);
|
||||
$trace->setFinishedAt(new \DateTime());
|
||||
$this->entityManager->persist($trace);
|
||||
|
||||
$image = $this->entityManager->getRepository(ImageImageRepository::class)->findOneBy(['uuid' => $imageUuid]);
|
||||
$this->createSoftwareProfile($data['contents'], $image);
|
||||
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
}
|
||||
|
||||
return new JsonResponse(data: 'Webhook finished', status: Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function createSoftwareProfile(string $base64Data, ?ImageImageRepository $imageImageRepository = null): void
|
||||
public function createSoftwareProfile(string $base64Data, ImageImageRepository $imageImageRepository): void
|
||||
{
|
||||
$decodedData = base64_decode($base64Data);
|
||||
$this->logger->info('Software profile decoded', ['data' => '']);
|
||||
|
@ -246,10 +200,10 @@ class StatusController extends AbstractController
|
|||
$this->entityManager->persist($softwareEntity);
|
||||
}
|
||||
|
||||
$image = $imageImageRepository?->getImage();
|
||||
$image = $imageImageRepository->getImage();
|
||||
|
||||
$softwareProfile = new SoftwareProfile();
|
||||
$softwareProfile->setDescription('SW Profile - ' . $image->getClient()->getName());
|
||||
$softwareProfile->setDescription('Perfil software: ' . $image->getClient()->getName());
|
||||
$softwareProfile->setOrganizationalUnit($image->getClient()->getOrganizationalUnit());
|
||||
|
||||
foreach ($existingSoftware as $softwareEntity) {
|
||||
|
|
|
@ -9,7 +9,6 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
|
@ -38,10 +37,6 @@ class OgBootController extends AbstractController
|
|||
{
|
||||
$data = $this->ogbootStatusService->__invoke();
|
||||
|
||||
if (isset($data['error']) && $data['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
throw new BadRequestHttpException('An error occurred while fetching the status: ' . $data['details']);
|
||||
}
|
||||
|
||||
return new JsonResponse( data: $data, status: Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ use App\Entity\OgLive;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
|
@ -27,13 +26,13 @@ class GetAction extends AbstractOgBootController
|
|||
public function __invoke(OgLive $data): JsonResponse
|
||||
{
|
||||
if (!$data->getChecksum()) {
|
||||
throw new BadRequestHttpException('Checksum is required');
|
||||
throw new ValidatorException('Checksum is required');
|
||||
}
|
||||
|
||||
$content = $this->createRequest('GET', '/ogboot/v1/oglives/'.$data->getChecksum());
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new BadRequestHttpException('An error occurred while fetching the OgLive: ' . $content['error']. ' (' . $content['details'] . ')');
|
||||
if (isset($content['error']) && $content['error'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new ValidatorException('An error occurred: ' . $content['error']);
|
||||
}
|
||||
|
||||
return new JsonResponse(data: $content, status: Response::HTTP_OK);
|
||||
|
|
|
@ -6,7 +6,6 @@ use App\Controller\OgBoot\AbstractOgBootController;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
|
@ -26,8 +25,8 @@ class GetCollectionAction extends AbstractOgBootController
|
|||
{
|
||||
$content = $this->createRequest('GET', '/ogboot/v1/oglives');
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new BadRequestHttpException('An error occurred while fetching the collection: ' . $content['error']. ' (' . $content['details'] . ')');
|
||||
if (isset($content['error']) && $content['error'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new ValidatorException('An error occurred: ' . $content['error']);
|
||||
}
|
||||
|
||||
return new JsonResponse(data: $content, status: Response::HTTP_OK);
|
||||
|
|
|
@ -6,7 +6,6 @@ use App\Controller\OgBoot\AbstractOgBootController;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
|
@ -26,8 +25,8 @@ class GetDefaultAction extends AbstractOgBootController
|
|||
{
|
||||
$content = $this->createRequest('GET', '/ogboot/v1/oglives/default');
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new BadRequestHttpException('An error occurred: ' . $content['error']. ' (' . $content['details'] . ')');
|
||||
if (isset($content['error']) && $content['error'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new ValidatorException('An error occurred: ' . $content['error']);
|
||||
}
|
||||
|
||||
return new JsonResponse(status: Response::HTTP_OK);
|
||||
|
|
|
@ -7,7 +7,6 @@ use App\Entity\OgLive;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
|
@ -26,8 +25,8 @@ class GetIsosAction extends AbstractOgBootController
|
|||
{
|
||||
$content = $this->createRequest('GET', '/ogboot/v1/oglives/isos');
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new BadRequestHttpException('An error occurred while fetching ISOs: ' . $content['error']. ' (' . $content['details'] . ')');
|
||||
if (!isset($content['message']) || !is_array($content['message'])) {
|
||||
return new JsonResponse(data: ['error' => 'Invalid response'], status: Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
$isos = array_map(function ($iso) {
|
||||
|
|
|
@ -11,7 +11,6 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
|
@ -31,7 +30,7 @@ class InstallAction extends AbstractOgBootController
|
|||
public function __invoke(OgLive $data): JsonResponse
|
||||
{
|
||||
if (!$data->getDownloadUrl()) {
|
||||
throw new BadRequestHttpException('Download URL is required');
|
||||
throw new ValidatorException('Download URL is required');
|
||||
}
|
||||
|
||||
$params = [
|
||||
|
@ -48,13 +47,13 @@ class InstallAction extends AbstractOgBootController
|
|||
|
||||
$content = $this->createRequest('POST', '/ogboot/v1/oglives/install', $params);
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new BadRequestHttpException('An error occurred while installing OgLive: ' . $content['error']. ' (' . $content['details'] . ')');
|
||||
if (isset($content['error']) && $content['error'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new ValidatorException('An error occurred: ' . $content['error']);
|
||||
}
|
||||
|
||||
$this->createService->__invoke(null, CommandTypes::INSTALL_OGLIVE, TraceStatus::IN_PROGRESS, 'InstallOgLive_'.$data->getUuid(), $inputData);
|
||||
|
||||
$data->setName($this->simplifyOgLiveFilenameService->__invoke($data->getFilename()) ?? 'OgLive_'.$data->getUuid());
|
||||
$data->setName($this->simplifyOgLiveFilenameService->__invoke($data->getFilename()));
|
||||
$data->setDate(new \DateTime());
|
||||
$data->setStatus(OgLiveStatus::PENDING);
|
||||
$this->entityManager->persist($data);
|
||||
|
|
|
@ -8,7 +8,6 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
|
@ -28,7 +27,7 @@ class SetDefaultAction extends AbstractOgBootController
|
|||
public function __invoke(OgLive $data): JsonResponse
|
||||
{
|
||||
if (!$data->getChecksum()) {
|
||||
throw new BadRequestHttpException('Checksum URL is required');
|
||||
throw new ValidatorException('Checksum URL is required');
|
||||
}
|
||||
|
||||
$params = [
|
||||
|
@ -39,8 +38,8 @@ class SetDefaultAction extends AbstractOgBootController
|
|||
|
||||
$content = $this->createRequest('PUT', '/ogboot/v1/oglives/default', $params);
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new BadRequestHttpException('An error occurred: ' . $content['error'] . ' (' . $content['details'] . ')');
|
||||
if (isset($content['error']) && $content['error'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new ValidatorException('An error occurred: ' . $content['error']);
|
||||
}
|
||||
|
||||
$oldDefaultOgLive = $this->entityManager->getRepository(OgLive::class)->findBy(['isDefault' => true]);
|
||||
|
|
|
@ -9,7 +9,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
|
@ -32,8 +32,8 @@ class SyncAction extends AbstractOgBootController
|
|||
{
|
||||
$content = $this->createRequest('GET', '/ogboot/v1/oglives');
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new BadRequestHttpException('An error occurred while fetching ogLives: ' . $content['message'] . ' (' . $content['details'] . ')');
|
||||
if (isset($content['error']) && $content['error'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new ValidatorException('An error occurred: ' . $content['error']);
|
||||
}
|
||||
|
||||
$allOgLives = $this->entityManager->getRepository(OgLive::class)->findAll();
|
||||
|
@ -80,9 +80,7 @@ class SyncAction extends AbstractOgBootController
|
|||
*/
|
||||
private function extracted(OgLive $ogLiveEntity, mixed $ogLive): void
|
||||
{
|
||||
$name = $this->simplifyOgLiveFilenameService->__invoke(str_replace(self::OG_BOOT_DIRECTORY, '', $ogLive['directory']));
|
||||
|
||||
$ogLiveEntity->setName($name ? $name : str_replace(self::OG_BOOT_DIRECTORY, '', $ogLive['directory']));
|
||||
$ogLiveEntity->setName($this->simplifyOgLiveFilenameService->__invoke(str_replace(self::OG_BOOT_DIRECTORY, '', $ogLive['directory'])));
|
||||
$ogLiveEntity->setDate(new \DateTime($this->extractOgLiveFilenameDateService->__invoke(str_replace(self::OG_BOOT_DIRECTORY, '', $ogLive['directory']))));
|
||||
$ogLiveEntity->setInstalled(true);
|
||||
$ogLiveEntity->setArchitecture($ogLive['architecture']);
|
||||
|
|
|
@ -8,7 +8,6 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
|
@ -29,13 +28,13 @@ class UninstallAction extends AbstractOgBootController
|
|||
public function __invoke(OgLive $data): JsonResponse
|
||||
{
|
||||
if (!$data->getChecksum()) {
|
||||
throw new BadRequestHttpException('Checksum is required');
|
||||
throw new ValidatorException('Checksum is required');
|
||||
}
|
||||
|
||||
$content = $this->createRequest( 'DELETE', '/ogboot/v1/oglives/'.$data->getChecksum());
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new BadRequestHttpException('An error occurred while uninstalling the OgLive: ' . $content['error'] . ' (' . $content['details'] . ')');
|
||||
if (isset($content['error']) && $content['error'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new ValidatorException('An error occurred: ' . $content['error']);
|
||||
}
|
||||
|
||||
$this->entityManager->remove($data);
|
||||
|
|
|
@ -25,11 +25,13 @@ class DeleteAction extends AbstractOgBootController
|
|||
{
|
||||
$response = $this->createRequest('DELETE', '/ogboot/v1/pxes/'.$mac);
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
if ($response->getStatusCode() !== Response::HTTP_OK) {
|
||||
return new JsonResponse( data: 'An error occurred', status: Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
return new JsonResponse( data: [], status: Response::HTTP_OK);
|
||||
$data = json_decode($response->getContent(), true);
|
||||
|
||||
return new JsonResponse( data: $data, status: Response::HTTP_OK);
|
||||
|
||||
}
|
||||
}
|
|
@ -28,10 +28,12 @@ class GetAction extends AbstractOgBootController
|
|||
{
|
||||
$response = $this->createRequest('GET', '/ogboot/v1/pxes/'.$client->getName());
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
if ($response->getStatusCode() !== Response::HTTP_OK) {
|
||||
return new JsonResponse( data: 'An error occurred', status: Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
return new JsonResponse( data: $response, status: Response::HTTP_OK);
|
||||
$data = json_decode($response->getContent(), true);
|
||||
|
||||
return new JsonResponse( data: $data, status: Response::HTTP_OK);
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ class PostAction extends AbstractOgBootController
|
|||
?? $client->getOrganizationalUnit()?->getNetworkSettings()?->getRepository()?->getIp();
|
||||
|
||||
$ogLive = $client->getOgLive()?->getFilename()
|
||||
?? $client->getOrganizationalUnit()?->getNetworkSettings()?->getOgLive()?->getFilename();
|
||||
?? $client->getOrganizationalUnit()?->getNetworkSettings()?->getOgLive()->getFilename();
|
||||
|
||||
$params = [
|
||||
'json' => [
|
||||
|
@ -45,10 +45,10 @@ class PostAction extends AbstractOgBootController
|
|||
'server_ip' => $this->ogBootIp,
|
||||
'server_api_port' => $this->ogBootApiPort,
|
||||
'server_pxe_port' => $this->ogBootPxePort,
|
||||
'router' => $client->getOrganizationalUnit()->getNetworkSettings()?->getRouter(),
|
||||
'router' => $client->getOrganizationalUnit()->getNetworkSettings()->getRouter(),
|
||||
'netmask' => $client->getOrganizationalUnit()->getNetworkSettings() ? $client->getOrganizationalUnit()->getNetworkSettings()->getNetmask() : '255.255.255.0',
|
||||
'computer_name' => $client->getName(),
|
||||
'netiface' => $client->getNetiface() ? $client->getNetiface() : $client->getOrganizationalUnit()->getNetworkSettings()?->getNetiface(),
|
||||
'netiface' => $client->getNetiface() ? $client->getNetiface() : $client->getOrganizationalUnit()->getNetworkSettings()->getNetiface(),
|
||||
'group' => $client->getOrganizationalUnit()->getName(),
|
||||
'ogrepo' => $ogRepoIp,
|
||||
'ogcore' => $this->ogCoreIP,
|
||||
|
|
|
@ -10,7 +10,6 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
|
@ -35,7 +34,7 @@ class DeleteAction extends AbstractOgBootController
|
|||
$content = $this->createRequest('DELETE', '/ogboot/v1/pxe-templates/'.$data->getName());
|
||||
|
||||
if (isset($content['error']) && $content['error'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new BadRequestHttpException('An error occurred: ' . $content['error']);
|
||||
throw new ValidatorException('An error occurred: ' . $content['error']);
|
||||
}
|
||||
|
||||
$defaultTemplateEntity = $this->entityManager->getRepository(PxeTemplate::class)->findOneBy(['isDefault' => true]);
|
||||
|
|
|
@ -7,7 +7,6 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
|
@ -29,7 +28,7 @@ class GetCollectionAction extends AbstractOgBootController
|
|||
$content = $this->createRequest('GET', '/ogboot/v1/pxe-templates');
|
||||
|
||||
if (isset($content['error']) && $content['error'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new BadRequestHttpException('An error occurred: ' . $content['error']);
|
||||
throw new ValidatorException('An error occurred: ' . $content['error']);
|
||||
}
|
||||
|
||||
return new JsonResponse( data: $content, status: Response::HTTP_OK);
|
||||
|
|
|
@ -9,7 +9,6 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
|
@ -38,7 +37,7 @@ class PostAction extends AbstractOgBootController
|
|||
$content = $this->createRequest('POST', '/ogboot/v1/pxe-templates' , $params);
|
||||
|
||||
if (isset($content['error']) && $content['error'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new BadRequestHttpException('An error occurred: ' . $content['error']);
|
||||
throw new ValidatorException('An error occurred: ' . $content['error']);
|
||||
}
|
||||
|
||||
$data->setSynchronized(true);
|
||||
|
|
|
@ -10,7 +10,6 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
|
@ -53,7 +52,7 @@ class SyncAction extends AbstractOgBootController
|
|||
$templateContent = $this->createRequest('GET', '/ogboot/v1/pxe-templates/' . $templateEntity->getName());
|
||||
|
||||
if (isset($templateContent['error']) && $templateContent['error'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new BadRequestHttpException('An error occurred: ' . $templateContent['error']);
|
||||
throw new ValidatorException('An error occurred: ' . $templateContent['error']);
|
||||
}
|
||||
|
||||
$templateEntity->setTemplateContent($templateContent['template_content']);
|
||||
|
|
|
@ -7,8 +7,6 @@ use App\Entity\Subnet;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
|
@ -28,26 +26,14 @@ class DeleteAction extends AbstractOgDhcpController
|
|||
public function __invoke(Subnet $data, HttpClientInterface $httpClient): JsonResponse
|
||||
{
|
||||
if (!$data->getId()) {
|
||||
throw new BadRequestHttpException('Data Id is required');
|
||||
throw new ValidatorException('Data Id is required');
|
||||
}
|
||||
|
||||
try {
|
||||
$content = $this->createRequest(
|
||||
'DELETE',
|
||||
'http://' . $this->ogDhcpApiUrl . '/ogdhcp/v1/subnets/' . $data->getServerId()
|
||||
);
|
||||
} catch (HttpException $e) {
|
||||
if ($e->getStatusCode() === 404) {
|
||||
$content = ['message' => 'Subnet not found on external API, proceeding with local deletion'];
|
||||
} else {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
$content = $this->createRequest('DELETE', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId());
|
||||
|
||||
$this->entityManager->remove($data);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return new JsonResponse(data: $content, status: Response::HTTP_OK);
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,6 @@ use App\Entity\Subnet;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
|
@ -30,11 +29,11 @@ class DeleteHostAction extends AbstractOgDhcpController
|
|||
$client = $this->entityManager->getRepository(Client::class)->findOneBy(['uuid' => $clientUuid]);
|
||||
|
||||
if (!$client || $client->getSubnet() !== $data) {
|
||||
throw new BadRequestHttpException('Client not found');
|
||||
throw new ValidatorException('Client not found');
|
||||
}
|
||||
|
||||
if (!$data->getId()) {
|
||||
throw new BadRequestHttpException('Data URL is required');
|
||||
throw new ValidatorException('Data URL is required');
|
||||
}
|
||||
|
||||
$params = [
|
||||
|
|
|
@ -7,7 +7,6 @@ use App\Entity\Subnet;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
|
@ -27,7 +26,7 @@ class GetAction extends AbstractOgDhcpController
|
|||
public function __invoke(Subnet $data): JsonResponse
|
||||
{
|
||||
if (!$data->getId()) {
|
||||
throw new BadRequestHttpException('Checksum is required');
|
||||
throw new ValidatorException('Checksum is required');
|
||||
}
|
||||
|
||||
$content = $this->createRequest('GET', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId());
|
||||
|
|
|
@ -7,7 +7,6 @@ use App\Entity\Subnet;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
|
@ -27,7 +26,7 @@ class GetHostsAction extends AbstractOgDhcpController
|
|||
public function __invoke(Subnet $data): JsonResponse
|
||||
{
|
||||
if (!$data->getId()) {
|
||||
throw new BadRequestHttpException('Checksum is required');
|
||||
throw new ValidatorException('Checksum is required');
|
||||
}
|
||||
|
||||
$content = $this->createRequest('GET', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId().'/hosts');
|
||||
|
|
|
@ -53,15 +53,17 @@ class PostHostAction extends AbstractOgDhcpController
|
|||
$params
|
||||
);
|
||||
|
||||
// Guardar resultado exitoso
|
||||
$success[] = [
|
||||
'client' => $clientEntity->getName(),
|
||||
'response' => $content
|
||||
];
|
||||
|
||||
// Persistir solo si la llamada fue exitosa
|
||||
$subnet->addClient($clientEntity);
|
||||
$this->entityManager->persist($subnet);
|
||||
$this->entityManager->flush();
|
||||
} catch (\Throwable $e) {
|
||||
} catch (\Throwable $e) { // Capturar cualquier error sin interrumpir
|
||||
$errors[] = [
|
||||
'client' => $clientEntity->getName(),
|
||||
'error' => $e->getMessage()
|
||||
|
|
|
@ -7,7 +7,6 @@ use App\Entity\Subnet;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
|
@ -27,7 +26,7 @@ class PutAction extends AbstractOgDhcpController
|
|||
public function __invoke(Subnet $data): JsonResponse
|
||||
{
|
||||
if (!$data->getId()) {
|
||||
throw new BadRequestHttpException('Id is required');
|
||||
throw new ValidatorException('Id is required');
|
||||
}
|
||||
|
||||
$params = [
|
||||
|
|
|
@ -24,23 +24,26 @@ class PutHostAction extends AbstractOgDhcpController
|
|||
* @throws RedirectionExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
public function __invoke(string $mac, Client $client): JsonResponse
|
||||
public function __invoke(SubnetAddHostInput $input, Subnet $subnet): JsonResponse
|
||||
{
|
||||
$subnet = $client->getSubnet();
|
||||
$clients = $input->clients;
|
||||
|
||||
/** @var Client $clientEntity */
|
||||
$data = [
|
||||
'hostname' => $client->getName(),
|
||||
'oldMacAddress' => strtolower($mac),
|
||||
'macAddress' => strtolower($client->getMac()),
|
||||
'address' => $client->getIp(),
|
||||
];
|
||||
foreach ($clients as $client) {
|
||||
/** @var Client $clientEntity */
|
||||
$clientEntity = $client->getEntity();
|
||||
$data = [
|
||||
'host' => $clientEntity->getName(),
|
||||
'oldMacAddress' => '',
|
||||
'macAddress' => '',
|
||||
'address' => '',
|
||||
];
|
||||
|
||||
$params = [
|
||||
'json' => $data
|
||||
];
|
||||
$params = [
|
||||
'json' => $data
|
||||
];
|
||||
|
||||
$content = $this->createRequest('PUT', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$subnet->getServerId().'/hosts', $params);
|
||||
$content = $this->createRequest('PUT', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$subnet->getId().'/hosts', $params);
|
||||
}
|
||||
|
||||
return new JsonResponse(status: Response::HTTP_OK);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ use App\Entity\ImageRepository;
|
|||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
|
@ -35,7 +34,7 @@ class CreateRepositoryAction extends AbstractOgRepositoryController
|
|||
$content = $this->createRequest('POST', 'http://'.$repository->getIp().':8006/ogrepository/v1/git/repositories', $params);
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new BadRequestHttpException('Error creating repository');
|
||||
throw new ValidatorException('Error creating repository');
|
||||
}
|
||||
|
||||
return new JsonResponse(data: [], status: Response::HTTP_OK);
|
||||
|
|
|
@ -9,7 +9,6 @@ use App\Entity\ImageRepository;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
|
@ -39,7 +38,7 @@ class CreateTagAction extends AbstractOgRepositoryController
|
|||
$image->getName().'/tags', $params);
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new BadRequestHttpException('Error creating repository');
|
||||
throw new ValidatorException('Error creating repository');
|
||||
}
|
||||
|
||||
return new JsonResponse(data: [], status: Response::HTTP_OK);
|
||||
|
|
|
@ -7,7 +7,6 @@ use App\Entity\GitImageRepository;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
|
@ -31,7 +30,7 @@ class GetTagsAction extends AbstractOgRepositoryController
|
|||
$content = $this->createRequest('GET', 'http://'.$repository->getIp().':8006/ogrepository/v1/git/repositories/'.$image->getName().'/tags');
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new BadRequestHttpException('Error getting tags');
|
||||
throw new ValidatorException('Error getting tags');
|
||||
}
|
||||
|
||||
return new JsonResponse(data: $content, status: Response::HTTP_OK);
|
||||
|
|
|
@ -14,7 +14,7 @@ use App\Model\TraceStatus;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
|
@ -35,7 +35,7 @@ class BackupImageAction extends AbstractOgRepositoryController
|
|||
$repository = $imageImageRepository->getRepository();
|
||||
|
||||
if (!$image->getName()) {
|
||||
throw new BadRequestHttpException('Name is required');
|
||||
throw new ValidatorException('Name is required');
|
||||
}
|
||||
|
||||
$params = [
|
||||
|
@ -54,10 +54,6 @@ class BackupImageAction extends AbstractOgRepositoryController
|
|||
|
||||
$content = $this->createRequest('PUT', 'http://'.$repository->getIp().':8006/ogrepository/v1/repo/images', $params);
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new BadRequestHttpException('Error backing up image: ' . $content['error'] . ' - ' . $content['details']);
|
||||
}
|
||||
|
||||
$inputData = [
|
||||
'imageName' => $image->getName(),
|
||||
'repositoryUuid' => $repository->getUuid(),
|
||||
|
|
|
@ -13,7 +13,7 @@ use App\Model\TraceStatus;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
|
@ -32,25 +32,25 @@ class CancelTransmissionAction extends AbstractOgRepositoryController
|
|||
public function __invoke(Trace $data): JsonResponse
|
||||
{
|
||||
if ($data->getCommand() !== CommandTypes::DEPLOY_IMAGE) {
|
||||
throw new BadRequestHttpException('Command is not DEPLOY_IMAGE');
|
||||
throw new ValidatorException('Command is not DEPLOY_IMAGE');
|
||||
}
|
||||
|
||||
$input = $data->getInput();
|
||||
|
||||
if (!isset($input['client']) || !isset($input['image']) || !isset($input['method'])) {
|
||||
throw new BadRequestHttpException('Client, image and method are required');
|
||||
throw new ValidatorException('Client, image and method are required');
|
||||
}
|
||||
$client = $this->entityManager->getRepository(Client::class)->findOneBy(['uuid' => $input['client']]);
|
||||
$image = $this->entityManager->getRepository(ImageImageRepository::class)->findOneBy(['uuid' => $input['image']]);
|
||||
|
||||
if (!$client || !$image) {
|
||||
throw new BadRequestHttpException('Client or image not found');
|
||||
throw new ValidatorException('Client or image not found');
|
||||
}
|
||||
|
||||
$method = $input['method'];
|
||||
|
||||
if (!$image->getImageFullsum()) {
|
||||
throw new BadRequestHttpException('Fullsum is required');
|
||||
throw new ValidatorException('Fullsum is required');
|
||||
}
|
||||
|
||||
if ($method === DeployMethodTypes::TORRENT) {
|
||||
|
@ -60,7 +60,7 @@ class CancelTransmissionAction extends AbstractOgRepositoryController
|
|||
}
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new BadRequestHttpException('Error cancelling transmission: ' . $content['details']);
|
||||
throw new ValidatorException('Error cancelling transmission');
|
||||
}
|
||||
|
||||
$data->setStatus(TraceStatus::CANCELLED);
|
||||
|
|
|
@ -14,8 +14,8 @@ use App\Model\TraceStatus;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
|
@ -40,7 +40,6 @@ class ConvertAction extends AbstractOgRepositoryController
|
|||
if (!$imageEntity){
|
||||
$imageEntity = new Image();
|
||||
$imageEntity->setName($image);
|
||||
$imageEntity->setType('monolithic');
|
||||
$imageEntity->setRemotePc(false);
|
||||
$imageEntity->setIsGlobal(false);
|
||||
|
||||
|
@ -50,7 +49,7 @@ class ConvertAction extends AbstractOgRepositoryController
|
|||
$imageImageRepositoryEntity = $this->entityManager->getRepository(ImageImageRepository::class)->findOneBy(['image' => $imageEntity, 'repository' => $repository]);
|
||||
|
||||
if ($imageImageRepositoryEntity){
|
||||
throw new BadRequestHttpException('This image already exists in this repository');
|
||||
throw new ValidatorException('This image already exists in this repository');
|
||||
}
|
||||
|
||||
$imageImageRepositoryEntity = new ImageImageRepository();
|
||||
|
@ -74,7 +73,7 @@ class ConvertAction extends AbstractOgRepositoryController
|
|||
$content = $this->createRequest('POST', 'http://'.$repository->getIp().':8006/ogrepository/v1/images/virtual', $params);
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new BadRequestHttpException('An error occurred while converting the image: ' . $content['error'] . ' - ' . $content['details']);
|
||||
throw new ValidatorException('Error converting image');
|
||||
}
|
||||
$this->entityManager->flush();
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ use App\Model\TraceStatus;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
|
@ -32,7 +32,7 @@ class ConvertImageToVirtualAction extends AbstractOgRepositoryController
|
|||
$image = $imageImageRepository->getImage();
|
||||
|
||||
if (!$image->getName()) {
|
||||
throw new BadRequestHttpException('Name is required');
|
||||
throw new ValidatorException('Name is required');
|
||||
}
|
||||
|
||||
$params = [
|
||||
|
@ -48,8 +48,8 @@ class ConvertImageToVirtualAction extends AbstractOgRepositoryController
|
|||
|
||||
$content = $this->createRequest('PUT', 'http://'.$repository->getIp().':8006/ogrepository/v1/images/virtual', $params);
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
throw new BadRequestHttpException('An error occurred while converting the image to virtual: ' . $content['error']);
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new ValidatorException('Error converting image');
|
||||
}
|
||||
|
||||
$inputData = [
|
||||
|
|
|
@ -13,7 +13,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
|
@ -34,7 +34,7 @@ class CreateAuxFilesAction extends AbstractOgRepositoryController
|
|||
$image = $data->getImage();
|
||||
|
||||
if (!$image->getName()) {
|
||||
throw new BadRequestHttpException('Name is required');
|
||||
throw new ValidatorException('Name is required');
|
||||
}
|
||||
|
||||
$params = [
|
||||
|
@ -49,10 +49,6 @@ class CreateAuxFilesAction extends AbstractOgRepositoryController
|
|||
|
||||
$content = $this->createRequest('POST', 'http://'.$repository->getIp().':8006/ogrepository/v1/images/torrentsum', $params);
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
throw new BadRequestHttpException('An error occurred while creating aux files: ' . $content['error'] . ' - ' . $content['details']);
|
||||
}
|
||||
|
||||
$inputData = [
|
||||
'imageName' => $data->getName(),
|
||||
'imageImageRepositoryUuid' => $data->getUuid(),
|
||||
|
|
|
@ -9,7 +9,7 @@ use App\Entity\ImageRepository;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
|
@ -28,7 +28,7 @@ class DeletePermanentAction extends AbstractOgRepositoryController
|
|||
public function __invoke(ImageImageRepository $data, HttpClientInterface $httpClient): JsonResponse
|
||||
{
|
||||
if (!$data->getImageFullsum()) {
|
||||
throw new BadRequestHttpException('Fullsum is required');
|
||||
throw new ValidatorException('Fullsum is required');
|
||||
}
|
||||
|
||||
/** @var ImageRepository $image */
|
||||
|
|
|
@ -11,7 +11,7 @@ use App\Model\ImageStatus;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
|
@ -32,7 +32,7 @@ class DeleteTrashAction extends AbstractOgRepositoryController
|
|||
$image = $imageImageRepository->getImage();
|
||||
|
||||
if (!$imageImageRepository->getImageFullsum()) {
|
||||
throw new BadRequestHttpException('Fullsum is required');
|
||||
throw new ValidatorException('Fullsum is required');
|
||||
}
|
||||
|
||||
$this->logger->info('Deleting image', ['image' => $image->getName()]);
|
||||
|
|
|
@ -8,7 +8,7 @@ use App\Entity\ImageImageRepository;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
|
@ -27,15 +27,11 @@ class GetAction extends AbstractOgRepositoryController
|
|||
public function __invoke(ImageImageRepository $data): JsonResponse
|
||||
{
|
||||
if (!$data->getImageFullsum()) {
|
||||
throw new BadRequestHttpException('Fullsum is required');
|
||||
throw new ValidatorException('Fullsum is required');
|
||||
}
|
||||
|
||||
$content = $this->createRequest('GET', 'http://'.$data->getRepository()->getIp().':8006/ogrepository/v1/images/'.$data->getImageFullsum());
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
throw new BadRequestHttpException('An error occurred while fetching the image: ' . $content['details']);
|
||||
}
|
||||
|
||||
return new JsonResponse(data: $content, status: Response::HTTP_OK);
|
||||
}
|
||||
}
|
|
@ -7,7 +7,6 @@ use App\Entity\ImageRepository;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
|
@ -26,10 +25,6 @@ class GetCollectionAction extends AbstractOgRepositoryController
|
|||
{
|
||||
$content = $this->createRequest('GET', 'http://'.$data->getIp(). ':8006/ogrepository/v1/images');
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
throw new BadRequestHttpException('An error occurred while fetching the image collection: ' . $content['details']);
|
||||
}
|
||||
|
||||
return new JsonResponse( data: $content, status: Response::HTTP_OK);
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ use App\Entity\ImageImageRepository;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
|
@ -27,13 +27,13 @@ class GetStatusAction extends AbstractOgRepositoryController
|
|||
public function __invoke(ImageImageRepository $data): JsonResponse
|
||||
{
|
||||
if (!$data->getImageFullsum()) {
|
||||
throw new BadRequestHttpException('Fullsum is required');
|
||||
throw new ValidatorException('Fullsum is required');
|
||||
}
|
||||
|
||||
$content = $this->createRequest('GET', 'http://'.$data->getRepository()->getIp().':8006/ogrepository/v1/status/images/'.$data->getImageFullsum());
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
throw new BadRequestHttpException('An error occurred while fetching the image status: ' . $content['details']);
|
||||
if (isset($content['error']) && $content['error'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new ValidatorException('Error getting status');
|
||||
}
|
||||
|
||||
return new JsonResponse(data: $content, status: Response::HTTP_OK);
|
||||
|
|
|
@ -13,8 +13,8 @@ use App\Model\TraceStatus;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
|
@ -31,12 +31,6 @@ class ImportAction extends AbstractOgRepositoryController
|
|||
*/
|
||||
public function __invoke(ImportImageRepositoryInput $input, ImageRepository $repository): JsonResponse
|
||||
{
|
||||
$content = $this->createRequest('GET', 'http://'.$repository->getIp(). ':8006/ogrepository/v1/status');
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
throw new BadRequestHttpException('An error occurred while fetching the status: ' . $content['details']);
|
||||
}
|
||||
|
||||
$image = $input->name;
|
||||
|
||||
$imageEntity = $this->entityManager->getRepository(Image::class)->findOneBy(['name' => $image]);
|
||||
|
@ -44,7 +38,6 @@ class ImportAction extends AbstractOgRepositoryController
|
|||
if (!$imageEntity){
|
||||
$imageEntity = new Image();
|
||||
$imageEntity->setName($image);
|
||||
$imageEntity->setType('monolithic');
|
||||
$imageEntity->setRemotePc(false);
|
||||
$imageEntity->setIsGlobal(false);
|
||||
|
||||
|
@ -54,7 +47,7 @@ class ImportAction extends AbstractOgRepositoryController
|
|||
$imageImageRepositoryEntity = $this->entityManager->getRepository(ImageImageRepository::class)->findOneBy(['image' => $imageEntity, 'repository' => $repository]);
|
||||
|
||||
if ($imageImageRepositoryEntity){
|
||||
throw new BadRequestHttpException('This image already exists in this repository');
|
||||
throw new ValidatorException('This image already exists in this repository');
|
||||
}
|
||||
|
||||
$imageImageRepositoryEntity = new ImageImageRepository();
|
||||
|
@ -78,7 +71,7 @@ class ImportAction extends AbstractOgRepositoryController
|
|||
$content = $this->createRequest('POST', 'http://'.$repository->getIp().':8006/ogrepository/v1/images/torrentsum', $params);
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new BadRequestHttpException('Error importing image' . ' - ' . $content['error'] . ' - ' . $content['details']);
|
||||
throw new ValidatorException('Error importing image');
|
||||
}
|
||||
|
||||
$inputData = [
|
||||
|
|
|
@ -12,7 +12,7 @@ use App\Model\TraceStatus;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
|
@ -31,7 +31,7 @@ class RecoverAction extends AbstractOgRepositoryController
|
|||
public function __invoke(ImageImageRepository $data, HttpClientInterface $httpClient): JsonResponse
|
||||
{
|
||||
if (!$data->getImageFullsum()) {
|
||||
throw new BadRequestHttpException('Fullsum is required');
|
||||
throw new ValidatorException('Fullsum is required');
|
||||
}
|
||||
|
||||
$image = $data->getImage();
|
||||
|
@ -48,10 +48,6 @@ class RecoverAction extends AbstractOgRepositoryController
|
|||
|
||||
$content = $this->createRequest('POST', 'http://'.$repository->getIp().':8006/ogrepository/v1/trash/images', $params);
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
throw new BadRequestHttpException('An error occurred while recovering the image: ' . $content['error'] . ' - ' . $content['details']);
|
||||
}
|
||||
|
||||
$this->logger->info('Image recovered successfully', ['image' => $image->getName()]);
|
||||
|
||||
$data->setStatus(ImageStatus::SUCCESS);
|
||||
|
|
|
@ -14,7 +14,7 @@ use App\Model\TraceStatus;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
|
@ -69,7 +69,7 @@ class RenameAction extends AbstractOgRepositoryController
|
|||
$this->entityManager->flush();
|
||||
|
||||
if ($hasError) {
|
||||
throw new BadRequestHttpException('An error occurred while renaming the image: ' . $content['error'] . ' - ' . $content['details']);
|
||||
return new JsonResponse(['error' => 'Error renaming image'], Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
return new JsonResponse([], Response::HTTP_OK);
|
||||
|
@ -112,7 +112,6 @@ class RenameAction extends AbstractOgRepositoryController
|
|||
'http://' . $repository->getRepository()->getIp() . ':8006/ogrepository/v1/images/rename',
|
||||
$params
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
private function jsonError(string $message): JsonResponse
|
||||
|
|
|
@ -14,7 +14,7 @@ use App\Model\TraceStatus;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
|
@ -40,7 +40,7 @@ class TransferAction extends AbstractOgRepositoryController
|
|||
$image = $imageImageRepository->getImage();
|
||||
|
||||
if (!$imageImageRepository->getImageFullsum()) {
|
||||
throw new BadRequestHttpException('Fullsum is required');
|
||||
throw new ValidatorException('Fullsum is required');
|
||||
}
|
||||
|
||||
$params = [
|
||||
|
@ -56,8 +56,8 @@ class TransferAction extends AbstractOgRepositoryController
|
|||
|
||||
$content = $this->createRequest('POST', 'http://'.$repository->getIp().':8006/ogrepository/v1/repo/images', $params);
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
throw new BadRequestHttpException('Error transferring image: ' . $content['error']);
|
||||
if (!isset($content['job_id'])) {
|
||||
throw new ValidatorException('Job ID not found');
|
||||
}
|
||||
|
||||
$inputData = [
|
||||
|
|
|
@ -14,7 +14,7 @@ use Doctrine\Common\Collections\ArrayCollection;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
|
@ -58,7 +58,7 @@ class TransferGlobalAction extends AbstractOgRepositoryController
|
|||
$content = $this->createRequest('POST', 'http://'.$repository->getIp().':8006/ogrepository/v1/repo/images', $params);
|
||||
|
||||
if (!isset($content['job_id'])) {
|
||||
throw new BadRequestHttpException('Job ID not found');
|
||||
throw new ValidatorException('Job ID not found');
|
||||
}
|
||||
|
||||
$inputData = [
|
||||
|
|
|
@ -6,7 +6,6 @@ use App\Entity\ImageRepository;
|
|||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
|
@ -26,10 +25,6 @@ class StatusAction extends AbstractOgRepositoryController
|
|||
{
|
||||
$content = $this->createRequest('GET', 'http://'.$data->getIp(). ':8006/ogrepository/v1/status');
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||
throw new BadRequestHttpException('An error occurred while fetching the status: ' . $content['details']);
|
||||
}
|
||||
|
||||
return new JsonResponse( data: $content, status: Response::HTTP_OK);
|
||||
}
|
||||
}
|
|
@ -20,7 +20,6 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
|
@ -45,7 +44,7 @@ class WoLAction extends AbstractOgRepositoryController
|
|||
$repository = $client->getRepository();
|
||||
|
||||
if (!$repository->getIp()) {
|
||||
throw new BadRequestHttpException('IP is required');
|
||||
throw new ValidatorException('IP is required');
|
||||
}
|
||||
|
||||
$params = [
|
||||
|
@ -59,7 +58,7 @@ class WoLAction extends AbstractOgRepositoryController
|
|||
|
||||
$content = $this->createRequest('POST', 'http://'.$repository->getIp(). ':8006/ogrepository/v1/wol', $params);
|
||||
|
||||
if (isset($content['error']) && $content['code'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
if (isset($content['error']) && $content['error'] === Response::HTTP_INTERNAL_SERVER_ERROR ) {
|
||||
$this->logger->error('Error sending WoL to client', ['mac' => $client->getMac()]);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -2,20 +2,7 @@
|
|||
|
||||
namespace App\Dto\Input;
|
||||
|
||||
use App\Dto\Output\ClientOutput;
|
||||
use App\Dto\Output\PartitionOutput;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
final class BootClientsInput
|
||||
class BootClientInput
|
||||
{
|
||||
/**
|
||||
* @var ClientOutput[]
|
||||
*/
|
||||
#[Groups(['client:write'])]
|
||||
public array $clients = [];
|
||||
|
||||
|
||||
#[Groups(['client:write'])]
|
||||
public ?PartitionOutput $partition = null;
|
||||
}
|
||||
|
||||
}
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Dto\Input;
|
||||
|
||||
use App\Dto\Output\ClientOutput;
|
||||
use App\Dto\Output\OrganizationalUnitOutput;
|
||||
use App\Entity\Client;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
@ -11,13 +10,13 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
final class ChangeOrganizationalUnitInput
|
||||
{
|
||||
/**
|
||||
* @var ClientOutput[]
|
||||
* @var Client[]
|
||||
*/
|
||||
#[Assert\GreaterThan(1)]
|
||||
#[Groups(['client:write'])]
|
||||
#[Groups(['user-group:write'])]
|
||||
public ?array $clients = [];
|
||||
|
||||
#[Assert\NotNull]
|
||||
#[Groups(['client:write'])]
|
||||
#[Groups(['user-group:write'])]
|
||||
public ?OrganizationalUnitOutput $organizationalUnit = null;
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dto\Input;
|
||||
|
||||
use App\Dto\Output\PartitionOutput;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
class SoftwareInventoryPartitionInput
|
||||
{
|
||||
#[Assert\NotNull]
|
||||
#[Groups(['client:write'])]
|
||||
public ?PartitionOutput $partition = null;
|
||||
}
|
|
@ -18,7 +18,7 @@ class ImageImageRepositoryOutput extends AbstractOutput
|
|||
#[Groups(['image-image-repository:read', 'image:read'])]
|
||||
public string $status;
|
||||
|
||||
#[Groups(['image-image-repository:read', 'image:read', 'partition:read', 'client:read'])]
|
||||
#[Groups(['image-image-repository:read', 'image:read', 'partition:read'])]
|
||||
public string $name;
|
||||
|
||||
#[Groups(['image-image-repository:read', 'image:read'])]
|
||||
|
|
|
@ -39,7 +39,7 @@ class Partition extends AbstractEntity
|
|||
private ?OperativeSystem $operativeSystem = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'partitions')]
|
||||
#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
private ?ImageImageRepository $image = null;
|
||||
|
||||
public function getDiskNumber(): ?int
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace App\EventListener;
|
|||
|
||||
use App\Controller\OgBoot\PxeBootFile\DeleteAction;
|
||||
use App\Controller\OgBoot\PxeBootFile\PostAction;
|
||||
use App\Controller\OgDhcp\Subnet\PutHostAction;
|
||||
use App\Entity\Client;
|
||||
use Doctrine\Bundle\DoctrineBundle\Attribute\AsEntityListener;
|
||||
use Doctrine\ORM\Event\PreUpdateEventArgs;
|
||||
|
@ -19,7 +18,6 @@ readonly class ClientMacListener
|
|||
{
|
||||
public function __construct(
|
||||
private DeleteAction $deleteAction,
|
||||
private PutHostAction $putHostAction,
|
||||
)
|
||||
{
|
||||
|
||||
|
@ -47,7 +45,7 @@ readonly class ClientMacListener
|
|||
return;
|
||||
}
|
||||
|
||||
$this->putHostAction->__invoke($oldMac, $client);
|
||||
$this->deleteAction->__invoke($oldMac);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\EventSubscriber;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
|
||||
readonly class ApiExceptionSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly RequestStack $requestStack,
|
||||
private readonly KernelInterface $kernel,
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
ExceptionEvent::class => 'onKernelException',
|
||||
];
|
||||
}
|
||||
|
||||
public function onKernelException(ExceptionEvent $event): void
|
||||
{
|
||||
if ($this->kernel->getEnvironment() === 'dev') {
|
||||
return;
|
||||
}
|
||||
|
||||
$exception = $event->getThrowable();
|
||||
$statusCode = $exception instanceof HttpExceptionInterface ? $exception->getStatusCode() : 500;
|
||||
$message = $exception->getMessage();
|
||||
|
||||
$data = [
|
||||
'@context' => '/contexts/Error',
|
||||
'@type' => 'hydra:Error',
|
||||
'hydra:title' => 'An error occurred',
|
||||
'hydra:description' => $message,
|
||||
];
|
||||
|
||||
$response = new JsonResponse($data, $statusCode);
|
||||
$event->setResponse($response);
|
||||
}
|
||||
|
||||
}
|
|
@ -4,11 +4,8 @@ namespace App\EventSubscriber;
|
|||
|
||||
use ApiPlatform\Symfony\EventListener\EventPriorities;
|
||||
use App\Controller\OgBoot\PxeBootFile\PostAction;
|
||||
use App\Controller\OgDhcp\Subnet\PutHostAction;
|
||||
use App\Dto\Output\ClientOutput;
|
||||
use App\Entity\Client;
|
||||
use App\Entity\PxeTemplate;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Event\ViewEvent;
|
||||
|
@ -21,9 +18,7 @@ use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
|||
final readonly class ClientSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private PostAction $postAction,
|
||||
private PutHostAction $putHostAction,
|
||||
)
|
||||
{
|
||||
|
||||
|
@ -54,23 +49,14 @@ final readonly class ClientSubscriber implements EventSubscriberInterface
|
|||
/** @var Client $client */
|
||||
$client = $clientOutput->getEntity();
|
||||
|
||||
$template = $client->getTemplate() ?
|
||||
$template = !$client->getTemplate() ?
|
||||
$client->getTemplate() :
|
||||
$client->getOrganizationalUnit()?->getNetworkSettings()?->getPxeTemplate();
|
||||
|
||||
if ($template === null) {
|
||||
$template = $this->entityManager->getRepository(PxeTemplate::class)->findOneBy(['isDefault' => true]);
|
||||
|
||||
if ($template === null) {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$this->postAction->__invoke($client, $template);
|
||||
|
||||
if (!$client->getSubnet()) {
|
||||
return;
|
||||
}
|
||||
$this->putHostAction->__invoke($client->getMac(), $client);
|
||||
}
|
||||
}
|
|
@ -63,25 +63,15 @@ class MercureSubscriber implements EventSubscriberInterface
|
|||
'status' => $client->getStatus(),
|
||||
];
|
||||
|
||||
try {
|
||||
$update = new Update(
|
||||
'clients',
|
||||
json_encode($data)
|
||||
);
|
||||
$update = new Update(
|
||||
'clients',
|
||||
json_encode($data)
|
||||
);
|
||||
$this->hub->publish($update);
|
||||
|
||||
$this->hub->publish($update);
|
||||
|
||||
$this->logger->info('Evento Mercure disparado', [
|
||||
'method' => $method,
|
||||
'path' => $request->getPathInfo()
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->error('Error setting method for Mercure update', [
|
||||
'method' => $method,
|
||||
'path' => $request->getPathInfo(),
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
return;
|
||||
}
|
||||
$this->logger->info('Evento Mercure disparado', [
|
||||
'method' => $method,
|
||||
'path' => $request->getPathInfo()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ final readonly class OrganizationalUnitSubscriber implements EventSubscriberInte
|
|||
return;
|
||||
}
|
||||
|
||||
$newNetworkSettings = $this->cloneNetworkSettings($organizationalUnitEntity->getNetworkSettings());
|
||||
$newNetworkSettings = $this->buildNetworkSettings($organizationalUnitEntity);
|
||||
|
||||
$this->updateChildrenNetworkSettings($organizationalUnitEntity, $newNetworkSettings);
|
||||
|
||||
|
@ -76,7 +76,6 @@ final readonly class OrganizationalUnitSubscriber implements EventSubscriberInte
|
|||
if ($childUnit->isExcludeParentChanges()) {
|
||||
$childUnit->setNetworkSettings(null);
|
||||
} else{
|
||||
|
||||
$childUnit->setNetworkSettings($networkSettings);
|
||||
|
||||
foreach ($childUnit->getClients() as $client) {
|
||||
|
@ -86,6 +85,7 @@ final readonly class OrganizationalUnitSubscriber implements EventSubscriberInte
|
|||
$client->setTemplate($networkSettings->getPxeTemplate());
|
||||
$this->entityManager->persist($client);
|
||||
}
|
||||
|
||||
}
|
||||
$this->entityManager->persist($childUnit);
|
||||
$this->entityManager->flush();
|
||||
|
@ -94,31 +94,6 @@ final readonly class OrganizationalUnitSubscriber implements EventSubscriberInte
|
|||
}
|
||||
}
|
||||
|
||||
private function cloneNetworkSettings(NetworkSettings $original): NetworkSettings
|
||||
{
|
||||
$cloned = new NetworkSettings();
|
||||
|
||||
$cloned->setNextServer($original->getNextServer());
|
||||
$cloned->setBootFileName($original->getBootFileName());
|
||||
$cloned->setProxy($original->getProxy());
|
||||
$cloned->setDns($original->getDns());
|
||||
$cloned->setNetmask($original->getNetmask());
|
||||
$cloned->setRouter($original->getRouter());
|
||||
$cloned->setP2pTime($original->getP2pTime());
|
||||
$cloned->setP2pMode($original->getP2pMode());
|
||||
$cloned->setMcastMode($original->getMcastMode());
|
||||
$cloned->setMcastIp($original->getMcastIp());
|
||||
$cloned->setMcastPort($original->getMcastPort());
|
||||
$cloned->setMcastSpeed($original->getMcastSpeed());
|
||||
$cloned->setMenu($original->getMenu());
|
||||
$cloned->setRepository($original->getRepository());
|
||||
$cloned->setOgLive($original->getOgLive());
|
||||
$cloned->setPxeTemplate($original->getPxeTemplate());
|
||||
$cloned->setNetiface($original->getNetiface());
|
||||
|
||||
return $cloned;
|
||||
}
|
||||
|
||||
private function buildNetworkSettings($organizationalUnitEntity): NetworkSettings
|
||||
{
|
||||
if ($organizationalUnitEntity->getNetworkSettings() === null) {
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filter;
|
||||
|
||||
use ApiPlatform\Doctrine\Orm\Filter\AbstractFilter;
|
||||
use ApiPlatform\Doctrine\Orm\Util\QueryNameGeneratorInterface;
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use Symfony\Component\PropertyInfo\Type;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
|
||||
class SoftwareProfileSearchSoftwareFilter extends AbstractFilter
|
||||
{
|
||||
protected function filterProperty(string $property, $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
|
||||
{
|
||||
if ($property !== 'softwareProfileId') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (null === $value || '' === $value || 'undefined' === $value) {
|
||||
return;
|
||||
}
|
||||
|
||||
$alias = $queryBuilder->getRootAliases()[0];
|
||||
$joinAlias = $queryNameGenerator->generateJoinAlias('softwareProfileId');
|
||||
|
||||
$queryBuilder
|
||||
->innerJoin(sprintf('%s.softwareProfiles', $alias), $joinAlias)
|
||||
->andWhere(sprintf('%s.id = :softwareProfileId', $joinAlias))
|
||||
->setParameter('softwareProfileId', $value);
|
||||
}
|
||||
|
||||
public function getDescription(string $resourceClass): array
|
||||
{
|
||||
return [
|
||||
'softwareProfileId' => [
|
||||
'property' => 'softwareProfileId',
|
||||
'type' => Type::BUILTIN_TYPE_INT,
|
||||
'required' => false,
|
||||
'description' => 'Filter software profiles by ID.',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
|
@ -23,9 +23,6 @@ final class CommandTypes
|
|||
public const string PARTITION_AND_FORMAT = 'partition-and-format';
|
||||
public const string INSTALL_OGLIVE = 'install-oglive';
|
||||
public const string RUN_SCRIPT = 'run-script';
|
||||
public const string REMOVE_CACHE_IMAGE = 'remove-cache-image';
|
||||
public const string HARDWARE_INVENTORY = 'hardware-inventory';
|
||||
public const string SOFTWARE_INVENTORY = 'software-inventory';
|
||||
|
||||
private const array COMMAND_TYPES = [
|
||||
self::DEPLOY_IMAGE => 'Deploy Image',
|
||||
|
@ -47,9 +44,6 @@ final class CommandTypes
|
|||
self::TRANSFER_IMAGE => 'Transfer Image',
|
||||
self::INSTALL_OGLIVE => 'Instalar OgLive',
|
||||
self::RUN_SCRIPT => 'Run Script',
|
||||
self::REMOVE_CACHE_IMAGE => 'Remove Cache Image',
|
||||
self::HARDWARE_INVENTORY => 'Hardware Inventory',
|
||||
self::SOFTWARE_INVENTORY => 'Software Inventory',
|
||||
];
|
||||
|
||||
public static function getCommandTypes(): array
|
||||
|
|
|
@ -40,25 +40,15 @@ readonly class StatusService
|
|||
]);
|
||||
|
||||
try {
|
||||
$response = $httpClient->request('GET', 'http://' . $this->ogBootIp . ':' . $this->ogBootApiPort . '/ogboot/v1/status', [
|
||||
'headers' => ['accept' => 'application/json'],
|
||||
$response = $httpClient->request('GET', 'http://'.$this->ogBootIp.':'.$this->ogBootApiPort.'/ogboot/v1/status', [
|
||||
'headers' => [
|
||||
'accept' => 'application/json',
|
||||
],
|
||||
]);
|
||||
|
||||
return json_decode($response->getContent(), true);
|
||||
|
||||
} catch (ClientExceptionInterface | ServerExceptionInterface $e) {
|
||||
return [
|
||||
'code' => Response::HTTP_INTERNAL_SERVER_ERROR,
|
||||
'error' => 'Client/Server error',
|
||||
'details' => $e->getMessage(),
|
||||
];
|
||||
} catch (TransportExceptionInterface $e) {
|
||||
return [
|
||||
'code' => Response::HTTP_INTERNAL_SERVER_ERROR,
|
||||
'error' => 'Transport error',
|
||||
'details' => $e->getMessage(),
|
||||
];
|
||||
return new JsonResponse( data: 'An error occurred', status: Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
return json_decode($response->getContent(), true);
|
||||
}
|
||||
}
|
|
@ -9,34 +9,18 @@ use ApiPlatform\Metadata\Post;
|
|||
use ApiPlatform\Metadata\Put;
|
||||
use ApiPlatform\State\ProcessorInterface;
|
||||
use ApiPlatform\Validator\ValidatorInterface;
|
||||
use App\Controller\OgBoot\PxeBootFile\DeleteAction;
|
||||
use App\Controller\OgDhcp\Subnet\DeleteHostAction;
|
||||
use App\Dto\Input\ClientInput;
|
||||
use App\Dto\Output\ClientOutput;
|
||||
use App\Dto\Output\UserGroupOutput;
|
||||
use App\Entity\OgLive;
|
||||
use App\Entity\PxeTemplate;
|
||||
use App\Repository\ClientRepository;
|
||||
use App\Repository\MenuRepository;
|
||||
use App\Repository\OgLiveRepository;
|
||||
use App\Repository\PxeTemplateRepository;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
|
||||
readonly class ClientProcessor implements ProcessorInterface
|
||||
{
|
||||
public function __construct(
|
||||
private ClientRepository $clientRepository,
|
||||
private MenuRepository $menuRepository,
|
||||
private PxeTemplateRepository $pxeTemplateRepository,
|
||||
private OgLiveRepository $ogLiveRepository,
|
||||
private ValidatorInterface $validator,
|
||||
private DeleteHostAction $deleteHostAction,
|
||||
private DeleteAction $deletePxeAction,
|
||||
private KernelInterface $kernel,
|
||||
private ClientRepository $clientRepository,
|
||||
private MenuRepository $menuRepository,
|
||||
private ValidatorInterface $validator
|
||||
)
|
||||
{
|
||||
}
|
||||
|
@ -71,47 +55,23 @@ readonly class ClientProcessor implements ProcessorInterface
|
|||
}
|
||||
|
||||
$defaultMenu = $this->menuRepository->findOneBy(['isDefault' => true]);
|
||||
$defaultPxe = $this->pxeTemplateRepository->findOneBy(['isDefault' => true]);
|
||||
$defaultPxeOgLive = $this->ogLiveRepository->findOneBy(['isDefault' => true]);
|
||||
|
||||
$client = $data->createOrUpdateEntity($entity);
|
||||
|
||||
if ($defaultMenu && !$client->getMenu()) {
|
||||
if ($defaultMenu) {
|
||||
$client->setMenu($defaultMenu);
|
||||
}
|
||||
|
||||
if ($defaultPxe && !$client->getTemplate()) {
|
||||
$client->setTemplate($defaultPxe);
|
||||
}
|
||||
|
||||
if ($defaultPxeOgLive && !$client->getOgLive()) {
|
||||
$client->setOgLive($defaultPxeOgLive);
|
||||
}
|
||||
|
||||
$this->validator->validate($client);
|
||||
$this->clientRepository->save($client);
|
||||
|
||||
return new ClientOutput($client);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
private function processDelete($data, Operation $operation, array $uriVariables = [], array $context = []): null
|
||||
{
|
||||
$client = $this->clientRepository->findOneByUuid($uriVariables['uuid']);
|
||||
$this->clientRepository->delete($client);
|
||||
|
||||
if ($this->kernel->getEnvironment() !== 'test') {
|
||||
|
||||
if ($client->getSubnet()) {
|
||||
$this->deleteHostAction->__invoke($client->getSubnet(), $client->getUuid());
|
||||
}
|
||||
$this->deletePxeAction->__invoke($client->getUuid());
|
||||
}
|
||||
$user = $this->clientRepository->findOneByUuid($uriVariables['uuid']);
|
||||
$this->clientRepository->delete($user);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -9,26 +9,15 @@ use ApiPlatform\Metadata\Post;
|
|||
use ApiPlatform\Metadata\Put;
|
||||
use ApiPlatform\State\ProcessorInterface;
|
||||
use ApiPlatform\Validator\ValidatorInterface;
|
||||
use App\Controller\OgBoot\OgLive\InstallAction;
|
||||
use App\Controller\OgBoot\OgLive\UninstallAction;
|
||||
use App\Dto\Input\OgLiveInput;
|
||||
use App\Dto\Output\OgLiveOutput;
|
||||
use App\Model\OgLiveStatus;
|
||||
use App\Repository\OgLiveRepository;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
|
||||
readonly class OgLiveProcessor implements ProcessorInterface
|
||||
{
|
||||
public function __construct(
|
||||
private OgLiveRepository $ogLiveRepository,
|
||||
private ValidatorInterface $validator,
|
||||
private InstallAction $installAction,
|
||||
private UninstallAction $uninstallAction,
|
||||
private KernelInterface $kernel,
|
||||
private ValidatorInterface $validator
|
||||
)
|
||||
{
|
||||
}
|
||||
|
@ -50,7 +39,6 @@ readonly class OgLiveProcessor implements ProcessorInterface
|
|||
|
||||
/**
|
||||
* @throws \Exception
|
||||
* @throws TransportExceptionInterface
|
||||
*/
|
||||
private function processCreateOrUpdate($data, Operation $operation, array $uriVariables = [], array $context = []): OgLiveOutput
|
||||
{
|
||||
|
@ -67,30 +55,12 @@ readonly class OgLiveProcessor implements ProcessorInterface
|
|||
$this->validator->validate($ogLive);
|
||||
$this->ogLiveRepository->save($ogLive);
|
||||
|
||||
if ($this->kernel->getEnvironment() !== 'test') {
|
||||
if ($operation instanceof Post) {
|
||||
$this->installAction->__invoke($ogLive);
|
||||
}
|
||||
}
|
||||
|
||||
return new OgLiveOutput($ogLive);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws TransportExceptionInterface
|
||||
* @throws ServerExceptionInterface
|
||||
* @throws RedirectionExceptionInterface
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
private function processDelete($data, Operation $operation, array $uriVariables = [], array $context = []): null
|
||||
{
|
||||
$ogLive = $this->ogLiveRepository->findOneByUuid($uriVariables['uuid']);
|
||||
|
||||
if ($this->kernel->getEnvironment() !== 'test') {
|
||||
if ($ogLive->getStatus() === OgLiveStatus::ACTIVE) {
|
||||
$this->uninstallAction->__invoke($ogLive);
|
||||
}
|
||||
}
|
||||
$this->ogLiveRepository->delete($ogLive);
|
||||
|
||||
return null;
|
||||
|
|
|
@ -60,7 +60,7 @@ readonly class OrganizationalUnitProcessor implements ProcessorInterface
|
|||
$this->validator->validate($organizationalUnit, ['groups' => ['organizational-unit:write']]);
|
||||
$this->organizationalUnitRepository->save($organizationalUnit);
|
||||
|
||||
//$this->changeClientNetworkSettingsService->__invoke($organizationalUnit);
|
||||
$this->changeClientNetworkSettingsService->__invoke($organizationalUnit);
|
||||
|
||||
return new OrganizationalUnitOutput($organizationalUnit);
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@ use Symfony\Component\Validator\ConstraintValidator;
|
|||
|
||||
class OrganizationalUnitMulticastPortValidator extends ConstraintValidator
|
||||
{
|
||||
public const int minPort = 9000;
|
||||
public const int maxPort = 9098;
|
||||
CONST int minPort = 9000;
|
||||
CONST int maxPort = 9050;
|
||||
|
||||
public function validate($value, Constraint $constraint): void
|
||||
{
|
||||
|
@ -18,14 +18,9 @@ class OrganizationalUnitMulticastPortValidator extends ConstraintValidator
|
|||
return;
|
||||
}
|
||||
|
||||
if ($value % 2 !== 0) {
|
||||
$this->context->buildViolation('El puerto debe ser un número par y encontrarse entre el 9000 y el 9098.')->addViolation();
|
||||
return;
|
||||
}
|
||||
|
||||
if ($value < self::minPort || $value > self::maxPort) {
|
||||
if (!(self::minPort <= $value) && ($value <= self::maxPort)) {
|
||||
$this->context->buildViolation($constraint->message)->addViolation();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -187,7 +187,7 @@
|
|||
<span>Tipo: {{ partition.filesystem }}</span>
|
||||
<span><strong>SO:</strong> {{ partition.operativeSystem ? partition.operativeSystem.name : '-' }}</span>
|
||||
{% if partition.operativeSystem %}
|
||||
<a href="command+output:/opt/opengnsys/scripts/bootOs.py {{ partition.diskNumber }} {{ partition.partitionNumber }}" class="partition-link">Arrancar {{ partition.operativeSystem.name }}</a>
|
||||
<a href="command+output:bootOs {{ partition.diskNumber }} {{ partition.partitionNumber }}" class="partition-link">Arrancar {{ partition.operativeSystem.name }}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
|
Loading…
Reference in New Issue