Browse Source

Se aÃade al comando la opcion add-nginx-links por defecto en false para
poder añadira los mÃdulos principales los links nginx, se aÃaden todos
por defecto en base, ftth, cablemodem, stats, dhcp, radius y mapas.

Maximiliano Schvindt 6 years ago
parent
commit
f30b45abab
1 changed files with 47 additions and 4 deletions
  1. 47 4
      tools/src/Release.php

+ 47 - 4
tools/src/Release.php

@@ -77,9 +77,14 @@ class Release extends Command
     private $_user_system;
 
     /**
-     * @var string $directory Directorio de instalacin
+     * @var string $directory Directorio de instalacion
      */
     private $directory;
+    
+    /**
+     * @var boolean $_use_nginx_links Para indicar si se crean los links nginx entre los modulos
+     */
+    private $_use_nginx_links;
 
     /**
      * Constructor.
@@ -210,6 +215,7 @@ class Release extends Command
                 'MODULE_INSTALL' => true
             ),
         );
+        $this->_add_nginx_links = false;
     }
 
     protected function configure()
@@ -253,7 +259,8 @@ class Release extends Command
             ->addOption('inventory', null, InputOption::VALUE_REQUIRED, 'Write inventory.ini by default.', true)
             ->addOption('docker-tag', null, InputOption::VALUE_REQUIRED, 'Docker tag to be used. Ej. v0.1.1', "latest")
             ->addOption('all-ref', null, InputOption::VALUE_REQUIRED, 'Git reference (branch or tag) to clone all app. Ej. 0.1.1', "")
-            ->addOption('general-version', null, InputOption::VALUE_REQUIRED, 'Set options all-ref and docker-tag with this value. Ej. 0.1.1', "");
+            ->addOption('general-version', null, InputOption::VALUE_REQUIRED, 'Set options all-ref and docker-tag with this value. Ej. 0.1.1', "")
+            ->addOption('add-nginx-links', null, InputOption::VALUE_REQUIRED, 'Add NGINX links between dockers', false);
     }
 
     protected function execute(InputInterface $input, OutputInterface $output)
@@ -313,8 +320,10 @@ class Release extends Command
             $this->_ansible_vars["CMD_USERNAME"] = $this->_user_system['users'][$this->internal_user_id]['user'];
             $this->_ansible_vars["CMD_PASSWORD"] = $this->_user_system['users'][$this->internal_user_id]['password'];
             $this->_ansible_vars["ENV_LIST"] = "prod,dev,test";
-	    $this->_ansible_vars["API_CIDR"] = "172.20.0.0/24";
-	    $this->_ansible_vars["MYSQL_ROOT_PASSWORD"] = $this->_mysql_root_pass;
+	        $this->_ansible_vars["API_CIDR"] = "172.20.0.0/24";
+            $this->_ansible_vars["MYSQL_ROOT_PASSWORD"] = $this->_mysql_root_pass;
+            
+            $this->_add_nginx_links = $input->getOption('add-nginx-links');
 
             $dObj = new DevOps\FileSystem(realpath($this->directory));
             $dObj->dirExists()->realpath();
@@ -417,6 +426,8 @@ class Release extends Command
             ->addEnv_file($module . "." . $host_env_file)
             ->addVolumes("./$module/", "/opt/$module");
 
+        $this->addNginxLinks($module, $composer);
+
         $this->addBuild($module, $composer);
 
         $this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
@@ -446,6 +457,8 @@ class Release extends Command
          ->addVolumes("./extra/netmiko", "/opt/netmiko")
          ->addVolumes("./extra/backups-config", "/opt/ftth/web/backups-config");
 
+        $this->addNginxLinks($module, $composer);
+
         $this->addBuild($module, $composer);
 
         $this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
@@ -474,6 +487,8 @@ class Release extends Command
             ->addEnv_file($module . "." . $host_env_file)
             ->addEnv_file("$module.oauth.env");
 
+        $this->addNginxLinks($module, $composer);
+
         $this->addBuild($module, $composer);
 
         $this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
@@ -501,6 +516,9 @@ class Release extends Command
             ->addEnv_file("$module.oauth.env")
             ->addVolumes("./$module/", "/opt/$module")
             ->addVolumes("./$module/web/uploads", "/opt/$module/web/uploads");
+
+        $this->addNginxLinks($module, $composer);
+
         $this->addBuild($module, $composer);
 
         $this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
@@ -528,6 +546,8 @@ class Release extends Command
             ->addEnv_file("$module.oauth.env")
             ->addVolumes("./$module/", "/opt/$module")
             ->addVolumes("./$module/web/uploads", "/opt/$module/web/uploads");
+        
+        $this->addNginxLinks($module, $composer);
 
         $this->addBuild($module, $composer);
 
@@ -578,6 +598,8 @@ class Release extends Command
             ->addEnv_file("$module.oauth.env")
             ->addVolumes("./$module/", "/opt/$module");
 
+        $this->addNginxLinks($module, $composer);
+
         $this->addBuild($module, $composer);
 
         $this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
@@ -606,6 +628,8 @@ class Release extends Command
             ->addVolumes("./kea/conf", "/opt/dhcp/web/kea")
             ;
 
+        $this->addNginxLinks($module, $composer);
+        
         $this->addBuild($module, $composer);
 
         $this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
@@ -1338,4 +1362,23 @@ class Release extends Command
 
         $this->_dObj->file("inventory.ini")->content($tmp . $all);
     }
+
+    /**
+     * Funcion que agrega links nginx a los modulos principales (para instalacion dev)
+     * @param string $module Contiene el nombre del modulo.
+     * @param FileFormat2 $composer Contiene el objeto FileFormat2.
+     */
+    private function addNginxLinks($module, FileFormat2 $composer)
+    {
+        if ($this->_add_nginx_links) {
+            $composer->service($module)
+                ->addLinks("nginx", $this->getDomain("base"))
+                ->addLinks("nginx", $this->getDomain("ftth"))
+                ->addLinks("nginx", $this->getDomain("cablemodem"))
+                ->addLinks("nginx", $this->getDomain("mapas"))
+                ->addLinks("nginx", $this->getDomain("stats"))
+                ->addLinks("nginx", $this->getDomain("dhcp"))
+                ->addLinks("nginx", $this->getDomain("radius"));
+        }
+    }
 }