39 $execRes = $shellAdapter->syncExec(
"sudo -u root /opt/webdir/bin/wrapper_ansible_conf -o json");
40 $serversData = $shellAdapter->getLastOutput();
44 $arData = json_decode($serversData,
true);
47 if(isset($arData[
"params"]) && is_array($arData[
"params"]))
49 foreach($arData[
"params"] as $hostname => $server)
53 $server[
"BX_ENV_VER"] = static::getBxEnvVer($hostname);
54 $bxInfo = static::getBxInfo($hostname);
57 if(isset(
$bxInfo[
"bx_last_password_change"]))
58 $server[
"LAST_PASSWORD_CHANGE"] =
$bxInfo[
"bx_last_password_change"];
61 $server[
"BX_ENV_NEED_UPDATE"] =
true;
63 $server[
"BX_ENV_NEED_UPDATE"] =
false;
68 $server[
"BX_INFO_ERROR"] = $e->getMessage();
71 $result[$hostname] = $server;
74 \sortByColumn($result, array(
"host_id" => array(SORT_NUMERIC, SORT_ASC)));
140 throw new \Bitrix\Main\ArgumentNullException(
"hostname");
144 if(isset(static::$bxInfo[$hostname]))
146 $result = static::$bxInfo[$hostname];
150 $action =
new Action(
"get_bx_info", array(
151 "START_COMMAND_TEMPLATE" =>
"sudo -u root /opt/webdir/bin/wrapper_ansible_conf -a bx_info -H ".$hostname.
" -o json",
159 $actRes = $action->getResult();
161 if(isset($actRes[
"get_bx_info"][
"OUTPUT"][
"DATA"][
"params"][
"bx_variables"][$hostname]))
163 $result = static::$bxInfo[$hostname] = $actRes[
"get_bx_info"][
"OUTPUT"][
"DATA"][
"params"][
"bx_variables"][$hostname];
165 elseif(isset($actRes[
"get_bx_info"][
"RESULT"])
166 && $actRes[
"get_bx_info"][
"RESULT"] =
"ERROR"
167 && $actRes[
"get_bx_info"][
"ERROR"] <>
''
170 throw new \Bitrix\Scale\ServerBxInfoException($actRes[
"get_bx_info"][
"ERROR"], $hostname);