本文整理汇总了PHP中Scalr_Account_User::getAccount方法的典型用法代码示例。如果您正苦于以下问题:PHP Scalr_Account_User::getAccount方法的具体用法?PHP Scalr_Account_User::getAccount怎么用?PHP Scalr_Account_User::getAccount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scalr_Account_User
的用法示例。
在下文中一共展示了Scalr_Account_User::getAccount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cloneFarm
/**
* Creates clone for the farm
*
* @param string $name The name of the farm
* @param Scalr_Account_User $user The user object
* @param int $envId The identifier of the environment
* @return DBFarm Returns clone
*/
public function cloneFarm($name = false, Scalr_Account_User $user, $envId)
{
$account = $user->getAccount();
$account->validateLimit(Scalr_Limits::ACCOUNT_FARMS, 1);
$definition = $this->getDefinition();
if (!$name) {
$template = "";
if (!preg_match('/^(.*?)\\(clone \\#([0-9]*)\\)$/si', $definition->name)) {
$name = $definition->name;
} else {
preg_match('/^(.*?)\\(clone \\#([0-9]*)\\)$/si', $definition->name, $matches);
$name = trim($matches[1]);
}
$name = preg_replace('/[^A-Za-z0-9_\\. -]+/', '', $name);
$lastUsedIndex = $this->DB->GetOne('SELECT MAX(CAST((SUBSTR(@p:=SUBSTRING_INDEX(name, \'#\', -1), 1, LENGTH(@p) - 1)) AS UNSIGNED)) as lastUsedCloneNumber FROM farms WHERE name REGEXP \'' . str_replace('.', '\\.', $name) . ' \\\\(clone #[0-9]+\\\\)\' AND env_id = ?', array($envId));
$name = $name . ' (clone #' . ($lastUsedIndex + 1) . ')';
}
$dbFarm = self::create($name, $user, $envId);
$dbFarm->createdByUserId = $user->id;
$dbFarm->createdByUserEmail = $user->getEmail();
$dbFarm->RolesLaunchOrder = $definition->rolesLaunchOrder;
$dbFarm->teamId = $definition->teamId;
$dbFarm->SetSetting(Entity\FarmSetting::TIMEZONE, $definition->settings[Entity\FarmSetting::TIMEZONE]);
$dbFarm->SetSetting(Entity\FarmSetting::EC2_VPC_ID, $definition->settings[Entity\FarmSetting::EC2_VPC_ID]);
$dbFarm->SetSetting(Entity\FarmSetting::EC2_VPC_REGION, $definition->settings[Entity\FarmSetting::EC2_VPC_REGION]);
$dbFarm->SetSetting(Entity\FarmSetting::SZR_UPD_REPOSITORY, $definition->settings[Entity\FarmSetting::SZR_UPD_REPOSITORY]);
$dbFarm->SetSetting(Entity\FarmSetting::SZR_UPD_SCHEDULE, $definition->settings[Entity\FarmSetting::SZR_UPD_SCHEDULE]);
$dbFarm->SetSetting(Entity\FarmSetting::LEASE_STATUS, $definition->settings[Entity\FarmSetting::LEASE_STATUS]);
if ($definition->settings[Entity\FarmSetting::PROJECT_ID]) {
$dbFarm->SetSetting(Entity\FarmSetting::PROJECT_ID, $definition->settings[Entity\FarmSetting::PROJECT_ID]);
}
$variables = new Scalr_Scripting_GlobalVariables($dbFarm->ClientID, $envId, ScopeInterface::SCOPE_FARM);
$variables->setValues($definition->globalVariables, 0, $dbFarm->ID, 0);
foreach ($definition->roles as $index => $role) {
$dbFarmRole = $dbFarm->AddRole(DBRole::loadById($role->roleId), $role->platform, $role->cloudLocation, $role->launchIndex, $role->alias);
$oldRoleSettings = $dbFarmRole->GetAllSettings();
$dbFarmRole->applyDefinition($role, true);
$newSettings = $dbFarmRole->GetAllSettings();
// Platform specified updates
if ($dbFarmRole->Platform == SERVER_PLATFORMS::EC2) {
\Scalr\Modules\Platforms\Ec2\Helpers\EbsHelper::farmUpdateRoleSettings($dbFarmRole, $oldRoleSettings, $newSettings);
\Scalr\Modules\Platforms\Ec2\Helpers\EipHelper::farmUpdateRoleSettings($dbFarmRole, $oldRoleSettings, $newSettings);
\Scalr\Modules\Platforms\Ec2\Helpers\ElbHelper::farmUpdateRoleSettings($dbFarmRole, $oldRoleSettings, $newSettings);
}
if (in_array($dbFarmRole->Platform, array(SERVER_PLATFORMS::IDCF, SERVER_PLATFORMS::CLOUDSTACK))) {
CloudstackHelper::farmUpdateRoleSettings($dbFarmRole, $oldRoleSettings, $newSettings);
}
$dbFarmRolesList[] = $dbFarmRole;
$usedPlatforms[$role->platform] = 1;
}
$dbFarm->save();
return $dbFarm;
}
示例2: cloneFarm
/**
* Creates clone for the farm
*
* @param string|bool $name The name of the farm
* @param Scalr_Account_User $user The user object
* @param int $envId The identifier of the environment
* @return DBFarm Returns clone
*/
public function cloneFarm($name = false, Scalr_Account_User $user, $envId)
{
$account = $user->getAccount();
$account->validateLimit(Scalr_Limits::ACCOUNT_FARMS, 1);
$definition = $this->getDefinition();
if (!$name) {
$template = "";
if (!preg_match('/^(.*?)\\(clone \\#([0-9]*)\\)$/si', $definition->name)) {
$name = $definition->name;
} else {
preg_match('/^(.*?)\\(clone \\#([0-9]*)\\)$/si', $definition->name, $matches);
$name = trim($matches[1]);
}
$name = preg_replace('/[^A-Za-z0-9_\\. -]+/', '', $name);
$lastUsedIndex = $this->DB->GetOne('SELECT MAX(CAST((SUBSTR(@p:=SUBSTRING_INDEX(name, \'#\', -1), 1, LENGTH(@p) - 1)) AS UNSIGNED)) as lastUsedCloneNumber FROM farms WHERE name REGEXP \'' . str_replace('.', '\\.', $name) . ' \\\\(clone #[0-9]+\\\\)\' AND env_id = ?', array($envId));
$name = $name . ' (clone #' . ($lastUsedIndex + 1) . ')';
}
$dbFarm = self::create($name, $user, $envId);
$dbFarm->RolesLaunchOrder = $definition->rolesLaunchOrder;
$dbFarm->SetSetting(Entity\FarmSetting::TIMEZONE, $definition->settings[Entity\FarmSetting::TIMEZONE]);
$dbFarm->SetSetting(Entity\FarmSetting::EC2_VPC_ID, $definition->settings[Entity\FarmSetting::EC2_VPC_ID]);
$dbFarm->SetSetting(Entity\FarmSetting::EC2_VPC_REGION, $definition->settings[Entity\FarmSetting::EC2_VPC_REGION]);
$dbFarm->SetSetting(Entity\FarmSetting::SZR_UPD_REPOSITORY, $definition->settings[Entity\FarmSetting::SZR_UPD_REPOSITORY]);
$dbFarm->SetSetting(Entity\FarmSetting::SZR_UPD_SCHEDULE, $definition->settings[Entity\FarmSetting::SZR_UPD_SCHEDULE]);
$dbFarm->SetSetting(Entity\FarmSetting::LEASE_STATUS, $definition->settings[Entity\FarmSetting::LEASE_STATUS]);
if ($definition->settings[Entity\FarmSetting::PROJECT_ID]) {
$dbFarm->SetSetting(Entity\FarmSetting::PROJECT_ID, $definition->settings[Entity\FarmSetting::PROJECT_ID]);
}
$variables = new Scalr_Scripting_GlobalVariables($dbFarm->ClientID, $envId, ScopeInterface::SCOPE_FARM);
$variables->setValues($definition->globalVariables, 0, $dbFarm->ID, 0);
$this->cloneFarmRoles($dbFarm);
$this->DB->Execute("\n INSERT INTO farm_teams (farm_id, team_id)\n SELECT ? AS farm_id, team_id\n FROM `farm_teams`\n WHERE farm_id = ?\n ", [$dbFarm->ID, $this->ID]);
$dbFarm->save();
return $dbFarm;
}
示例3: cloneFarm
/**
* Creates clone for the farm
*
* @param string $name The name of the farm
* @param Scalr_Account_User $user The user object
* @param int $envId The identifier of the environment
* @return DBFarm Returns clone
*/
public function cloneFarm($name = false, Scalr_Account_User $user, $envId)
{
$account = $user->getAccount();
$account->validateLimit(Scalr_Limits::ACCOUNT_FARMS, 1);
$definition = $this->getDefinition();
if (!$name) {
$template = "";
if (!stristr($definition->name, "clone")) {
$template = $definition->name . ' (clone #%s)';
$i = 1;
} else {
preg_match("/^(.*?)\\(clone \\#([0-9]*)\\)\$/si", $definition->name, $matches);
$template = trim($matches[1]) . " (clone #%s)";
$i = $matches[2] + 1;
}
while (true) {
$name = sprintf($template, $i);
if (!$this->DB->GetOne("SELECT id FROM farms WHERE name = ? AND env_id = ? LIMIT 1", array($name, $this->EnvID))) {
break;
} else {
$i++;
}
}
}
$dbFarm = self::create($name, $user, $envId);
$dbFarm->createdByUserId = $user->id;
$dbFarm->createdByUserEmail = $user->getEmail();
$dbFarm->RolesLaunchOrder = $definition->rolesLaunchOrder;
$dbFarm->SetSetting(DBFarm::SETTING_TIMEZONE, $definition->settings[DBFarm::SETTING_TIMEZONE]);
$dbFarm->SetSetting(DBFarm::SETTING_EC2_VPC_ID, $definition->settings[DBFarm::SETTING_EC2_VPC_ID]);
$dbFarm->SetSetting(DBFarm::SETTING_EC2_VPC_REGION, $definition->settings[DBFarm::SETTING_EC2_VPC_REGION]);
$dbFarm->SetSetting(DBFarm::SETTING_SZR_UPD_REPOSITORY, $definition->settings[DBFarm::SETTING_SZR_UPD_REPOSITORY]);
$dbFarm->SetSetting(DBFarm::SETTING_SZR_UPD_SCHEDULE, $definition->settings[DBFarm::SETTING_SZR_UPD_SCHEDULE]);
$dbFarm->SetSetting(DBFarm::SETTING_LEASE_STATUS, $definition->settings[DBFarm::SETTING_LEASE_STATUS]);
$variables = new Scalr_Scripting_GlobalVariables($dbFarm->ClientID, $envId, Scalr_Scripting_GlobalVariables::SCOPE_FARM);
$variables->setValues($definition->globalVariables, 0, $dbFarm->ID, 0);
foreach ($definition->roles as $index => $role) {
$dbFarmRole = $dbFarm->AddRole(DBRole::loadById($role->roleId), $role->platform, $role->cloudLocation, $index + 1, $role->alias);
$oldRoleSettings = $dbFarmRole->GetAllSettings();
$dbFarmRole->applyDefinition($role, true);
$newSettings = $dbFarmRole->GetAllSettings();
Scalr_Helpers_Dns::farmUpdateRoleSettings($dbFarmRole, $oldRoleSettings, $newSettings);
// Platfrom specified updates
if ($dbFarmRole->Platform == SERVER_PLATFORMS::EC2) {
\Scalr\Modules\Platforms\Ec2\Helpers\EbsHelper::farmUpdateRoleSettings($dbFarmRole, $oldRoleSettings, $newSettings);
\Scalr\Modules\Platforms\Ec2\Helpers\EipHelper::farmUpdateRoleSettings($dbFarmRole, $oldRoleSettings, $newSettings);
\Scalr\Modules\Platforms\Ec2\Helpers\ElbHelper::farmUpdateRoleSettings($dbFarmRole, $oldRoleSettings, $newSettings);
}
if (in_array($dbFarmRole->Platform, array(SERVER_PLATFORMS::IDCF, SERVER_PLATFORMS::CLOUDSTACK))) {
CloudstackHelper::farmUpdateRoleSettings($dbFarmRole, $oldRoleSettings, $newSettings);
}
$dbFarmRolesList[] = $dbFarmRole;
$usedPlatforms[$role->platform] = 1;
}
if ($usedPlatforms[SERVER_PLATFORMS::EC2]) {
\Scalr\Modules\Platforms\Ec2\Helpers\Ec2Helper::farmSave($dbFarm, $dbFarmRolesList);
}
if ($usedPlatforms[SERVER_PLATFORMS::EUCALYPTUS]) {
\Scalr\Modules\Platforms\Eucalyptus\Helpers\EucalyptusHelper::farmSave($dbFarm, $dbFarmRolesList);
}
if ($usedPlatforms[SERVER_PLATFORMS::CLOUDSTACK]) {
CloudstackHelper::farmSave($dbFarm, $dbFarmRolesList);
}
$dbFarm->save();
return $dbFarm;
}