refs #2085. Boot OS
testing/ogcore-api/pipeline/head There was a failure building this commit
Details
testing/ogcore-api/pipeline/head There was a failure building this commit
Details
parent
76a90d1129
commit
9be2f5fd9b
|
@ -50,11 +50,11 @@ resources:
|
||||||
uriTemplate: /clients/server/{uuid}/get-pxe
|
uriTemplate: /clients/server/{uuid}/get-pxe
|
||||||
controller: App\Controller\OgBoot\PxeBootFile\GetAction
|
controller: App\Controller\OgBoot\PxeBootFile\GetAction
|
||||||
|
|
||||||
login_client:
|
boot_client:
|
||||||
class: ApiPlatform\Metadata\Post
|
class: ApiPlatform\Metadata\Post
|
||||||
method: POST
|
method: POST
|
||||||
input: App\Dto\Input\MultipleClientsInput
|
input: App\Dto\Input\BootClientsInput
|
||||||
uriTemplate: /clients/server/login-client
|
uriTemplate: /clients/server/boot-client
|
||||||
controller: App\Controller\OgAgent\LoginAction
|
controller: App\Controller\OgAgent\LoginAction
|
||||||
|
|
||||||
reboot_client:
|
reboot_client:
|
||||||
|
|
|
@ -4,10 +4,12 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Controller\OgAgent;
|
namespace App\Controller\OgAgent;
|
||||||
|
|
||||||
|
use App\Dto\Input\BootClientsInput;
|
||||||
use App\Dto\Input\MultipleClientsInput;
|
use App\Dto\Input\MultipleClientsInput;
|
||||||
use App\Entity\Client;
|
use App\Entity\Client;
|
||||||
use App\Entity\Command;
|
use App\Entity\Command;
|
||||||
use App\Entity\Image;
|
use App\Entity\Image;
|
||||||
|
use App\Entity\Partition;
|
||||||
use App\Entity\Trace;
|
use App\Entity\Trace;
|
||||||
use App\Model\ClientStatus;
|
use App\Model\ClientStatus;
|
||||||
use App\Model\CommandTypes;
|
use App\Model\CommandTypes;
|
||||||
|
@ -35,8 +37,11 @@ class LoginAction extends AbstractOgAgentController
|
||||||
* @throws RedirectionExceptionInterface
|
* @throws RedirectionExceptionInterface
|
||||||
* @throws ClientExceptionInterface
|
* @throws ClientExceptionInterface
|
||||||
*/
|
*/
|
||||||
public function __invoke(MultipleClientsInput $input): JsonResponse
|
public function __invoke(BootClientsInput $input): JsonResponse
|
||||||
{
|
{
|
||||||
|
/** @var Partition $partition */
|
||||||
|
$partition = $input->partition->getEntity();
|
||||||
|
|
||||||
foreach ($input->clients as $clientEntity) {
|
foreach ($input->clients as $clientEntity) {
|
||||||
/** @var Client $client */
|
/** @var Client $client */
|
||||||
$client = $clientEntity->getEntity();
|
$client = $clientEntity->getEntity();
|
||||||
|
@ -52,17 +57,18 @@ class LoginAction extends AbstractOgAgentController
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'nfn' => 'IniciarSesion',
|
'nfn' => 'IniciarSesion',
|
||||||
'dsk' => '1',
|
'dsk' => (string) $partition->getDiskNumber(),
|
||||||
'par' => '1',
|
'par' => (string) $partition->getPartitionNumber(),
|
||||||
'ids' => '0'
|
'ids' => '0'
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $this->createRequest(
|
$response = $this->createRequest(
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: 'http://'.$client->getIp().':8000/opengnsys/IniciarSesion',
|
url: 'https://'.$client->getIp().':8000/opengnsys/IniciarSesion',
|
||||||
params: [
|
params: [
|
||||||
'json' => $data,
|
'json' => $data,
|
||||||
]
|
],
|
||||||
|
token: $client->getToken(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isset($response['error']) && $response['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
if (isset($response['error']) && $response['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) {
|
||||||
|
@ -77,7 +83,7 @@ class LoginAction extends AbstractOgAgentController
|
||||||
$this->entityManager->persist($client);
|
$this->entityManager->persist($client);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
$this->createService->__invoke($client, CommandTypes::REBOOT, TraceStatus::SUCCESS, $jobId, []);
|
$this->createService->__invoke($client, CommandTypes::LOGIN, TraceStatus::SUCCESS, $jobId, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new JsonResponse(data: [], status: Response::HTTP_OK);
|
return new JsonResponse(data: [], status: Response::HTTP_OK);
|
||||||
|
|
|
@ -55,7 +55,7 @@ class RebootAction extends AbstractOgAgentController
|
||||||
|
|
||||||
$response = $this->createRequest(
|
$response = $this->createRequest(
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: 'http://'.$client->getIp().':8000/'.$endpoint,
|
url: 'https://'.$client->getIp().':8000/'.$endpoint,
|
||||||
params: [
|
params: [
|
||||||
'json' => $data,
|
'json' => $data,
|
||||||
],
|
],
|
||||||
|
|
|
@ -2,7 +2,20 @@
|
||||||
|
|
||||||
namespace App\Dto\Input;
|
namespace App\Dto\Input;
|
||||||
|
|
||||||
class BootClientInput
|
use App\Dto\Output\ClientOutput;
|
||||||
{
|
use App\Dto\Output\PartitionOutput;
|
||||||
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
|
|
||||||
|
final class BootClientsInput
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var ClientOutput[]
|
||||||
|
*/
|
||||||
|
#[Groups(['client:write'])]
|
||||||
|
public array $clients = [];
|
||||||
|
|
||||||
|
|
||||||
|
#[Groups(['client:write'])]
|
||||||
|
public ?PartitionOutput $partition = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue