浏览代码

Merge branch 'master' of https://bitbucket.org/ikflowdat/installer

Fernando Alonso 7 年之前
父节点
当前提交
f11dfbe293
共有 6 个文件被更改,包括 105 次插入6 次删除
  1. 6 0
      README.md
  2. 二进制
      tools/.readme.md.swp
  3. 21 0
      tools/modules.ini
  4. 22 1
      tools/readme.md
  5. 12 2
      tools/src/ComposerRequireCommand.php
  6. 44 3
      tools/src/Release.php

+ 6 - 0
README.md

@@ -8,3 +8,9 @@ En general nuevas instalaciones deben ser creadas en el directorio /opt/flowdat
 #Archivo tools/repositories.ini
 Contiene todos los repositorios vendors que se versionan y taguean con el installer.
 Cada vez que se genere un repositorio vendor nuevo, se debe agregar la dirección del repositorio de bitbucket a este archivo.
+
+#Archivo tools/modules.ini
+Contiene todos los repositorios que son módulos que se versionan y taguean con el installer.
+Cada vez que se genere un módulo nuevo se debe agregar la dirección del repositorio de bitbucket a este archivo.
+
+

二进制
tools/.readme.md.swp


+ 21 - 0
tools/modules.ini

@@ -0,0 +1,21 @@
+[base]
+repo = "ssh://git@bitbucket.org:ikflowdat/base.git"
+
+[cablemodem]
+repo = "ssh://git@bitbucket.org:ikflowdat/cablemodem.git"
+
+[dhcp]
+repo = "ssh://git@bitbucket.org:ikflowdat/dhcp.git"
+
+[ftth]
+repo = "ssh://git@bitbucket.org:ikflowdat/ftth.git"
+
+[mapas]
+repo = "ssh://git@bitbucket.org:ikflowdat/mapas.git"
+
+[radius]
+repo = "ssh://git@bitbucket.org:ikflowdat/radius.git"
+
+[stats]
+repo = "ssh://git@bitbucket.org:ikflowdat/stats.git"
+

+ 22 - 1
tools/readme.md

@@ -164,4 +164,25 @@
         exit
     Ejecuto nuevamente el playbook (ansible)
 
-    
+   
+#Nombres de branch y tag
+    Los branchs y tags se denominaran con vX.Y.Z, siendo la primer letra una "v" para denotar que es una versión, luego X/Y/Z son los números que la identifican.
+    Los branchs solo tendrán las posiciones "X" e "Y".
+    Los tags tendrán las posiciones "X", "Y" y "Z".
+
+#Branch y tag de vendors
+    Estos pasos se deben hacer por separado, es decir, primero se debe hacer un branch y luego el tag.
+    Primero debemos estar situados en el directorio /opt/flowdat/tools.
+    Para realizar un branch debemos ejecucar la siguiente sentencia
+        php cmd.php make:tag:vendors repositories.ini vX.Y --branch=true
+    Para realizar un tag debemos ejecucar la siguiente sentencia
+        php cmd.php make:tag:vendors repositories.ini vX.Y.Z 
+
+#Branch y tag de módulos
+    Primero debemos estar situados en el directorio /opt/flowdat/tools.
+    Ahora debemos modificar los archivos "composer.json" de cada módulo y ajustarlo a la versión deseada. Este proceso ejecuta el composer update, por lo tanto se debe tener en cuenta que se debe ejecutar en alguna máquina que posea los dockers de los módulos creados.
+    Para esto debemos ejecutar la siguiente sentencia
+        php cmd.php composer:require modules.ini ik/* vX.Y.Z --composer_update=true --pull=master
+    Una vez finalizado la generación de los composer json/lock, debemos hacer un commit de los cambios y para esto ejecutamos la sentencia
+        php cmd.php make:tag:vendors modules.ini vX.Y.Z
+        

+ 12 - 2
tools/src/ComposerRequireCommand.php

@@ -17,12 +17,16 @@ class ComposerRequireCommand extends Command
             ->setDescription('Tag all composer software using a ini file.')
             ->setHelp('This command allows you to tag and change the required code on the composer.json file...')
             ->addArgument('ini_file', InputArgument::REQUIRED, 'The ini file from where to get the source code config.')
-            ->addArgument('packages', InputArgument::REQUIRED, 'tag the required packages (suggested value : ik/*)')
-            ->addArgument('version', InputArgument::REQUIRED, 'use the version expression.');
+            ->addArgument('packages', InputArgument::REQUIRED, 'Tag the required packages (suggested value : ik/*).')
+	    ->addArgument('version', InputArgument::REQUIRED, 'Use the version expression.')
+	    ->addOption('composer_update', null, InputOption::VALUE_OPTIONAL, 'If true, run "docker-compose run ... bin/composer-update.sh" to generate composer.lock', 'true')
+	    ->addOption('pull', null, InputOption::VALUE_OPTIONAL, 'Indicates branch to pull for every modules', '');
     }
 
     protected function execute(InputInterface $input, OutputInterface $output)
     {
+        $dockerCompose = $input->getOption("composer_update");
+        $pull = $input->getOption("pull");
         $file = $input->getArgument("ini_file");
         $packages = $input->getArgument("packages");
         $new_version = $input->getArgument("version");
@@ -39,6 +43,9 @@ class ComposerRequireCommand extends Command
                 $output->writeln($sec);
                 $composer_data = json_decode(file_get_contents($composer_file), true);
                 foreach (array("require", "require-dev") as $k) {
+		    if (strlen($pull) > 0) {
+                        shell_exec('cd ' . $sec . '; git pull origin ' . $pull);
+                    }
                     foreach ($composer_data[$k] as $package => $version) {
                         if (strpos($packages, "*") !== false) {
                             $preg = "|^" . str_replace("*", "[^\b]*", $packages) . "$|";
@@ -55,6 +62,9 @@ class ComposerRequireCommand extends Command
                     }
                 }
                 file_put_contents($composer_file, json_encode($composer_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
+		if ($dockerCompose) {
+                    shell_exec('docker-compose run ' . $sec . ' bin/composer-update.sh');
+                }
             } else {
                 $output->writeln($sec . " no composer.json found");
             }

+ 44 - 3
tools/src/Release.php

@@ -77,7 +77,7 @@ class Release extends Command
     private $_user_system;
 
     /**
-     * @var string $directory Directorio de instalación
+     * @var string $directory Directorio de instalación
      */
     private $directory;
 
@@ -243,12 +243,28 @@ class Release extends Command
             ->addOption('client', null, InputOption::VALUE_REQUIRED, 'Client name, if is not provided uses, the dirname of the installation', false)
             ->addOption('modules', null, InputOption::VALUE_REQUIRED, 'List of modules to install separated by coma.', "all")
             ->addOption('inventory', null, InputOption::VALUE_REQUIRED, 'Write inventory.ini by default.', true)
-            ->addOption('docker-tag', null, InputOption::VALUE_REQUIRED, 'Docker tag to be used', "latest");
+            ->addOption('docker-tag', null, InputOption::VALUE_REQUIRED, 'Docker tag to be used', "latest")
+            ->addOption('all-ref', null, InputOption::VALUE_REQUIRED, 'Git reference (branch or tag) to clone all app', "")
+            ->addOption('general-version', null, InputOption::VALUE_REQUIRED, 'Set options all-ref and docker-tag with this value. Ej. 0.1.1', "");
     }
 
     protected function execute(InputInterface $input, OutputInterface $output)
     {
         try {
+            if (strlen(trim($input->getOption("general-version"))) > 0) {
+                $input->setOption('all-ref', 'v' . $input->getOption('general-version'));
+                $input->setOption('docker-tag', $input->getOption('general-version'));
+            }
+            if (strlen(trim($input->getOption("all-ref"))) > 0) {
+                $input->setOption('base-ref', $input->getOption('all-ref'));
+                $input->setOption('ftth-ref', $input->getOption('all-ref'));
+                $input->setOption('mapas-ref', $input->getOption('all-ref'));
+                $input->setOption('radius-ref', $input->getOption('all-ref'));
+                $input->setOption('stats-ref', $input->getOption('all-ref'));
+                $input->setOption('cablemodem-ref', $input->getOption('all-ref'));
+                $input->setOption('dhcp-ref', $input->getOption('all-ref'));
+                $input->setOption('extra-ref', $input->getOption('all-ref'));
+            }
             if (strtolower($input->getOption("modules")) == "all") {
                 // seteo todos los modulos a instalar por defecto
                 $modules = "";
@@ -499,6 +515,28 @@ class Release extends Command
         $this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
     }
 
+    /**
+     * atftp, tod
+     *
+     * @param FileFormat2 $composer
+     * @param array $config
+     */
+    function addTftp(FileFormat2 $composer, $config = array())
+    {
+        $version = "latest";
+        $registry = "";
+        $host_env_file = "";
+        extract($config);
+
+        $composer
+        ->addService("tftp")
+        ->build("extra/tftp/")
+        ->image($registry . "fd3/tftp:" . $version)
+        ->addEnv_file($host_env_file)
+        ->restart($this->_docker_restart_default)
+        ->addPorts(69, 69);
+    }
+
     function addRadius(FileFormat2 $composer, $config = array())
     {
         $module = "radius";
@@ -627,7 +665,8 @@ class Release extends Command
             ->image($registry . "fd3/$module:" . $version)
             ->build("./extra/mysql")
             ->addEnv_file($module . "." . $host_env_file)
-            ->addVolumes("./mysql/", "/var/lib/mysql/");
+            ->addVolumes("./mysql/", "/var/lib/mysql/")
+            ->addVolumes("./extra/mysql/fd3.conf", "/etc/mysql/conf.d/fd3.conf");
         $this->writeVariablesEnviroment($module . "." . $host_env_file, $module,
             array(
                 "MYSQL_ROOT_PASSWORD" => $this->_mysql_root_pass,
@@ -952,6 +991,8 @@ class Release extends Command
         $this->addSupervisord($composer, $base_vars);
         $this->addCommandWorkers($composer, $base_vars);
 
+        $this->addTftp($composer, $base_vars);
+
         // Geoserver
         $this->addGeoserver($composer, $base_vars);