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
|
||||
controller: App\Controller\OgBoot\PxeBootFile\GetAction
|
||||
|
||||
login_client:
|
||||
boot_client:
|
||||
class: ApiPlatform\Metadata\Post
|
||||
method: POST
|
||||
input: App\Dto\Input\MultipleClientsInput
|
||||
uriTemplate: /clients/server/login-client
|
||||
input: App\Dto\Input\BootClientsInput
|
||||
uriTemplate: /clients/server/boot-client
|
||||
controller: App\Controller\OgAgent\LoginAction
|
||||
|
||||
reboot_client:
|
||||
|
|
|
@ -4,10 +4,12 @@ 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;
|
||||
|
@ -35,8 +37,11 @@ class LoginAction extends AbstractOgAgentController
|
|||
* @throws RedirectionExceptionInterface
|
||||
* @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) {
|
||||
/** @var Client $client */
|
||||
$client = $clientEntity->getEntity();
|
||||
|
@ -52,17 +57,18 @@ class LoginAction extends AbstractOgAgentController
|
|||
|
||||
$data = [
|
||||
'nfn' => 'IniciarSesion',
|
||||
'dsk' => '1',
|
||||
'par' => '1',
|
||||
'dsk' => (string) $partition->getDiskNumber(),
|
||||
'par' => (string) $partition->getPartitionNumber(),
|
||||
'ids' => '0'
|
||||
];
|
||||
|
||||
$response = $this->createRequest(
|
||||
method: 'POST',
|
||||
url: 'http://'.$client->getIp().':8000/opengnsys/IniciarSesion',
|
||||
url: 'https://'.$client->getIp().':8000/opengnsys/IniciarSesion',
|
||||
params: [
|
||||
'json' => $data,
|
||||
]
|
||||
],
|
||||
token: $client->getToken(),
|
||||
);
|
||||
|
||||
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->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);
|
||||
|
|
|
@ -55,7 +55,7 @@ class RebootAction extends AbstractOgAgentController
|
|||
|
||||
$response = $this->createRequest(
|
||||
method: 'POST',
|
||||
url: 'http://'.$client->getIp().':8000/'.$endpoint,
|
||||
url: 'https://'.$client->getIp().':8000/'.$endpoint,
|
||||
params: [
|
||||
'json' => $data,
|
||||
],
|
||||
|
|
|
@ -2,7 +2,20 @@
|
|||
|
||||
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