Ejemplo n.º 1
0
 /**
  * @return array List of servers & their params
  */
 public static function getList()
 {
     $result = array();
     $shellAdapter = new ShellAdapter();
     $execRes = $shellAdapter->syncExec("sudo -u root /opt/webdir/bin/wrapper_ansible_conf -o json");
     $serversData = $shellAdapter->getLastOutput();
     if ($execRes) {
         $arData = json_decode($serversData, true);
         //mgmt server must be first
         if (isset($arData["params"]) && is_array($arData["params"])) {
             foreach ($arData["params"] as $hostname => $server) {
                 try {
                     $server["BX_ENV_VER"] = static::getBxEnvVer($hostname);
                     $bxInfo = static::getBxInfo($hostname);
                     if (isset($bxInfo["bx_last_password_change"])) {
                         $server["LAST_PASSWORD_CHANGE"] = $bxInfo["bx_last_password_change"];
                     }
                     if (!$server["BX_ENV_VER"] || !Helper::checkBxEnvVersion($server["BX_ENV_VER"])) {
                         $server["BX_ENV_NEED_UPDATE"] = true;
                     } else {
                         $server["BX_ENV_NEED_UPDATE"] = false;
                     }
                 } catch (ServerBxInfoException $e) {
                     $server["BX_INFO_ERROR"] = $e->getMessage();
                 }
                 $result[$hostname] = $server;
             }
             \sortByColumn($result, array("host_id" => array(SORT_NUMERIC, SORT_ASC)));
         }
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * @param string $dbName
  * @return array List of all sites & their params
  */
 public static function getList($dbName = false)
 {
     if (!$dbName) {
         $connection = \Bitrix\Main\Application::getConnection();
         $dbName = $connection->getDbName();
     }
     $result = array();
     $shellAdapter = new ShellAdapter();
     $execRes = $shellAdapter->syncExec("sudo -u root /opt/webdir/bin/bx-sites -o json -a list -d " . $dbName);
     $sitesData = $shellAdapter->getLastOutput();
     if ($execRes) {
         $arData = json_decode($sitesData, true);
         if (isset($arData["params"])) {
             $result = $arData["params"];
         }
         $rsSite = \Bitrix\Main\SiteTable::getList();
         while ($site = $rsSite->fetch()) {
             foreach ($result as $siteId => $siteInfo) {
                 $docRoot = strlen($site["DOC_ROOT"]) > 0 ? $site["DOC_ROOT"] : \Bitrix\Main\Application::getDocumentRoot();
                 if ($siteInfo["DocumentRoot"] == $docRoot) {
                     $result[$siteId]["NAME"] = $site["NAME"] . " (" . $site["LID"] . ") ";
                 } else {
                     $result[$siteId]["NAME"] = $siteId;
                 }
             }
         }
     }
     return $result;
 }
Ejemplo n.º 3
0
 /**
  * @return array List of servers & their params
  */
 public static function getList()
 {
     $result = array();
     $shellAdapter = new ShellAdapter();
     $execRes = $shellAdapter->syncExec("sudo -u root /opt/webdir/bin/wrapper_ansible_conf -o json");
     $serversData = $shellAdapter->getLastOutput();
     if ($execRes) {
         $arData = json_decode($serversData, true);
         //mgmt server must be first
         if (isset($arData["params"]) && is_array($arData["params"])) {
             foreach ($arData["params"] as $hostname => $server) {
                 $server["BX_ENV_VER"] = static::getBxEnvVer($hostname);
                 if (!$server["BX_ENV_VER"] || !Helper::checkBxEnvVersion($server["BX_ENV_VER"])) {
                     $server["BX_ENV_NEED_UPDATE"] = true;
                 } else {
                     $server["BX_ENV_NEED_UPDATE"] = false;
                 }
                 $result[$hostname] = $server;
             }
             \sortByColumn($result, array("host_id" => array(SORT_NUMERIC, SORT_ASC)));
         }
     }
     return $result;
 }