airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [12/12] airavata-php-gateway git commit: AIRAVATA-2500 Disallow editing auto provisioned ssh accounts
Date Mon, 25 Sep 2017 21:11:06 GMT
AIRAVATA-2500 Disallow editing auto provisioned ssh accounts


Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/f78e49e0
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/f78e49e0
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/f78e49e0

Branch: refs/heads/AIRAVATA-2500
Commit: f78e49e07486d66fc68e9838ed858bc6bc19c3fb
Parents: 4727617
Author: Marcus Christie <machrist@iu.edu>
Authored: Mon Sep 25 17:10:02 2017 -0400
Committer: Marcus Christie <machrist@iu.edu>
Committed: Mon Sep 25 17:10:02 2017 -0400

----------------------------------------------------------------------
 app/controllers/UserSettingsController.php      | 12 +++++++++
 .../user-compute-resource-preferences.blade.php | 27 +++++++++++++-------
 2 files changed, 30 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f78e49e0/app/controllers/UserSettingsController.php
----------------------------------------------------------------------
diff --git a/app/controllers/UserSettingsController.php b/app/controllers/UserSettingsController.php
index 7f449a6..ef17e17 100644
--- a/app/controllers/UserSettingsController.php
+++ b/app/controllers/UserSettingsController.php
@@ -102,6 +102,12 @@ class UserSettingsController extends BaseController
     public function getComputeResources(){
 
         $userResourceProfile = URPUtilities::get_or_create_user_resource_profile();
+        $gatewayResourceProfile = CRUtilities::getGatewayResourceProfile();
+        $computeResourcePreferences = $gatewayResourceProfile->computeResourcePreferences;
+        $computeResourcePreferencesById = array();
+        foreach ($computeResourcePreferences as $computeResourcePreference) {
+            $computeResourcePreferencesById[$computeResourcePreference->computeResourceId]
= $computeResourcePreference;
+        }
 
         $allCRs = CRUtilities::getAllCRObjects();
         foreach( $allCRs as $index => $crObject)
@@ -111,6 +117,12 @@ class UserSettingsController extends BaseController
         // Add crDetails to each UserComputeResourcePreference
         foreach ($userResourceProfile->userComputeResourcePreferences as $index =>
$userCompResPref) {
             $userCompResPref->crDetails = $allCRsById[$userCompResPref->computeResourceId];
+            // Disallow editing a UserComputeResourcePreference that was automatically setup
by an sshAccountProvisioner
+            $userCompResPref->editable = true;
+            if (array_key_exists($userCompResPref->computeResourceId, $computeResourcePreferencesById))
{
+                $computeResourcePreference = $computeResourcePreferencesById[$userCompResPref->computeResourceId];
+                $userCompResPref->editable = $computeResourcePreference->sshAccountProvisioner
== null;
+            }
             // To figure out the unselectedCRs, remove this compute resource from allCRsById
             unset($allCRsById[$userCompResPref->computeResourceId]);
         }

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f78e49e0/app/views/partials/user-compute-resource-preferences.blade.php
----------------------------------------------------------------------
diff --git a/app/views/partials/user-compute-resource-preferences.blade.php b/app/views/partials/user-compute-resource-preferences.blade.php
index 49c3f85..caedb92 100644
--- a/app/views/partials/user-compute-resource-preferences.blade.php
+++ b/app/views/partials/user-compute-resource-preferences.blade.php
@@ -13,14 +13,15 @@
 
     <div class="col-md-9">
         <input type="text" name="loginUserName" class="form-control"
-               value="@if( isset( $preferences) ){{$preferences->loginUserName}}@endif"/>
+               value="@if( isset( $preferences) ){{$preferences->loginUserName}}@endif"
+               @if(isset($preferences) && !$preferences->editable) disabled @endif/>
     </div>
 </div>
 <div class="form-group">
     <label class="control-label col-md-3">Preferred Batch Queue</label>
 
     <div class="col-md-9">
-        <select name="preferredBatchQueue" class="form-control">
+        <select name="preferredBatchQueue" class="form-control" @if(isset($preferences)
&& !$preferences->editable) disabled @endif>
             <option value="">Select a Queue from list</option>
             @foreach( (array)$computeResource->batchQueues as $index => $queue)
             <option value="{{ $queue->queueName}}"
@@ -35,7 +36,8 @@
 
     <div class="col-md-9">
         <input type="text" name="scratchLocation" class="form-control"
-               value="@if( isset( $preferences) ){{$preferences->scratchLocation}}@endif"/>
+               value="@if( isset( $preferences) ){{$preferences->scratchLocation}}@endif"
+               @if(isset($preferences) && !$preferences->editable) disabled @endif/>
     </div>
 </div>
 
@@ -44,7 +46,8 @@
 
     <div class="col-md-9">
         <input type="text" name="allocationProjectNumber" class="form-control"
-               value="@if( isset( $preferences) ){{$preferences->allocationProjectNumber}}@endif"/>
+               value="@if( isset( $preferences) ){{$preferences->allocationProjectNumber}}@endif"
+               @if(isset($preferences) && !$preferences->editable) disabled @endif/>
     </div>
 </div>
 
@@ -52,7 +55,7 @@
     <label class="control-label col-md-3">Resource Specific SSH Key</label>
 
     <div class="col-md-9">
-        <select class="form-control" name="resourceSpecificCredentialStoreToken" >
+        <select class="form-control" name="resourceSpecificCredentialStoreToken" @if(isset($preferences)
&& !$preferences->editable) disabled @endif>
             <option value="" @if( isset( $preferences) && $preferences->resourceSpecificCredentialStoreToken
== null) selected @endif>
                 No resource specific SSH key, just use the default one ({{{$defaultCredentialSummary->description}}})
             </option>
@@ -72,7 +75,8 @@
 
     <div class="col-md-9">
         <input type="text" name="qualityOfService" class="qualityOfService form-control"
-               value="@if( isset( $preferences) ){{$preferences->qualityOfService}}@endif"
data-toggle="popover" data-placement="bottom" data-content="Format: <queue name1>=<qos1>,<queue
name2>=<qos2>"/>
+               value="@if( isset( $preferences) ){{$preferences->qualityOfService}}@endif"
data-toggle="popover" data-placement="bottom" data-content="Format: <queue name1>=<qos1>,<queue
name2>=<qos2>"
+               @if(isset($preferences) && !$preferences->editable) disabled @endif/>
     </div>
 </div>
 
@@ -81,7 +85,8 @@
 
     <div class="col-md-9">
         <input type="text" name="reservation" class="form-control"
-               value="@if( isset( $preferences) ){{$preferences->reservation}}@endif"/>
+               value="@if( isset( $preferences) ){{$preferences->reservation}}@endif"
+               @if(isset($preferences) && !$preferences->editable) disabled @endif/>
     </div>
 </div>
 <?php
@@ -106,7 +111,8 @@ if( isset( $preferences) && $preferences->reservationEndTime
!= '') {
 
         <div class="input-group date datetimepicker1">
             <input type="text" name="reservationStartTime" class="form-control"
-                   value="{{$reservationStartTime}}"/>
+                   value="{{$reservationStartTime}}"
+                   @if(isset($preferences) && !$preferences->editable) disabled
@endif/>
             <span class="input-group-addon">
                 <span class="glyphicon glyphicon-calendar"></span>
             </span>
@@ -118,7 +124,8 @@ if( isset( $preferences) && $preferences->reservationEndTime
!= '') {
 
         <div class="input-group date datetimepicker2">
             <input type="text" name="reservationEndTime" class="form-control"
-                   value="{{$reservationEndTime}}"/>
+                   value="{{$reservationEndTime}}"
+                   @if(isset($preferences) && !$preferences->editable) disabled
@endif/>
             <span class="input-group-addon">
                 <span class="glyphicon glyphicon-calendar"></span>
             </span>
@@ -126,6 +133,7 @@ if( isset( $preferences) && $preferences->reservationEndTime
!= '') {
     </div>
 </div>
 
+@if(!isset($preferences) || $preferences->editable)
 <div class="row">
     <div class="form-group col-md-12 text-center">
         <input type="submit" class="btn btn-primary" value="Save"/>
@@ -138,5 +146,6 @@ if( isset( $preferences) && $preferences->reservationEndTime
!= '') {
         </button>
     </div>
 </div>
+@endif
 
 </div>


Mime
View raw message