Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
actionmodifyer.php
1<?
2namespace Bitrix\Scale;
3
4use \Bitrix\Main\Localization\Loc;
5Loc::loadMessages(__FILE__);
6
12{
22 public static function mysqlAddSlave($actionId, $actionParams, $hostname, $userParamsValues)
23 {
24 $action = new Action("MYSQL_ADD_SLAVE_MODIFYER", array(
25 "START_COMMAND_TEMPLATE" => "sudo -u root /opt/webdir/bin/bx-mysql -a options -o json",
26 "LOG_LEVEL" => Logger::LOG_LEVEL_DISABLE
27 ),
28 "",
29 array()
30 );
31
32 $action->start();
33 $actRes = $action->getResult();
34
35 $needModeInfo = false;
36
37 if(isset($actRes["MYSQL_ADD_SLAVE_MODIFYER"]["OUTPUT"]["DATA"]["params"]["options"])
38 && is_array($actRes["MYSQL_ADD_SLAVE_MODIFYER"]["OUTPUT"]["DATA"]["params"]["options"])
39 )
40 {
41 foreach($actRes["MYSQL_ADD_SLAVE_MODIFYER"]["OUTPUT"]["DATA"]["params"]["options"] as $option)
42 {
43 if($option == "cluster_password" || $option == "replica_password")
44 {
45 $actionParams["START_COMMAND_TEMPLATE"] .=" --".$option."=".\Bitrix\Scale\Helper::generatePass();
46 }
47 elseif($option == "mysql_password")
48 {
49 $actionParams["START_COMMAND_TEMPLATE"] .=" --".$option."=##USER_PARAMS:MYSQL_PASS##";
50
51 if(!isset($actionParams["USER_PARAMS"]))
52 $actionParams["USER_PARAMS"] = array();
53
54 $actionParams["USER_PARAMS"]["MYSQL_PASS"] = array(
55 "NAME" => Loc::getMessage("SCALE_AM_MYAR_MYSQL_PASS"),
56 "TYPE" => "PASSWORD",
57 "REQUIRED" => "Y",
58 "VERIFY_TWICE" => "Y"
59 );
60
61 $needModeInfo = true;
62 }
63 }
64
65 if($needModeInfo)
66 throw new NeedMoreUserInfoException("Need more user's info", $actionParams);
67 }
68
69 return $actionParams;
70 }
71
81 public static function checkExtraDbExist($actionId, $actionParams, $hostname, $userParamsValues)
82 {
83 if($actionId == "MYSQL_ADD_SLAVE" || $actionId == "MYSQL_CHANGE_MASTER")
85
86 if(Helper::isExtraDbExist($hostname))
87 {
88 $actionParams["CHECK_EXTRA_DB_USER_ASK"] = "Y";
89 throw new NeedMoreUserInfoException("Need more user's info", $actionParams);
90 }
91
92 return $actionParams;
93 }
94
103 public static function emailSettingsModifier($actionId, $actionParams, $hostname, $userParamsValues)
104 {
105 if($actionId != 'SET_EMAIL_SETTINGS')
106 return $actionParams;
107
108 if($userParamsValues['USE_AUTH'] == 'Y')
109 $pattern = '/(--8<--AUTH_BEGIN----|----AUTH_END--8<--)/';
110 else
111 $pattern = '/--8<--AUTH_BEGIN----.*----AUTH_END--8<--/';
112
113 $actionParams['START_COMMAND_TEMPLATE'] = preg_replace($pattern, '', $actionParams['START_COMMAND_TEMPLATE']);
114 return $actionParams;
115 }
116
125 public static function siteCreateLinkModifier($actionId, $actionParams, $hostname, $userParamsValues)
126 {
127 if($actionId != 'SITE_CREATE_LINK')
128 return $actionParams;
129
130 if(empty($userParamsValues['KERNEL_SITE']))
131 return $actionParams;
132
133 $siteId = $userParamsValues['KERNEL_SITE'];
134 $sites = SitesData::getList();
135
136 if(empty($sites[$siteId]))
137 return $actionParams;
138
139 $actionParams['START_COMMAND_TEMPLATE'] = str_replace(
140 '##MODIFYER:KERNEL_ROOT##',
141 $sites[$siteId]['DocumentRoot'],
142 $actionParams['START_COMMAND_TEMPLATE']
143 );
144
145 return $actionParams;
146 }
147}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static checkExtraDbExist($actionId, $actionParams, $hostname, $userParamsValues)
static mysqlAddSlave($actionId, $actionParams, $hostname, $userParamsValues)
static siteCreateLinkModifier($actionId, $actionParams, $hostname, $userParamsValues)
static emailSettingsModifier($actionId, $actionParams, $hostname, $userParamsValues)
static isExtraDbExist($hostname)
Definition helper.php:160
const LOG_LEVEL_DISABLE
Definition logger.php:14
static getList($dbName=false)
Definition sitesdata.php:72