Commit 32a8f8200c0f728d7eae2ab8bc0b79abd85db9bb
Exists in
master
Cadastro e download de agentes utilizando o método HTTP por tipo de SO
Showing
18 changed files
with
722 additions
and
409 deletions
Show diff stats
src/Cacic/CommonBundle/Controller/AgenteController.php
| ... | ... | @@ -22,6 +22,7 @@ use ZipArchive; |
| 22 | 22 | class AgenteController extends Controller { |
| 23 | 23 | |
| 24 | 24 | public function indexAction(Request $request) { |
| 25 | + $em = $this->getDoctrine()->getManager(); | |
| 25 | 26 | $logger = $this->get('logger'); |
| 26 | 27 | // Cria diretório dos agentes se não existir |
| 27 | 28 | $rootDir = $this->container->get('kernel')->getRootDir(); |
| ... | ... | @@ -36,132 +37,62 @@ class AgenteController extends Controller { |
| 36 | 37 | mkdir($cacicDir); |
| 37 | 38 | } |
| 38 | 39 | |
| 39 | - $linuxDir = $cacicDir . "linux/"; | |
| 40 | - if (!is_dir($linuxDir)) { | |
| 41 | - mkdir($linuxDir); | |
| 42 | - } | |
| 43 | - | |
| 44 | - $windowsDir = $cacicDir . "windows/"; | |
| 45 | - if (!is_dir($windowsDir)) { | |
| 46 | - mkdir($windowsDir); | |
| 47 | - } | |
| 40 | + #$linuxDir = $cacicDir . "linux/"; | |
| 41 | + #if (!is_dir($linuxDir)) { | |
| 42 | + # mkdir($linuxDir); | |
| 43 | + #} | |
| 44 | + # | |
| 45 | + #$windowsDir = $cacicDir . "windows/"; | |
| 46 | + #if (!is_dir($windowsDir)) { | |
| 47 | + # mkdir($windowsDir); | |
| 48 | + #} | |
| 48 | 49 | |
| 49 | 50 | |
| 50 | 51 | $outrosDir = $downloadsDir . "outros/"; |
| 51 | 52 | if (!is_dir($outrosDir)) { |
| 52 | 53 | mkdir($outrosDir); |
| 53 | 54 | } |
| 55 | + // Carrega a lista de Agentes por plataforma | |
| 56 | + $tipo_so = $em->getRepository('CacicCommonBundle:TipoSo')->findAll(); | |
| 54 | 57 | |
| 55 | 58 | |
| 56 | - $form = $this->createForm( new AgenteType() ); | |
| 59 | + $form = $this->createForm( new AgenteType(), null, array( | |
| 60 | + 'tipo_so' => $tipo_so | |
| 61 | + )); | |
| 57 | 62 | $locale = $request->getLocale(); |
| 58 | 63 | |
| 59 | - // Constrói array de arquivos e hashes | |
| 60 | - $finder = new Finder(); | |
| 61 | - $saida = array(); | |
| 62 | - $base_url = $request->getBaseUrl(); | |
| 63 | - $base_url = preg_replace('/\/app.*.php/', "/", $base_url); | |
| 64 | - | |
| 65 | - // Primeiro tratamos agentes Linux | |
| 66 | - // A regra é que o agente mais atual estará na pasta current | |
| 67 | - $finder->directories()->in($linuxDir); | |
| 68 | - $saida['linux']['versions'] = array(); | |
| 69 | - foreach($finder as $version) { | |
| 70 | - $agentes = new Finder(); | |
| 71 | - if ($version->getFileName() == 'current') { | |
| 72 | - continue; | |
| 73 | - } | |
| 74 | - $saida['linux']['versions'][$version->getFileName()] = array(); | |
| 75 | - $agentes->files()->in($version->getRealPath()); | |
| 76 | - foreach ($agentes as $file) { | |
| 77 | - array_push($saida['linux']['versions'][$version->getFileName()], array( | |
| 78 | - 'name' => $file->getFileName(), | |
| 79 | - 'download_url' => $base_url . 'downloads/cacic/linux/' . $version->getFileName() . '/' . $file->getFileName(), | |
| 80 | - 'hash' => md5_file($file->getRealPath()), | |
| 81 | - 'size' => $file->getSize(), | |
| 82 | - 'filename' => 'cacic/linux/' . $version->getFileName() . '/' . $file->getFileName() | |
| 83 | - )); | |
| 84 | - | |
| 85 | - } | |
| 86 | - } | |
| 87 | - // Get latest version | |
| 88 | - $current = @basename(@readlink($linuxDir."current")); | |
| 89 | - $saida['linux']['live_version'] = $current; | |
| 90 | - | |
| 91 | - // Aí tratamos Windows | |
| 92 | - $finder->directories()->in($windowsDir); | |
| 93 | - $saida['windows']['versions'] = array(); | |
| 94 | - foreach($finder as $version) { | |
| 95 | - $agentes = new Finder(); | |
| 96 | - if ($version->getFileName() == 'current') { | |
| 97 | - continue; | |
| 98 | - } | |
| 99 | - $saida['windows']['versions'][$version->getFileName()] = array(); | |
| 100 | - $agentes->files()->in($version->getRealPath()); | |
| 101 | - //$logger->debug("1111111111111111111111111111111111111111111 ".$version->getRealPath()); | |
| 102 | - foreach ($agentes as $file) { | |
| 103 | - //$logger->debug("77777777777777777777777777777777777777777 $file"); | |
| 104 | - array_push($saida['windows']['versions'][$version->getFileName()], array( | |
| 105 | - 'name' => $file->getFileName(), | |
| 106 | - 'download_url' => $base_url . 'downloads/cacic/windows/' . $version->getFileName() . '/' . $file->getFileName(), | |
| 107 | - 'hash' => md5_file($file->getRealPath()), | |
| 108 | - 'size' => $file->getSize(), | |
| 109 | - 'filename' => 'cacic/windows/' . $version->getFileName() . '/' . $file->getFileName() | |
| 110 | - )); | |
| 111 | - | |
| 112 | - } | |
| 113 | - } | |
| 114 | - // Get latest version | |
| 115 | - $current = @basename(@readlink($windowsDir."current")); | |
| 116 | - $saida['windows']['live_version'] = $current; | |
| 117 | - | |
| 118 | 64 | //$logger->debug("4444444444444444444444444444444444 ".print_r($saida, true)); |
| 119 | 65 | |
| 120 | 66 | if ( $request->isMethod('POST') ) |
| 121 | 67 | { |
| 122 | 68 | // Aqui vamos fazer o tratamento dos agentes |
| 123 | 69 | $data = $form->getData(); |
| 124 | - $data['windows_version'] = $request->get('agentes')['windows_version']; | |
| 125 | - $data['linux_version'] = $request->get('agentes')['linux_version']; | |
| 70 | + $data['version'] = $request->get('agentes')['version']; | |
| 126 | 71 | $files = $request->files->get('agentes'); |
| 127 | 72 | |
| 128 | 73 | //$logger->debug("99999999999999999999999999999999999 ".print_r($data, true)); |
| 129 | - if (!empty($files['windows'])) { | |
| 74 | + if (!empty($files)) { | |
| 130 | 75 | //$logger->debug("88888888888888888888888888888888888888 ".print_r($files['windows'], true)); |
| 131 | - if (empty($data['windows_version'])) { | |
| 76 | + if (empty($data['version'])) { | |
| 132 | 77 | $logger->error("O parâmetro versão é obrigatório"); |
| 133 | 78 | $this->get('session')->getFlashBag()->add('error', 'O parâmetro versão é obrigatório'); |
| 134 | 79 | } else { |
| 135 | - $versionDir = $windowsDir . $data['windows_version']; | |
| 136 | - $result = $this->uploadPackage($files['windows'], $versionDir); | |
| 137 | - if (!$result) { | |
| 138 | - $logger->error("Erro na atualização dos Agentes Windows"); | |
| 139 | - $this->get('session')->getFlashBag()->add('error', 'Erro na atualização dos agentes Windows'); | |
| 140 | - } else { | |
| 141 | - // Make this version current | |
| 142 | - $logger->debug("Agentes atualizados com sucesso. Ajustando para versão $versionDir"); | |
| 143 | - @unlink("$windowsDir"."current"); | |
| 144 | - symlink($versionDir, "$windowsDir"."current"); | |
| 145 | - $this->get('session')->getFlashBag()->add('success', 'Agentes atualizados com sucesso!'); | |
| 80 | + // Carrega as versões dos sistemas operacionais | |
| 81 | + $versionDir = $cacicDir . $data['version']; | |
| 82 | + $result = false; | |
| 83 | + foreach($tipo_so as $so) { | |
| 84 | + $tipoDir = $versionDir . "/" . $so->getTipo(); | |
| 85 | + $result = $this->uploadPackage($files[$so->getTipo()], $tipoDir); | |
| 146 | 86 | } |
| 147 | - } | |
| 148 | - } | |
| 149 | 87 | |
| 150 | - if (!empty($files['linux'])) { | |
| 151 | - if (empty($data['linux_version'])) { | |
| 152 | - $logger->error("O parâmetro versão é obrigatório"); | |
| 153 | - $this->get('session')->getFlashBag()->add('error', 'O parâmetro versão é obrigatório'); | |
| 154 | - } else { | |
| 155 | - $versionDir = $linuxDir . $data['linux_version']; | |
| 156 | - $result = $this->uploadPackage($files['linux'], $versionDir); | |
| 157 | 88 | if (!$result) { |
| 158 | - $logger->error("Erro na atualização dos Agentes Linux"); | |
| 159 | - $this->get('session')->getFlashBag()->add('error', 'Erro na atualização dos agentes Linux'); | |
| 89 | + $logger->error("Erro na atualização dos Agentes"); | |
| 90 | + $this->get('session')->getFlashBag()->add('error', 'Erro na atualização dos agentes'); | |
| 160 | 91 | } else { |
| 161 | 92 | // Make this version current |
| 162 | 93 | $logger->debug("Agentes atualizados com sucesso. Ajustando para versão $versionDir"); |
| 163 | - @unlink("$linuxDir"."current"); | |
| 164 | - symlink($versionDir, $linuxDir."current"); | |
| 94 | + @unlink("$cacicDir"."current"); | |
| 95 | + symlink($versionDir, "$cacicDir"."current"); | |
| 165 | 96 | $this->get('session')->getFlashBag()->add('success', 'Agentes atualizados com sucesso!'); |
| 166 | 97 | } |
| 167 | 98 | } |
| ... | ... | @@ -169,6 +100,52 @@ class AgenteController extends Controller { |
| 169 | 100 | |
| 170 | 101 | } |
| 171 | 102 | |
| 103 | + // Constrói array de arquivos e hashes | |
| 104 | + $finder = new Finder(); | |
| 105 | + $saida = array(); | |
| 106 | + $base_url = $request->getBaseUrl(); | |
| 107 | + $base_url = preg_replace('/\/app.*.php/', "", $base_url); | |
| 108 | + | |
| 109 | + // Varre diretório do Cacic | |
| 110 | + $finder->depth('== 0'); | |
| 111 | + $finder->directories()->in($cacicDir); | |
| 112 | + | |
| 113 | + // Agora busca diretórios de versão | |
| 114 | + $saida['tipo_so'] = array(); | |
| 115 | + foreach($finder as $version) { | |
| 116 | + //$logger->debug("1111111111111111111111111111111 ".$version->getFileName()); | |
| 117 | + if ($version->getFileName() == 'current') { | |
| 118 | + continue; | |
| 119 | + } | |
| 120 | + | |
| 121 | + // Agora busca um diretório pra cada tipo de SO | |
| 122 | + foreach($tipo_so as $so) { | |
| 123 | + $saida['tipo_so'][$so->getTipo()][$version->getFileName()] = array(); | |
| 124 | + $agentes_path = $version->getRealPath() . "/" . $so->getTipo(); | |
| 125 | + | |
| 126 | + // Cria diretório se não existir | |
| 127 | + if (!is_dir($agentes_path)) { | |
| 128 | + mkdir($agentes_path); | |
| 129 | + } | |
| 130 | + $agentes = new Finder(); | |
| 131 | + $agentes->files()->in($agentes_path); | |
| 132 | + foreach($agentes as $file) { | |
| 133 | + array_push($saida['tipo_so'][$so->getTipo()][$version->getFileName()], array( | |
| 134 | + 'name' => $file->getFileName(), | |
| 135 | + 'download_url' => $base_url . '/downloads/cacic/' . $version->getFileName() . '/' . $so->getTipo() . "/" . $file->getFileName(), | |
| 136 | + 'hash' => md5_file($file->getRealPath()), | |
| 137 | + 'size' => $file->getSize(), | |
| 138 | + 'filename' => 'cacic/' . $version->getFileName() . '/' . $so->getTipo() . "/" . $file->getFileName() | |
| 139 | + )); | |
| 140 | + } | |
| 141 | + } | |
| 142 | + } | |
| 143 | + | |
| 144 | + | |
| 145 | + // Get latest version | |
| 146 | + $current = @basename(@readlink($cacicDir."current")); | |
| 147 | + $saida['live_version'] = $current; | |
| 148 | + | |
| 172 | 149 | return $this->render( 'CacicCommonBundle:Agente:index.html.twig', |
| 173 | 150 | array( |
| 174 | 151 | 'local'=>$locale, |
| ... | ... | @@ -322,7 +299,7 @@ class AgenteController extends Controller { |
| 322 | 299 | |
| 323 | 300 | } |
| 324 | 301 | |
| 325 | - $logger->debug("3333333333333333333333333333333333333333 ".print_r($saida, true)); | |
| 302 | + //$logger->debug("3333333333333333333333333333333333333333 ".print_r($saida, true)); | |
| 326 | 303 | |
| 327 | 304 | return $this->render( 'CacicCommonBundle:Agente:deploy.html.twig', |
| 328 | 305 | array( | ... | ... |
src/Cacic/CommonBundle/Controller/RedeController.php
| ... | ... | @@ -734,40 +734,39 @@ class RedeController extends Controller |
| 734 | 734 | |
| 735 | 735 | // Varro todas as subredes para cada módulo |
| 736 | 736 | $subredes = array(); |
| 737 | - $windows = array(); | |
| 738 | - $linux = array(); | |
| 737 | + $saida = array(); | |
| 739 | 738 | foreach ($subredesOrig as $redeItem) { |
| 740 | - // Busca o módulo em cada uma das redes | |
| 739 | + // Busca o tipo de SO | |
| 741 | 740 | $codigos = array(); |
| 742 | - foreach ($modulos as $key => $value) { | |
| 743 | - $idRede = $redeItem['idRede']; | |
| 744 | - // Verifico se o módulo existe na subrede | |
| 745 | - $rede = $this->getDoctrine()->getRepository('CacicCommonBundle:RedeVersaoModulo')->subrede($idRede, $key); | |
| 746 | - | |
| 747 | - if (empty($rede)) { | |
| 748 | - // O módulo não foi encontrado. Adiciona o código 1 | |
| 749 | - array_push($codigos, 0); | |
| 750 | - //$rede = $redeItem[0]; | |
| 751 | - } else { | |
| 752 | - if ($value['hash'] == $rede[0]['teHash']) { | |
| 753 | - // Se o hash for igual, adiciona o código 2 | |
| 754 | - array_push($codigos, 2); | |
| 755 | - | |
| 741 | + foreach($modulos as $tipo_so => $file) { | |
| 742 | + // Busca o módulo em cada uma das redes | |
| 743 | + foreach ($file as $key => $value) { | |
| 744 | + $idRede = $redeItem['idRede']; | |
| 745 | + // Verifico se o módulo existe na subrede | |
| 746 | + $rede = $this->getDoctrine()->getRepository('CacicCommonBundle:RedeVersaoModulo')->subredeFilePath($idRede, $value['filename']); | |
| 747 | + | |
| 748 | + if (empty($rede)) { | |
| 749 | + // O módulo não foi encontrado. Adiciona o código 1 | |
| 750 | + array_push($codigos, 0); | |
| 751 | + //$rede = $redeItem[0]; | |
| 756 | 752 | } else { |
| 757 | - // Se o hash for diferente, adiciona o código 1 | |
| 758 | - array_push($codigos, 1); | |
| 753 | + if ($value['hash'] == $rede[0]['teHash']) { | |
| 754 | + // Se o hash for igual, adiciona o código 2 | |
| 755 | + array_push($codigos, 2); | |
| 756 | + | |
| 757 | + } else { | |
| 758 | + // Se o hash for diferente, adiciona o código 1 | |
| 759 | + array_push($codigos, 1); | |
| 760 | + } | |
| 759 | 761 | } |
| 760 | - } | |
| 761 | 762 | |
| 762 | - // Cria um array para Windows e outro para Linux | |
| 763 | - if ($value['tipoSo'] == 'windows') { | |
| 764 | - $windows[$key] = $value; | |
| 765 | - } else { | |
| 766 | - $linux[$key] = $value; | |
| 767 | - } | |
| 763 | + // Array de saída | |
| 764 | + $saida[$tipo_so][$value['name']] = $value; | |
| 768 | 765 | |
| 766 | + } | |
| 769 | 767 | } |
| 770 | 768 | |
| 769 | + | |
| 771 | 770 | // Define o elemento HTML para os módulos |
| 772 | 771 | if (in_array(0, $codigos)) { |
| 773 | 772 | // Se o código 0 for encontrato, marcamos o módulo como inexistente |
| ... | ... | @@ -799,10 +798,11 @@ class RedeController extends Controller |
| 799 | 798 | } |
| 800 | 799 | } |
| 801 | 800 | |
| 801 | + //$logger->debug("111111111111111111111111111111111111111 \n".print_r($saida, true)); | |
| 802 | + | |
| 802 | 803 | return $this->render( 'CacicCommonBundle:Rede:manutencaoNeo.html.twig', |
| 803 | 804 | array( |
| 804 | - 'windows'=> $windows, | |
| 805 | - 'linux' => $linux, | |
| 805 | + 'saida'=> $saida, | |
| 806 | 806 | 'subredes' => $subredes |
| 807 | 807 | ) |
| 808 | 808 | ); |
| ... | ... | @@ -839,78 +839,50 @@ class RedeController extends Controller |
| 839 | 839 | // Constrói array de arquivos e hashes |
| 840 | 840 | $saida = array(); |
| 841 | 841 | $base_url = $request->getBaseUrl(); |
| 842 | - $base_url = preg_replace('/\/app.*.php/', "/", $base_url); | |
| 842 | + $base_url = preg_replace('/\/app.*.php/', "", $base_url); | |
| 843 | 843 | |
| 844 | 844 | // Primeiro tratamos agentes Linux |
| 845 | 845 | // A regra é que o agente mais atual estará na pasta current |
| 846 | - $current = basename(readlink($linuxDir."current")); | |
| 846 | + $current = basename(readlink($cacicDir."current")); | |
| 847 | 847 | $finder = new Finder(); |
| 848 | - $finder->directories()->in($linuxDir); | |
| 848 | + $finder->depth('== 0'); | |
| 849 | + $finder->directories()->in($cacicDir); | |
| 849 | 850 | foreach($finder as $version) { |
| 850 | - $agentes = new Finder(); | |
| 851 | 851 | if ($version->getFileName() == 'current') { |
| 852 | - // Aqui considera somente a última versão | |
| 853 | - $agentes->files()->in($version->getRealPath()); | |
| 854 | - foreach ($agentes as $file) { | |
| 855 | - if (!empty($nmModulos)) { | |
| 856 | - // Filtra por nome de módulo | |
| 857 | - if (!in_array($file->getFileName(), $nmModulos)) { | |
| 858 | - continue; | |
| 852 | + $tipos = new Finder(); | |
| 853 | + $tipos->depth('== 0'); | |
| 854 | + $tipos->directories()->in($version->getRealPath()); | |
| 855 | + foreach($tipos as $tipo_so) { | |
| 856 | + // Aqui considera somente a última versão | |
| 857 | + $agentes = new Finder(); | |
| 858 | + $agentes->depth('== 0'); | |
| 859 | + $agentes->files()->in($tipo_so->getRealPath()); | |
| 860 | + foreach ($agentes as $file) { | |
| 861 | + $filename = 'cacic/' . $version->getFileName() . '/' . $tipo_so->getFileName() . "/" . $file->getFileName(); | |
| 862 | + if (!empty($nmModulos)) { | |
| 863 | + // Filtra por nome de módulo | |
| 864 | + if (!in_array($filename, $nmModulos)) { | |
| 865 | + continue; | |
| 866 | + } | |
| 859 | 867 | } |
| 868 | + $saida[$tipo_so->getFileName()][$file->getFileName()] = array( | |
| 869 | + 'name' => $file->getFileName(), | |
| 870 | + 'download_url' => $base_url . '/downloads/cacic/' . $version->getFileName() . '/' . $tipo_so->getFileName() . "/" . $file->getFileName(), | |
| 871 | + 'hash' => md5_file($file->getRealPath()), | |
| 872 | + 'size' => $file->getSize(), | |
| 873 | + 'filename' => $filename, | |
| 874 | + 'versao' => $current, | |
| 875 | + 'tipoSo' => $tipo_so->getFileName() | |
| 876 | + ); | |
| 860 | 877 | } |
| 861 | - $saida[$file->getFileName()] = array( | |
| 862 | - 'name' => $file->getFileName(), | |
| 863 | - 'versao' => $current, | |
| 864 | - 'download_url' => $base_url . 'downloads/cacic/linux/' . $version->getFileName() . '/' . $file->getFileName(), | |
| 865 | - 'hash' => md5_file($file->getRealPath()), | |
| 866 | - 'size' => $file->getSize(), | |
| 867 | - 'filename' => 'cacic/linux/' . $version->getFileName() . '/' . $file->getFileName(), | |
| 868 | - 'tipoSo' => 'linux' | |
| 869 | - ); | |
| 870 | 878 | } |
| 871 | - } else { | |
| 872 | - continue; | |
| 873 | - } | |
| 874 | - | |
| 875 | - } | |
| 876 | - // Get latest version | |
| 877 | - //$current = basename(readlink($cacicDir."current")); | |
| 878 | - //$saida['linux']['live_version'] = $current; | |
| 879 | 879 | |
| 880 | - // Aí tratamos Windows | |
| 881 | - $finder = new Finder(); | |
| 882 | - $finder->directories()->in($windowsDir); | |
| 883 | - $current = basename(readlink($windowsDir."current")); | |
| 884 | - foreach($finder as $version) { | |
| 885 | - $agentes = new Finder(); | |
| 886 | - if ($version->getFileName() == 'current') { | |
| 887 | - // Aqui considera somente a última versão | |
| 888 | - $agentes->files()->in($version->getRealPath()); | |
| 889 | - foreach ($agentes as $file) { | |
| 890 | - if (!empty($nmModulos)) { | |
| 891 | - // Filtra por nome de módulo | |
| 892 | - if (!in_array($file->getFileName(), $nmModulos)) { | |
| 893 | - continue; | |
| 894 | - } | |
| 895 | - } | |
| 896 | - $saida[$file->getFileName()] = array( | |
| 897 | - 'name' => $file->getFileName(), | |
| 898 | - 'versao' => $current, | |
| 899 | - 'download_url' => $base_url . 'downloads/cacic/windows/' . $version->getFileName() . '/' . $file->getFileName(), | |
| 900 | - 'hash' => md5_file($file->getRealPath()), | |
| 901 | - 'size' => $file->getSize(), | |
| 902 | - 'filename' => 'cacic/windows/' . $version->getFileName() . '/' . $file->getFileName(), | |
| 903 | - 'tipoSo' => 'windows' | |
| 904 | - ); | |
| 905 | - } | |
| 906 | 880 | } else { |
| 907 | 881 | continue; |
| 908 | 882 | } |
| 909 | 883 | |
| 910 | 884 | } |
| 911 | - // Get latest version | |
| 912 | - //$current = basename(readlink($windowsDir."current")); | |
| 913 | - //$saida['windows']['live_version'] = $current; | |
| 885 | + | |
| 914 | 886 | |
| 915 | 887 | // Retorna o array com todos os resultados |
| 916 | 888 | return $saida; |
| ... | ... | @@ -934,66 +906,84 @@ class RedeController extends Controller |
| 934 | 906 | $modulos = $this->modulosNeoArray($request, $modulos); |
| 935 | 907 | //$logger->debug("6666666666666666666666666666666666666 ".print_r($modulos, true)); |
| 936 | 908 | |
| 937 | - foreach ($modulos as $key => $value) | |
| 938 | - { | |
| 939 | - $logger->debug("Nome do módulo: $key"); | |
| 909 | + foreach($modulos as $tipo => $modulo) { | |
| 940 | 910 | |
| 941 | - // Carrega dados da rede | |
| 942 | - $em = $this->getDoctrine()->getManager(); | |
| 943 | - //$arrDadosRede = array( 'rede' => $em->getRepository( 'CacicCommonBundle:Rede' )->listar() ); | |
| 944 | - //Debug::dump($arrDadosRede['rede'][0][0]); | |
| 945 | - //$arrDadosRede = $arrDadosRede['rede'][0]; | |
| 946 | - $arrDadosRede = array( | |
| 947 | - 'teServUpdates' => $rede->getTeServUpdates(), | |
| 948 | - 'tePathServUpdates' => $rede->getTePathServUpdates(), | |
| 949 | - 'nmUsuarioLoginServUpdatesGerente' => $rede->getNmUsuarioLoginServUpdatesGerente(), | |
| 950 | - 'teSenhaLoginServUpdatesGerente' => $rede->getTeSenhaLoginServUpdatesGerente(), | |
| 951 | - 'nuPortaServUpdates' => $rede->getNuPortaServUpdates(), | |
| 952 | - ); | |
| 953 | - | |
| 954 | - $strResult = $this->checkAndSend( | |
| 955 | - $value['name'], | |
| 956 | - $downloadsDir . $value['filename'], | |
| 957 | - $arrDadosRede['teServUpdates'], | |
| 958 | - $arrDadosRede['tePathServUpdates'], | |
| 959 | - $arrDadosRede['nmUsuarioLoginServUpdatesGerente'], | |
| 960 | - $arrDadosRede['teSenhaLoginServUpdatesGerente'], | |
| 961 | - $arrDadosRede['nuPortaServUpdates'] | |
| 962 | - ); | |
| 963 | - | |
| 964 | - $arrResult = explode('_=_',$strResult); | |
| 965 | - | |
| 966 | - if ($arrResult[1] == 'Ok!') | |
| 911 | + foreach ($modulo as $key => $value) | |
| 967 | 912 | { |
| 968 | - // Consertar CRUD no Symfony | |
| 969 | - $redeVersaoModulo = $em->getRepository('CacicCommonBundle:RedeVersaoModulo')->findOneBy( | |
| 970 | - array( | |
| 971 | - 'idRede' => $pIntIdRede, | |
| 972 | - 'nmModulo' => $value['name'] | |
| 973 | - ) | |
| 913 | + $logger->debug("Nome do módulo: ".$value['filename']); | |
| 914 | + | |
| 915 | + // Carrega dados da rede | |
| 916 | + $em = $this->getDoctrine()->getManager(); | |
| 917 | + //$arrDadosRede = array( 'rede' => $em->getRepository( 'CacicCommonBundle:Rede' )->listar() ); | |
| 918 | + //Debug::dump($arrDadosRede['rede'][0][0]); | |
| 919 | + //$arrDadosRede = $arrDadosRede['rede'][0]; | |
| 920 | + $arrDadosRede = array( | |
| 921 | + 'teServUpdates' => $rede->getTeServUpdates(), | |
| 922 | + 'tePathServUpdates' => $rede->getTePathServUpdates(), | |
| 923 | + 'nmUsuarioLoginServUpdatesGerente' => $rede->getNmUsuarioLoginServUpdatesGerente(), | |
| 924 | + 'teSenhaLoginServUpdatesGerente' => $rede->getTeSenhaLoginServUpdatesGerente(), | |
| 925 | + 'nuPortaServUpdates' => $rede->getNuPortaServUpdates(), | |
| 974 | 926 | ); |
| 975 | 927 | |
| 976 | - // Se não existir, instancia o objeto | |
| 977 | - if (empty($redeVersaoModulo)) { | |
| 978 | - $redeVersaoModulo = new RedeVersaoModulo(null, null, null, null, null, $rede); | |
| 928 | + if ($rede->getDownloadMethod() == 'ftp') { | |
| 929 | + $strResult = $this->checkAndSend( | |
| 930 | + $value['name'], | |
| 931 | + $downloadsDir . $value['filename'], | |
| 932 | + $arrDadosRede['teServUpdates'], | |
| 933 | + $arrDadosRede['tePathServUpdates'], | |
| 934 | + $arrDadosRede['nmUsuarioLoginServUpdatesGerente'], | |
| 935 | + $arrDadosRede['teSenhaLoginServUpdatesGerente'], | |
| 936 | + $arrDadosRede['nuPortaServUpdates'] | |
| 937 | + ); | |
| 938 | + | |
| 939 | + $arrResult = explode('_=_',$strResult); | |
| 940 | + } else { | |
| 941 | + $arrResult[1] = 'Ok!'; | |
| 979 | 942 | } |
| 980 | 943 | |
| 981 | - // Adicione o restante dos atributos | |
| 982 | - $redeVersaoModulo->setNmModulo($value['name']); | |
| 983 | - $redeVersaoModulo->setTeVersaoModulo($value['versao']); | |
| 984 | - $redeVersaoModulo->setDtAtualizacao(new \DateTime('NOW')); | |
| 985 | - $redeVersaoModulo->setCsTipoSo( $value['tipoSo'] ); | |
| 986 | - $redeVersaoModulo->setTeHash($value['hash']); | |
| 987 | - $redeVersaoModulo->setTipo('cacic'); | |
| 988 | 944 | |
| 989 | - $em->persist($redeVersaoModulo); | |
| 990 | - $em->flush(); | |
| 991 | - } else { | |
| 992 | - $logger->error("Erro no envio dos módulos via FTP!\n".$arrResult[1]); | |
| 993 | - return false; | |
| 945 | + | |
| 946 | + if ($arrResult[1] == 'Ok!') | |
| 947 | + { | |
| 948 | + // Consertar CRUD no Symfony | |
| 949 | + $redeVersaoModulo = $em->getRepository('CacicCommonBundle:RedeVersaoModulo')->findOneBy( | |
| 950 | + array( | |
| 951 | + 'idRede' => $pIntIdRede, | |
| 952 | + 'nmModulo' => $value['name'], | |
| 953 | + 'filepath' => $value['filename'] | |
| 954 | + ) | |
| 955 | + ); | |
| 956 | + | |
| 957 | + // Se não existir, instancia o objeto | |
| 958 | + if (empty($redeVersaoModulo)) { | |
| 959 | + $redeVersaoModulo = new RedeVersaoModulo(null, null, null, null, null, $rede); | |
| 960 | + } | |
| 961 | + | |
| 962 | + $tipo_so = $em->getRepository('CacicCommonBundle:TipoSo')->findOneBy(array( | |
| 963 | + 'tipo' => $tipo | |
| 964 | + )); | |
| 965 | + | |
| 966 | + // Adicione o restante dos atributos | |
| 967 | + $redeVersaoModulo->setNmModulo($value['name']); | |
| 968 | + $redeVersaoModulo->setTeVersaoModulo($value['versao']); | |
| 969 | + $redeVersaoModulo->setDtAtualizacao(new \DateTime('NOW')); | |
| 970 | + $redeVersaoModulo->setCsTipoSo( $value['tipoSo'] ); | |
| 971 | + $redeVersaoModulo->setTeHash($value['hash']); | |
| 972 | + $redeVersaoModulo->setTipoSo($tipo_so); | |
| 973 | + $redeVersaoModulo->setFilepath($value['filename']); | |
| 974 | + $redeVersaoModulo->setTipo('cacic'); | |
| 975 | + | |
| 976 | + $em->persist($redeVersaoModulo); | |
| 977 | + $em->flush(); | |
| 978 | + } else { | |
| 979 | + $logger->error("Erro no envio dos módulos!\n".$arrResult[1]); | |
| 980 | + return false; | |
| 981 | + } | |
| 994 | 982 | } |
| 995 | 983 | } |
| 996 | 984 | |
| 985 | + | |
| 986 | + | |
| 997 | 987 | return true; |
| 998 | 988 | } |
| 999 | 989 | ... | ... |
src/Cacic/CommonBundle/DataFixtures/ORM/LoadRedeData.php
| ... | ... | @@ -37,6 +37,7 @@ class LoadRedeData extends AbstractFixture implements FixtureInterface, Containe |
| 37 | 37 | $rede->setNuLimiteFtp(100); |
| 38 | 38 | $rede->setCsPermitirDesativarSrcacic('S'); |
| 39 | 39 | $rede->setIdLocal($this->getReference('local')); |
| 40 | + $rede->setDownloadMethod('http'); | |
| 40 | 41 | |
| 41 | 42 | $manager->persist($rede); |
| 42 | 43 | $manager->flush(); | ... | ... |
src/Cacic/CommonBundle/Entity/RedeVersaoModulo.php
| ... | ... | @@ -239,4 +239,60 @@ class RedeVersaoModulo |
| 239 | 239 | { |
| 240 | 240 | return $this->tipo; |
| 241 | 241 | } |
| 242 | + /** | |
| 243 | + * @var \Cacic\CommonBundle\Entity\TipoSo | |
| 244 | + */ | |
| 245 | + private $tipoSo; | |
| 246 | + | |
| 247 | + | |
| 248 | + /** | |
| 249 | + * Set tipoSo | |
| 250 | + * | |
| 251 | + * @param \Cacic\CommonBundle\Entity\TipoSo $tipoSo | |
| 252 | + * @return RedeVersaoModulo | |
| 253 | + */ | |
| 254 | + public function setTipoSo(\Cacic\CommonBundle\Entity\TipoSo $tipoSo = null) | |
| 255 | + { | |
| 256 | + $this->tipoSo = $tipoSo; | |
| 257 | + | |
| 258 | + return $this; | |
| 259 | + } | |
| 260 | + | |
| 261 | + /** | |
| 262 | + * Get tipoSo | |
| 263 | + * | |
| 264 | + * @return \Cacic\CommonBundle\Entity\TipoSo | |
| 265 | + */ | |
| 266 | + public function getTipoSo() | |
| 267 | + { | |
| 268 | + return $this->tipoSo; | |
| 269 | + } | |
| 270 | + /** | |
| 271 | + * @var string | |
| 272 | + */ | |
| 273 | + private $filepath; | |
| 274 | + | |
| 275 | + | |
| 276 | + /** | |
| 277 | + * Set filepath | |
| 278 | + * | |
| 279 | + * @param string $filepath | |
| 280 | + * @return RedeVersaoModulo | |
| 281 | + */ | |
| 282 | + public function setFilepath($filepath) | |
| 283 | + { | |
| 284 | + $this->filepath = $filepath; | |
| 285 | + | |
| 286 | + return $this; | |
| 287 | + } | |
| 288 | + | |
| 289 | + /** | |
| 290 | + * Get filepath | |
| 291 | + * | |
| 292 | + * @return string | |
| 293 | + */ | |
| 294 | + public function getFilepath() | |
| 295 | + { | |
| 296 | + return $this->filepath; | |
| 297 | + } | |
| 242 | 298 | } | ... | ... |
src/Cacic/CommonBundle/Entity/RedeVersaoModuloRepository.php
| ... | ... | @@ -70,4 +70,39 @@ class RedeVersaoModuloRepository extends EntityRepository |
| 70 | 70 | return $qb->getQuery()->getArrayResult(); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | + /* | |
| 74 | + * Traz a lista de módulos para a subrede fornecida | |
| 75 | + */ | |
| 76 | + public function subredeFilePath($id = null, $modulo = null) | |
| 77 | + { | |
| 78 | + $qb = $this->createQueryBuilder('r') | |
| 79 | + ->select('red.idRede', | |
| 80 | + 'r.nmModulo', | |
| 81 | + 'r.teVersaoModulo', | |
| 82 | + 'r.teHash', | |
| 83 | + 'red.teIpRede', | |
| 84 | + 'red.nmRede', | |
| 85 | + 'red.teServUpdates', | |
| 86 | + 'red.tePathServUpdates', | |
| 87 | + 'l.nmLocal') | |
| 88 | + ->innerJoin('CacicCommonBundle:Rede', 'red', 'WITH', 'red.idRede = r.idRede') | |
| 89 | + ->innerJoin('CacicCommonBundle:Local', 'l', 'WITH', 'red.idLocal = l.idLocal') | |
| 90 | + ->groupBy('r', 'l', 'red') | |
| 91 | + ->orderBy('red.nmRede'); | |
| 92 | + | |
| 93 | + // Adiciona filtro por módulo se fornecido | |
| 94 | + if ($modulo != null) { | |
| 95 | + // Aqui trago somente a lista de todos os módulos naquela subrede | |
| 96 | + $qb->andWhere('r.filepath = :modulo')->setParameter('modulo', $modulo); | |
| 97 | + } | |
| 98 | + | |
| 99 | + // Adiciona filtro por subrede se fornecido | |
| 100 | + if ($id != null) { | |
| 101 | + // Somente os módulos desa subrede | |
| 102 | + $qb->andWhere('r.idRede = :id')->setParameter('id', $id); | |
| 103 | + } | |
| 104 | + | |
| 105 | + return $qb->getQuery()->getArrayResult(); | |
| 106 | + } | |
| 107 | + | |
| 73 | 108 | } |
| 74 | 109 | \ No newline at end of file | ... | ... |
src/Cacic/CommonBundle/Entity/TipoSo.php
| ... | ... | @@ -97,4 +97,42 @@ class TipoSo |
| 97 | 97 | { |
| 98 | 98 | return $this->so; |
| 99 | 99 | } |
| 100 | + /** | |
| 101 | + * @var \Doctrine\Common\Collections\Collection | |
| 102 | + */ | |
| 103 | + private $redeVersaoModulo; | |
| 104 | + | |
| 105 | + | |
| 106 | + /** | |
| 107 | + * Add redeVersaoModulo | |
| 108 | + * | |
| 109 | + * @param \Cacic\CommonBundle\Entity\RedeVersaoModulo $redeVersaoModulo | |
| 110 | + * @return TipoSo | |
| 111 | + */ | |
| 112 | + public function addRedeVersaoModulo(\Cacic\CommonBundle\Entity\RedeVersaoModulo $redeVersaoModulo) | |
| 113 | + { | |
| 114 | + $this->redeVersaoModulo[] = $redeVersaoModulo; | |
| 115 | + | |
| 116 | + return $this; | |
| 117 | + } | |
| 118 | + | |
| 119 | + /** | |
| 120 | + * Remove redeVersaoModulo | |
| 121 | + * | |
| 122 | + * @param \Cacic\CommonBundle\Entity\RedeVersaoModulo $redeVersaoModulo | |
| 123 | + */ | |
| 124 | + public function removeRedeVersaoModulo(\Cacic\CommonBundle\Entity\RedeVersaoModulo $redeVersaoModulo) | |
| 125 | + { | |
| 126 | + $this->redeVersaoModulo->removeElement($redeVersaoModulo); | |
| 127 | + } | |
| 128 | + | |
| 129 | + /** | |
| 130 | + * Get redeVersaoModulo | |
| 131 | + * | |
| 132 | + * @return \Doctrine\Common\Collections\Collection | |
| 133 | + */ | |
| 134 | + public function getRedeVersaoModulo() | |
| 135 | + { | |
| 136 | + return $this->redeVersaoModulo; | |
| 137 | + } | |
| 100 | 138 | } | ... | ... |
src/Cacic/CommonBundle/Form/Type/AgenteType.php
| ... | ... | @@ -10,6 +10,7 @@ namespace Cacic\CommonBundle\Form\Type; |
| 10 | 10 | |
| 11 | 11 | use Symfony\Component\Form\AbstractType; |
| 12 | 12 | use Symfony\Component\Form\FormBuilderInterface; |
| 13 | +use Symfony\Component\OptionsResolver\OptionsResolverInterface; | |
| 13 | 14 | |
| 14 | 15 | /** |
| 15 | 16 | * Formulário para upload dos agentes |
| ... | ... | @@ -30,33 +31,39 @@ class AgenteType extends AbstractType { |
| 30 | 31 | |
| 31 | 32 | public function buildForm( FormBuilderInterface $builder, array $options ) |
| 32 | 33 | { |
| 33 | - $builder->add('windows_version', 'text', | |
| 34 | - array( | |
| 35 | - 'label' => 'Versão dos Agentes Windows', | |
| 36 | - 'required' => false | |
| 37 | - ) | |
| 38 | - ); | |
| 34 | + $tipo_so = $options['tipo_so']; | |
| 39 | 35 | |
| 40 | - $builder->add('windows', 'file', | |
| 36 | + $builder->add('version', 'text', | |
| 41 | 37 | array( |
| 42 | - 'label' => 'Agentes Windows', | |
| 38 | + 'label' => 'Versão dos Agentes', | |
| 43 | 39 | 'required' => false |
| 44 | 40 | ) |
| 45 | 41 | ); |
| 46 | 42 | |
| 47 | - $builder->add('linux_version', 'text', | |
| 48 | - array( | |
| 49 | - 'label' => 'Versão dos Agentes Linux', | |
| 50 | - 'required' => false | |
| 51 | - ) | |
| 52 | - ); | |
| 43 | + foreach($tipo_so as $so) { | |
| 44 | + $builder->add($so->getTipo(), 'file', | |
| 45 | + array( | |
| 46 | + 'label' => 'Agentes para SO Tipo '.$so->getTipo(), | |
| 47 | + 'required' => false | |
| 48 | + ) | |
| 49 | + ); | |
| 50 | + } | |
| 53 | 51 | |
| 54 | - $builder->add('linux', 'file', | |
| 55 | - array( | |
| 56 | - 'label' => 'Agentes Linux', | |
| 57 | - 'required' => false | |
| 58 | - ) | |
| 59 | - ); | |
| 60 | 52 | } |
| 61 | 53 | |
| 54 | + /** | |
| 55 | + * Add TipoSo as required option | |
| 56 | + * | |
| 57 | + * @param OptionsResolverInterface $resolver | |
| 58 | + */ | |
| 59 | + public function setDefaultOptions(OptionsResolverInterface $resolver) | |
| 60 | + { | |
| 61 | + $resolver | |
| 62 | + ->setRequired(array( | |
| 63 | + 'tipo_so', | |
| 64 | + )); | |
| 65 | + | |
| 66 | + } | |
| 67 | + | |
| 68 | + | |
| 62 | 69 | } |
| 63 | 70 | \ No newline at end of file | ... | ... |
src/Cacic/CommonBundle/Form/Type/RedeType.php
| ... | ... | @@ -80,7 +80,7 @@ class RedeType extends AbstractType |
| 80 | 80 | 'http' => 'HTTP' |
| 81 | 81 | ), |
| 82 | 82 | 'required' => true, |
| 83 | - 'data' => 'ftp', | |
| 83 | + //'data' => 'ftp', | |
| 84 | 84 | //'expanded' => true, |
| 85 | 85 | ) |
| 86 | 86 | ); |
| ... | ... | @@ -97,15 +97,18 @@ class RedeType extends AbstractType |
| 97 | 97 | $builder->add('nuPortaServUpdates', null, |
| 98 | 98 | array( |
| 99 | 99 | 'label' => 'Porta', |
| 100 | - 'data'=>'21' | |
| 100 | + 'data'=>'21', | |
| 101 | + 'required' => false | |
| 101 | 102 | ) |
| 102 | 103 | ); |
| 103 | 104 | $builder->add('nuLimiteFtp', null, |
| 104 | 105 | array( |
| 105 | 106 | 'label' => 'Limite FTP', |
| 106 | - 'data'=>'100' | |
| 107 | + 'data'=>'100', | |
| 108 | + 'required' => false | |
| 107 | 109 | ) |
| 108 | 110 | ); |
| 111 | + /* | |
| 109 | 112 | $builder->add('nmUsuarioLoginServUpdates', null, |
| 110 | 113 | array( |
| 111 | 114 | 'label' => 'Usuário do Servidor de Updates (para AGENTE)' |
| ... | ... | @@ -117,9 +120,11 @@ class RedeType extends AbstractType |
| 117 | 120 | 'required' => false |
| 118 | 121 | ) |
| 119 | 122 | ); |
| 123 | + */ | |
| 120 | 124 | $builder->add('nmUsuarioLoginServUpdatesGerente', null, |
| 121 | 125 | array( |
| 122 | - 'label' => 'Usuário do Servidor de Updates (para GERENTE)' | |
| 126 | + 'label' => 'Usuário do Servidor de Updates (para GERENTE)', | |
| 127 | + 'required' => false | |
| 123 | 128 | ) |
| 124 | 129 | ); |
| 125 | 130 | $builder->add('teSenhaLoginServUpdatesGerente', 'password', |
| ... | ... | @@ -130,7 +135,8 @@ class RedeType extends AbstractType |
| 130 | 135 | ); |
| 131 | 136 | $builder->add('tePathServUpdates', null, |
| 132 | 137 | array( |
| 133 | - 'label' => 'Path no Servidor de Updates' | |
| 138 | + 'label' => 'Path no Servidor de Updates', | |
| 139 | + 'required' => false | |
| 134 | 140 | ) |
| 135 | 141 | ); |
| 136 | 142 | $builder->add('teObservacao', 'textarea', | ... | ... |
src/Cacic/CommonBundle/Resources/config/doctrine/RedeVersaoModulo.orm.yml
| ... | ... | @@ -40,6 +40,10 @@ Cacic\CommonBundle\Entity\RedeVersaoModulo: |
| 40 | 40 | fixed: false |
| 41 | 41 | nullable: true |
| 42 | 42 | column: tipo |
| 43 | + filepath: | |
| 44 | + type: text | |
| 45 | + nullable: true | |
| 46 | + column: filepath | |
| 43 | 47 | manyToOne: |
| 44 | 48 | idRede: |
| 45 | 49 | targetEntity: Rede |
| ... | ... | @@ -50,4 +54,13 @@ Cacic\CommonBundle\Entity\RedeVersaoModulo: |
| 50 | 54 | id_rede: |
| 51 | 55 | referencedColumnName: id_rede |
| 52 | 56 | orphanRemoval: false |
| 57 | + tipoSo: | |
| 58 | + targetEntity: TipoSo | |
| 59 | + cascade: { } | |
| 60 | + mappedBy: null | |
| 61 | + inversedBy: null | |
| 62 | + joinColumns: | |
| 63 | + id_tipo_so: | |
| 64 | + referencedColumnName: id_tipo_so | |
| 65 | + orphanRemoval: false | |
| 53 | 66 | lifecycleCallbacks: { } | ... | ... |
src/Cacic/CommonBundle/Resources/config/doctrine/TipoSo.orm.yml
src/Cacic/CommonBundle/Resources/views/Agente/index.html.twig
| ... | ... | @@ -40,13 +40,9 @@ |
| 40 | 40 | |
| 41 | 41 | {{ form_errors(form) }} |
| 42 | 42 | |
| 43 | - {{ form_row(form.windows_version) }} | |
| 43 | + {{ form_row(form.version) }} | |
| 44 | 44 | |
| 45 | - {{ form_row(form.windows) }} | |
| 46 | - | |
| 47 | - {{ form_row(form.linux_version) }} | |
| 48 | - | |
| 49 | - {{ form_row(form.linux) }} | |
| 45 | + {{ form_rest(form) }} | |
| 50 | 46 | |
| 51 | 47 | <input type="submit"> |
| 52 | 48 | |
| ... | ... | @@ -82,65 +78,12 @@ |
| 82 | 78 | <div class="box grad_colour_black"> |
| 83 | 79 | <h2 class="box_head round_top"><i class="icon-list"></i> {{'Resultado da pesquisa' |trans }}</h2> |
| 84 | 80 | |
| 85 | - <div class="block box_content round_bottom padding_10"> | |
| 86 | - <h4><center>{{ "Agentes para GNU/LINUX"|trans }}</h4> | |
| 87 | - <table class="table table-striped table-bordered"> | |
| 88 | - <thead> | |
| 89 | - <tr> | |
| 90 | - <th width="15%" style="text-align: center">{{ 'Versão'|trans }}</th> | |
| 91 | - <th width="30%" style="text-align: center">{{ 'Arquivo'|trans }}</th> | |
| 92 | - <th width="25%" style="text-align: center">{{ 'Hash'|trans }}</th> | |
| 93 | - <th width="20%" style="text-align: center">{{ 'Tamanho'|trans }}</th> | |
| 94 | - <th style="text-align: center">{{ "Ações"|trans }}</th> | |
| 95 | - </tr> | |
| 96 | - </thead> | |
| 97 | - <tbody> | |
| 98 | - | |
| 99 | - {% for version, value in saida.linux.versions %} | |
| 100 | - | |
| 101 | - {% if version == saida.linux.live_version %} | |
| 102 | - <tr> | |
| 103 | - <th rowspan="{{ value|length + 1 }}" style="vertical-align: middle; text-align: center;"> | |
| 104 | - {{ "Versão"|trans }} {{ version }} <br> {{ "(Em Produção)"|trans }} | |
| 105 | - </th> | |
| 106 | - </tr> | |
| 107 | - {% else %} | |
| 108 | - <tr> | |
| 109 | - <th rowspan="{{ value|length + 1 }}" style="vertical-align: middle; text-align: center;"> | |
| 110 | - {{ "Versão"|trans }} {{ version }} | |
| 111 | - </th> | |
| 112 | - </tr> | |
| 113 | - {% endif %} | |
| 114 | 81 | |
| 115 | - {% for modulo in value %} | |
| 82 | + <div class="block box_content round_bottom padding_10"> | |
| 116 | 83 | |
| 117 | - <tr id="{{ modulo['filename'] }}" class="{{ cycle(['row0', 'row1'], loop.index) }}"> | |
| 118 | - <td style="text-align: center" >{{ modulo['name'] }}</td> | |
| 119 | - <td style="text-align: center" >{{ modulo['hash'] }}</td> | |
| 120 | - <td style="text-align: center" >{{ format.bytesToSize(modulo['size']) }}</td> | |
| 121 | - <td class="td-actions"> | |
| 122 | - <a href="{{ path('cacic_agente_excluir') }}" class="btn btn-small btn-danger bt-excluir" title="{{ "Excluir Item"|trans }}"> | |
| 123 | - <i class="btn-icon-only icon-trash icon-large"></i> | |
| 124 | - </a> | |
| 125 | - <a href="{{ modulo['download_url'] }}" class="btn btn-small" title="{{ "Baixar"|trans }}" target="_blank"> | |
| 126 | - <i class="btn-icon-only icon-download-alt icon-large"></i> | |
| 127 | - </a> | |
| 128 | - </td> | |
| 129 | - </tr> | |
| 130 | - {% else %} | |
| 131 | - <tr> | |
| 132 | - <td style="text-align: center" colspan="6"><b>{{ 'NENHUM REGISTRO ENCONTRADO!'|trans }}</b></td> | |
| 133 | - </tr> | |
| 134 | - {% endfor %} | |
| 135 | - {% else %} | |
| 136 | - <tr> | |
| 137 | - <td style="text-align: center" colspan="6"><b>{{ 'NENHUM REGISTRO ENCONTRADO!'|trans }}</b></td> | |
| 138 | - </tr> | |
| 139 | - {% endfor %} | |
| 140 | - </tbody> | |
| 141 | - </table> | |
| 84 | + {% for tipo, so in saida.tipo_so %} | |
| 142 | 85 | |
| 143 | - <h4><center>{{ "Agentes para Windows"|trans }}</h4> | |
| 86 | + <h4><center>{{ "Agentes para "|trans }}{{ tipo }}</h4> | |
| 144 | 87 | <table class="table table-striped table-bordered"> |
| 145 | 88 | <thead> |
| 146 | 89 | <tr> |
| ... | ... | @@ -153,9 +96,9 @@ |
| 153 | 96 | </thead> |
| 154 | 97 | <tbody> |
| 155 | 98 | |
| 156 | - {% for version, value in saida.windows.versions %} | |
| 99 | + {% for version, value in so %} | |
| 157 | 100 | |
| 158 | - {% if version == saida.windows.live_version %} | |
| 101 | + {% if version == saida.live_version %} | |
| 159 | 102 | <tr> |
| 160 | 103 | <th rowspan="{{ value|length + 1 }}" style="vertical-align: middle; text-align: center;"> |
| 161 | 104 | {{ "Versão"|trans }} {{ version }} <br> {{ "(Em Produção)"|trans }} |
| ... | ... | @@ -169,7 +112,6 @@ |
| 169 | 112 | </tr> |
| 170 | 113 | {% endif %} |
| 171 | 114 | |
| 172 | - | |
| 173 | 115 | {% for modulo in value %} |
| 174 | 116 | |
| 175 | 117 | <tr id="{{ modulo['filename'] }}" class="{{ cycle(['row0', 'row1'], loop.index) }}"> |
| ... | ... | @@ -197,6 +139,7 @@ |
| 197 | 139 | {% endfor %} |
| 198 | 140 | </tbody> |
| 199 | 141 | </table> |
| 142 | + {% endfor %} | |
| 200 | 143 | |
| 201 | 144 | </div> <!-- /block --> |
| 202 | 145 | </div> <!-- /box --> | ... | ... |
src/Cacic/CommonBundle/Resources/views/Rede/cadastrar.html.twig
| ... | ... | @@ -39,13 +39,13 @@ |
| 39 | 39 | {{ form_row(form.teServUpdates, {'form_type': 'horizontal'} ) }} |
| 40 | 40 | {{ form_row(form.downloadMethod, {'form_type': 'horizontal'} ) }} |
| 41 | 41 | {{ form_row(form.selTeServUpdates, {'form_type': 'horizontal'} ) }} |
| 42 | - {{ form_row(form.nuPortaServUpdates, {'form_type': 'horizontal'} ) }} | |
| 43 | - {{ form_row(form.nuLimiteFtp, {'form_type': 'horizontal'} ) }} | |
| 44 | - {{ form_row(form.nmUsuarioLoginServUpdates, {'form_type': 'horizontal'} ) }} | |
| 45 | - {{ form_row(form.teSenhaLoginServUpdates, {'form_type': 'horizontal'} ) }} | |
| 46 | - {{ form_row(form.nmUsuarioLoginServUpdatesGerente, {'form_type': 'horizontal'} ) }} | |
| 47 | - {{ form_row(form.teSenhaLoginServUpdatesGerente, {'form_type': 'horizontal'} ) }} | |
| 48 | - {{ form_row(form.tePathServUpdates, {'form_type': 'horizontal'} ) }} | |
| 42 | + <div id="rede_ftp"> | |
| 43 | + {{ form_row(form.nuPortaServUpdates, {'form_type': 'horizontal'} ) }} | |
| 44 | + {{ form_row(form.nuLimiteFtp, {'form_type': 'horizontal'} ) }} | |
| 45 | + {{ form_row(form.nmUsuarioLoginServUpdatesGerente, {'form_type': 'horizontal'} ) }} | |
| 46 | + {{ form_row(form.teSenhaLoginServUpdatesGerente, {'form_type': 'horizontal'} ) }} | |
| 47 | + {{ form_row(form.tePathServUpdates, {'form_type': 'horizontal'} ) }} | |
| 48 | + </div> | |
| 49 | 49 | {{ form_row(form.teObservacao, {'form_type': 'horizontal'} ) }} |
| 50 | 50 | </fieldset> |
| 51 | 51 | |
| ... | ... | @@ -146,6 +146,17 @@ |
| 146 | 146 | // Verifica se o nono dígito foi informado |
| 147 | 147 | |
| 148 | 148 | }); |
| 149 | + | |
| 150 | + $('#rede_downloadMethod') | |
| 151 | + .on('change', function(e){ | |
| 152 | + // Esconde os elementos se o método for HTTP | |
| 153 | + var method = $(this).val(); | |
| 154 | + if ( method == 'http') { | |
| 155 | + $('#rede_ftp').hide(); | |
| 156 | + } else { | |
| 157 | + $('#rede_ftp').show(); | |
| 158 | + } | |
| 159 | + }); | |
| 149 | 160 | }); |
| 150 | 161 | |
| 151 | 162 | //System.Form.focusFirstTabOnError('#formRede'); | ... | ... |
src/Cacic/CommonBundle/Resources/views/Rede/manutencaoNeo.html.twig
| ... | ... | @@ -20,77 +20,45 @@ |
| 20 | 20 | <br /> |
| 21 | 21 | |
| 22 | 22 | <form id={{ 'formSoftwaresNaoUsados'|trans }} class="form-horizontal" action="{{ path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params')) }}" method="post"> |
| 23 | - <h4 align="center">{{ "Agentes para MS-Windows"|trans }}</h4> | |
| 24 | - <table class="table table-striped table-bordered"> | |
| 25 | - <thead> | |
| 26 | - <tr> | |
| 27 | - <th width="40%" style="text-align: center">{{ 'Arquivo'|trans }}</th> | |
| 28 | - <th width="20%" style="text-align: center">{{ 'Versão'|trans }}</th> | |
| 29 | - <th width="40%" style="text-align: center">{{ 'Hash'|trans }}</th> | |
| 30 | - <th style="text-align: center"> | |
| 31 | - <label style="margin: auto; width:12px; height:10px;"> | |
| 32 | - <input type="checkbox" class="toggleCheck" name="toggleCheck[]" value="windows" checked> | |
| 33 | - </label> | |
| 34 | - </th> | |
| 35 | - </tr> | |
| 36 | - </thead> | |
| 37 | - <tbody> | |
| 38 | - | |
| 39 | - {% for key, modulo in windows %} | |
| 40 | 23 | |
| 41 | - <tr id="item_{{ key }}"> | |
| 42 | - <td style="text-align: center" id="item_desc_{{ key }}">{{ key }}</td> | |
| 43 | - <td style="text-align: center" >{{ modulo['versao'] }}</td> | |
| 44 | - <td style="text-align: center" >{{ modulo['hash'] }}</td> | |
| 45 | - <td> | |
| 46 | - <label style="margin: auto; width:12px; height:10px;"> | |
| 47 | - <input type="checkbox" id="item_id_{{ key }}" name="windows[]" value="{{ key }}" checked> | |
| 48 | - </label> | |
| 49 | - </td> | |
| 50 | - </tr> | |
| 51 | - {% else %} | |
| 52 | - <tr> | |
| 53 | - <td style="text-align: center" colspan="6"><b>{{ 'NENHUM REGISTRO ENCONTRADO!'|trans }}</b></td> | |
| 54 | - </tr> | |
| 55 | - {% endfor %} | |
| 56 | - </tbody> | |
| 57 | - </table> | |
| 58 | - <br /> | |
| 59 | - <table class="table table-striped table-bordered"> | |
| 60 | - <h4><center>{{ "Agentes para GNU/LINUX"|trans }}</h4> | |
| 61 | - <thead> | |
| 62 | - <tr> | |
| 63 | - <th width="40%"style="text-align: center">{{ 'Arquivo'|trans }}</th> | |
| 64 | - <th width="20%"style="text-align: center">{{ 'Versão'|trans }}</th> | |
| 65 | - <th width="40%"style="text-align: center">{{ 'Hash'|trans }}</th> | |
| 66 | - <th style="text-align: center"> | |
| 67 | - <label style="margin: auto; width:12px; height:10px;"> | |
| 68 | - <input type="checkbox" class="toggleCheck" name="toggleCheck[]" value="linux" checked> | |
| 69 | - </label> | |
| 70 | - </th> | |
| 71 | - </tr> | |
| 72 | - </thead> | |
| 73 | - <tbody> | |
| 74 | - {% for key, modulo in linux %} | |
| 75 | - | |
| 76 | - <tr id="item_{{ key }}"> | |
| 77 | - <td style="text-align: center" id="item_desc_{{ key }}">{{ key }}</td> | |
| 78 | - <td style="text-align: center" >{{ modulo['versao'] }}</td> | |
| 79 | - <td style="text-align: center" >{{ modulo['hash'] }}</td> | |
| 80 | - <td> | |
| 81 | - <label style="margin: auto; width:12px; height:10px;"> | |
| 82 | - <input type="checkbox" id="item_id_{{ key }}" name="linux[]" value="{{ key }}" checked> | |
| 83 | - </label> | |
| 84 | - </td> | |
| 85 | - </tr> | |
| 86 | - {% else %} | |
| 87 | - <tr> | |
| 88 | - <td style="text-align: center" colspan="6"><b>{{ 'NENHUM REGISTRO ENCONTRADO!'|trans }}</b></td> | |
| 89 | - </tr> | |
| 24 | + {% for so, files in saida %} | |
| 25 | + <h4 align="center">{{ "Agentes para "|trans }}{{ so }}</h4> | |
| 26 | + <table class="table table-striped table-bordered"> | |
| 27 | + <thead> | |
| 28 | + <tr> | |
| 29 | + <th width="40%" style="text-align: center">{{ 'Arquivo'|trans }}</th> | |
| 30 | + <th width="20%" style="text-align: center">{{ 'Versão'|trans }}</th> | |
| 31 | + <th width="40%" style="text-align: center">{{ 'Hash'|trans }}</th> | |
| 32 | + <th style="text-align: center"> | |
| 33 | + <label style="margin: auto; width:12px; height:10px;"> | |
| 34 | + <input type="checkbox" class="toggleCheck" name="toggleCheck[]" value="windows" checked> | |
| 35 | + </label> | |
| 36 | + </th> | |
| 37 | + </tr> | |
| 38 | + </thead> | |
| 39 | + <tbody> | |
| 40 | + | |
| 41 | + {% for key, modulo in files %} | |
| 42 | + | |
| 43 | + <tr id="item_{{ modulo['filename'] }}"> | |
| 44 | + <td style="text-align: center" id="item_desc_{{ key }}">{{ key }}</td> | |
| 45 | + <td style="text-align: center" >{{ modulo['versao'] }}</td> | |
| 46 | + <td style="text-align: center" >{{ modulo['hash'] }}</td> | |
| 47 | + <td> | |
| 48 | + <label style="margin: auto; width:12px; height:10px;"> | |
| 49 | + <input type="checkbox" id="item_id_{{ modulo['filename'] }}" name="windows[]" value="{{ modulo['filename'] }}" checked> | |
| 50 | + </label> | |
| 51 | + </td> | |
| 52 | + </tr> | |
| 53 | + {% else %} | |
| 54 | + <tr> | |
| 55 | + <td style="text-align: center" colspan="6"><b>{{ 'NENHUM REGISTRO ENCONTRADO!'|trans }}</b></td> | |
| 56 | + </tr> | |
| 57 | + {% endfor %} | |
| 58 | + </tbody> | |
| 59 | + </table> | |
| 60 | + <br /> | |
| 90 | 61 | {% endfor %} |
| 91 | - | |
| 92 | - </tbody> | |
| 93 | - </table> | |
| 94 | 62 | <br /> |
| 95 | 63 | |
| 96 | 64 | <hr> | ... | ... |
src/Cacic/CommonBundle/Tests/BaseTestCase.php
src/Cacic/WSBundle/Controller/NeoController.php
| ... | ... | @@ -245,9 +245,11 @@ class NeoController extends Controller { |
| 245 | 245 | |
| 246 | 246 | // 0 - Array de saída |
| 247 | 247 | $saida['agentcomputer'] = ""; |
| 248 | + $so_json = $dados['computador']['operatingSystem']; | |
| 248 | 249 | |
| 249 | 250 | |
| 250 | 251 | // 1 - Ações para o computador |
| 252 | + //$logger->debug("11111111111111111111111111111111 ".print_r($computador->getIdRede(), true)); | |
| 251 | 253 | $acoes = $em->getRepository('CacicCommonBundle:Acao')->listaAcaoComputador( |
| 252 | 254 | $computador->getIdRede()->getIdRede(), |
| 253 | 255 | $computador->getIdSo()->getIdSo(), |
| ... | ... | @@ -277,11 +279,16 @@ class NeoController extends Controller { |
| 277 | 279 | if (empty($mods[$tipo])) { |
| 278 | 280 | $mods[$tipo] = array(); |
| 279 | 281 | } |
| 280 | - // Adiciona módulos e hashes | |
| 281 | - array_push($mods[$tipo], array( | |
| 282 | - 'nome' => $elm->getNmModulo(), | |
| 283 | - 'hash' => $elm->getTeHash() | |
| 284 | - )); | |
| 282 | + | |
| 283 | + // Adiciona somente o módulo que estiver com o tipo de SO cadastrado | |
| 284 | + if ($so_json['tipo'] == $elm->getTipoSo()->getTipo() ) { | |
| 285 | + // Adiciona módulos e hashes | |
| 286 | + array_push($mods[$tipo], array( | |
| 287 | + 'nome' => $elm->getNmModulo(), | |
| 288 | + 'hash' => $elm->getTeHash() | |
| 289 | + )); | |
| 290 | + } | |
| 291 | + | |
| 285 | 292 | } |
| 286 | 293 | $saida['agentcomputer']['modulos'] = $mods; |
| 287 | 294 | //$logger->debug("2222222222222222222222222222222222222 \n".print_r($saida, true)); |
| ... | ... | @@ -302,10 +309,20 @@ class NeoController extends Controller { |
| 302 | 309 | $saida['agentcomputer']['metodoDownload'] = array( |
| 303 | 310 | "tipo" => $computador->getIdRede()->getDownloadMethod(), |
| 304 | 311 | "url" => $computador->getIdRede()->getTeServUpdates(), |
| 305 | - "path" => $computador->getIdRede()->getTePathServUpdates(), | |
| 306 | 312 | "usuario" => $computador->getIdRede()->getNmUsuarioLoginServUpdates(), |
| 307 | 313 | "senha" => $computador->getIdRede()->getTeSenhaLoginServUpdates() |
| 308 | 314 | ); |
| 315 | + | |
| 316 | + // 4.1 - Configuração de método de Download | |
| 317 | + if ($computador->getIdRede()->getDownloadMethod() == 'http') { | |
| 318 | + $base_url = $request->getBaseUrl(); | |
| 319 | + $base_url = preg_replace('/\/app.*.php/', "", $base_url); | |
| 320 | + $saida['agentcomputer']['metodoDownload']['path'] = $base_url . '/downloads/cacic/current/' . $so_json['tipo']; | |
| 321 | + } else { | |
| 322 | + $saida['agentcomputer']['metodoDownload']['path'] = $computador->getIdRede()->getTePathServUpdates(); | |
| 323 | + } | |
| 324 | + | |
| 325 | + | |
| 309 | 326 | //$logger->debug("4444444444444444444444444444444444444444 \n".print_r($saida, true)); |
| 310 | 327 | |
| 311 | 328 | // 5 - Configurações do local | ... | ... |
src/Cacic/WSBundle/DataFixtures/ORM/LoadRedeVersaoModuloData.php
0 → 100644
| ... | ... | @@ -0,0 +1,99 @@ |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Created by PhpStorm. | |
| 4 | + * User: eduardo | |
| 5 | + * Date: 07/11/14 | |
| 6 | + * Time: 23:38 | |
| 7 | + */ | |
| 8 | + | |
| 9 | +namespace Cacic\WSBundle\DataFixtures\ORM; | |
| 10 | + | |
| 11 | +use Cacic\CommonBundle\Entity\TipoSo; | |
| 12 | +use Doctrine\Common\DataFixtures\AbstractFixture; | |
| 13 | +use Doctrine\Common\DataFixtures\FixtureInterface; | |
| 14 | +use Doctrine\Common\DataFixtures\OrderedFixtureInterface; | |
| 15 | +use Doctrine\Common\Persistence\ObjectManager; | |
| 16 | +use Symfony\Component\DependencyInjection\ContainerAwareInterface; | |
| 17 | +use Symfony\Component\DependencyInjection\ContainerInterface; | |
| 18 | + | |
| 19 | +use Cacic\CommonBundle\Entity\RedeVersaoModulo; | |
| 20 | + | |
| 21 | + | |
| 22 | +class LoadRedeVersaoModuloData extends AbstractFixture implements FixtureInterface, ContainerAwareInterface, OrderedFixtureInterface { | |
| 23 | + | |
| 24 | + /* | |
| 25 | + * Array de dados das classes que serão carregadas | |
| 26 | + */ | |
| 27 | + private $modulos = array( | |
| 28 | + array('nmModulo' => 'cacic-service.exe', | |
| 29 | + 'teVersaoModulo' => '3.0a1', | |
| 30 | + 'csTipoSo' => 'windows-64-bit', | |
| 31 | + 'teHash' => '79df3561f83ac86eb19e2996b17d5e30', | |
| 32 | + 'tipo' => 'cacic', | |
| 33 | + 'tipoSo' => 'windows-64-bit', | |
| 34 | + 'filepath' => 'cacic/current/Windows-64-bit/cacic-service.exe' | |
| 35 | + ), | |
| 36 | + array('nmModulo' => 'install-cacic.exe', | |
| 37 | + 'teVersaoModulo' => '3.0a1', | |
| 38 | + 'csTipoSo' => 'windows-64-bit', | |
| 39 | + 'teHash' => '50cf34bf584880fd401619eb367b2c2d', | |
| 40 | + 'tipo' => 'cacic', | |
| 41 | + 'tipoSo' => 'windows-64-bit', | |
| 42 | + 'filepath' => 'cacic/current/linux-64-bit/install-cacic.exe' | |
| 43 | + ), | |
| 44 | + array('nmModulo' => 'cacic-service', | |
| 45 | + 'teVersaoModulo' => '3.0a1', | |
| 46 | + 'csTipoSo' => 'linux-64-bit', | |
| 47 | + 'teHash' => 'd61f05787b452246bd75d0cfb16bf415', | |
| 48 | + 'tipo' => 'cacic', | |
| 49 | + 'tipoSo' => 'linux-64-bit', | |
| 50 | + 'filepath' => 'cacic/current/Windows-64-bit/cacic-service' | |
| 51 | + ), | |
| 52 | + array('nmModulo' => 'install-cacic', | |
| 53 | + 'teVersaoModulo' => '3.0a1', | |
| 54 | + 'csTipoSo' => 'linux-64-bit', | |
| 55 | + 'teHash' => '548b95c40a9a3336ec85bcd3e87a62e3', | |
| 56 | + 'tipo' => 'cacic', | |
| 57 | + 'tipoSo' => 'linux-64-bit', | |
| 58 | + 'filepath' => 'cacic/current/linux-64-bit/install-cacic' | |
| 59 | + ), | |
| 60 | + ); | |
| 61 | + | |
| 62 | + private $container; | |
| 63 | + | |
| 64 | + public function setContainer(ContainerInterface $container = null) | |
| 65 | + { | |
| 66 | + $this->container = $container; | |
| 67 | + } | |
| 68 | + | |
| 69 | + public function load(ObjectManager $manager) | |
| 70 | + { | |
| 71 | + $rede = $manager->getRepository('CacicCommonBundle:Rede')->findOneBy(array( | |
| 72 | + 'teIpRede' => '0.0.0.0' | |
| 73 | + )); | |
| 74 | + foreach ($this->modulos as $elemento){ | |
| 75 | + // Crio os objetos e atributos para a classe | |
| 76 | + $classe = new RedeVersaoModulo(null, null, null, null, null, $rede); | |
| 77 | + $classe->setNmModulo($elemento['nmModulo']); | |
| 78 | + $classe->setTeVersaoModulo($elemento['teVersaoModulo']); | |
| 79 | + $classe->setDtAtualizacao(new \DateTime()); | |
| 80 | + $classe->setCsTipoSo($elemento['csTipoSo']); | |
| 81 | + $classe->setTeHash($elemento['teHash']); | |
| 82 | + $classe->setTipo('cacic'); | |
| 83 | + $classe->setTipoSo($this->getReference($elemento['tipoSo'])); | |
| 84 | + $classe->setFilepath($elemento['filepath']); | |
| 85 | + | |
| 86 | + // Grava os dados | |
| 87 | + $manager->persist($classe); | |
| 88 | + } | |
| 89 | + | |
| 90 | + $manager->flush(); | |
| 91 | + | |
| 92 | + } | |
| 93 | + | |
| 94 | + public function getOrder() | |
| 95 | + { | |
| 96 | + return 100; | |
| 97 | + } | |
| 98 | + | |
| 99 | +} | |
| 0 | 100 | \ No newline at end of file | ... | ... |
| ... | ... | @@ -0,0 +1,62 @@ |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Created by PhpStorm. | |
| 4 | + * User: eduardo | |
| 5 | + * Date: 07/11/14 | |
| 6 | + * Time: 23:38 | |
| 7 | + */ | |
| 8 | + | |
| 9 | +namespace Cacic\WSBundle\DataFixtures\ORM; | |
| 10 | + | |
| 11 | +use Doctrine\Common\DataFixtures\AbstractFixture; | |
| 12 | +use Doctrine\Common\DataFixtures\FixtureInterface; | |
| 13 | +use Doctrine\Common\DataFixtures\OrderedFixtureInterface; | |
| 14 | +use Doctrine\Common\Persistence\ObjectManager; | |
| 15 | +use Symfony\Component\DependencyInjection\ContainerAwareInterface; | |
| 16 | +use Symfony\Component\DependencyInjection\ContainerInterface; | |
| 17 | + | |
| 18 | +use Cacic\CommonBundle\Entity\TipoSo; | |
| 19 | + | |
| 20 | + | |
| 21 | +class LoadTipoSo extends AbstractFixture implements FixtureInterface, ContainerAwareInterface, OrderedFixtureInterface { | |
| 22 | + | |
| 23 | + private $container; | |
| 24 | + | |
| 25 | + public function setContainer(ContainerInterface $container = null) | |
| 26 | + { | |
| 27 | + $this->container = $container; | |
| 28 | + } | |
| 29 | + | |
| 30 | + public function load(ObjectManager $manager) | |
| 31 | + { | |
| 32 | + | |
| 33 | + // Crio os objetos e atributos para a classe | |
| 34 | + $classe = new TipoSo(); | |
| 35 | + $classe->setTipo('windows-64-bit'); | |
| 36 | + | |
| 37 | + // Adiciona referência | |
| 38 | + $this->addReference('windows-64-bit', $classe); | |
| 39 | + | |
| 40 | + // Grava os dados | |
| 41 | + $manager->persist($classe); | |
| 42 | + | |
| 43 | + // Crio os objetos e atributos para a classe | |
| 44 | + $classe = new TipoSo(); | |
| 45 | + $classe->setTipo('linux-64-bit'); | |
| 46 | + | |
| 47 | + // Adiciona referência | |
| 48 | + $this->addReference('linux-64-bit', $classe); | |
| 49 | + | |
| 50 | + // Grava os dados | |
| 51 | + $manager->persist($classe); | |
| 52 | + | |
| 53 | + $manager->flush(); | |
| 54 | + | |
| 55 | + } | |
| 56 | + | |
| 57 | + public function getOrder() | |
| 58 | + { | |
| 59 | + return 90; | |
| 60 | + } | |
| 61 | + | |
| 62 | +} | |
| 0 | 63 | \ No newline at end of file | ... | ... |
src/Cacic/WSBundle/Tests/Controller/NeoControllerTest.php
| ... | ... | @@ -17,6 +17,7 @@ use Symfony\Component\Serializer\Encoder\JsonEncoder; |
| 17 | 17 | |
| 18 | 18 | class NeoControllerTest extends BaseTestCase |
| 19 | 19 | { |
| 20 | + | |
| 20 | 21 | /** |
| 21 | 22 | * Método que cria dados comuns a todos os testes |
| 22 | 23 | */ |
| ... | ... | @@ -24,6 +25,17 @@ class NeoControllerTest extends BaseTestCase |
| 24 | 25 | // Load setup from BaseTestCase method |
| 25 | 26 | parent::setUp(); |
| 26 | 27 | |
| 28 | + // Load specific fixtures | |
| 29 | + $fixtures = array_merge( | |
| 30 | + $this->classes, | |
| 31 | + array( | |
| 32 | + 'Cacic\WSBundle\DataFixtures\ORM\LoadRedeVersaoModuloData', | |
| 33 | + 'Cacic\WSBundle\DataFixtures\ORM\LoadTipoSo' | |
| 34 | + ) | |
| 35 | + ); | |
| 36 | + $this->loadFixtures($fixtures); | |
| 37 | + | |
| 38 | + // Basic data | |
| 27 | 39 | $this->client = static::createClient(); |
| 28 | 40 | $this->container = $this->client->getContainer(); |
| 29 | 41 | $this->apiKey = $this->container->getParameter('test_api_key'); |
| ... | ... | @@ -50,7 +62,7 @@ class NeoControllerTest extends BaseTestCase |
| 50 | 62 | "operatingSystem": { |
| 51 | 63 | "idOs": 176, |
| 52 | 64 | "nomeOs": "Windows_NT", |
| 53 | - "tipo": "Windows-64-bit" | |
| 65 | + "tipo": "windows-64-bit" | |
| 54 | 66 | }, |
| 55 | 67 | "usuario": "Eric Menezes", |
| 56 | 68 | "nmComputador": "Notebook-XPTO", |
| ... | ... | @@ -77,7 +89,8 @@ class NeoControllerTest extends BaseTestCase |
| 77 | 89 | ], |
| 78 | 90 | "operatingSystem": { |
| 79 | 91 | "idOs": 176, |
| 80 | - "nomeOs": "Windows_NT" | |
| 92 | + "nomeOs": "Windows_NT", | |
| 93 | + "tipo": "windows-64-bit" | |
| 81 | 94 | }, |
| 82 | 95 | "usuario": "Eric Menezes", |
| 83 | 96 | "nmComputador": "Notebook-XPTO", |
| ... | ... | @@ -106,7 +119,8 @@ class NeoControllerTest extends BaseTestCase |
| 106 | 119 | ], |
| 107 | 120 | "operatingSystem": { |
| 108 | 121 | "idOs": 176, |
| 109 | - "nomeOs": "Windows_NT" | |
| 122 | + "nomeOs": "Windows_NT", | |
| 123 | + "tipo": "windows-64-bit" | |
| 110 | 124 | }, |
| 111 | 125 | "usuario": "Eric Menezes", |
| 112 | 126 | "nmComputador": "Notebook-XPTO", |
| ... | ... | @@ -213,6 +227,36 @@ class NeoControllerTest extends BaseTestCase |
| 213 | 227 | } |
| 214 | 228 | } |
| 215 | 229 | }'; |
| 230 | + $this->computador_http = '{ | |
| 231 | + "computador": { | |
| 232 | + "networkDevices": [ | |
| 233 | + { | |
| 234 | + "ipv4": "0.0.0.1", | |
| 235 | + "ipv6": "fe80::295b:a8db:d433:ebe%4", | |
| 236 | + "mac": "9C:D2:1E:EA:E0:89", | |
| 237 | + "netmask_ipv4": "255.255.255.255", | |
| 238 | + "netmask_ipv6": "ffff:ffff:ffff:ffff::", | |
| 239 | + "nome": "Wi-Fi" | |
| 240 | + }, | |
| 241 | + { | |
| 242 | + "ipv4": "192.168.56.1", | |
| 243 | + "ipv6": "fe80::19f2:4739:8a9e:45e4%16", | |
| 244 | + "mac": "08:00:27:00:14:2B", | |
| 245 | + "netmask_ipv4": "255.255.255.0", | |
| 246 | + "netmask_ipv6": "ffff:ffff:ffff:ffff::", | |
| 247 | + "nome": "VirtualBox Host-Only Network" | |
| 248 | + } | |
| 249 | + ], | |
| 250 | + "operatingSystem": { | |
| 251 | + "idOs": 176, | |
| 252 | + "nomeOs": "Windows_NT", | |
| 253 | + "tipo": "windows-64-bit" | |
| 254 | + }, | |
| 255 | + "usuario": "Eric Menezes", | |
| 256 | + "nmComputador": "Notebook-XPTO", | |
| 257 | + "versaoAgente": "2.8.0" | |
| 258 | + } | |
| 259 | + }'; | |
| 216 | 260 | } |
| 217 | 261 | |
| 218 | 262 | /** |
| ... | ... | @@ -480,6 +524,49 @@ class NeoControllerTest extends BaseTestCase |
| 480 | 524 | $this->assertEquals($status, 200); |
| 481 | 525 | } |
| 482 | 526 | |
| 527 | + public function testHttpUpdate() { | |
| 528 | + $logger = $this->container->get('logger'); | |
| 529 | + $this->client->request( | |
| 530 | + 'POST', | |
| 531 | + '/ws/neo/config', | |
| 532 | + array(), | |
| 533 | + array(), | |
| 534 | + array( | |
| 535 | + 'CONTENT_TYPE' => 'application/json', | |
| 536 | + //'HTTPS' => true | |
| 537 | + ), | |
| 538 | + $this->computador_http | |
| 539 | + ); | |
| 540 | + //$logger->debug("Dados JSON do computador enviados \n".$this->client->getRequest()->getcontent()); | |
| 541 | + | |
| 542 | + $response = $this->client->getResponse(); | |
| 543 | + $status = $response->getStatusCode(); | |
| 544 | + $logger->debug("Response status: $status"); | |
| 545 | + //$logger->debug("JSON do getConfig: \n".$response->getContent()); | |
| 546 | + | |
| 547 | + $this->assertEquals($status, 200); | |
| 548 | + | |
| 549 | + $status = $response->getContent(); | |
| 550 | + $dados = json_decode($status, true); | |
| 551 | + | |
| 552 | + // Checa se método de download foi informado | |
| 553 | + $this->assertEquals( | |
| 554 | + $dados['agentcomputer']['metodoDownload']['tipo'], | |
| 555 | + 'http' | |
| 556 | + ); | |
| 557 | + | |
| 558 | + // Verifica se o hash correto foi enviado | |
| 559 | + $result = false; | |
| 560 | + foreach($dados['agentcomputer']['modulos']['cacic'] as $modulo) { | |
| 561 | + //$logger->debug("99999999999999999999999999999999999 ".print_r($modulo, true)); | |
| 562 | + if ($modulo['hash'] == '50cf34bf584880fd401619eb367b2c2d') { | |
| 563 | + $result = true; | |
| 564 | + } | |
| 565 | + } | |
| 566 | + $this->assertTrue($result); | |
| 567 | + | |
| 568 | + } | |
| 569 | + | |
| 483 | 570 | /** |
| 484 | 571 | * Método que apaga todos os dados criados no teste |
| 485 | 572 | */ | ... | ... |