本文整理汇总了PHP中Scalr::config方法的典型用法代码示例。如果您正苦于以下问题:PHP Scalr::config方法的具体用法?PHP Scalr::config怎么用?PHP Scalr::config使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scalr
的用法示例。
在下文中一共展示了Scalr::config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: defaultAction
public function defaultAction()
{
if ($this->user->getType() == Scalr_Account_User::TYPE_SCALR_ADMIN) {
$this->response->page('ui/dashboard/admin.js');
} else {
if ($this->user->getType() == Scalr_Account_User::TYPE_FIN_ADMIN) {
self::loadController('Dashboard', 'Scalr_UI_Controller_Admin_Analytics')->defaultAction();
} else {
$loadJs = array('ui/dashboard/columns.js');
$scope = $this->request->getScope();
$cloudynEnabled = \Scalr::config('scalr.cloudyn.master_email') ? true : false;
$billingEnabled = \Scalr::config('scalr.billing.enabled') ? true : false;
$panel = $this->user->getDashboard($this->getEnvironmentId(true));
if (empty($panel['configuration'])) {
// default configurations
$client = Client::Load($this->user->getAccountId());
if ($client->GetSettingValue(CLIENT_SETTINGS::DATE_FARM_CREATED)) {
// old customer
if ($scope == 'account') {
$panel['configuration'] = array(array(array('name' => 'dashboard.announcement', 'params' => array('newsCount' => 5))), array(array('name' => 'dashboard.environments')));
if ($this->user->getType() == Scalr_Account_User::TYPE_ACCOUNT_OWNER && $billingEnabled) {
array_unshift($panel['configuration'], array(array('name' => 'dashboard.billing')));
}
} else {
$panel['configuration'] = array(array(array('name' => 'dashboard.status'), array('name' => 'dashboard.addfarm')), array(array('name' => 'dashboard.announcement', 'params' => array('newsCount' => 5))), array(array('name' => 'dashboard.lasterrors', 'params' => array('errorCount' => 10))));
}
} else {
if ($scope == 'account') {
// new customer
$panel['configuration'] = array(array(array('name' => 'dashboard.newuser')), array(array('name' => 'dashboard.announcement', 'params' => array('newsCount' => 5))));
if ($this->user->getType() == Scalr_Account_User::TYPE_ACCOUNT_OWNER && $billingEnabled) {
array_unshift($panel['configuration'][1], array('name' => 'dashboard.billing'));
}
} else {
// new customer
$panel['configuration'] = array(array(array('name' => 'dashboard.addfarm')), array(array('name' => 'dashboard.newuser')), array(array('name' => 'dashboard.announcement', 'params' => array('newsCount' => 5))));
}
}
$this->user->setDashboard($this->getEnvironmentId(true), $panel);
$panel = $this->user->getDashboard($this->getEnvironmentId(true));
}
// section for adding required widgets
if ($scope == 'environment') {
if ($cloudynEnabled && !in_array('cloudynInstalled', $panel['flags']) && !in_array('dashboard.cloudyn', $panel['widgets']) && !!$this->environment->isPlatformEnabled(SERVER_PLATFORMS::EC2)) {
if (!isset($panel['configuration'][0])) {
$panel['configuration'][0] = array();
}
array_unshift($panel['configuration'][0], array('name' => 'dashboard.cloudyn'));
$panel['flags'][] = 'cloudynInstalled';
$this->user->setDashboard($this->getEnvironmentId(), $panel);
$panel = $this->user->getDashboard($this->getEnvironmentId());
}
}
$panel = $this->fillDash($panel);
$conf = $this->getContainer()->config->get('scalr.load_statistics.connections.plotter');
$monitoringUrl = "{$conf['scheme']}://{$conf['host']}:{$conf['port']}";
$this->response->page('ui/dashboard/view.js', array('panel' => $panel, 'flags' => array('cloudynEnabled' => $cloudynEnabled, 'billingEnabled' => $billingEnabled), 'params' => array('monitoringUrl' => $monitoringUrl)), $loadJs, array('ui/dashboard/view.css', 'ui/analytics/analytics.css'));
}
}
}
示例2: ListGlobalVariables
public function ListGlobalVariables()
{
$ResponseDOMDocument = $this->CreateResponse();
$configNode = $ResponseDOMDocument->createElement("variables");
$globalVariables = new Scalr_Scripting_GlobalVariables($this->DBServer->envId, Scalr_Scripting_GlobalVariables::SCOPE_FARMROLE);
$vars = $globalVariables->listVariables($this->DBServer->roleId, $this->DBServer->farmId, $this->DBServer->farmRoleId);
foreach ($vars as $key => $value) {
$settingNode = $ResponseDOMDocument->createElement("variable", $value);
$settingNode->setAttribute("name", $key);
$configNode->appendChild($settingNode);
}
$formats = \Scalr::config("scalr.system.global_variables.format");
foreach ($this->DBServer->GetScriptingVars() as $name => $value) {
$name = "SCALR_" . strtoupper($name);
$value = trim($value);
if (isset($formats[$name])) {
$value = @sprintf($formats[$name], $value);
}
$settingNode = $ResponseDOMDocument->createElement("variable", $value);
$settingNode->setAttribute("name", $name);
$configNode->appendChild($settingNode);
}
$ResponseDOMDocument->documentElement->appendChild($configNode);
return $ResponseDOMDocument;
}
示例3: setupScalrAgent
public static function setupScalrAgent(\DBServer $dbServer)
{
$baseurl = \Scalr::config('scalr.endpoint.scheme') . "://" . \Scalr::config('scalr.endpoint.host');
$env = $dbServer->GetEnvironmentObject();
$azure = $env->azure();
$branch = $dbServer->getScalarizrRepository()['repository'];
$develRepos = \Scalr::getContainer()->config->get('scalr.scalarizr_update.devel_repos');
$scmBranch = $dbServer->GetFarmRoleObject()->GetSetting('user-data.scm_branch');
if ($scmBranch != '' && $develRepos) {
$branch = $dbServer->GetFarmRoleObject()->GetSetting('base.devel_repository');
$scmBranch = "{$scmBranch}/";
} else {
$scmBranch = '';
}
if ($dbServer->osType == 'linux') {
$extensionProperties = new ResourceExtensionProperties('Microsoft.OSTCExtensions', 'CustomScriptForLinux', '1.2');
$extensionProperties->setSettings(['commandToExecute' => "bash -c 'curl -k -L \"{$baseurl}/public/linux/{$branch}/azure/{$scmBranch}install_scalarizr.sh\" | bash && service scalr-upd-client start'"]);
} else {
$extensionProperties = new ResourceExtensionProperties('Microsoft.Compute', 'CustomScriptExtension', '1.4');
$extensionProperties->setSettings(["commandToExecute" => "powershell -NoProfile -ExecutionPolicy Bypass -Command \"iex ((new-object net.webclient).DownloadString('{$baseurl}/public/windows/{$branch}/{$scmBranch}install_scalarizr.ps1')); start-service ScalrUpdClient\""]);
}
$createExtension = new CreateResourceExtension('scalarizr', $dbServer->cloudLocation, $extensionProperties);
try {
$response = $azure->compute->resourceExtension->create($env->keychain(SERVER_PLATFORMS::AZURE)->properties[Entity\CloudCredentialsProperty::AZURE_SUBSCRIPTION_ID], $dbServer->GetProperty(\AZURE_SERVER_PROPERTIES::RESOURCE_GROUP), $dbServer->GetProperty(\AZURE_SERVER_PROPERTIES::SERVER_NAME), $createExtension);
\Scalr::getContainer()->logger(\LOG_CATEGORY::FARM)->info(new \FarmLogMessage($dbServer, sprintf(_("Created azure resource extension to install and launch scalr agent"))));
$dbServer->SetProperty(\AZURE_SERVER_PROPERTIES::SZR_EXTENSION_DEPLOYED, 1);
} catch (\Exception $e) {
\Scalr::getContainer()->logger(\LOG_CATEGORY::FARM)->fatal(new \FarmLogMessage($dbServer, sprintf(_("Unable to create azure resource extension to install and launch scalr agent: %s"), $e->getMessage())));
}
}
示例4: xRequestResultAction
public function xRequestResultAction()
{
$this->request->defineParams(array('requests' => array('type' => 'json'), 'decision'));
if (!in_array($this->getParam('decision'), array(FarmLease::STATUS_APPROVE, FarmLease::STATUS_DECLINE))) {
throw new Scalr_Exception_Core('Wrong status');
}
foreach ($this->getParam('requests') as $id) {
$req = $this->db->GetRow('SELECT * FROM farm_lease_requests WHERE id = ? LIMIT 1', array($id));
if ($req) {
$dbFarm = DBFarm::LoadByID($req['farm_id']);
$this->user->getPermissions()->validate($dbFarm);
$this->db->Execute('UPDATE farm_lease_requests SET status = ?, answer_comment = ?, answer_user_id = ? WHERE id = ?', array($this->getParam('decision'), $this->getParam('comment'), $this->user->getId(), $id));
try {
$mailer = Scalr::getContainer()->mailer;
if ($dbFarm->ownerId) {
$user = Entity\Account\User::findPk($dbFarm->ownerId);
if (\Scalr::config('scalr.auth_mode') == 'ldap') {
$email = $user->getSetting(Entity\Account\User\UserSetting::NAME_LDAP_EMAIL);
if (!$email) {
$email = $user->email;
}
} else {
$email = $user->email;
}
$mailer->addTo($email);
} else {
$mailer = null;
}
} catch (Exception $e) {
$mailer = null;
}
if ($this->getParam('decision') == FarmLease::STATUS_APPROVE) {
if ($req['request_days'] > 0) {
$dt = $dbFarm->GetSetting(Entity\FarmSetting::LEASE_TERMINATE_DATE);
$dt = new DateTime($dt);
$dt->add(new DateInterval('P' . $req['request_days'] . 'D'));
$dbFarm->SetSetting(Entity\FarmSetting::LEASE_TERMINATE_DATE, $dt->format('Y-m-d H:i:s'));
$dbFarm->SetSetting(Entity\FarmSetting::LEASE_NOTIFICATION_SEND, null);
if ($mailer) {
$mailer->sendTemplate(SCALR_TEMPLATES_PATH . '/emails/farm_lease_non_standard_approve.eml', array('{{farm_name}}' => $dbFarm->Name, '{{user_name}}' => $this->user->getEmail(), '{{comment}}' => $this->getParam('comment'), '{{date}}' => $dt->format('M j, Y'), '{{envName}}' => $dbFarm->GetEnvironmentObject()->name, '{{envId}}' => $dbFarm->GetEnvironmentObject()->id));
}
} else {
$dbFarm->SetSetting(Entity\FarmSetting::LEASE_STATUS, '');
$dbFarm->SetSetting(Entity\FarmSetting::LEASE_TERMINATE_DATE, '');
$dbFarm->SetSetting(Entity\FarmSetting::LEASE_NOTIFICATION_SEND, '');
if ($mailer) {
$mailer->sendTemplate(SCALR_TEMPLATES_PATH . '/emails/farm_lease_non_standard_forever.eml', array('{{farm_name}}' => $dbFarm->Name, '{{user_name}}' => $this->user->getEmail(), '{{comment}}' => $this->getParam('comment'), '{{envName}}' => $dbFarm->GetEnvironmentObject()->name, '{{envId}}' => $dbFarm->GetEnvironmentObject()->id));
}
}
} else {
$dt = new DateTime($dbFarm->GetSetting(Entity\FarmSetting::LEASE_TERMINATE_DATE));
SettingEntity::increase(SettingEntity::LEASE_DECLINED_REQUEST);
if ($mailer) {
$mailer->sendTemplate(SCALR_TEMPLATES_PATH . '/emails/farm_lease_non_standard_decline.eml', array('{{farm_name}}' => $dbFarm->Name, '{{user_name}}' => $this->user->getEmail(), '{{date}}' => $dt->format('M j, Y'), '{{comment}}' => $this->getParam('comment'), '{{envName}}' => $dbFarm->GetEnvironmentObject()->name, '{{envId}}' => $dbFarm->GetEnvironmentObject()->id));
}
}
}
}
$this->response->success();
}
示例5: testUser
/**
* @functional
*/
public function testUser()
{
$userId = \Scalr::config('scalr.phpunit.userid');
$envId = \Scalr::config('scalr.phpunit.envid');
if (empty($userId) || empty($envId)) {
$this->markTestSkipped("This test requires valid database connection so it's considered to be functional.");
}
/* @var $user User */
$user = User::findOne([['id' => $userId]]);
$this->assertInstanceOf('Scalr\\Model\\Entity\\Account\\User', $user);
$email = $user->getSetting(UserSetting::NAME_GRAVATAR_EMAIL);
$this->assertNotEmpty($email);
$environment = Environment::findPk($envId);
$this->assertInstanceOf('Scalr\\Model\\Entity\\Account\\Environment', $environment);
$entityIterator = User::result(User::RESULT_ENTITY_ITERATOR)->find(null, null, null, 10);
$this->assertInstanceOf('Scalr\\Model\\Collections\\EntityIterator', $entityIterator);
$this->assertNotEmpty($entityIterator->count());
$this->assertNotEmpty($entityIterator->getArrayCopy());
foreach ($entityIterator->filterByType(User::TYPE_ACCOUNT_OWNER) as $item) {
$this->assertEquals(User::TYPE_ACCOUNT_OWNER, $item->type);
}
foreach (User::result(User::RESULT_ENTITY_ITERATOR)->findByType(User::TYPE_SCALR_ADMIN) as $item) {
$this->assertEquals(User::TYPE_SCALR_ADMIN, $item->type);
}
$arrayCollection = User::result(User::RESULT_ENTITY_COLLECTION)->find(null, null, null, 10);
$this->assertInstanceOf('Scalr\\Model\\Collections\\ArrayCollection', $arrayCollection);
$this->assertNotEmpty($arrayCollection->count());
$this->assertNotEmpty($arrayCollection->getArrayCopy());
$rs = User::result(User::RESULT_RAW)->find(null, null, null, 10);
$this->assertInstanceOf('ADORecordSet', $rs);
foreach ($rs as $item) {
$this->assertNotEmpty($item);
$this->assertInternalType('array', $item);
}
}
示例6: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
if (self::isSkippedFunctionalTest(self::TEST_TYPE_UI)) {
return;
}
$db = \Scalr::getDb();
self::deleteTestVariables();
$envId = \Scalr::config('scalr.phpunit.envid');
if (!$envId) {
return;
}
$env = \Scalr_Environment::init()->loadById($envId);
self::$vars[ScopeInterface::SCOPE_SCALR] = new Scalr_Scripting_GlobalVariables();
self::$vars[ScopeInterface::SCOPE_ACCOUNT] = new Scalr_Scripting_GlobalVariables($env->clientId, 0, ScopeInterface::SCOPE_ACCOUNT);
self::$vars[ScopeInterface::SCOPE_ENVIRONMENT] = new Scalr_Scripting_GlobalVariables($env->clientId, $env->id, ScopeInterface::SCOPE_ENVIRONMENT);
self::$args[ScopeInterface::SCOPE_SCALR] = self::$args[ScopeInterface::SCOPE_ACCOUNT] = self::$args[ScopeInterface::SCOPE_ENVIRONMENT] = [0, 0, 0, ''];
/* @var $farm Farm */
$farm = Farm::findOne([['envId' => $env->id]]);
if ($farm) {
self::$vars[ScopeInterface::SCOPE_FARM] = new Scalr_Scripting_GlobalVariables($env->clientId, $env->id, ScopeInterface::SCOPE_FARM);
self::$args[ScopeInterface::SCOPE_FARM] = [0, $farm->id, 0, ''];
/* @var $farmRole FarmRole */
$farmRole = FarmRole::findOne([['farmId' => $farm->id]]);
if ($farmRole) {
self::$vars[ScopeInterface::SCOPE_ROLE] = new Scalr_Scripting_GlobalVariables($env->clientId, $env->id, ScopeInterface::SCOPE_ROLE);
self::$args[ScopeInterface::SCOPE_ROLE] = [$farmRole->roleId, 0, 0, ''];
self::$vars[ScopeInterface::SCOPE_FARMROLE] = new Scalr_Scripting_GlobalVariables($env->clientId, $env->id, ScopeInterface::SCOPE_FARMROLE);
self::$args[ScopeInterface::SCOPE_FARMROLE] = [$farmRole->roleId, $farm->id, $farmRole->id, ''];
}
}
}
示例7: __construct
/**
* Constructor. Instantiates ApiLogger, prepares backend
*
* @param ApiLoggerConfiguration $config Api logger config object
*/
public function __construct($config)
{
parent::__construct(\Scalr::config('scalr.logger.api'));
$this->ipAddress = $config->ipAddress;
$this->requestId = $config->requestId;
$this->requestType = $config->requestType;
}
示例8: providerRs
/**
* Provider of the instances for the functional tests
*/
public function providerRs()
{
$data = \Scalr::config('scalr.phpunit.cloudstack.platforms');
if (empty($data) || !is_array($data)) {
return array(array(self::EMPTY_CONFIG, 'jp-east-t1v', '2530', '24'));
}
return $data;
}
示例9: providerRs
/**
* Provider of the instances for the functional tests
*/
public function providerRs()
{
$data = \Scalr::config('scalr.phpunit.openstack.platforms');
if (empty($data) || !is_array($data)) {
return array(array(self::EMPTY_CONFIG, 'DFW', '3afe97b2-26dc-49c5-a2cc-a2fc8d80c001'));
}
return $data;
}
示例10: providerRs
/**
* Provider of the instances for the functional tests
*/
public function providerRs()
{
$data = \Scalr::config('scalr.phpunit.openstack.platforms');
if (empty($data) || !is_array($data)) {
return array(array(SERVER_PLATFORMS::RACKSPACENG_US, 'DFW', '3afe97b2-26dc-49c5-a2cc-a2fc8d80c001'));
}
return $data;
}
示例11: setUp
/**
* {@inheritdoc}
* @see PHPUnit_Framework_TestCase::setUp()
*/
protected function setUp()
{
parent::setUp();
$this->container = \Scalr::getContainer();
$this->environment = new \Scalr_Environment();
if (!$this->isSkipFunctionalTests()) {
$this->environment->loadById(\Scalr::config('scalr.phpunit.envid'));
$this->container->environment = $this->environment;
}
}
示例12: isSkippedFunctionalTest
/**
* Returns true if functional tests should be skipped.
*
* @param string $type optional The type of the test ui, api, cloud-dependent.
* If option is not provided it will try to resolve static::TEST_TYPE constant
*
* @return bool Returns true if functional tests should be skipped.
*/
public static function isSkippedFunctionalTest($type = null)
{
$type = $type ?: static::TEST_TYPE;
$value = \Scalr::config('scalr.phpunit.functional_tests');
if (!is_array($value)) {
return !$value;
}
//It silently skips test with undefined type.
return $type ? !in_array($type, $value) : true;
}
示例13: testFunctionalServiceActions
/**
* @test
* @functional
*/
public function testFunctionalServiceActions()
{
$cy = new Cloudyn('', '', \Scalr::config('scalr.cloudyn.environment'));
$version = $cy->getVersion();
$this->assertNotEmpty($version);
$res = $cy->checkStatus();
$this->assertTrue($res);
$countries = $cy->countries();
$this->assertArrayHasKey('US', $countries);
}
示例14: getConfiguration
/**
* {@inheritdoc}
* @see Scalr_Role_Behavior::getConfiguration()
*/
public function getConfiguration(DBServer $dbServer)
{
$router = new stdClass();
// Set scalr address
$router->scalrAddr = \Scalr::config('scalr.endpoint.scheme') . "://" . \Scalr::config('scalr.endpoint.host');
// Set scalr IPs whitelist
$router->whitelist = \Scalr::config('scalr.aws.ip_pool');
// Set CIDR
$router->cidr = '10.0.0.0/8';
return $router;
}
示例15: __construct
/**
* Constructor. Instantiates AuditLogger, prepares backend
*
* @param AuditLoggerConfiguration $config Audit logger config data
*/
public function __construct(AuditLoggerConfiguration $config)
{
parent::__construct(\Scalr::config('scalr.logger.audit'));
$this->user = $config->user;
$this->accountId = $config->accountId;
$this->envId = $config->envId;
$this->remoteAddr = $config->remoteAddr;
$this->ruid = $config->ruid;
$this->requestType = $config->requestType;
$this->systemTask = $config->systemTask;
}