|
@@ -430,11 +430,8 @@ class Release extends Command
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
$modules = implode(",", $modules);
|
|
|
return $modules;
|
|
|
}
|
|
@@ -468,7 +465,7 @@ class Release extends Command
|
|
|
|
|
|
function getDockerComposer($version = "latest", $host_env_file = "host.env", $registry = "docker.infra.flowdat.com/")
|
|
|
{
|
|
|
- $composer = new FileFormat("../", 3);
|
|
|
+ $composer = new FileFormat("../", "3.7");
|
|
|
$this->registerVolumes($composer);
|
|
|
$nc = new NetworkConfig();
|
|
|
$nc->addDriver()->addSubnetGateway("172.172.172.0/24");
|
|
@@ -479,10 +476,6 @@ class Release extends Command
|
|
|
"host_env_file" => $host_env_file,
|
|
|
"registry" => $registry);
|
|
|
|
|
|
-
|
|
|
- /**************************************************************************************/
|
|
|
- /* Apps / Web UI / PMA */
|
|
|
- /**************************************************************************************/
|
|
|
$ip = explode(".", $this->_network_ip);
|
|
|
array_pop($ip);
|
|
|
$ip = implode(".", $ip);
|
|
@@ -500,7 +493,7 @@ class Release extends Command
|
|
|
->add();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ $this->checkLinkDependencyDockerCompose($composer);
|
|
|
$this->_dObj->file("docker-compose.yml")->content($composer->render());
|
|
|
|
|
|
// escribo un archivo inventory.ini por defecto para no tener que lanzar los docker
|
|
@@ -601,8 +594,10 @@ class Release extends Command
|
|
|
$oautModules = "";
|
|
|
foreach ($this->_modules as $nameApp => $app) {
|
|
|
if (isset($app['OAUTH']) && $app['OAUTH']) {
|
|
|
- $this->_dObj->file($nameApp . ".oauth.env")->content("");
|
|
|
- $oautModules = $oautModules . $nameApp . ",";
|
|
|
+ if (!file_exists(realpath($this->directory) . $nameApp . ".oauth.env")) {
|
|
|
+ $this->_dObj->file($nameApp . ".oauth.env")->content("");
|
|
|
+ $oautModules = $oautModules . $nameApp . ",";
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
$this->_ansible_vars["MODULES_INSTALL"] = substr($oautModules, 0, strlen($oautModules) - 1);
|
|
@@ -747,63 +742,94 @@ class Release extends Command
|
|
|
public function addNginxLinks($module, FileFormat $composer)
|
|
|
{
|
|
|
if ($this->_add_nginx_links) {
|
|
|
- $composer->service($module)
|
|
|
- ->addLinks((new Nginx())->getModuleName(), $this->getDomain((new Base())->getModuleName()))
|
|
|
- ->addLinks((new Nginx())->getModuleName(), $this->getDomain((new Ftth())->getModuleName()))
|
|
|
- ->addLinks((new Nginx())->getModuleName(), $this->getDomain((new Cablemodem())->getModuleName()))
|
|
|
- ->addLinks((new Nginx())->getModuleName(), $this->getDomain((new Stats())->getModuleName()))
|
|
|
- ->addLinks((new Nginx())->getModuleName(), $this->getDomain((new Dhcp())->getModuleName()))
|
|
|
- ->addLinks((new Nginx())->getModuleName(), $this->getDomain((new Radius())->getModuleName()));
|
|
|
+ if (in_array((new Base())->getModuleName(), $this->_modules_all)) {
|
|
|
+ $composer->service($module)->addLinks((new Nginx())->getModuleName(), $this->getDomain((new Base())->getModuleName()));
|
|
|
+ }
|
|
|
+ if (in_array((new Ftth())->getModuleName(), $this->_modules_all)) {
|
|
|
+ $composer->service($module)->addLinks((new Nginx())->getModuleName(), $this->getDomain((new Ftth())->getModuleName()));
|
|
|
+ }
|
|
|
+ if (in_array((new Cablemodem())->getModuleName(), $this->_modules_all)) {
|
|
|
+ $composer->service($module)->addLinks((new Nginx())->getModuleName(), $this->getDomain((new Cablemodem())->getModuleName()));
|
|
|
+ }
|
|
|
+ if (in_array((new Stats())->getModuleName(), $this->_modules_all)) {
|
|
|
+ $composer->service($module)->addLinks((new Nginx())->getModuleName(), $this->getDomain((new Stats())->getModuleName()));
|
|
|
+ }
|
|
|
+ if (in_array((new Dhcp())->getModuleName(), $this->_modules_all)) {
|
|
|
+ $composer->service($module)->addLinks((new Nginx())->getModuleName(), $this->getDomain((new Dhcp())->getModuleName()));
|
|
|
+ }
|
|
|
+ if (in_array((new Radius())->getModuleName(), $this->_modules_all)) {
|
|
|
+ $composer->service($module)->addLinks((new Nginx())->getModuleName(), $this->getDomain((new Radius())->getModuleName()));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private function registerVolumes(FileFormat $composer)
|
|
|
{
|
|
|
- $composer->getVolumes()->addVolumen(Pma::PMA_VOLUMEN, 'local');
|
|
|
- $composer->getVolumes()->addVolumen(Swagger::SWAGGER_VOLUMEN, 'local');
|
|
|
- $composer->getVolumes()->addVolumen(Base::BASE_SOCKET_VOLUMEN, 'local');
|
|
|
- $composer->getVolumes()->addVolumen(Cablemodem::CABLEMODEM_SOCKET_VOLUMEN, 'local');
|
|
|
- $composer->getVolumes()->addVolumen(Dhcp::DHCP_SOCKET_VOLUMEN, 'local');
|
|
|
- $composer->getVolumes()->addVolumen(Ftth::FTTH_SOCKET_VOLUMEN, 'local');
|
|
|
- $composer->getVolumes()->addVolumen(Radius::RADIUS_SOCKET_VOLUMEN, 'local');
|
|
|
- $composer->getVolumes()->addVolumen(Stats::STATS_SOCKET_VOLUMEN, 'local');
|
|
|
- $composer->getVolumes()->addVolumen(Api::API_SOCKET_VOLUMEN, 'local');
|
|
|
-
|
|
|
+ if (in_array((new Pma())->getModuleName(), $this->_modules_all)) {
|
|
|
+ $composer->getVolumes()->addVolumen(Pma::PMA_VOLUMEN, 'local');
|
|
|
+ }
|
|
|
+ if (in_array((new Swagger())->getModuleName(), $this->_modules_all)) {
|
|
|
+ $composer->getVolumes()->addVolumen(Swagger::SWAGGER_VOLUMEN, 'local');
|
|
|
+ }
|
|
|
+ if (in_array((new Base())->getModuleName(), $this->_modules_all)) {
|
|
|
+ $composer->getVolumes()->addVolumen(Base::BASE_SOCKET_VOLUMEN, 'local');
|
|
|
+ }
|
|
|
+ if (in_array((new Cablemodem())->getModuleName(), $this->_modules_all)) {
|
|
|
+ $composer->getVolumes()->addVolumen(Cablemodem::CABLEMODEM_SOCKET_VOLUMEN, 'local');
|
|
|
+ }
|
|
|
+ if (in_array((new Dhcp())->getModuleName(), $this->_modules_all)) {
|
|
|
+ $composer->getVolumes()->addVolumen(Dhcp::DHCP_SOCKET_VOLUMEN, 'local');
|
|
|
+ }
|
|
|
+ if (in_array((new Ftth())->getModuleName(), $this->_modules_all)) {
|
|
|
+ $composer->getVolumes()->addVolumen(Ftth::FTTH_SOCKET_VOLUMEN, 'local');
|
|
|
+ }
|
|
|
+ if (in_array((new Radius())->getModuleName(), $this->_modules_all)) {
|
|
|
+ $composer->getVolumes()->addVolumen(Radius::RADIUS_SOCKET_VOLUMEN, 'local');
|
|
|
+ }
|
|
|
+ if (in_array((new Stats())->getModuleName(), $this->_modules_all)) {
|
|
|
+ $composer->getVolumes()->addVolumen(Stats::STATS_SOCKET_VOLUMEN, 'local');
|
|
|
+ }
|
|
|
+ if (in_array((new Api())->getModuleName(), $this->_modules_all)) {
|
|
|
+ $composer->getVolumes()->addVolumen(Api::API_SOCKET_VOLUMEN, 'local');
|
|
|
+ }
|
|
|
}
|
|
|
-}
|
|
|
-// 2= Nginx
|
|
|
-// 3= Mongodb
|
|
|
-// 4= Mysql
|
|
|
-// 5= Supervisord
|
|
|
-// 6= Amqp
|
|
|
-// 7= Redis
|
|
|
-// 8= Api
|
|
|
-// 9= Swagger
|
|
|
-//10= Pma
|
|
|
-//11= Base
|
|
|
-//12= Base_log
|
|
|
-//13= Cablemodem
|
|
|
-//14= Cablemodem_cmd
|
|
|
-//15= Cablemodem_task
|
|
|
-//16= Dhcp
|
|
|
-//17= Dhcp_task
|
|
|
-//18= Ftth
|
|
|
-//19= Ftth_cmd
|
|
|
-//20= Ftth_task
|
|
|
-//21= Kea
|
|
|
-//22= Radius
|
|
|
-//23= Stats
|
|
|
-//24= Stats_cmd
|
|
|
-//25= Statsd
|
|
|
-//26= Tftp
|
|
|
-//27= Freeradius
|
|
|
-//28= Genieacs_cwmp
|
|
|
-//29= Genieacs_fs
|
|
|
-//30= Genieacs_gui
|
|
|
-//31= Genieacs_nbi
|
|
|
-//32= Geoserver
|
|
|
-//33= Jsendpoint
|
|
|
-//34= Jsonep_mongo
|
|
|
-//35= Jsonep_mysql
|
|
|
-
|
|
|
|
|
|
+ /**
|
|
|
+ * @param FileFormat $composer Contains composer.
|
|
|
+ * @return FileFormat Return composer with corrected link.
|
|
|
+ */
|
|
|
+ private function checkLinkDependencyDockerCompose(FileFormat $composer)
|
|
|
+ {
|
|
|
+ foreach ($composer->getServices() as $key => $value) {
|
|
|
+ // every service in docker compose
|
|
|
+ if ($value->getLinks()) {
|
|
|
+ $arrtmp = [];
|
|
|
+ foreach ($value->getLinks() as $link) {
|
|
|
+ // every link in service in docker compose
|
|
|
+ $found = false;
|
|
|
+ foreach ($this->_modules as $module => $env) {
|
|
|
+ // every module selected for install
|
|
|
+ if (strpos($module, "genieacs") !== false) {
|
|
|
+ $moduleg = str_replace("-", "_", $module);
|
|
|
+ } else {
|
|
|
+ $moduleg = "";
|
|
|
+ }
|
|
|
+ //remove nginx: to compare because nginx is always TRUE
|
|
|
+ $linkTmp = str_replace("nginx:", "", $link);
|
|
|
+ if (strpos($linkTmp, $module) === false) {
|
|
|
+ } else if ($moduleg != "" && strpos($linkTmp, $moduleg) === false) {
|
|
|
+ } else {
|
|
|
+ $found = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($found) {
|
|
|
+ // add link only if is in list of modules install
|
|
|
+ $arrtmp[] = $link;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $value->setLinks($arrtmp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $composer;
|
|
|
+ }
|
|
|
+}
|