Ejemplo n.º 1
0
 public function getList($isBeta = false)
 {
     $roles = array();
     $e_platforms = $this->getEnvironment()->getEnabledPlatforms();
     $platforms = array();
     $l_platforms = SERVER_PLATFORMS::GetList();
     foreach ($e_platforms as $platform) {
         $platforms[$platform] = $l_platforms[$platform];
     }
     $roles_sql = "SELECT id FROM roles WHERE (env_id = 0 OR env_id=?) AND id IN (SELECT role_id FROM role_images WHERE platform IN ('" . implode("','", array_keys($platforms)) . "'))";
     $args[] = $this->getEnvironmentId();
     $dbroles = $this->db->Execute($roles_sql, $args);
     while ($role = $dbroles->FetchRow()) {
         if ($this->db->GetOne("SELECT id FROM roles_queue WHERE role_id=?", array($role['id']))) {
             continue;
         }
         $dbRole = DBRole::loadById($role['id']);
         if ($dbRole->generation != 2 && $dbRole->origin == ROLE_TYPE::SHARED) {
             continue;
         }
         $role_platforms = $dbRole->getPlatforms();
         $role_locations = array();
         foreach ($role_platforms as $platform) {
             $role_locations[$platform] = $dbRole->getCloudLocations($platform);
         }
         $roles[] = array('role_id' => $dbRole->id, 'arch' => $dbRole->architecture, 'group' => ROLE_GROUPS::GetConstByBehavior($dbRole->getBehaviors()), 'name' => $dbRole->name, 'generation' => $dbRole->generation, 'behaviors' => implode(",", $dbRole->getBehaviors()), 'origin' => $dbRole->origin, 'isstable' => (bool) $dbRole->isStable, 'platforms' => implode(",", $role_platforms), 'locations' => $role_locations, 'os' => $dbRole->os == 'Unknown' ? 'Unknown OS' : $dbRole->os, 'tags' => $dbRole->getTags());
     }
     return $roles;
 }
Ejemplo n.º 2
0
 public function getContent($params = array())
 {
     try {
         $dbFarm = DBFarm::LoadByID($params['farmId']);
         $this->user->getPermissions()->validate($dbFarm);
         $farmRoles = array();
         foreach ($dbFarm->GetFarmRoles() as $dbFarmRole) {
             $servCount = $this->db->GetOne("SELECT COUNT(*) FROM servers WHERE farm_roleid = ? AND status IN ('Pending', 'Initializing', 'Running', 'Temporary')", array($dbFarmRole->ID));
             if ($servCount) {
                 $farmRoles[] = array('farmId' => $params['farmId'], 'roleId' => $this->db->GetOne("SELECT role_id FROM farm_roles WHERE id=? AND farmid=?", array($dbFarmRole->ID, $params['farmId'])), 'farmRoleId' => $dbFarmRole->ID, 'group' => ROLE_GROUPS::GetConstByBehavior($dbFarmRole->GetRoleObject()->getBehaviors()), 'behaviors' => implode(",", $dbFarmRole->GetRoleObject()->getBehaviors()), 'servCount' => $servCount);
             }
         }
         return array('servers' => $farmRoles, 'name' => $dbFarm->Name);
     } catch (Exception $e) {
         return '';
     }
 }
Ejemplo n.º 3
0
 public function xGetRolesAction()
 {
     $roles = array();
     $platforms = $this->getEnvironment()->getEnabledPlatforms();
     $rolesSql = "SELECT id FROM roles WHERE (env_id = 0 OR env_id=?) AND id IN (SELECT role_id FROM role_images WHERE platform IN ('" . implode("','", array_keys($platforms)) . "'))";
     $dbroles = $this->db->Execute($rolesSql, array($this->getEnvironmentId()));
     while ($role = $dbroles->FetchRow()) {
         if ($this->db->GetOne("SELECT id FROM roles_queue WHERE role_id=?", array($role['id']))) {
             continue;
         }
         $dbRole = DBRole::loadById($role['id']);
         $rolePlatforms = $dbRole->getPlatforms();
         $roleLocations = array();
         foreach ($rolePlatforms as $platform) {
             $roleLocations[$platform] = $dbRole->getCloudLocations($platform);
         }
         $roles[] = array('role_id' => $dbRole->id, 'arch' => $dbRole->architecture, 'group' => ROLE_GROUPS::GetConstByBehavior($dbRole->getBehaviors()), 'name' => $dbRole->name, 'generation' => $dbRole->generation, 'behaviors' => implode(",", $dbRole->getBehaviors()), 'origin' => $dbRole->origin, 'isstable' => (bool) $dbRole->isStable, 'platforms' => implode(",", $rolePlatforms), 'locations' => $roleLocations, 'os' => $dbRole->os == 'Unknown' ? 'Unknown OS' : $dbRole->os, 'tags' => $dbRole->getTags());
     }
     $this->response->success();
     $this->response->data(array('roles' => $roles));
 }