/** * Get information about role */ public function infoAction() { $this->request->defineParams(array('roleId' => array('type' => 'int'))); $roleId = $this->getParam('roleId'); $dbRole = DBRole::loadById($roleId); if ($dbRole->envId != 0) { $this->user->getPermissions()->validate($dbRole); } $dbRole->groupName = ROLE_GROUPS::GetNameByBehavior($dbRole->getBehaviors()); $dbRole->behaviorsList = implode(", ", $dbRole->getBehaviors()); foreach ($dbRole->getSoftwareList() as $soft) { $dbRole->softwareList[] = "{$soft['name']} {$soft['version']}"; } $dbRole->softwareList = implode(", ", $dbRole->softwareList); $dbRole->tagsString = implode(", ", $dbRole->getTags()); $dbRole->platformsList = array(); foreach ($dbRole->getPlatforms() as $platform) { $dbRole->platformsList[] = array('name' => SERVER_PLATFORMS::GetName($platform), 'locations' => implode(", ", $dbRole->getCloudLocations($platform))); } $this->response->page('ui/roles/info.js', array('name' => $dbRole->name, 'info' => get_object_vars($dbRole))); }
public function FarmGetDetails($FarmID) { $response = $this->CreateInitialResponse(); try { $DBFarm = DBFarm::LoadByID($FarmID); if ($DBFarm->EnvID != $this->Environment->id) { throw new Exception("N"); } } catch (Exception $e) { throw new Exception(sprintf("Farm #%s not found", $FarmID)); } $response->FarmRoleSet = new stdClass(); $response->FarmRoleSet->Item = array(); foreach ($DBFarm->GetFarmRoles() as $DBFarmRole) { $itm = new stdClass(); $itm->{"ID"} = $DBFarmRole->ID; $itm->{"RoleID"} = $DBFarmRole->RoleID; $itm->{"Name"} = $DBFarmRole->GetRoleObject()->name; $itm->{"Platform"} = $DBFarmRole->Platform; $itm->{"Category"} = ROLE_GROUPS::GetNameByBehavior($DBFarmRole->GetRoleObject()->getBehaviors()); $itm->{"ScalingProperties"} = new stdClass(); $itm->{"ScalingProperties"}->{"MinInstances"} = $DBFarmRole->GetSetting(DBFarmRole::SETTING_SCALING_MIN_INSTANCES); $itm->{"ScalingProperties"}->{"MaxInstances"} = $DBFarmRole->GetSetting(DBFarmRole::SETTING_SCALING_MAX_INSTANCES); //TODO: if ($DBFarmRole->Platform == SERVER_PLATFORMS::EC2) { $itm->{"PlatformProperties"} = new stdClass(); $itm->{"PlatformProperties"}->{"InstanceType"} = $DBFarmRole->GetSetting(DBFarmRole::SETTING_AWS_INSTANCE_TYPE); $itm->{"PlatformProperties"}->{"AvailabilityZone"} = $DBFarmRole->GetSetting(DBFarmRole::SETTING_AWS_AVAIL_ZONE); } elseif ($DBFarmRole->Platform == SERVER_PLATFORMS::RDS) { $itm->{"PlatformProperties"} = new stdClass(); $itm->{"PlatformProperties"}->{"InstanceClass"} = $DBFarmRole->GetSetting(DBFarmRole::SETTING_RDS_INSTANCE_CLASS); $itm->{"PlatformProperties"}->{"AvailabilityZone"} = $DBFarmRole->GetSetting(DBFarmRole::SETTING_RDS_AVAIL_ZONE); $itm->{"PlatformProperties"}->{"InstanceEngine"} = $DBFarmRole->GetSetting(DBFarmRole::SETTING_RDS_INSTANCE_ENGINE); } $itm->{"ServerSet"} = new stdClass(); $itm->{"ServerSet"}->Item = array(); foreach ($DBFarmRole->GetServersByFilter() as $DBServer) { $iitm = new stdClass(); $iitm->{"ServerID"} = $DBServer->serverId; $iitm->{"ExternalIP"} = $DBServer->remoteIp; $iitm->{"InternalIP"} = $DBServer->localIp; $iitm->{"Status"} = $DBServer->status; $iitm->{"ScalarizrVersion"} = $DBServer->GetProperty(SERVER_PROPERTIES::SZR_VESION); $iitm->{"Uptime"} = round((time() - strtotime($DBServer->dateAdded)) / 60, 2); //seconds -> minutes $iitm->{"IsDbMaster"} = $DBServer->GetProperty(SERVER_PROPERTIES::DB_MYSQL_MASTER) == 1 || $DBServer->GetProperty(Scalr_Db_Msr::REPLICATION_MASTER) == 1 ? '1' : '0'; if ($DBFarmRole->Platform == SERVER_PLATFORMS::EC2) { $iitm->{"PlatformProperties"} = new stdClass(); $iitm->{"PlatformProperties"}->{"InstanceType"} = $DBServer->GetProperty(EC2_SERVER_PROPERTIES::INSTANCE_TYPE); $iitm->{"PlatformProperties"}->{"AvailabilityZone"} = $DBServer->GetProperty(EC2_SERVER_PROPERTIES::AVAIL_ZONE); $iitm->{"PlatformProperties"}->{"AMIID"} = $DBServer->GetProperty(EC2_SERVER_PROPERTIES::AMIID); $iitm->{"PlatformProperties"}->{"InstanceID"} = $DBServer->GetProperty(EC2_SERVER_PROPERTIES::INSTANCE_ID); } elseif ($DBFarmRole->Platform == SERVER_PLATFORMS::RDS) { $iitm->{"PlatformProperties"} = new stdClass(); $iitm->{"PlatformProperties"}->{"InstanceClass"} = $DBServer->GetProperty(RDS_SERVER_PROPERTIES::INSTANCE_CLASS); $iitm->{"PlatformProperties"}->{"AvailabilityZone"} = $DBServer->GetProperty(RDS_SERVER_PROPERTIES::AVAIL_ZONE); $iitm->{"PlatformProperties"}->{"InstanceEngine"} = $DBServer->GetProperty(RDS_SERVER_PROPERTIES::INSTANCE_ENGINE); $iitm->{"PlatformProperties"}->{"InstanceID"} = $DBServer->GetProperty(RDS_SERVER_PROPERTIES::INSTANCE_ID); } $itm->{"ServerSet"}->Item[] = $iitm; } $response->FarmRoleSet->Item[] = $itm; } return $response; }