Skip to content

Commit 5f93cce

Browse files
committed
jupyters as individual project
1 parent 894128e commit 5f93cce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+3471
-61
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,9 @@ tests/_support/_generated
6161
/web/img/faq
6262
.htaccess
6363
web/.htaccess
64+
65+
66+
web/fileTicket
67+
/jupyter
68+
/scheduler_files
69+
/test_per

commands/CronJobController.php

+36
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use app\models\Notification;
1414
use app\models\User;
1515
use app\models\Email;
16+
use app\models\JupyterServer;
1617
use webvimark\modules\UserManagement\models\User as Userw;
1718

1819

@@ -25,6 +26,8 @@ public function actionIndex() {
2526
}
2627

2728
public function actionInit($from, $to){
29+
30+
2831
$dates = CronJob::getDateRange($from, $to);
2932
$command = CronJob::run($this->id, $this->action->id, 0, CronJob::countDateRange($dates));
3033

@@ -137,6 +140,39 @@ public function actionInit($from, $to){
137140
public function actionYesterday(){
138141
return $this->actionInit(date("Y-m-d", strtotime("-1 days")), date("Y-m-d", strtotime("-1 days")));
139142
}
143+
144+
public function actionDeleteServers($from, $to){
145+
146+
$dates = CronJob::getDateRange($from, $to);
147+
$command = CronJob::run($this->id, $this->action->id, 0, CronJob::countDateRange($dates));
148+
if ($command === false)
149+
{
150+
return Controller::EXIT_CODE_ERROR;
151+
}
152+
else
153+
{
154+
$expired_owner=Project::getExpiredProjects();
155+
$expired_projects = $expired_owner;
156+
foreach ($expired_projects as $expired_project){
157+
if ($expired_project['project_type']==4){
158+
$all_servers=JupyterServer::find()->where(['active'=>true,'project'=>$expired_project['name']])->all();
159+
if (!empty($all_servers)){
160+
foreach ($all_servers as $server){
161+
$server->Stopserver();
162+
}
163+
}
164+
165+
}
166+
}
167+
168+
$command->finish();
169+
return Controller::EXIT_CODE_NORMAL;
170+
}
171+
}
172+
173+
public function actionToday(){
174+
return $this->actionDeleteServers(date("Y-m-d"), date("Y-m-d"));
175+
}
140176

141177

142178
}

components/NotificationWidget.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,16 @@ public static function createMenuItem()
7070
;
7171
$items[]="<li class='dropdown-header'>You have $notifCount new messages.</li>";
7272

73+
$items[]=['label'=>'View notification history', 'url'=>['site/notification-history'],'options'=>['class'=>'notification-history']];
74+
75+
7376
foreach ($notifications as $notification)
7477
{
7578
$type=$typeClass[$notification->type];
7679
$items[]=['label'=>$notification->message, 'url'=>['/site/notification-redirect','id'=>$notification->id],
7780
'options'=>['class'=>"notification $type"]];
7881
}
79-
$items[]=['label'=>'View notification history', 'url'=>['site/notification-history'],'options'=>['class'=>'notification-history']];
82+
// $items[]=['label'=>'View notification history', 'url'=>['site/notification-history'],'options'=>['class'=>'notification-history']];
8083
if ($notifCount!=0)
8184
{
8285
$items[]=['label'=>'Mark all as seen','options'=>['id'=>'mark_all_seen']];

components/ProjectValueDisplay.php

+41
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace app\components;
44

5+
use app\models\JupyterImages;
6+
57
/**
68
* A class created for organizing and producing formats of values of common attributes shared amongst the projects
79
*/
@@ -108,4 +110,43 @@ public static function simpleValue($defaultValue, $targetField, $requestHistory=
108110

109111
return $renderedHtml;
110112
}
113+
114+
public static function image($defaultValue, $targetField, $requestHistory=null) {
115+
$renderedHtml = '';
116+
if (isset($requestHistory['diff']['details'][$targetField]['current']) && isset($requestHistory['diff']['details'][$targetField]['other'])) {
117+
118+
$selected_image_bef = JupyterImages::find()->where(['id'=>$requestHistory['diff']['details'][$targetField]['other']])->one();
119+
$description=$selected_image_bef->description;
120+
if ($selected_image_bef->gpu==true)
121+
{
122+
$description.=' (GPU)';
123+
}
124+
$image_bef=$description;
125+
126+
$selected_image_after = JupyterImages::find()->where(['id'=>$requestHistory['diff']['details'][$targetField]['current']])->one();
127+
$description=$selected_image_after->description;
128+
if ($selected_image_after->gpu==true)
129+
{
130+
$description.=' (GPU)';
131+
}
132+
133+
$image_after=$description;
134+
$renderedHtml.= ProjectDiff::str($image_bef, $image_after);
135+
136+
}
137+
138+
else {
139+
140+
$selected_image_bef = JupyterImages::find()->where(['id'=>$defaultValue])->one();
141+
$description=$selected_image_bef->description;
142+
if ($selected_image_bef->gpu==true)
143+
{
144+
$description.=' (GPU)';
145+
}
146+
$image_bef=$description;
147+
$renderedHtml .= $image_bef;
148+
}
149+
150+
return $renderedHtml;
151+
}
111152
}

config/params-template.php

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
<?php
22

33
return [
4+
'jupyter_deployments_url' => 'jupyter delpoyment url',
5+
'jupyter_services_url' => 'jupyter service url',
6+
'jupyter_ingresses_url' => 'jupyter ingress url',
7+
'jupyter_bearer_token' => 'jupyter auth token',
8+
'tmpFolderPath' => 'json folder for jupyter',
9+
'userDataPath' => '',
10+
'systemUser' => '',
411
'bsDependencyEnabled'=>false,
512
'adminEmail' => '[email protected]',
613
'senderEmail' => '[email protected]',

controllers/AdministrationController.php

+48-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212
use app\models\ContactForm;
1313
use app\models\ServiceAutoaccept;
1414
use app\models\OndemandAutoaccept;
15+
use app\models\JupyterAutoaccept;
1516
use app\models\ColdStorageAutoaccept;
1617
use app\models\ServiceLimits;
1718
use app\models\OndemandLimits;
19+
use app\models\JupyterLimits;
20+
use app\models\JupyterServer;
1821
use app\models\ColdStorageLimits;
1922
use app\models\Configuration;
2023
use app\models\Openstack;
@@ -110,13 +113,18 @@ public function actionConfigure()
110113
$smtp= Smtp::find()->one();
111114
$openstack=Openstack::find()->one();
112115
$openstackMachines=OpenstackMachines::find()->one();
116+
$jupyter=JupyterAutoaccept::find()->where(['user_type'=>$currentUser])->one();
117+
$jupyterLimits=JupyterLimits::find()->where(['user_type'=>$currentUser])->one();
118+
119+
120+
113121

114122

115123
$general=Configuration::find()->one();
116124
$pages=Page::getPagesDropdown();
117125

118-
$activeButtons=['','','','','','','',''];
119-
$activeTabs=['','','','','','','',''];
126+
$activeButtons=['','','','','','','','',''];
127+
$activeTabs=['','','','','','','','',''];
120128

121129
if (!isset($_POST['hidden-active-button']))
122130
{
@@ -148,6 +156,7 @@ public function actionConfigure()
148156
&& ($coldStorageLimits->load(Yii::$app->request->post())) && ($serviceLimits->load(Yii::$app->request->post()))
149157
&& ($ondemandLimits->load(Yii::$app->request->post())) && ($smtp->load(Yii::$app->request->post()))
150158
&& ($openstack->load(Yii::$app->request->post())) && $openstackMachines->load(Yii::$app->request->post())
159+
&& ($jupyter->load(Yii::$app->request->post())) && ($jupyterLimits->load(Yii::$app->request->post()))
151160
)
152161
{
153162

@@ -171,6 +180,10 @@ public function actionConfigure()
171180
$isValid = $coldStorageLimits->validate() && $isValid;
172181
$isValid = $serviceLimits->validate() && $isValid;
173182
$isValid = $ondemandLimits->validate() && $isValid;
183+
$isValid = $jupyter->validate() && $isValid;
184+
$isValid = $jupyterLimits->validate() && $isValid;
185+
186+
174187
if ($isValid)
175188
{
176189

@@ -227,6 +240,12 @@ public function actionConfigure()
227240
$ondemandLimits->updateDB($previousUserType);
228241
}
229242

243+
$jupyter->updateDB($previousUserType);
244+
$jupyterLimits->updateDB($previousUserType);
245+
246+
247+
248+
230249
$max_autoaccepted_volumes=Project::getMaximumActiveAcceptedProjects(2,$previousUserType,2);
231250
$max_accepted_volumes=Project::getMaximumActiveAcceptedProjects(2,$previousUserType,[1,2]);
232251

@@ -278,7 +297,8 @@ public function actionConfigure()
278297
$coldStorageLimits=ColdStorageLimits::find()->where(['user_type'=>$currentUser])->one();
279298
$machineComputationLimits=MachineComputeLimits::find()->where(['user_type'=>$currentUser])->one();
280299
$general=Configuration::find()->one();
281-
300+
$jupyter=JupyterAutoaccept::find()->where(['user_type'=>$currentUser])->one();
301+
$jupyterLimits=JupyterLimits::find()->where(['user_type'=>$currentUser])->one();
282302

283303

284304
$activeButton=$_POST['hidden-active-button'];
@@ -326,6 +346,14 @@ public function actionConfigure()
326346
$activeButtons[7]='button-active';
327347
$activeTabs[7]='tab-active';
328348
$hiddenActiveButton='openstack-machines-button';
349+
350+
351+
352+
} else if ($activeButton=='jupyter-button')
353+
{
354+
$activeButtons[8]='button-active';
355+
$activeTabs[8]='tab-active';
356+
$hiddenActiveButton='jupyter-button';
329357
}
330358
else
331359
{
@@ -342,6 +370,7 @@ public function actionConfigure()
342370

343371
return $this->render('configure',['form_params'=>$form_params,'service'=>$service,
344372
'ondemand'=>$ondemand,'general'=>$general,
373+
'jupyter'=>$jupyter, 'jupyterLimits'=>$jupyterLimits,
345374
'coldStorage'=>$coldStorage, 'success'=>$success,
346375
"hiddenUser" => $currentUser,'userTypes'=>$userTypes, 'serviceLimits'=>$serviceLimits,
347376
'ondemandLimits'=>$ondemandLimits,'coldStorageLimits'=>$coldStorageLimits,
@@ -354,6 +383,7 @@ public function actionConfigure()
354383
$openstackMachines->decode();
355384
return $this->render('configure',['form_params'=>$form_params,'service'=>$service,
356385
'ondemand'=>$ondemand,'coldStorage'=>$coldStorage,'serviceLimits'=>$serviceLimits,
386+
'jupyter'=>$jupyter, 'jupyterLimits'=>$jupyterLimits,
357387
'ondemandLimits'=>$ondemandLimits,'coldStorageLimits'=>$coldStorageLimits,'general'=>$general,
358388
'userTypes'=>$userTypes, 'success'=>'',"hiddenUser" => $currentUser,
359389
'activeTabs'=>$activeTabs,'activeButtons' => $activeButtons,'hiddenActiveButton'=>$hiddenActiveButton, 'smtp'=>$smtp, 'machineComputationLimits'=>$machineComputationLimits,
@@ -579,7 +609,7 @@ public function actionAllProjects()
579609

580610
$project_types=Project::TYPES;
581611
$button_links=[0=>'/project/view-ondemand-request-user', 1=>'/project/view-service-request-user',
582-
2=>'/project/view-cold-storage-request-user', 3=>'/project/view-machine-compute-user'];
612+
2=>'/project/view-cold-storage-request-user', 3=>'/project/view-machine-compute-user', 4=>'/project/view-jupyter-request-user'];
583613

584614

585615
$deleted=Project::getAllDeletedProjects();
@@ -825,4 +855,18 @@ public function actionUserStatsList()
825855
return $this->render('user_stats_list', ['users'=>$users,'username'=>$username, 'activeFilter'=>$activeFilter,
826856
'activeFilterDrop'=>$activeFilterDrop, 'activeUsers'=>$activeUsers, 'totalUsers'=>$totalUsers]);
827857
}
858+
859+
public function actionViewActiveJupyters()
860+
{
861+
862+
if (!Userw::hasRole("Admin", $superAdminAllowed = true))
863+
{
864+
return $this->render('unauthorized');
865+
}
866+
867+
$servers=JupyterServer::find()->where(['active'=>true])->all();
868+
869+
return $this->render('view_active_jupyters',['servers'=>$servers]);
870+
871+
}
828872
}

0 commit comments

Comments
 (0)