refs #952. ogAgent. Create partition
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
0c94a1921e
commit
dce78eef29
|
@ -3,6 +3,7 @@
|
|||
namespace App\Controller\OgAgent;
|
||||
|
||||
use App\Entity\Client;
|
||||
use App\Entity\Partition;
|
||||
use App\Model\OgLiveStatus;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
@ -59,6 +60,26 @@ class StatusAction extends AbstractController
|
|||
);
|
||||
}
|
||||
|
||||
$data = json_decode($response->getContent(), true);
|
||||
|
||||
if (isset($data['cfg'])) {
|
||||
foreach ($data['cfg'] as $cfg) {
|
||||
$partitionEntity = $this->entityManager->getRepository(Partition::class)
|
||||
->findOneBy(['client' => $client, 'diskNumber' => $cfg['disk'], 'partitionNumber' => $cfg['par']]);
|
||||
|
||||
if (!$partitionEntity) {
|
||||
$partitionEntity = new Partition();
|
||||
}
|
||||
|
||||
$partitionEntity->setClient($client);
|
||||
$partitionEntity->setDiskNumber($cfg['disk']);
|
||||
$partitionEntity->setPartitionNumber($cfg['par']);
|
||||
$partitionEntity->setSize($cfg['tam']);
|
||||
$partitionEntity->setMemoryUsage($cfg['uso']);
|
||||
$this->entityManager->persist($partitionEntity);
|
||||
}
|
||||
}
|
||||
|
||||
$this->entityManager->persist($client);
|
||||
$this->entityManager->flush();
|
||||
|
||||
|
|
|
@ -38,6 +38,13 @@ class SetDefaultAction extends AbstractOgBootController
|
|||
|
||||
$content = $this->createRequest($httpClient, 'PUT', $this->ogBootApiUrl.'/ogboot/v1/oglives/default', $params);
|
||||
|
||||
$oldDefaultOgLive = $this->entityManager->getRepository(OgLive::class)->findBy(['isDefault' => true]);
|
||||
|
||||
foreach ($oldDefaultOgLive as $oldOgLive) {
|
||||
$oldOgLive->setIsDefault(false);
|
||||
$this->entityManager->persist($oldOgLive);
|
||||
}
|
||||
|
||||
$data->setIsDefault(true);
|
||||
$entityManager->persist($data);
|
||||
$entityManager->flush();
|
||||
|
|
|
@ -82,9 +82,6 @@ class InstallOgLiveResponseAction extends AbstractController
|
|||
|
||||
$ogLive->setStatus($status === self::OG_LIVE_INSTALL_SUCCESS ? OgLiveStatus::ACTIVE : OgLiveStatus::FAILED);
|
||||
$ogLive->setInstalled($status === self::OG_LIVE_INSTALL_SUCCESS);
|
||||
$ogLive->setIsDefault(true);
|
||||
|
||||
$this->entityManager->persist($ogLive);
|
||||
|
||||
$oldDefaultOgLive = $this->entityManager->getRepository(OgLive::class)->findBy(['isDefault' => true]);
|
||||
|
||||
|
@ -93,6 +90,9 @@ class InstallOgLiveResponseAction extends AbstractController
|
|||
$this->entityManager->persist($oldOgLive);
|
||||
}
|
||||
|
||||
$ogLive->setIsDefault(true);
|
||||
$this->entityManager->persist($ogLive);
|
||||
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Entity;
|
||||
|
||||
use App\Repository\PxeTemplateRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
@ -25,6 +26,12 @@ class PxeTemplate extends AbstractEntity
|
|||
#[ORM\OneToMany(mappedBy: 'template', targetEntity: Client::class)]
|
||||
private Collection $clients;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->clients = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getTemplateContent(): ?string
|
||||
{
|
||||
return $this->templateContent;
|
||||
|
|
Loading…
Reference in New Issue