Añadido tratamiento a RESPUESTA_Actualizar para tratar la informacion de configuracion que envia el agente, de esta forma actualiza la informacion de la particion con el nombre y la fecha de despliegue de una imagen
parent
b990a3d894
commit
2eff4066da
|
|
@ -44,6 +44,7 @@ class StatusController extends AbstractController
|
|||
const string RESTORE_IMAGE_GIT = 'RESPUESTA_RestaurarImagenGit';
|
||||
const string CONFIGURE_IMAGE = 'RESPUESTA_Configurar';
|
||||
const string HARDWARE_INVENTORY = 'RESPUESTA_InventarioHardware';
|
||||
const string REFRESH = 'RESPUESTA_Actualizar';
|
||||
const string SOFTWARE_INVENTORY = 'RESPUESTA_InventarioSoftware';
|
||||
const string RUN_SCRIPT = 'RESPUESTA_EjecutarScript';
|
||||
|
||||
|
|
@ -324,6 +325,30 @@ class StatusController extends AbstractController
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($data['nfn']) && $data['nfn'] === self::REFRESH) {
|
||||
$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);
|
||||
} else {
|
||||
$clientIp = $data['iph'] ?? $request->getClientIp();
|
||||
$client = $this->entityManager->getRepository(Client::class)->findOneBy(['ip' => $clientIp]);
|
||||
}
|
||||
|
||||
if ($client) {
|
||||
$client->setStatus(ClientStatus::OG_LIVE);
|
||||
$this->entityManager->persist($client);
|
||||
|
||||
if (isset($data['cfg'])) {
|
||||
$this->createPartitionService->__invoke($data, $client);
|
||||
$this->logger->info('Partition configuration updated via RESPUESTA_Actualizar', ['job_id' => $data['job_id'] ?? 'none']);
|
||||
}
|
||||
}
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
return new JsonResponse(data: 'Webhook finished', status: Response::HTTP_OK);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class CreatePartitionService
|
|||
|
||||
if (isset($cfg['img']) && $cfg['img'] !== '') {
|
||||
$imgParts = explode(':', $cfg['img']);
|
||||
$imgName = $imgParts[0];
|
||||
$imgName = trim($imgParts[0]);
|
||||
$imgDate = $imgParts[1] ?? null;
|
||||
|
||||
$imageImageRepository = $this->entityManager->getRepository(\App\Entity\ImageImageRepository::class)
|
||||
|
|
@ -76,7 +76,7 @@ class CreatePartitionService
|
|||
$partitionEntity->setImage($imageImageRepository);
|
||||
$partitionEntity->setDeployDate(null);
|
||||
if ($imgDate) {
|
||||
$dateObj = \DateTime::createFromFormat('YmdHi', $imgDate);
|
||||
$dateObj = \DateTime::createFromFormat('YmdHi', trim($imgDate));
|
||||
if ($dateObj) {
|
||||
$partitionEntity->setDeployDate($dateObj);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue