|
@@ -2,18 +2,18 @@
|
|
|
|
|
|
namespace FD3;
|
|
|
|
|
|
+use Docker\Composer\FileFormat2;
|
|
|
use Docker\Composer\ServiceNotFoundException;
|
|
|
-use function GuzzleHttp\default_user_agent;
|
|
|
-use League\Flysystem\File;
|
|
|
use Symfony\Component\Console\Command\Command;
|
|
|
-use Symfony\Component\Console\Input\InputInterface;
|
|
|
+use Symfony\Component\Console\Exception\LogicException;
|
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
|
+use Symfony\Component\Console\Input\InputInterface;
|
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
-use Docker\Composer\FileFormat2;
|
|
|
-use Symfony\Component\Console\Exception\LogicException;
|
|
|
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
|
|
use Symfony\Component\Yaml\Yaml;
|
|
|
+use function GuzzleHttp\default_user_agent;
|
|
|
+use League\Flysystem\File;
|
|
|
|
|
|
class Release extends Command
|
|
|
{
|
|
@@ -80,7 +80,7 @@ class Release extends Command
|
|
|
* @var string $directory Directorio de instalacion
|
|
|
*/
|
|
|
protected $directory;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @var boolean $_use_nginx_links Para indicar si se crean los links nginx entre los modulos
|
|
|
*/
|
|
@@ -119,7 +119,8 @@ class Release extends Command
|
|
|
'AMQP_KEY' => 'base'
|
|
|
),
|
|
|
'OAUTH' => false,
|
|
|
- 'MODULE_INSTALL' => true
|
|
|
+ 'MODULE_INSTALL' => true,
|
|
|
+ 'REQUIRED' => true
|
|
|
),
|
|
|
"ftth" => array(
|
|
|
'HOST_ENV' => true,
|
|
@@ -131,15 +132,6 @@ class Release extends Command
|
|
|
'OAUTH' => true,
|
|
|
'MODULE_INSTALL' => true
|
|
|
),
|
|
|
- "mapas" => array(
|
|
|
- 'HOST_ENV' => true,
|
|
|
- "VAR_ENV" => array(
|
|
|
- 'VIRTUAL_HOST' => '',
|
|
|
- 'HTTPS_METHOD' => 'nohttps',
|
|
|
- ),
|
|
|
- 'OAUTH' => true,
|
|
|
- 'MODULE_INSTALL' => true
|
|
|
- ),
|
|
|
"radius" => array(
|
|
|
'HOST_ENV' => true,
|
|
|
"VAR_ENV" => array(
|
|
@@ -179,15 +171,6 @@ class Release extends Command
|
|
|
'OAUTH' => true,
|
|
|
'MODULE_INSTALL' => true
|
|
|
),
|
|
|
- "grafana" => array(
|
|
|
- 'HOST_ENV' => true,
|
|
|
- "VAR_ENV" => array(
|
|
|
- 'VIRTUAL_HOST' => '',
|
|
|
- 'HTTPS_METHOD' => 'nohttps',
|
|
|
- ),
|
|
|
- 'OAUTH' => false,
|
|
|
- 'MODULE_INSTALL' => true
|
|
|
- ),
|
|
|
"api" => array(
|
|
|
'HOST_ENV' => true,
|
|
|
"VAR_ENV" => array(
|
|
@@ -200,12 +183,12 @@ class Release extends Command
|
|
|
"pma" => array(
|
|
|
'HOST_ENV' => true,
|
|
|
"VAR_ENV" => array(
|
|
|
- "PMA_HOST"=> "mysql",
|
|
|
- "PMA_PORT"=> "3306",
|
|
|
- "PMA_ABSOLUTE_URI"=> ""
|
|
|
+ "PMA_HOST" => "mysql",
|
|
|
+ "PMA_PORT" => "3306",
|
|
|
+ "PMA_ABSOLUTE_URI" => ""
|
|
|
),
|
|
|
'OAUTH' => false,
|
|
|
- 'MODULE_INSTALL' => true
|
|
|
+ 'MODULE_INSTALL' => true
|
|
|
),
|
|
|
"swagger" => array(
|
|
|
'HOST_ENV' => true,
|
|
@@ -214,12 +197,13 @@ class Release extends Command
|
|
|
"PORT" => "80"
|
|
|
),
|
|
|
'OAUTH' => false,
|
|
|
- 'MODULE_INSTALL' => true
|
|
|
+ 'MODULE_INSTALL' => true
|
|
|
),
|
|
|
"extra" => array(
|
|
|
'HOST_ENV' => false,
|
|
|
'OAUTH' => false,
|
|
|
- 'MODULE_INSTALL' => true
|
|
|
+ 'MODULE_INSTALL' => true,
|
|
|
+ 'REQUIRED' => true
|
|
|
),
|
|
|
"kea" => array(
|
|
|
'HOST_ENV' => false,
|
|
@@ -252,9 +236,6 @@ class Release extends Command
|
|
|
->addOption('ftth-repo', null, InputOption::VALUE_REQUIRED, 'Git clone Url fot the app FTTH', "git@bitbucket.org:ikflowdat/ftth.git")
|
|
|
->addOption('ftth-ref', null, InputOption::VALUE_REQUIRED, 'Git reference (branch or tag) to clone the Ftth ', "master")
|
|
|
->addOption('ftth-build', null, InputOption::VALUE_REQUIRED, 'Generate image build', "false")
|
|
|
- ->addOption('mapas-repo', null, InputOption::VALUE_REQUIRED, 'Git clone Url fot the app Mapas', "git@bitbucket.org:ikflowdat/mapas.git")
|
|
|
- ->addOption('mapas-ref', null, InputOption::VALUE_REQUIRED, 'Git reference (branch or tag) to clone the Mapas app', "master")
|
|
|
- ->addOption('mapas-build', null, InputOption::VALUE_REQUIRED, 'Generate image build', "false")
|
|
|
->addOption('radius-repo', null, InputOption::VALUE_REQUIRED, 'Git clone Url fot the app radius', "git@bitbucket.org:ikflowdat/radius.git")
|
|
|
->addOption('radius-ref', null, InputOption::VALUE_REQUIRED, 'Git reference (branch or tag) to clone the radius app', "master")
|
|
|
->addOption('radius-build', null, InputOption::VALUE_REQUIRED, 'Generate image build', "false")
|
|
@@ -294,7 +275,6 @@ class Release extends Command
|
|
|
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'));
|
|
@@ -305,9 +285,18 @@ class Release extends Command
|
|
|
if (strtolower($input->getOption("modules")) == "all") {
|
|
|
// seteo todos los modulos a instalar por defecto
|
|
|
$modules = "";
|
|
|
+ $output->writeln("Seleccione los módulos que desea instalar:");
|
|
|
foreach ($this->_modules_all as $name => $value) {
|
|
|
if (isset($value['MODULE_INSTALL']) && $value['MODULE_INSTALL']) {
|
|
|
- $modules = $modules . $name . ",";
|
|
|
+ if (isset($value['REQUIRED']) && $value['REQUIRED']) {
|
|
|
+ $modules .= $name . ",";
|
|
|
+ } else {
|
|
|
+ $helper = $this->getHelper('question');
|
|
|
+ $question = new ConfirmationQuestion("$name? (Y/n)");
|
|
|
+ if ($helper->ask($input, $output, $question)) {
|
|
|
+ $modules .= $name . ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
$modules = substr($modules, 0, strlen($modules) - 1);
|
|
@@ -341,9 +330,9 @@ 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["API_CIDR"] = "172.20.0.0/24";
|
|
|
$this->_ansible_vars["MYSQL_ROOT_PASSWORD"] = $this->_mysql_root_pass;
|
|
|
-
|
|
|
+
|
|
|
$this->_add_nginx_links = (boolean)$input->getOption('add-nginx-links');
|
|
|
|
|
|
$dObj = new DevOps\FileSystem(realpath($this->directory));
|
|
@@ -393,8 +382,6 @@ class Release extends Command
|
|
|
copy(getcwd() . "/mysql/freeradius/schema.sql", $dObj->dirExists()->realpath()->getPath() . "/freeradius_schema.sql");
|
|
|
// copio el docker-compose.service
|
|
|
copy(getcwd() . "/docker-compose.service", $dObj->dirExists()->realpath()->getPath() . "/docker-compose.service");
|
|
|
- // copio el archivo con variables de entorno de grafana
|
|
|
- copy(getcwd() . "/grafana.env", $dObj->dirExists()->realpath()->getPath() . "/grafana.env");
|
|
|
} catch (\Throwable $error) {
|
|
|
throw $error;
|
|
|
} finally {
|
|
@@ -475,8 +462,8 @@ class Release extends Command
|
|
|
->addEnv_file($module . "." . $host_env_file)
|
|
|
->addEnv_file($module . ".oauth.env")
|
|
|
->addVolumes("./$module/", "/opt/" . $module)
|
|
|
- ->addVolumes("./extra/netmiko", "/opt/netmiko")
|
|
|
- ->addVolumes("./extra/backups-config", "/opt/ftth/web/backups-config");
|
|
|
+ ->addVolumes("./extra/netmiko", "/opt/netmiko")
|
|
|
+ ->addVolumes("./extra/backups-config", "/opt/ftth/web/backups-config");
|
|
|
|
|
|
$this->addNginxLinks($module, $composer);
|
|
|
|
|
@@ -515,36 +502,6 @@ class Release extends Command
|
|
|
$this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
|
|
|
}
|
|
|
|
|
|
- function addMapas(FileFormat2 $composer, $config = array())
|
|
|
- {
|
|
|
- $module = "mapas";
|
|
|
- $version = "latest";
|
|
|
- $registry = "";
|
|
|
- $host_env_file = "";
|
|
|
- extract($config);
|
|
|
-
|
|
|
- $composer
|
|
|
- ->addService($module)
|
|
|
- ->image($registry . "fd3/$module:" . $version)
|
|
|
- ->restart($this->_docker_restart_default)
|
|
|
- ->build("mapas/")
|
|
|
- ->addLinks("mysql:mysql")
|
|
|
- ->addLinks("base")
|
|
|
- //->addLinks("base", $this->getDomain("base"))
|
|
|
- ->addEnv_file("running.env")
|
|
|
- ->addEnv_file($host_env_file)
|
|
|
- ->addEnv_file($module . "." . $host_env_file)
|
|
|
- ->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);
|
|
|
- }
|
|
|
-
|
|
|
function addCablemodem(FileFormat2 $composer, $config = array())
|
|
|
{
|
|
|
$module = "cablemodem";
|
|
@@ -567,7 +524,7 @@ 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);
|
|
@@ -589,12 +546,12 @@ class Release extends Command
|
|
|
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/udp');
|
|
|
+ ->addService("tftp")
|
|
|
+ ->build("extra/tftp/")
|
|
|
+ ->image($registry . "fd3/tftp:" . $version)
|
|
|
+ ->addEnv_file($host_env_file)
|
|
|
+ ->restart($this->_docker_restart_default)
|
|
|
+ ->addPorts(69, '69/udp');
|
|
|
}
|
|
|
|
|
|
function addRadius(FileFormat2 $composer, $config = array())
|
|
@@ -646,16 +603,15 @@ class Release extends Command
|
|
|
->addEnv_file($module . "." . $host_env_file)
|
|
|
->addEnv_file("$module.oauth.env")
|
|
|
->addVolumes("./$module/", "/opt/$module")
|
|
|
- ->addVolumes("./kea/conf", "/opt/dhcp/web/kea")
|
|
|
- ;
|
|
|
+ ->addVolumes("./kea/conf", "/opt/dhcp/web/kea");
|
|
|
|
|
|
$this->addNginxLinks($module, $composer);
|
|
|
-
|
|
|
+
|
|
|
$this->addBuild($module, $composer);
|
|
|
|
|
|
$this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function addApi(FileFormat2 $composer, $config = array())
|
|
|
{
|
|
|
$module = "api";
|
|
@@ -695,12 +651,10 @@ class Release extends Command
|
|
|
->addPorts(443, 443)
|
|
|
->addVolumes("./base/", "/opt/base")
|
|
|
->addVolumes("./ftth/", "/opt/ftth")
|
|
|
- ->addVolumes("./mapas/", "/opt/mapas")
|
|
|
->addVolumes("./radius/", "/opt/radius")
|
|
|
->addVolumes("./stats/", "/opt/stats")
|
|
|
->addVolumes("./cablemodem/", "/opt/cablemodem")
|
|
|
->addVolumes("./dhcp/", "/opt/dhcp")
|
|
|
- ->addVolumes("./grafana/", "/opt/grafana")
|
|
|
->addVolumes('./extra/api/', '/opt/api')
|
|
|
->addVolumes("/var/run/docker.sock", "/tmp/docker.sock:ro")
|
|
|
->addVolumes("pma_volumen", "/opt/pma")
|
|
@@ -872,25 +826,6 @@ class Release extends Command
|
|
|
$this->writeVariablesEnviroment($module . "." . $host_env_file, $module);
|
|
|
}
|
|
|
|
|
|
- function addGrafana(FileFormat2 $composer, $config = array())
|
|
|
- {
|
|
|
- $module = "grafana";
|
|
|
- $host_env_file = "";
|
|
|
- extract($config);
|
|
|
-
|
|
|
- $composer
|
|
|
- ->addService($module)
|
|
|
- ->image("grafana/grafana:5.0.4")
|
|
|
- ->addLinks("mysql")
|
|
|
- ->restart($this->_docker_restart_default)
|
|
|
- ->addEnv_file("running.env")
|
|
|
- ->addEnv_file("grafana.env")
|
|
|
- ->addVolumes("./extra/statsd/grafana/lib", "/var/lib/grafana");
|
|
|
-
|
|
|
- $this->addJsonEndPoints($composer, $config);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
function addJsonEndPoints(FileFormat2 $composer, $config = array())
|
|
|
{
|
|
|
$version = "latest";
|
|
@@ -970,8 +905,8 @@ class Release extends Command
|
|
|
->addEnv_file("ftth.host.env")
|
|
|
->addEnviroment("AMQP_KEY", "ftth")
|
|
|
->addVolumes("./ftth/", "/opt/ftth")
|
|
|
- ->addVolumes("./extra/netmiko", "/opt/netmiko")
|
|
|
- ->addVolumes("./extra/backups-config", "/opt/ftth/web/backups-config");
|
|
|
+ ->addVolumes("./extra/netmiko", "/opt/netmiko")
|
|
|
+ ->addVolumes("./extra/backups-config", "/opt/ftth/web/backups-config");
|
|
|
|
|
|
$composer
|
|
|
->addService("cablemodem_tasklogger_worker")
|
|
@@ -1004,8 +939,7 @@ class Release extends Command
|
|
|
->addEnv_file("dhcp.host.env")
|
|
|
->addEnviroment("AMQP_KEY", "dhcp")
|
|
|
->addVolumes("./dhcp/", "/opt/dhcp")
|
|
|
- ->addVolumes("./kea/conf", "/opt/dhcp/web/kea")
|
|
|
- ;
|
|
|
+ ->addVolumes("./kea/conf", "/opt/dhcp/web/kea");
|
|
|
|
|
|
$composer
|
|
|
->addService("ftth_command_worker")
|
|
@@ -1086,13 +1020,14 @@ class Release extends Command
|
|
|
*/
|
|
|
public function addKea(FileFormat2 $composer, $config = array())
|
|
|
{
|
|
|
+ $module = 'kea';
|
|
|
$version = "latest";
|
|
|
$registry = "";
|
|
|
+ $host_env_file = "";
|
|
|
extract($config);
|
|
|
|
|
|
- $module = 'kea';
|
|
|
$composer
|
|
|
- ->addService("kea")
|
|
|
+ ->addService($module)
|
|
|
->image($registry . "fd3/kea-ik-1.4.0:" . $version)
|
|
|
// ->build("./extra/kea/")
|
|
|
->restart($this->_docker_restart_default)
|
|
@@ -1105,8 +1040,7 @@ class Release extends Command
|
|
|
->addVolumes("./kea/conf/kea-ctrl-agent.conf", "/usr/local/etc/kea/kea-ctrl-agent.conf")
|
|
|
->addVolumes("./kea/conf/kea-dhcp4.conf", "/usr/local/etc/kea/kea-dhcp4.conf")
|
|
|
->addVolumes("./kea/supervisord", "/etc/supervisord")
|
|
|
- ->addVolumes("./kea/hooks", "/opt/hooks")
|
|
|
- ;
|
|
|
+ ->addVolumes("./kea/hooks", "/opt/hooks");
|
|
|
$this->writeVariablesEnviroment($module . "." . $host_env_file, $module,
|
|
|
array(
|
|
|
"MYSQL_ROOT_PASSWORD" => $this->_mysql_root_pass,
|
|
@@ -1114,7 +1048,7 @@ class Release extends Command
|
|
|
));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
+ /**
|
|
|
* @param FileFormat2 $composer
|
|
|
* @param array $config
|
|
|
*/
|
|
@@ -1125,7 +1059,7 @@ class Release extends Command
|
|
|
$registry = "";
|
|
|
$host_env_file = "";
|
|
|
extract($config);
|
|
|
-
|
|
|
+
|
|
|
$composer
|
|
|
->addService($module)
|
|
|
->image($registry . "fd3/swagger-ui:" . $version)
|
|
@@ -1153,7 +1087,7 @@ class Release extends Command
|
|
|
$this->addNginx($composer, $base_vars);
|
|
|
|
|
|
/**************************************************************************************/
|
|
|
- /* Apps / Web UI / Grafana / PMA */
|
|
|
+ /* Apps / Web UI / PMA */
|
|
|
/**************************************************************************************/
|
|
|
foreach ($this->_modules_all as $module => $env) {
|
|
|
$method = 'add' . ucfirst($module);
|
|
@@ -1270,7 +1204,7 @@ class Release extends Command
|
|
|
foreach ($app['VAR_ENV'] as $key => $value) {
|
|
|
if ($key == 'VIRTUAL_HOST') {
|
|
|
$env .= "VIRTUAL_HOST=" . $this->getDomain($module) . "\n";
|
|
|
- } else if($key == 'PMA_ABSOLUTE_URI') {
|
|
|
+ } else if ($key == 'PMA_ABSOLUTE_URI') {
|
|
|
$env .= "PMA_ABSOLUTE_URI=" . $this->getDomain("pma") . "\n";
|
|
|
} else {
|
|
|
$env .= $key . "=" . $value . "\n";
|
|
@@ -1442,7 +1376,6 @@ class Release extends Command
|
|
|
->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"));
|