diff options
author | devega <ma.devega@globunet.com> | 2019-04-03 13:07:58 +0200 |
---|---|---|
committer | devega <ma.devega@globunet.com> | 2019-04-03 13:07:58 +0200 |
commit | 320686abdd195a5637647536ba324dbbba7664b0 (patch) | |
tree | fd677147ceac122d0baa033f1f90022ada7a81c2 /admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Command/MigrateCommand.php | |
parent | b082903077cb649cf5b81e74b69816afe6c36643 (diff) |
Creado el Bundle OpengnsysCoreBundle e implementado Auth2, Rest y User (entidades y configuraciĆ³n necesaria)
Actualizacion del command migration
Creado repositorio para algunas entidades
Actualizado el shell instalador
Diffstat (limited to 'admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Command/MigrateCommand.php')
-rw-r--r-- | admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Command/MigrateCommand.php | 165 |
1 files changed, 159 insertions, 6 deletions
diff --git a/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Command/MigrateCommand.php b/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Command/MigrateCommand.php index 20922975..3f0f4bee 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Command/MigrateCommand.php +++ b/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Command/MigrateCommand.php @@ -5,15 +5,22 @@ namespace Opengnsys\MigrationBundle\Command; use Opengnsys\MigrationBundle\Entity\Aulas; use Opengnsys\MigrationBundle\Entity\Centros; use Opengnsys\MigrationBundle\Entity\Gruposordenadores; +use Opengnsys\MigrationBundle\Entity\Imagenes; use Opengnsys\MigrationBundle\Entity\Menus; use Opengnsys\MigrationBundle\Entity\Ordenadores; +use Opengnsys\MigrationBundle\Entity\OrdenadoresParticiones; use Opengnsys\MigrationBundle\Entity\Perfileshard; +use Opengnsys\MigrationBundle\Entity\Perfilessoft; use Opengnsys\MigrationBundle\Entity\Repositorios; +use Opengnsys\MigrationBundle\Entity\Sistemasficheros; +use Opengnsys\MigrationBundle\Entity\Tiposos; use Opengnsys\ServerBundle\Entity\Client; use Opengnsys\ServerBundle\Entity\HardwareProfile; +use Opengnsys\ServerBundle\Entity\Image; use Opengnsys\ServerBundle\Entity\Menu; use Opengnsys\ServerBundle\Entity\NetworkSettings; use Opengnsys\ServerBundle\Entity\OrganizationalUnit; +use Opengnsys\ServerBundle\Entity\Partition; use Opengnsys\ServerBundle\Entity\Repository; use Opengnsys\ServerBundle\Entity\SoftwareProfile; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; @@ -34,6 +41,8 @@ class MigrateCommand extends ContainerAwareCommand protected function execute(InputInterface $input, OutputInterface $output) { $logger = $this->getContainer()->get('monolog.logger.og_migration'); + //$logger = $this->getContainer()->get('logger'); + $em = $this->getContainer()->get('doctrine')->getManager(); $emSlave = $this->getContainer()->get('doctrine')->getManager('og_1'); @@ -45,7 +54,12 @@ class MigrateCommand extends ContainerAwareCommand $repositorios = $emSlave->getRepository(Repositorios::class)->findAll(); $menuses = $emSlave->getRepository(Menus::class)->findAll(); $perfileshards = $emSlave->getRepository(Perfileshard::class)->findAll(); - $perfilessofts = $emSlave->getRepository(Perfileshard::class)->findAll(); + $perfilessofts = $emSlave->getRepository(Perfilessoft::class)->findAll(); + $imagenes = $emSlave->getRepository(Imagenes::class)->findAll(); + $particiones = $emSlave->getRepository(OrdenadoresParticiones::class)->findAll(); + + $sistemasFicherosRepository = $emSlave->getRepository(Sistemasficheros::class); + $tipososRepository = $emSlave->getRepository(Tiposos::class); // og_3 $organizationalUnitRepository = $em->getRepository(OrganizationalUnit::class); @@ -54,7 +68,8 @@ class MigrateCommand extends ContainerAwareCommand $menuRepository = $em->getRepository(Menu::class); $hardwareProfileRepository = $em->getRepository(HardwareProfile::class); $softwareProfileRepository = $em->getRepository(SoftwareProfile::class); - + $imageRepository = $em->getRepository(Image::class); + $partitionRepository = $em->getRepository(Partition::class); /** Centros **/ $logger->info("CENTROS TOTAL: ". count($centros)); @@ -113,7 +128,7 @@ class MigrateCommand extends ContainerAwareCommand } /** Grupo Ordenador **/ - $logger->info("Grupos TOTAL: ". count($grupos)); + $logger->info("GRUPOS TOTAL: ". count($grupos)); foreach ($grupos as $grupo){ $id = $grupo->getIdgrupo(); $migrateId ="grupo:".$id; @@ -175,7 +190,6 @@ class MigrateCommand extends ContainerAwareCommand /** Perfil Hardware **/ $logger->info("PERFIL HARDWARES TOTAL: ". count($perfileshards)); foreach ($perfileshards as $perfileshard){ - $perfileshard = new Perfileshard(); $id = $perfileshard->getIdperfilhard(); $migrateId ="perfilHardware:".$id; @@ -188,7 +202,6 @@ class MigrateCommand extends ContainerAwareCommand $hardwareProfile->setDescription($perfileshard->getDescripcion()); $hardwareProfile->setComments($perfileshard->getComentarios()); - // OrganizationalUnit if($perfileshard->getGrupoid() == 0){ $migrateId = "centro:".$perfileshard->getIdcentro(); @@ -201,11 +214,64 @@ class MigrateCommand extends ContainerAwareCommand $em->flush(); /** Perfil Softwares **/ + $logger->info("PERFIL SOFTWARES TOTAL: ". count($perfilessofts)); + foreach ($perfilessofts as $perfilessoft){ + $id = $perfilessoft->getIdperfilsoft(); + $migrateId ="perfilSoftware:".$id; + + $softwareProfile = $softwareProfileRepository->findOneByNotes($migrateId); + if(!$softwareProfile){ + $softwareProfile = new SoftwareProfile(); + $softwareProfile->setNotes($migrateId); + $em->persist($softwareProfile); + } + $softwareProfile->setDescription($perfilessoft->getDescripcion()); + $softwareProfile->setComments($perfilessoft->getComentarios()); + + // OrganizationalUnit + if($perfilessoft->getGrupoid() == 0){ + $migrateId = "centro:".$perfilessoft->getIdcentro(); + }else{ + $migrateId = "grupo:".$perfilessoft->getGrupoid(); + } + $organizationalUnit = $organizationalUnitRepository->findOneByNotes($migrateId); + $softwareProfile->setOrganizationalUnit($organizationalUnit); + } + $em->flush(); /** Menus **/ + $logger->info("PERFIL MENUS TOTAL: ". count($menuses)); + foreach ($menuses as $menuse){ + $id = $menuse->getIdmenu(); + $migrateId ="menu:".$id; + + $menu = $menuRepository->findOneByNotes($migrateId); + if(!$menu){ + $menu = new Menu(); + $menu->setNotes($migrateId); + $em->persist($menu); + } + $menu->setTitle($menuse->getTitulo()); + $menu->setDescription($menuse->getDescripcion()); + $menu->setComments($menuse->getComentarios()); + $menu->setResolution($menuse->getResolucion()); + + $menu->setIdurlimg($menuse->getIdurlimg()); + $menu->setPublicmenuhtml($menuse->getHtmlmenupub()); + + // OrganizationalUnit + if($menuse->getGrupoid() == 0){ + $migrateId = "centro:".$menuse->getIdcentro(); + }else{ + $migrateId = "grupo:".$menuse->getGrupoid(); + } + $organizationalUnit = $organizationalUnitRepository->findOneByNotes($migrateId); + $menu->setOrganizationalUnit($organizationalUnit); + } + $em->flush(); /** Ordenadores **/ - $logger->info("Ordenadores TOTAL: ". count($ordenadores)); + $logger->info("ORDENADORES TOTAL: ". count($ordenadores)); foreach ($ordenadores as $ordenador){ //$ordenador = new Ordenadores(); $id = $ordenador->getIdordenador(); @@ -262,6 +328,93 @@ class MigrateCommand extends ContainerAwareCommand } $em->flush(); + /** Imagen **/ + $logger->info("PERFIL IMAGENES TOTAL: ". count($imagenes)); + foreach ($imagenes as $imagen){ + //$imagen = new Imagenes(); + $id = $imagen->getIdimagen(); + $migrateId ="imagen:".$id; + + $image = $imageRepository->findOneByNotes($migrateId); + if(!$image){ + $image = new Image(); + $image->setNotes($migrateId); + $em->persist($image); + } + $image->setCanonicalName($imagen->getNombreca()); + $image->setDescription($imagen->getDescripcion()); + $image->setComments($imagen->getComentarios()); + $image->setPath($imagen->getRuta()); + $image->setRevision($imagen->getRevision()); + + $image->setType($imagen->getTipo()); + //$image->setPartitionInfo(); + //$image->setFileSize(); + + // SoftwareProfile + $migrateId = "perfilSoftware:".$imagen->getIdperfilsoft(); + $softwareProfile = $softwareProfileRepository->findOneByNotes($migrateId); + $image->setSoftwareProfile($softwareProfile); + + // Client + $migrateId = "ordenador:".$imagen->getIdordenador(); + $client = $clientRepository->findOneByNotes($migrateId); + $image->setClient($client); + + // Repository + $migrateId = "repositorio:".$imagen->getIdrepositorio(); + $repository = $repositoryRepository->findOneByNotes($migrateId); + $image->setRepository($repository); + + } + $em->flush(); + + /** Particiones **/ + $logger->info("PARTICIONES TOTAL: ". count($particiones)); + foreach ($particiones as $particion){ + //$particion = new OrdenadoresParticiones(); + $ordenadorId = $particion->getIdordenador(); + $numDisk = $particion->getNumdisk(); + $numPar = $particion->getNumpar(); + $migrateId ="paricion:".$ordenadorId."_".$numDisk."_".$numPar; + + $partition = $partitionRepository->findOneByNotes($migrateId); + if(!$partition){ + $partition = new Partition(); + $partition->setNotes($migrateId); + $em->persist($partition); + } + $partition->setNumDisk($particion->getNumdisk()); + $partition->setNumPartition($particion->getNumpar()); + $partition->setPartitionCode($particion->getCodpar()); + $partition->setSize($particion->getTamano()); + $partition->setCacheContent($particion->getCache()); + $partition->setUsage($particion->getUso()); + + //$logger->warning("Find FylesSystema ID: ". $particion->getIdsistemafichero()); + $sistemasFicheros = $sistemasFicherosRepository->find($particion->getIdsistemafichero()); + if($sistemasFicheros){ + $partition->setFilesystem($sistemasFicheros->getDescripcion()); + } + + $tiposos = $tipososRepository->find($particion->getIdnombreso()); + if($tiposos){ + $partition->setOsName($tiposos->getTiposo()); + } + + // Image + $migrateId = "image:".$particion->getIdimagen(); + $image = $imageRepository->findOneByNotes($migrateId); + $partition->setImage($image); + //$particion->getIdperfilsoft(); + + // Client + $migrateId ="ordenador:".$ordenadorId; + $client = $clientRepository->findOneByNotes($migrateId); + $partition->setClient($client); + } + $em->flush(); + |