private function getBackupDetails($backupId) { $links = array(); $backup = Scalr_Db_Backup::init()->loadById($backupId); $this->user->getPermissions()->validate($backup); $data = array('backup_id' => $backup->id, 'farm_id' => $backup->farmId, 'type' => ROLE_BEHAVIORS::GetName($backup->service) ? ROLE_BEHAVIORS::GetName($backup->service) : 'unknown', 'date' => Scalr_Util_DateTime::convertTz($backup->dtCreated), 'size' => $backup->size ? round($backup->size / 1024 / 1024, 2) : 0, 'provider' => $backup->provider, 'cloud_location' => $backup->cloudLocation, 'farmName' => DBFarm::LoadByIDOnlyName($backup->farmId)); $downloadParts = $backup->getParts(); foreach ($downloadParts as $part) { $part['size'] = $part['size'] ? round($part['size'] / 1024 / 1024, 2) : ''; if ($part['size'] == 0) { $part['size'] = 0.01; } if ($data['provider'] == 's3') { $part['link'] = $this->getS3SignedUrl($part['path']); } else { if ($data['provider'] == 'cf') { if ($backup->platform == SERVER_PLATFORMS::RACKSPACE) { $part['link'] = $this->getCfSignedUrl($part['path'], $data['cloud_location'], $backup->platform); } else { $part['link'] = "swift://{$part['path']}"; } } else { continue; } } $part['path'] = pathinfo($part['path']); $links[$part['number']] = $part; } $data['links'] = $links; return $data; }
public function manageAction() { $farmRole = DBFarmRole::LoadByID($this->getParam('farmRoleId')); $this->user->getPermissions()->validate($farmRole); $behavior = $this->getParam('behavior'); if (!$farmRole->GetRoleObject()->hasBehavior($behavior)) { throw new Exception("Behavior not assigned to this role"); } if ($farmRole->GetRoleObject()->getDbMsrBehavior()) { foreach ($farmRole->GetServersByFilter(array('status' => SERVER_STATUS::RUNNING)) as $dbServer) { if ($dbServer->GetProperty(Scalr_Db_Msr::REPLICATION_MASTER)) { $masterServer = $dbServer; break; } } } if ($behavior == ROLE_BEHAVIORS::MYSQL) { foreach ($farmRole->GetServersByFilter(array('status' => SERVER_STATUS::RUNNING)) as $dbServer) { if ($dbServer->GetProperty(SERVER_PROPERTIES::DB_MYSQL_MASTER)) { $masterServer = $dbServer; break; } } } $params = array('farmRoleId' => $farmRole->ID, 'behavior' => $behavior, 'farmName' => $farmRole->GetFarmObject()->Name, 'roleName' => $farmRole->GetRoleObject()->name, 'behaviorName' => ROLE_BEHAVIORS::GetName($behavior)); if ($masterServer) { $params['masterServer'] = array('serverId' => $masterServer->serverId, 'localIp' => $masterServer->localIp, 'remoteIp' => $masterServer->remoteIp); $params['masterServerId'] = $masterServer->serverId; $config = (array) $this->getConfig($masterServer, $behavior); if (is_array($config)) { foreach ($config as $file => $conf) { $conf = (array) $conf; ksort($conf, SORT_ASC | SORT_STRING); $params['config'][$file] = $conf; } } else { throw new Exception("Unable to retrieve configuration from master server"); } } else { $params['config'] = $farmRole->GetServiceConfiguration2($behavior); } $this->response->page('ui/services/configurations/manage.js', $params, array('ui/services/configurations/configfield.js')); }
public function buildAction() { $this->request->restrictAccess(Acl::RESOURCE_FARMS, Acl::PERM_FARMS_MANAGE); $this->request->defineParams(array('farmId' => array('type' => 'int'), 'roleId' => array('type' => 'int'))); $farmId = $this->getParam('farmId'); $roleId = $this->getParam('roleId'); $moduleParams = array('farmId' => $farmId, 'roleId' => $roleId, 'behaviors' => ROLE_BEHAVIORS::GetName(null, true)); unset($moduleParams['behaviors'][ROLE_BEHAVIORS::CASSANDRA]); unset($moduleParams['behaviors'][ROLE_BEHAVIORS::CUSTOM]); unset($moduleParams['behaviors'][ROLE_BEHAVIORS::HAPROXY]); //platforms list $platforms = self::loadController('Platforms')->getEnabledPlatforms(); if (empty($platforms)) { throw new Exception('Before building new farm you need to configure environment and setup cloud credentials'); } //categories list $categories = $this->db->GetAll("SELECT c.id, c.name, COUNT(DISTINCT r.id) AS total\n FROM role_categories c\n LEFT JOIN roles r ON c.id = r.cat_id AND r.env_id IN(0, ?) AND r.id IN (\n SELECT role_id\n FROM role_images\n WHERE role_id = r.id\n AND platform IN ('" . implode("','", array_keys($platforms)) . "')\n )\n LEFT JOIN roles_queue q ON r.id = q.role_id\n WHERE c.env_id IN (0, ?)\n AND q.id IS NULL\n GROUP BY c.id\n ", array($this->environment->id, $this->environment->id)); $moduleParams['categories'] = array(); foreach ($categories as $g) { $moduleParams['categories'][$g['id']] = $g; } $moduleParams['farmVpcEc2Enabled'] = $this->getEnvironment()->isPlatformEnabled(SERVER_PLATFORMS::EC2); if ($moduleParams['farmVpcEc2Enabled']) { $moduleParams['farmVpcEc2Locations'] = self::loadController('Platforms')->getCloudLocations(SERVER_PLATFORMS::EC2, false); } if ($farmId) { $c = self::loadController('Builder', 'Scalr_UI_Controller_Farms'); $moduleParams['farm'] = $c->getFarm2($farmId); } else { // TODO: remove hack, do better $vars = new Scalr_Scripting_GlobalVariables($this->user->getAccountId(), $this->getEnvironmentId(), Scalr_Scripting_GlobalVariables::SCOPE_FARM); $moduleParams['farmVariables'] = $vars->getValues(); } $moduleParams['tabs'] = array('vpcrouter', 'dbmsr', 'mongodb', 'mysql', 'scaling', 'network', 'gce', 'cloudfoundry', 'rabbitmq', 'haproxy', 'proxy', 'rds', 'scripting', 'nimbula', 'ec2', 'security', 'devel', 'storage', 'variables', 'advanced'); if ($this->user->getAccount()->isFeatureEnabled(Scalr_Limits::FEATURE_CHEF)) { $moduleParams['tabs'][] = 'chef'; } //deprecated tabs $moduleParams['tabs'][] = 'deployments'; $moduleParams['tabs'][] = 'ebs'; $moduleParams['tabs'][] = 'params'; $moduleParams['tabs'][] = 'servicesconfig'; $conf = $this->getContainer()->config->get('scalr.load_statistics.connections.plotter'); $moduleParams['tabParams'] = array('farmId' => $farmId, 'farmHash' => $moduleParams['farm'] ? $moduleParams['farm']['farm']['hash'] : '', 'accountId' => $this->environment->getPlatformConfigValue(Ec2PlatformModule::ACCOUNT_ID), 'remoteAddress' => $this->request->getRemoteAddr(), 'monitoringHostUrl' => "{$conf['scheme']}://{$conf['host']}:{$conf['port']}", 'nginx' => array('server_section' => @file_get_contents("../templates/services/nginx/server_section.tpl"), 'server_section_ssl' => @file_get_contents("../templates/services/nginx/server_section_ssl.tpl"))); // TODO: Features $moduleParams['tabParams']['featureRAID'] = $this->user->getAccount()->isFeatureEnabled(Scalr_Limits::FEATURE_RAID); $moduleParams['tabParams']['featureMFS'] = $this->user->getAccount()->isFeatureEnabled(Scalr_Limits::FEATURE_MFS); $moduleParams['tabParams']['scalr.dns.global.enabled'] = \Scalr::config('scalr.dns.global.enabled'); $moduleParams['tabParams']['scalr.instances_connection_policy'] = \Scalr::config('scalr.instances_connection_policy'); $moduleParams['tabParams']['scalr.scalarizr_update.repos'] = array_keys(\Scalr::config('scalr.scalarizr_update.repos')); $moduleParams['tabParams']['scalr.scalarizr_update.default_repo'] = \Scalr::config('scalr.scalarizr_update.default_repo'); $moduleParams['metrics'] = self::loadController('Metrics', 'Scalr_UI_Controller_Scaling')->getList(); $moduleParams['timezones_list'] = Scalr_Util_DateTime::getTimezones(); $moduleParams['timezone_default'] = $this->user->getSetting(Scalr_Account_User::SETTING_UI_TIMEZONE); if ($moduleParams['farm']['farm']['ownerEditable']) { $moduleParams['usersList'] = Scalr_Account_User::getList($this->user->getAccountId()); } $governance = new Scalr_Governance($this->getEnvironmentId()); $moduleParams['governance'] = $governance->getValues(true); $defaultFarmRoleSecurityGroups = array('default'); if (\Scalr::config('scalr.aws.security_group_name')) { $defaultFarmRoleSecurityGroups[] = \Scalr::config('scalr.aws.security_group_name'); } $moduleParams['roleDefaultSettings'] = array('base.keep_scripting_logs_time' => \Scalr::config('scalr.system.scripting.default_instance_log_rotation_period'), 'security_groups.list' => json_encode($defaultFarmRoleSecurityGroups)); //cost analytics if ($this->getContainer()->analytics->enabled && $this->getEnvironment()->getPlatformConfigValue(Scalr_Environment::SETTING_CC_ID)) { $costCenter = $this->getContainer()->analytics->ccs->get($this->getEnvironment()->getPlatformConfigValue(Scalr_Environment::SETTING_CC_ID)); $projects = []; if ($costCenter instanceof CostCentreEntity) { $projectsIterator = new SharedProjectsFilterIterator($costCenter->getProjects(), $costCenter->ccId, $this->user, $this->getEnvironment()); foreach ($projectsIterator as $item) { /* @var $item ProjectEntity */ $projects[] = array('projectId' => $item->projectId, 'name' => $item->name); } $costCentreName = $costCenter->name; } else { $costCentreName = ''; } $moduleParams['analytics'] = array('costCenterName' => $costCentreName, 'projects' => $projects); if ($farmId) { $dbFarm = DBFarm::LoadByID($farmId); $moduleParams['farm']['farm']['projectId'] = $dbFarm->GetSetting(DBFarm::SETTING_PROJECT_ID); } } $this->response->page('ui/farms/builder.js', $moduleParams, array('ui/farms/builder/selroles.js', 'ui/farms/builder/roleedit.js', 'ui/farms/builder/roleslibrary.js', 'ui/farms/builder/tabs/dbmsr.js', 'ui/farms/builder/tabs/cloudfoundry.js', 'ui/farms/builder/tabs/rabbitmq.js', 'ui/farms/builder/tabs/mongodb.js', 'ui/farms/builder/tabs/haproxy.js', 'ui/farms/builder/tabs/proxy.js', 'ui/farms/builder/tabs/mysql.js', 'ui/farms/builder/tabs/nimbula.js', 'ui/farms/builder/tabs/rds.js', 'ui/farms/builder/tabs/gce.js', 'ui/farms/builder/tabs/scaling.js', 'ui/farms/builder/tabs/scripting.js', 'ui/farms/builder/tabs/advanced.js', 'ui/farms/builder/tabs/ec2.js', 'ui/farms/builder/tabs/security.js', 'ui/farms/builder/tabs/storage.js', 'ui/farms/builder/tabs/variables.js', 'ui/farms/builder/tabs/devel.js', 'ui/farms/builder/tabs/chef.js', 'ui/farms/builder/tabs/vpcrouter.js', 'ui/farms/builder/tabs/network.js', 'ui/farms/builder/tabs/deployments.js', 'ui/farms/builder/tabs/ebs.js', 'ui/farms/builder/tabs/params.js', 'ui/farms/builder/tabs/servicesconfig.js', 'ui/farms/builder/roleslibrary/ec2.js', 'ui/farms/builder/roleslibrary/vpc.js', 'ui/farms/builder/roleslibrary/euca.js', 'ui/farms/builder/roleslibrary/rackspace.js', 'ui/farms/builder/roleslibrary/openstack.js', 'ui/farms/builder/roleslibrary/cloudstack.js', 'ui/farms/builder/roleslibrary/gce.js', 'ui/farms/builder/roleslibrary/mongodb.js', 'ui/farms/builder/roleslibrary/dbmsr.js', 'ui/farms/builder/roleslibrary/proxy.js', 'ui/farms/builder/roleslibrary/haproxy.js', 'ui/farms/builder/roleslibrary/chef.js', 'codemirror/codemirror.js', 'ui/core/variablefield.js', 'ui/scripts/scriptfield.js', 'ux-boxselect.js', 'ui/monitoring/window.js', 'ui/services/chef/chefsettings.js', 'ui/security/groups/sgeditor.js'), array('ui/farms/builder/selroles.css', 'ui/farms/builder/roleedit.css', 'ui/farms/builder/roleslibrary.css', 'codemirror/codemirror.css', 'ui/core/variablefield.css', 'ui/scripts/scriptfield.css', 'ui/farms/builder/tabs/scaling.css')); }
public function dashboardAction() { $this->request->defineParams(array('farmId' => array('type' => 'int'), 'farmRoleId' => array('type' => 'int'), 'type')); $dbFarm = DBFarm::LoadByID($this->getParam('farmId')); $this->user->getPermissions()->validate($dbFarm); if ($this->getParam('farmRoleId')) { $dbFarmRole = DBFarmRole::LoadByID($this->getParam('farmRoleId')); if ($dbFarmRole->FarmID != $dbFarm->ID) { throw new Exception("Role not found"); } } elseif ($this->getParam('type')) { foreach ($dbFarm->GetFarmRoles() as $sDbFarmRole) { if ($sDbFarmRole->GetRoleObject()->hasBehavior($this->getParam('type'))) { $dbFarmRole = $sDbFarmRole; break; } } if (!$dbFarmRole) { throw new Exception("Role not found"); } } else { throw new Scalr_UI_Exception_NotFound(); } $data = array('farmRoleId' => $dbFarmRole->ID, 'farmId' => $dbFarmRole->FarmID); $data['dbType'] = $dbFarmRole->GetRoleObject()->getDbMsrBehavior(); if (!$data['dbType']) { $this->response->failure("Unknown db type"); return; } switch ($data['dbType']) { case ROLE_BEHAVIORS::MYSQL2: case ROLE_BEHAVIORS::PERCONA: case ROLE_BEHAVIORS::MARIADB: $szrApiNamespace = Scalr_Net_Scalarizr_Client::NAMESPACE_MYSQL; break; case ROLE_BEHAVIORS::REDIS: $szrApiNamespace = Scalr_Net_Scalarizr_Client::NAMESPACE_REDIS; $data['extras'] = array(array('name' => 'Processes', 'value' => $dbFarmRole->GetSetting(Scalr_Db_Msr_Redis::NUM_PROCESSES)), array('name' => 'Persistence type', 'value' => $dbFarmRole->GetSetting(Scalr_Db_Msr_Redis::PERSISTENCE_TYPE))); break; case ROLE_BEHAVIORS::POSTGRESQL: $szrApiNamespace = Scalr_Net_Scalarizr_Client::NAMESPACE_POSTGRESQL; break; } // Get PMA details for MySQL / Percona if (in_array($data['dbType'], array(ROLE_BEHAVIORS::MYSQL, ROLE_BEHAVIORS::MYSQL2, ROLE_BEHAVIORS::PERCONA, ROLE_BEHAVIORS::MARIADB))) { $data['pma'] = $this->getPmaDetails($dbFarmRole); } $behavior = Scalr_Role_Behavior::loadByName($data['dbType']); $masterServer = $behavior->getMasterServer($dbFarmRole); if ($masterServer) { // Get Storage details $data['storage'] = $this->getDbStorageStatus($masterServer, $data['dbType']); } // Get Access details and DNS endpoints $data['accessDetails'] = $this->getDbAccessDetails($dbFarmRole); $data['name'] = ROLE_BEHAVIORS::GetName($data['dbType']); // Get data bundle info $bundlesEnabled = $dbFarmRole->GetSetting(Scalr_Db_Msr::DATA_BUNDLE_ENABLED); $lastActionTime = $dbFarmRole->GetSetting(Scalr_Db_Msr::getConstant("DATA_BUNDLE_LAST_TS")); $data['bundles'] = array('history' => $this->db->GetAll("SELECT *, UNIX_TIMESTAMP(date) as date FROM services_db_backups_history WHERE `farm_role_id` = ? AND `operation` = ? ORDER BY id ASC", array($dbFarmRole->ID, 'bundle')), 'inProgress' => array('status' => (int) $dbFarmRole->GetSetting(Scalr_Db_Msr::DATA_BUNDLE_IS_RUNNING), 'serverId' => $dbFarmRole->GetSetting(Scalr_Db_Msr::DATA_BUNDLE_SERVER_ID)), 'last' => $lastActionTime ? Scalr_Util_DateTime::convertTz((int) $lastActionTime, 'd M Y \\a\\t H:i:s') : 'Never'); foreach ($data['bundles']['history'] as &$h) { $h['date'] = Scalr_Util_DateTime::convertTz((int) $h['date'], 'd M Y \\a\\t H:i:s'); } if ($bundlesEnabled) { $period = $dbFarmRole->GetSetting(Scalr_Db_Msr::DATA_BUNDLE_EVERY); if ($lastActionTime) { $nextTime = $lastActionTime + $period * 3600; } $data['bundles']['next'] = !$nextTime || $nextTime < time() ? "Within 30 minutes" : Scalr_Util_DateTime::convertTz((int) $nextTime, 'd M Y \\a\\t H:i:s'); $data['bundles']['schedule'] = "Every {$period} hours"; } else { $data['bundles']['next'] = " - "; $data['bundles']['schedule'] = "Auto-snapshotting disabled"; } // Get backups info $lastActionTime = $dbFarmRole->GetSetting(Scalr_Db_Msr::getConstant("DATA_BACKUP_LAST_TS")); $nextTime = false; $backupsEnabled = $dbFarmRole->GetSetting(Scalr_Db_Msr::DATA_BACKUP_ENABLED); $data['backups'] = array('history' => $this->db->GetAll("SELECT *, UNIX_TIMESTAMP(date) as date FROM services_db_backups_history WHERE `farm_role_id` = ? AND `operation` = ? ORDER BY id ASC", array($dbFarmRole->ID, 'backup')), 'inProgress' => array('status' => (int) $dbFarmRole->GetSetting(Scalr_Db_Msr::DATA_BACKUP_IS_RUNNING), 'serverId' => $dbFarmRole->GetSetting(Scalr_Db_Msr::DATA_BACKUP_SERVER_ID)), 'last' => $lastActionTime ? Scalr_Util_DateTime::convertTz((int) $lastActionTime, 'd M Y \\a\\t H:i:s') : 'Never', 'supported' => !PlatformFactory::isCloudstack($dbFarmRole->Platform) && (!PlatformFactory::isOpenstack($dbFarmRole->Platform) || PlatformFactory::NewPlatform($dbFarmRole->Platform)->getConfigVariable(OpenstackPlatformModule::EXT_SWIFT_ENABLED, $this->getEnvironment(), false))); foreach ($data['backups']['history'] as &$h) { $h['date'] = Scalr_Util_DateTime::convertTz((int) $h['date'], 'd M Y \\a\\t H:i:s'); } if ($backupsEnabled) { $period = $dbFarmRole->GetSetting(Scalr_Db_Msr::DATA_BACKUP_EVERY); if ($lastActionTime) { $nextTime = $lastActionTime + $period * 3600; } $data['backups']['next'] = !$nextTime || $nextTime < time() ? "Within 30 minutes" : Scalr_Util_DateTime::convertTz((int) $nextTime, 'd M Y \\a\\t H:i:s'); $data['backups']['schedule'] = "Every {$period} hours"; } else { $data['backups']['next'] = " - "; $data['backups']['schedule'] = "Auto-backups disabled"; } /* if ($dbFarmRole->GetSetting(Scalr_Db_Msr::DATA_STORAGE_ENGINE) == 'lvm') { $data['noDataBundleForSlaves'] = ($dbFarmRole->GetSetting(Scalr_Role_DbMsrBehavior::ROLE_NO_DATA_BUNDLE_FOR_SLAVES)) ? true : false; } */ $conf = $this->getContainer()->config->get('scalr.load_statistics.connections.plotter'); foreach ($dbFarmRole->GetServersByFilter(array('status' => array(SERVER_STATUS::INIT, SERVER_STATUS::RUNNING, SERVER_STATUS::PENDING))) as $dbServer) { $isMaster = $dbServer->GetProperty(Scalr_Db_Msr::REPLICATION_MASTER) == 1; $serverRole = $isMaster ? 'master' : 'slave'; $serverInfo = array('status' => $dbServer->status, 'remoteIp' => $dbServer->remoteIp, 'localIp' => $dbServer->localIp, 'serverId' => $dbServer->serverId, 'cloudServerId' => $dbServer->GetCloudServerID(), 'cloudLocation' => $dbServer->GetCloudLocation(), 'serverRole' => $serverRole, 'index' => $dbServer->index); $serverInfo['monitoring'] = array('farmId' => $dbFarmRole->FarmID, 'farmRoleId' => $dbFarmRole->ID, 'index' => $dbServer->index, 'hash' => $dbFarm->Hash, 'hostUrl' => "{$conf['scheme']}://{$conf['host']}:{$conf['port']}"); if ($dbServer->platform == SERVER_PLATFORMS::EC2) { $serverInfo['cloudLocation'] = $dbServer->GetProperty(EC2_SERVER_PROPERTIES::AVAIL_ZONE); } if ($dbServer->status == SERVER_STATUS::RUNNING) { try { $rStatus = $dbServer->scalarizr->{$szrApiNamespace}->replicationStatus(); if ($data['dbType'] != ROLE_BEHAVIORS::REDIS) { $rStatus = (array) $rStatus->{$serverRole}; $replication = $rStatus; } else { if ($isMaster) { $rStatus = (array) $rStatus->masters; foreach ($rStatus as $port => $status) { $rStatus['status'] = $status; if ($status != 'up') { break; } } } else { $rStatus = (array) $rStatus->slaves; foreach ($rStatus as $port => $status) { $rStatus['status'] = $status->status; if ($status->status != 'up') { break; } } } $replication = $rStatus; } if (in_array($data['dbType'], array(ROLE_BEHAVIORS::MYSQL2, ROLE_BEHAVIORS::PERCONA, ROLE_BEHAVIORS::MARIADB))) { if ($rStatus['status'] == 'up' && $replication['seconds_behind_master'] > 0) { $status = 'lagging'; } else { $status = $rStatus['status']; } } elseif ($data['dbType'] == ROLE_BEHAVIORS::REDIS) { $status = $rStatus['status']; } elseif ($data['dbType'] == ROLE_BEHAVIORS::POSTGRESQL) { if ($rStatus['status'] == 'up' && $replication['Xlog_delay'] > 1000) { $status = 'lagging'; } else { $status = $rStatus['status']; } } $serverInfo['replication'] = array('status' => $status, $data['dbType'] => $replication); } catch (Exception $e) { $serverInfo['replication'] = array('status' => 'error', 'message' => $e->getMessage()); } } $data['servers'][] = $serverInfo; } $this->response->page('ui/db/manager/dashboard.js', $data, array('ui/monitoring/window.js'), array('ui/db/manager/dashboard.css')); }
/** * @param int $farmId optional * @param int $roleId optional * @param string $scalrPageHash optional * @param string $scalrPageUiHash optional * @throws Scalr_Exception_InsufficientPermissions */ public function xGetFarmAction($farmId = null, $roleId = null, $scalrPageHash = null, $scalrPageUiHash = null) { if ($scalrPageHash && $scalrPageHash != $this->calcFarmDesignerHash()) { $this->response->data(['scalrPageHashMismatch' => true]); return; } if ($scalrPageUiHash && $scalrPageUiHash != $this->response->pageUiHash()) { $this->response->data(['scalrPageUiHashMismatch' => true]); return; } $moduleParams = array('farmId' => $farmId, 'roleId' => $roleId, 'behaviors' => ROLE_BEHAVIORS::GetName(null, true)); unset($moduleParams['behaviors'][ROLE_BEHAVIORS::CASSANDRA]); unset($moduleParams['behaviors'][ROLE_BEHAVIORS::CUSTOM]); unset($moduleParams['behaviors'][ROLE_BEHAVIORS::HAPROXY]); //platforms list $platforms = self::loadController('Platforms')->getEnabledPlatforms(); if (empty($platforms)) { throw new Exception('Before building new farm you need to configure environment and setup cloud credentials'); } $moduleParams['categories'] = self::loadController('Roles')->listRoleCategories(true, true); $moduleParams['farmVpcEc2Enabled'] = $this->getEnvironment()->isPlatformEnabled(SERVER_PLATFORMS::EC2); if ($moduleParams['farmVpcEc2Enabled']) { $moduleParams['farmVpcEc2Locations'] = self::loadController('Platforms')->getCloudLocations(SERVER_PLATFORMS::EC2, false); } if ($farmId) { $this->request->checkPermissions(DBFarm::LoadByID($farmId)->__getNewFarmObject(), Acl::PERM_FARMS_UPDATE); $c = self::loadController('Builder', 'Scalr_UI_Controller_Farms'); $moduleParams['farm'] = $c->getFarm2($farmId); } else { $this->request->restrictAccess(Acl::RESOURCE_OWN_FARMS, Acl::PERM_FARMS_CREATE); // TODO: remove hack, do better $vars = new Scalr_Scripting_GlobalVariables($this->user->getAccountId(), $this->getEnvironmentId(), ScopeInterface::SCOPE_FARM); $moduleParams['farmVariables'] = $vars->getValues(); } $moduleParams['tabs'] = array('vpcrouter', 'dbmsr', 'mongodb', 'mysql', 'scaling', 'network', 'cloudfoundry', 'rabbitmq', 'haproxy', 'proxy', 'scripting', 'ec2', 'openstack', 'gce', 'azure', 'security', 'devel', 'storage', 'variables', 'advanced', 'chef'); //deprecated tabs if (\Scalr::config('scalr.ui.show_deprecated_features')) { $moduleParams['tabs'][] = 'ebs'; } $conf = $this->getContainer()->config->get('scalr.load_statistics.connections.plotter'); $moduleParams['tabParams'] = array('farmId' => $farmId, 'farmHash' => $moduleParams['farm'] ? $moduleParams['farm']['farm']['hash'] : '', 'accountId' => $this->environment->keychain(SERVER_PLATFORMS::EC2)->properties[Entity\CloudCredentialsProperty::AWS_ACCOUNT_ID], 'remoteAddress' => $this->request->getRemoteAddr(), 'monitoringHostUrl' => "{$conf['scheme']}://{$conf['host']}:{$conf['port']}", 'nginx' => array('server_section' => file_get_contents(APPPATH . '/templates/services/nginx/server_section.tpl'), 'server_section_ssl' => file_get_contents(APPPATH . '/templates/services/nginx/server_section_ssl.tpl'))); $moduleParams['tabParams']['scalr.instances_connection_policy'] = \Scalr::config('scalr.instances_connection_policy'); $moduleParams['tabParams']['scalr.scalarizr_update.default_repo'] = \Scalr::config('scalr.scalarizr_update.default_repo'); if (Scalr::isHostedScalr()) { $moduleParams['tabParams']['scalr.scalarizr_update.repos'] = ['latest' => Utils::getScalarizrUpdateRepoTitle('latest')]; if ($this->user->getAccount()->priority == 100) { $moduleParams['tabParams']['scalr.scalarizr_update.repos']['stable'] = Utils::getScalarizrUpdateRepoTitle('stable'); } } else { $repos = array_keys(\Scalr::config('scalr.scalarizr_update.repos')); $moduleParams['tabParams']['scalr.scalarizr_update.repos'] = array_combine($repos, $repos); } $moduleParams['tabParams']['scalr.scalarizr_update.devel_repos'] = is_array(\Scalr::config('scalr.scalarizr_update.devel_repos')) ? array_keys(\Scalr::config('scalr.scalarizr_update.devel_repos')) : []; $moduleParams['tabParams']['scalr.aws.ec2.limits.security_groups_per_instance'] = \Scalr::config('scalr.aws.ec2.limits.security_groups_per_instance'); $moduleParams['metrics'] = Entity\ScalingMetric::getList($this->getEnvironmentId()); $moduleParams['timezones_list'] = Scalr_Util_DateTime::getTimezones(); $moduleParams['timezone_default'] = $this->user->getSetting(Scalr_Account_User::SETTING_UI_TIMEZONE); if ($moduleParams['farm']['farm']['ownerEditable']) { $moduleParams['usersList'] = []; foreach (Entity\Account\User::findByAccountId($this->user->getAccountId()) as $user) { $moduleParams['usersList'][] = ['id' => $user->id, 'email' => $user->email]; } } $defaultFarmRoleSecurityGroups = array('default'); if (\Scalr::config('scalr.aws.security_group_name')) { $defaultFarmRoleSecurityGroups[] = \Scalr::config('scalr.aws.security_group_name'); } $moduleParams['roleDefaultSettings'] = array('base.keep_scripting_logs_time' => \Scalr::config('scalr.system.scripting.default_instance_log_rotation_period'), 'security_groups.list' => json_encode($defaultFarmRoleSecurityGroups), 'base.abort_init_on_script_fail' => \Scalr::config('scalr.system.scripting.default_abort_init_on_script_fail') ? 1 : 0, 'base.disable_firewall_management' => \Scalr::config('scalr.system.default_disable_firewall_management') ? 1 : 0); //cost analytics if ($this->getContainer()->analytics->enabled && $this->getEnvironment()->getPlatformConfigValue(Scalr_Environment::SETTING_CC_ID)) { $farmCostData = $this->getFarmCostData($farmId); $moduleParams['analytics'] = $farmCostData['analytics']; if ($farmId) { $moduleParams['farm']['farm']['projectId'] = $farmCostData['projectId']; $moduleParams['analytics']['farmCostMetering'] = $farmCostData['farmCostMetering']; } } $moduleParams['farmLaunchPermission'] = $farmId ? $moduleParams['farm']['farm']['launchPermission'] : $this->request->isAllowed([Acl::RESOURCE_FARMS, Acl::RESOURCE_TEAM_FARMS, Acl::RESOURCE_OWN_FARMS], Acl::PERM_FARMS_LAUNCH_TERMINATE); $this->response->data($moduleParams); }
/** * Get list of roles for listView */ public function xListRolesAction() { $this->request->restrictAccess(Acl::RESOURCE_FARMS_ROLES); $this->request->defineParams(array('client_id' => array('type' => 'int'), 'roleId' => array('type' => 'int'), 'platform', 'cloudLocation', 'origin', 'query', 'sort' => array('type' => 'json'))); if ($this->user->getType() == Scalr_Account_User::TYPE_SCALR_ADMIN) { $sql = 'SELECT DISTINCT(roles.id) from roles INNER JOIN role_images ON role_images.role_id = roles.id WHERE env_id = 0 AND :FILTER:'; $args = array(); } else { $sql = 'SELECT DISTINCT(roles.id) from roles INNER JOIN role_images ON role_images.role_id = roles.id WHERE env_id IN (?, 0) AND generation=? AND :FILTER:'; $args = array($this->getEnvironmentId(), 2); } if ($this->getParam('platform')) { $sql .= ' AND role_images.platform = ?'; $args[] = $this->getParam('platform'); } if ($this->getParam('cloudLocation')) { $sql .= ' AND role_images.cloud_location = ?'; $args[] = $this->getParam('cloudLocation'); } if ($this->getParam('roleId')) { $sql .= ' AND roles.id = ?'; $args[] = $this->getParam('roleId'); } if ($this->getParam('origin')) { $sql .= ' AND origin = ?'; $args[] = $this->getParam('origin'); } if ($this->getParam('status')) { $sql .= ' AND ('; $used = $this->getParam('status') == 'Used' ? true : false; if ($this->user->getAccountId() != 0) { $sql .= 'roles.id ' . ($used ? '' : 'NOT') . ' IN(SELECT role_id FROM farm_roles WHERE farmid IN(SELECT id from farms WHERE env_id = ?))'; $sql .= ' OR roles.id ' . ($used ? '' : 'NOT') . ' IN(SELECT new_role_id FROM farm_roles WHERE farmid IN(SELECT id from farms WHERE env_id = ?))'; $args[] = $this->getEnvironmentId(); $args[] = $this->getEnvironmentId(); } else { $sql .= 'roles.id ' . $used ? '' : 'NOT' . ' IN(SELECT role_id FROM farm_roles)'; $sql .= ' OR ' . $used ? '' : 'NOT' . ' roles.id IN(SELECT new_role_id FROM farm_roles)'; } $sql .= ')'; } $response = $this->buildResponseFromSql2($sql, array('name', 'os'), array('name'), $args); foreach ($response["data"] as &$row) { $dbRole = DBRole::loadById($row['id']); $platforms = array(); foreach ($dbRole->getPlatforms() as $platform) { $platforms[$platform] = SERVER_PLATFORMS::GetName($platform); } if ($this->user->getAccountId() != 0) { $usedBy = $this->db->GetOne("SELECT COUNT(*) FROM farm_roles WHERE (role_id=? OR new_role_id=?) AND farmid IN (SELECT id FROM farms WHERE env_id=?)", array($dbRole->id, $dbRole->id, $this->getEnvironmentId())); } else { $usedBy = $this->db->GetOne("SELECT COUNT(*) FROM farm_roles WHERE role_id=? OR new_role_id=?", array($dbRole->id, $dbRole->id)); } $status = '<span style="color:gray;">Not used</span>'; if ($this->db->GetOne("SELECT id FROM roles_queue WHERE role_id=? LIMIT 1", array($dbRole->id))) { $status = '<span style="color:red;">Deleting</span>'; } elseif ($usedBy > 0) { $status = '<span style="color:green;">In use</span>'; } $role = array('name' => $dbRole->name, 'id' => $dbRole->id, 'client_id' => $dbRole->clientId, 'env_id' => $dbRole->envId, 'status' => $status, 'origin' => $dbRole->origin, 'os' => $dbRole->os, 'osFamily' => $dbRole->osFamily, 'platforms' => $platforms); $behaviors = array(); foreach ($dbRole->getBehaviors() as $b) { $behaviors[] = ROLE_BEHAVIORS::GetName($b); } $role['behaviors_name'] = implode(', ', $behaviors); $behaviors = array(); foreach ($dbRole->getBehaviors() as $b) { $behaviors[] = ROLE_BEHAVIORS::GetName($b); } $role['behaviors'] = implode(', ', $dbRole->getBehaviors()); try { $envId = $this->getEnvironmentId(); $role['used_servers'] = $this->db->GetOne("SELECT COUNT(*) FROM servers WHERE role_id=? AND env_id=?", array($dbRole->id, $envId)); } catch (Exception $e) { if ($this->user->getAccountId() == 0) { $role['used_servers'] = $this->db->GetOne("SELECT COUNT(*) FROM servers WHERE role_id=?", array($dbRole->id)); if ($this->db->GetOne("SELECT COUNT(*) FROM farm_roles WHERE role_id=?", array($dbRole->id)) > 0) { $status = '<span style="color:green;">In use</span>'; } $role['status'] = $status; } } $role['client_name'] = $dbRole->clientId == 0 ? 'Scalr' : 'Private'; $row = $role; } $this->response->data($response); }
/** * @param int $farmId optional * @param int $roleId optional * @param string $scalrPageHash optional * @param string $scalrPageUiHash optional * @throws Scalr_Exception_InsufficientPermissions */ public function xGetFarmAction($farmId = null, $roleId = null, $scalrPageHash = null, $scalrPageUiHash = null) { if ($scalrPageHash && $scalrPageHash != $this->calcFarmDesignerHash()) { $this->response->data(['scalrPageHashMismatch' => true]); return; } if ($scalrPageUiHash && $scalrPageUiHash != $this->response->pageUiHash()) { $this->response->data(['scalrPageUiHashMismatch' => true]); return; } $moduleParams = array('farmId' => $farmId, 'roleId' => $roleId, 'behaviors' => ROLE_BEHAVIORS::GetName(null, true)); unset($moduleParams['behaviors'][ROLE_BEHAVIORS::CASSANDRA]); unset($moduleParams['behaviors'][ROLE_BEHAVIORS::CUSTOM]); unset($moduleParams['behaviors'][ROLE_BEHAVIORS::HAPROXY]); //platforms list $platforms = self::loadController('Platforms')->getEnabledPlatforms(); if (empty($platforms)) { throw new Exception('Before building new farm you need to configure environment and setup cloud credentials'); } //categories list $categories = $this->db->GetAll("SELECT c.id, c.name, COUNT(DISTINCT r.id) AS total\n FROM role_categories c\n LEFT JOIN roles r ON c.id = r.cat_id AND (r.env_id IS NULL OR r.env_id = ?) AND r.id IN (\n SELECT role_id\n FROM role_images\n WHERE role_id = r.id\n AND platform IN ('" . implode("','", array_keys($platforms)) . "')\n )\n WHERE c.env_id IS NULL OR c.env_id = ?\n GROUP BY c.id\n ", array($this->environment->id, $this->environment->id)); $moduleParams['categories'] = array(); foreach ($categories as $g) { $moduleParams['categories'][$g['id']] = $g; } $moduleParams['farmVpcEc2Enabled'] = $this->getEnvironment()->isPlatformEnabled(SERVER_PLATFORMS::EC2); if ($moduleParams['farmVpcEc2Enabled']) { $moduleParams['farmVpcEc2Locations'] = self::loadController('Platforms')->getCloudLocations(SERVER_PLATFORMS::EC2, false); } if ($farmId) { $this->request->restrictFarmAccess(DBFarm::LoadByID($farmId), Acl::PERM_FARMS_MANAGE); $c = self::loadController('Builder', 'Scalr_UI_Controller_Farms'); $moduleParams['farm'] = $c->getFarm2($farmId); } else { $this->request->restrictFarmAccess(null, Acl::PERM_FARMS_MANAGE); // TODO: remove hack, do better $vars = new Scalr_Scripting_GlobalVariables($this->user->getAccountId(), $this->getEnvironmentId(), ScopeInterface::SCOPE_FARM); $moduleParams['farmVariables'] = $vars->getValues(); } $moduleParams['tabs'] = array('vpcrouter', 'dbmsr', 'mongodb', 'mysql', 'scaling', 'network', 'cloudfoundry', 'rabbitmq', 'haproxy', 'proxy', 'scripting', 'ec2', 'openstack', 'gce', 'azure', 'security', 'devel', 'storage', 'variables', 'advanced', 'chef'); //deprecated tabs if (\Scalr::config('scalr.ui.show_deprecated_features')) { $moduleParams['tabs'][] = 'deployments'; $moduleParams['tabs'][] = 'ebs'; $moduleParams['tabs'][] = 'servicesconfig'; } $conf = $this->getContainer()->config->get('scalr.load_statistics.connections.plotter'); $moduleParams['tabParams'] = array('farmId' => $farmId, 'farmHash' => $moduleParams['farm'] ? $moduleParams['farm']['farm']['hash'] : '', 'accountId' => $this->environment->cloudCredentials(SERVER_PLATFORMS::EC2)->properties[Entity\CloudCredentialsProperty::AWS_ACCOUNT_ID], 'remoteAddress' => $this->request->getRemoteAddr(), 'monitoringHostUrl' => "{$conf['scheme']}://{$conf['host']}:{$conf['port']}", 'nginx' => array('server_section' => file_get_contents(APPPATH . '/templates/services/nginx/server_section.tpl'), 'server_section_ssl' => file_get_contents(APPPATH . '/templates/services/nginx/server_section_ssl.tpl'))); $moduleParams['tabParams']['scalr.dns.global.enabled'] = \Scalr::config('scalr.dns.global.enabled'); $moduleParams['tabParams']['scalr.instances_connection_policy'] = \Scalr::config('scalr.instances_connection_policy'); $moduleParams['tabParams']['scalr.scalarizr_update.repos'] = array_keys(\Scalr::config('scalr.scalarizr_update.repos')); $moduleParams['tabParams']['scalr.scalarizr_update.devel_repos'] = is_array(\Scalr::config('scalr.scalarizr_update.devel_repos')) ? array_keys(\Scalr::config('scalr.scalarizr_update.devel_repos')) : []; $moduleParams['tabParams']['scalr.scalarizr_update.default_repo'] = \Scalr::config('scalr.scalarizr_update.default_repo'); $moduleParams['tabParams']['scalr.aws.ec2.limits.security_groups_per_instance'] = \Scalr::config('scalr.aws.ec2.limits.security_groups_per_instance'); $moduleParams['metrics'] = Entity\ScalingMetric::getList($this->getEnvironmentId()); $moduleParams['timezones_list'] = Scalr_Util_DateTime::getTimezones(); $moduleParams['timezone_default'] = $this->user->getSetting(Scalr_Account_User::SETTING_UI_TIMEZONE); if ($moduleParams['farm']['farm']['ownerEditable']) { $moduleParams['usersList'] = Scalr_Account_User::getList($this->user->getAccountId()); } $defaultFarmRoleSecurityGroups = array('default'); if (\Scalr::config('scalr.aws.security_group_name')) { $defaultFarmRoleSecurityGroups[] = \Scalr::config('scalr.aws.security_group_name'); } $moduleParams['roleDefaultSettings'] = array('base.keep_scripting_logs_time' => \Scalr::config('scalr.system.scripting.default_instance_log_rotation_period'), 'security_groups.list' => json_encode($defaultFarmRoleSecurityGroups), 'base.abort_init_on_script_fail' => \Scalr::config('scalr.system.scripting.default_abort_init_on_script_fail') ? 1 : 0, 'base.disable_firewall_management' => \Scalr::config('scalr.system.default_disable_firewall_management') ? 1 : 0); //cost analytics if ($this->getContainer()->analytics->enabled && $this->getEnvironment()->getPlatformConfigValue(Scalr_Environment::SETTING_CC_ID)) { $farmCostData = $this->getFarmCostData($farmId); $moduleParams['analytics'] = $farmCostData['analytics']; if ($farmId) { $moduleParams['farm']['farm']['projectId'] = $farmCostData['projectId']; $moduleParams['analytics']['farmCostMetering'] = $farmCostData['farmCostMetering']; } } $moduleParams['farmLaunchPermission'] = $farmId ? $moduleParams['farm']['farm']['launchPermission'] : $this->request->isFarmAllowed(null, Acl::PERM_FARMS_LAUNCH_TERMINATE); if ($moduleParams['farm']['farm']['teamOwnerEditable'] || !$farmId) { if ($this->user->canManageAcl()) { $teams = $this->db->getAll('SELECT id, name, description FROM account_teams WHERE account_id = ?', array($this->user->getAccountId())); } else { $teams = $this->user->getTeams(); $teamId = $moduleParams['farm']['farm']['teamOwner']; $flag = !!$teamId; foreach ($teams as $t) { if ($t['id'] == $teamId) { $flag = false; break; } } if ($flag) { // team is missed in list, add manually $team = $this->db->GetRow('SELECT name, description FROM account_teams WHERE id = ?', [$teamId]); array_unshift($teams, ['id' => $teamId, 'name' => $team ? $team['name'] : '', 'description' => $team ? $team['description'] : '']); } } array_unshift($teams, ['id' => 0, 'name' => '']); $moduleParams['teamsList'] = $teams; } $this->response->data($moduleParams); }
/** * Get list of roles for listView */ public function xListRolesAction() { $this->request->defineParams(array('client_id' => array('type' => 'int'), 'roleId' => array('type' => 'int'), 'cloudLocation', 'origin', 'approval_state', 'query', 'sort' => array('type' => 'string', 'default' => 'id'), 'dir' => array('type' => 'string', 'default' => 'ASC'))); if ($this->user->getType() == Scalr_Account_User::TYPE_SCALR_ADMIN) { $sql = "SELECT id from roles WHERE env_id = '0'"; } else { $sql = "SELECT id from roles WHERE env_id IN ({$this->getEnvironmentId()},0)"; } if ($this->getParam('cloudLocation')) { $sql .= " AND id IN (SELECT role_id FROM role_images WHERE cloud_location={$this->db->qstr($this->getParam('cloudLocation'))})"; } if ($this->getParam('roleId')) { $sql .= " AND id='{$this->getParam('roleId')}'"; } if ($this->getParam('origin')) { $sql .= " AND origin = " . $this->db->qstr($this->getParam('origin')); } $response = $this->buildResponseFromSql($sql, array("name", "description")); foreach ($response["data"] as &$row) { $dbRole = DBRole::loadById($row['id']); $platforms = array(); foreach ($dbRole->getPlatforms() as $platform) { $platforms[] = SERVER_PLATFORMS::GetName($platform); } $status = '<span style="color:gray;">Not used</span>'; if ($this->db->GetOne("SELECT id FROM roles_queue WHERE role_id=?", array($dbRole->id))) { $status = '<span style="color:red;">Deleting</span>'; } elseif ($this->db->GetOne("SELECT COUNT(*) FROM farm_roles WHERE role_id=? AND farmid IN (SELECT id FROM farms WHERE clientid=?)", array($dbRole->id, $this->user->getAccountId())) > 0) { $status = '<span style="color:green;">In use</span>'; } $role = array('name' => $dbRole->name, 'id' => $dbRole->id, 'architecture' => $dbRole->architecture, 'client_id' => $dbRole->clientId, 'env_id' => $dbRole->envId, 'status' => $status, 'origin' => $dbRole->origin, 'os' => $dbRole->os, 'tags' => implode(", ", $dbRole->getTags()), 'platforms' => implode(", ", $platforms), 'generation' => $dbRole->generation == 2 ? 'scalarizr' : 'ami-scripts'); $behaviors = array(); foreach ($dbRole->getBehaviors() as $b) { $behaviors[] = ROLE_BEHAVIORS::GetName($b); } $role['behaviors_name'] = implode(', ', $behaviors); $behaviors = array(); foreach ($dbRole->getBehaviors() as $b) { $behaviors[] = ROLE_BEHAVIORS::GetName($b); } $role['behaviors'] = implode(', ', $dbRole->getBehaviors()); try { $envId = $this->getEnvironmentId(); $role['used_servers'] = $this->db->GetOne("SELECT COUNT(*) FROM servers WHERE role_id=? AND env_id=?", array($dbRole->id, $envId)); } catch (Exception $e) { if ($this->user->getAccountId() == 0) { $role['used_servers'] = $this->db->GetOne("SELECT COUNT(*) FROM servers WHERE role_id=?", array($dbRole->id)); if ($this->db->GetOne("SELECT COUNT(*) FROM farm_roles WHERE role_id=?", array($dbRole->id)) > 0) { $status = '<span style="color:green;">In use</span>'; } $role['status'] = $status; } } if ($dbRole->clientId == 0) { $role["client_name"] = "Scalr"; } else { $role["client_name"] = $this->user->getAccount()->getOwner()->fullname; } if (!$role["client_name"]) { $role["client_name"] = ""; } $row = $role; } $this->response->data($response); }
public function importAction() { $behaviors = array(array(ROLE_BEHAVIORS::BASE, ROLE_BEHAVIORS::GetName(ROLE_BEHAVIORS::BASE)), array(ROLE_BEHAVIORS::APACHE, ROLE_BEHAVIORS::GetName(ROLE_BEHAVIORS::APACHE)), array(ROLE_BEHAVIORS::MYSQL, ROLE_BEHAVIORS::GetName(ROLE_BEHAVIORS::MYSQL)), array(ROLE_BEHAVIORS::MYSQL2, ROLE_BEHAVIORS::GetName(ROLE_BEHAVIORS::MYSQL2)), array(ROLE_BEHAVIORS::NGINX, ROLE_BEHAVIORS::GetName(ROLE_BEHAVIORS::NGINX)), array(ROLE_BEHAVIORS::MEMCACHED, ROLE_BEHAVIORS::GetName(ROLE_BEHAVIORS::MEMCACHED)), array(ROLE_BEHAVIORS::POSTGRESQL, ROLE_BEHAVIORS::GetName(ROLE_BEHAVIORS::POSTGRESQL)), array(ROLE_BEHAVIORS::REDIS, ROLE_BEHAVIORS::GetName(ROLE_BEHAVIORS::REDIS)), array(ROLE_BEHAVIORS::RABBITMQ, ROLE_BEHAVIORS::GetName(ROLE_BEHAVIORS::RABBITMQ)), array(ROLE_BEHAVIORS::MONGODB, ROLE_BEHAVIORS::GetName(ROLE_BEHAVIORS::MONGODB))); if ($this->getParam('beta') == 1) { array_push($behaviors, array(ROLE_BEHAVIORS::HAPROXY, ROLE_BEHAVIORS::GetName(ROLE_BEHAVIORS::HAPROXY))); } $euca_locations = array(); $rs_locations = array(); $platforms = array(); $env = Scalr_Environment::init()->loadById($this->getEnvironmentId()); $enabledPlatforms = $env->getEnabledPlatforms(); foreach (SERVER_PLATFORMS::getList() as $k => $v) { if (in_array($k, $enabledPlatforms)) { if ($k == 'rds') { continue; } $platforms[] = array($k, $v); if ($k == SERVER_PLATFORMS::EUCALYPTUS) { foreach (PlatformFactory::NewPlatform($k)->getLocations() as $lk => $lv) { $euca_locations[$lk] = array('id' => $lk, 'name' => $lv); } } elseif ($k == SERVER_PLATFORMS::RACKSPACE) { foreach (PlatformFactory::NewPlatform($k)->getLocations() as $lk => $lv) { $rs_locations[$lk] = array('id' => $lk, 'name' => $lv); } } elseif ($k == SERVER_PLATFORMS::OPENSTACK) { foreach (PlatformFactory::NewPlatform($k)->getLocations() as $lk => $lv) { $os_locations[$lk] = array('id' => $lk, 'name' => $lv); } } } } unset($platforms['rds']); $this->response->page('ui/servers/import_step1.js', array('platforms' => $platforms, 'behaviors' => $behaviors, 'euca_locations' => $euca_locations, 'rs_locations' => $rs_locations, 'os_locations' => $os_locations)); }