Bläddra i källkod

Merge branch 'feature-export' into 'master'

Feature export

See merge request interlink-sa/flowdat3/modules/installer!63
Jean Sumara Leopoldo 5 år sedan
förälder
incheckning
fd31a0dd70

+ 4 - 1
tools/modules.gitlab.ini

@@ -56,4 +56,7 @@ repo = "https://${GITLAB_USER}:${GITLAB_PASS}@gitlab.com/interlink-sa/flowdat3/m
 repo = "https://${GITLAB_USER}:${GITLAB_PASS}@gitlab.com/interlink-sa/flowdat3/modules/swagger.git"
 
 [tftp]
-repo = "https://${GITLAB_USER}:${GITLAB_PASS}@gitlab.com/interlink-sa/flowdat3/modules/tftp.git"
+repo = "https://${GITLAB_USER}:${GITLAB_PASS}@gitlab.com/interlink-sa/flowdat3/modules/tftp.git"
+
+[export]
+repo = "https://${GITLAB_USER}:${GITLAB_PASS}@gitlab.com/interlink-sa/flowdat3/modules/export.git"

+ 4 - 1
tools/modules.ini

@@ -56,4 +56,7 @@ repo = "ssh://git@gitlab.com/interlink-sa/flowdat3/modules/supervisord.git"
 repo = "ssh://git@gitlab.com/interlink-sa/flowdat3/modules/swagger.git"
 
 [tftp]
-repo = "ssh://git@gitlab.com/interlink-sa/flowdat3/modules/tftp.git"
+repo = "ssh://git@gitlab.com/interlink-sa/flowdat3/modules/tftp.git"
+
+[export]
+repo = "ssh://git@gitlab.com/interlink-sa/flowdat3/modules/export.git"

+ 23 - 0
tools/src/ReleaseImages.php

@@ -37,6 +37,8 @@ use FD3\Services\Statsd;
 use FD3\Services\Supervisord;
 use FD3\Services\Swagger;
 use FD3\Services\Tftp;
+use FD3\Services\Minio;
+use FD3\Services\Export;
 use Symfony\Component\Console\Command\Command;
 use Symfony\Component\Console\Exception\LogicException;
 use Symfony\Component\Console\Formatter\OutputFormatterStyle;
@@ -739,6 +741,27 @@ class ReleaseImages extends Command
         $this->_dObj->file($this->_host_env)->content($env_content);
     }
 
+    /**
+     * Crea el archivo minio.env
+     */
+    protected function writeMinioEnv()
+    {
+        $env_content = "";
+        $env_content .= "MINIO_ACCESS_KEY=" . $this->generateRandomString(10) . "\n";
+        $env_content .= "MINIO_SECRET_KEY=" . $this->generateRandomString(15) . "\n";
+        $this->_dObj->file('minio.env')->content($env_content);
+    }
+
+    function generateRandomString($length = 10) {
+        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+        $charactersLength = strlen($characters);
+        $randomString = '';
+        for ($i = 0; $i < $length; $i++) {
+            $randomString .= $characters[rand(0, $charactersLength - 1)];
+        }
+        return $randomString;
+    }
+
     /**
      * Crea el archivo hostsDile
      * @param string $config_ip Contiene la ip.

+ 1 - 0
tools/src/Services/Base.php

@@ -57,6 +57,7 @@ class Base extends InitialService
                 ->addEnv_file($this->getRelease()->_running_env)
                 ->addEnv_file($host_env_file)
                 ->addEnv_file($module . "." . $host_env_file)
+                ->addEnv_file('minio.env')
                 ->addVolumes(self::BASE_SOCKET_VOLUMEN, "/run/php/")
                 ->addVolumes(Nginx::BASE_NGINX_VOLUMEN, "/opt/base/web")
                 ->addVolumes("/etc/localtime:/etc/localtime:ro")

+ 66 - 0
tools/src/Services/Export.php

@@ -0,0 +1,66 @@
+<?php
+
+
+namespace FD3\Services;
+
+use Docker\Composer\FileFormat;
+use FD3\Release;
+
+class Export extends InitialService
+{
+    /**
+     * @var int ip server
+     */
+    protected $ip_server = 61;
+
+    /**
+     * Ftth constructor.
+     */
+    public function __construct()
+    {
+        $this
+            ->setHelp("Modulo de export")
+            ->setHostEnv(true)
+            ->setVarEnv([
+                'FTTH_EXPORT' => 'export.ftth'
+            ])
+            ->setOauth(true)
+            ->setRequired(false)
+            ->setDepends([]);
+    }
+
+    /**
+     * Add config
+     * @throws \Docker\Composer\ServiceNotFoundException
+     */
+    public function add()
+    {
+        $module = $this->getModuleName();
+        $version = "latest";
+        $registry = "";
+        $host_env_file = "";
+        extract($this->getConfigVar());
+        if ($this->getRelease()->needInstallModule($module)) {
+            $this->getComposer()->addService($module)
+                ->image($registry . "fd3/$module:" . $version);
+            if ($this->getProduction() === false) {
+                $this->getComposer()->service($module)
+                    ->build("./$module/")
+                    ->addVolumes("./$module/", "/opt/$module/");
+            }
+            $this->getComposer()->service($module)
+                ->hostname($module)
+                ->restart($this->getRelease()->_docker_restart_task)
+                ->addEnv_file($this->getRelease()->_running_env)
+                ->addEnv_file($module . "." . $host_env_file)
+                ->addEnv_file("minio.env")
+                ->network($this->getRelease()->_network_name)->ipv4_address($this->generateIP());
+
+            $this->addLink(new Amqp(), $module)
+                ->addLink(new Minio(), $module);
+
+            $this->getRelease()->addBuild($module, $this->getComposer());
+            $this->getRelease()->writeVariablesEnviroment($module . "." . $host_env_file, $module);
+        }
+    }
+}

+ 1 - 0
tools/src/Services/Ftth.php

@@ -60,6 +60,7 @@ class Ftth extends InitialService
                 ->addEnv_file($host_env_file)
                 ->addEnv_file($module . "." . $host_env_file)
                 ->addEnv_file($module . ".oauth.env")
+                ->addEnv_file("export.".$host_env_file)
                 ->addVolumes(self::FTTH_SOCKET_VOLUMEN, "/run/php/")
 //                ->addVolumes(self::FTTH_SUPERVISORD_VOLUMEN, "/opt/ftth/")
                 ->addVolumes("./backups-config", "/opt/ftth/web/backups-config")

+ 52 - 0
tools/src/Services/Minio.php

@@ -0,0 +1,52 @@
+<?php
+
+
+namespace FD3\Services;
+
+use Docker\Composer\FileFormat;
+use FD3\Release;
+
+class Minio extends InitialService
+{
+    /**
+     * @var int ip server
+     */
+    protected $ip_server = 60;
+
+    /**
+     * Mongodb constructor.
+     */
+    public function __construct()
+    {
+        $this
+            ->setHelp("Modulo de minio")
+            ->setHostEnv(false)
+            ->setVarEnv([])
+            ->setOauth(false)
+            ->setRequired(true);
+    }
+
+    /**
+     * Add config
+     * @throws \Docker\Composer\ServiceNotFoundException
+     */
+    public function add()
+    {
+        $module = $this->getModuleName();
+        $registry = "";
+        extract($this->getConfigVar());
+        $version = "v1.13";
+        if ($this->getRelease()->needInstallModule($module)) {
+            $this->getComposer()
+                ->addService($module)
+                ->image($registry . "fd3/$module:" . $version)
+                ->addVolumes("./storage/minio", "/data");
+
+            $this->getComposer()->service($module)
+                ->hostname($module)
+                ->command("server /data")
+                ->addPorts(9004, 9000)
+                ->network($this->getRelease()->_network_name)->ipv4_address($this->generateIP());
+        }
+    }
+}

+ 1 - 0
tools/src/UpdateImages.php

@@ -37,6 +37,7 @@ use FD3\Services\Statsd;
 use FD3\Services\Supervisord;
 use FD3\Services\Swagger;
 use FD3\Services\Tftp;
+use FD3\Services\Minio;
 use Symfony\Component\Console\Command\Command;
 use Symfony\Component\Console\Exception\LogicException;
 use Symfony\Component\Console\Input\InputArgument;