예제 #1
0
 public function testOne()
 {
     /** @type Cluster $_cluster */
     $_cluster = Cluster::byNameOrId('cluster-east-1')->firstOrFail();
     $_assigns = $_cluster->assignedServers();
     foreach ($_assigns as $_assign) {
         if ($_assign->server) {
             $_server = $_assign->server;
             if ($_server->mount) {
                 $_mount = $_server->mount;
             }
         }
     }
 }
 public function index()
 {
     $_clusters = Cluster::join('cluster_server_asgn_t', 'cluster_id', '=', 'id')->distinct()->get(['cluster_t.*', 'cluster_id']);
     $_excluded = [];
     foreach ($_clusters as $_cluster) {
         $_excluded[] = $_cluster->id;
     }
     $_notAssigned = Cluster::whereNotIn('id', $_excluded)->get();
     $result = array_merge(json_decode($_clusters), json_decode($_notAssigned));
     return $this->renderView('app.clusters', ['clusters' => $result]);
 }
예제 #3
0
 /**
  * @return array
  */
 protected function gatherConsoleStatistics()
 {
     $_stats = ['uri' => config('app.url', \Request::getSchemeAndHttpHost()), 'user' => ServiceUser::count(), 'mount' => Mount::count(), 'server' => Server::count(), 'cluster' => Cluster::count(), 'limit' => Limit::count(), 'instance' => Instance::count()];
     return $_stats;
     //  The new way
     //return $this->telemetry->make('console')->getTelemetry();
 }
 /**
  * @param string|int $clusterId
  *
  * @return Cluster
  */
 protected static function findCluster($clusterId)
 {
     return Cluster::byNameOrId($clusterId)->firstOrFail();
 }
 public function edit($id)
 {
     return $this->renderView('app.instances.edit', ['instance_id' => $id, 'instance' => Instance::with(['user', 'cluster'])->find($id), 'clusters' => Cluster::all()]);
 }
예제 #6
0
 /**
  * Cluster in which I belong
  *
  * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany|Cluster
  */
 public function cluster()
 {
     return Cluster::whereRaw('id IN (SELECT csa.cluster_id FROM cluster_server_asgn_t csa WHERE csa.server_id = :server_id)', [':server_id' => $this->id])->first();
 }
예제 #7
0
 /**
  * Create a cluster
  *
  * @param $clusterId
  *
  * @return bool|\DreamFactory\Enterprise\Database\Models\Cluster
  */
 protected function _createCluster($clusterId)
 {
     if (false === ($_data = $this->_prepareData($clusterId))) {
         return false;
     }
     $_cluster = Models\Cluster::create($_data);
     $this->concat('cluster id ')->asComment($clusterId)->flush(' created.');
     return $_cluster;
 }
예제 #8
0
 /**
  * @param integer $id
  *
  * @return \Illuminate\View\View
  */
 public function edit($id)
 {
     /** @type Limit $_limit */
     $_limit = Limit::find($id);
     $_values = ['limit_nbr' => $_limit->limit_nbr, 'user_id' => null, 'service_name' => '', 'role_id' => 0, 'api_key' => '', 'period_name' => '', 'label_text' => $_limit->label_text, 'cluster_id_text' => '', 'instance_id_text' => ''];
     $defaultPos = strpos($_limit['limit_key_text'], 'default.');
     $clusterDefaultPos = strpos($_limit['limit_key_text'], 'cluster.default.');
     $instanceDefaultPos = strpos($_limit['limit_key_text'], 'instance.default.');
     if ($defaultPos !== false && $defaultPos == 0) {
         $_values['notes'] = 'Default for all clusters and instances';
     } elseif ($clusterDefaultPos !== false && $clusterDefaultPos == 0) {
         $_values['notes'] = 'Default for cluster';
     } elseif ($instanceDefaultPos !== false && $instanceDefaultPos == 0) {
         $_values['notes'] = 'Default for instance';
     } else {
         $_values['notes'] = '';
     }
     $_userName = null;
     $_this_limit_type = null;
     foreach (explode('.', $_limit['limit_key_text']) as $_value) {
         $_limit_key = explode(':', $_value);
         switch ($_limit_key[0]) {
             case 'default':
                 break;
             case 'cluster':
                 $_this_limit_type = 'cluster';
                 break;
             case 'instance':
                 $_this_limit_type = 'instance';
                 break;
             case 'user':
                 $_values['user_id'] = $_limit_key[1];
                 $_this_limit_type = 'user';
                 break;
             case 'service':
                 $_values['service_name'] = $_limit_key[1];
                 break;
             case 'role':
                 $_values['role_id'] = $_limit_key[1];
                 break;
             case 'api_key':
                 $_values['api_key'] = $_limit_key[1];
                 break;
             default:
                 // It's time period
                 $_values['period_name'] = ucwords(str_replace('-', ' ', $_limit_key[0]));
         }
     }
     if (!empty($_limit->cluster_id)) {
         $_cluster = $this->_findCluster($_limit['cluster_id']);
         $_values['cluster_id_text'] = $_cluster->cluster_id_text;
     }
     if (!empty($_limit->instance_id)) {
         $_instance = $this->_findInstance($_limit->instance_id);
         $_values['instance_id_text'] = $_instance->instance_id_text;
         if (!empty($_values['user_id'])) {
             if (false !== ($_rows = $this->getInstanceUsers($_instance))) {
                 foreach ($_rows as $_user) {
                     if ($_user['id'] != $_values['user_id']) {
                         continue;
                     }
                     $_userName = $_user['name'];
                     break;
                 }
             }
         }
     }
     $_limits = ['id' => $_limit['id'], 'type' => $_this_limit_type, 'cluster_id' => $_limit['cluster_id'], 'cluster_id_text' => $_values['cluster_id_text'], 'instance_id' => $_limit['instance_id'], 'instance_id_text' => $_values['instance_id_text'], 'user_id' => $_values['user_id'], 'user_name' => $_userName, 'period_name' => $_values['period_name'], 'limit_nbr' => $_limit->limit_nbr, 'label_text' => $_limit->label_text, 'active_ind' => $_limit->active_ind, 'notes' => $_values['notes']];
     logger('limit: ' . print_r($_limits, true));
     return \View::make('app.limits.edit', ['limitPeriods' => $this->periods, 'prefix' => $this->_prefix, 'clusters' => Cluster::all(), 'limit' => $_limits]);
 }