airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [1/3] airavata-php-gateway git commit: AIRAVATA-2200 User can opt to use their own compute resource account
Date Fri, 04 Nov 2016 21:09:23 GMT
Repository: airavata-php-gateway
Updated Branches:
  refs/heads/develop 35a9e8e50 -> 5f6e8e445


AIRAVATA-2200 User can opt to use their own compute resource account


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/00094b4c
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/00094b4c
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/00094b4c

Branch: refs/heads/develop
Commit: 00094b4c82d3c1eb2fa7b509784c1008e3f6f7ed
Parents: 35a9e8e
Author: Marcus Christie <machrist@iu.edu>
Authored: Fri Nov 4 16:00:50 2016 -0400
Committer: Marcus Christie <machrist@iu.edu>
Committed: Fri Nov 4 16:00:50 2016 -0400

----------------------------------------------------------------------
 app/controllers/ExperimentController.php        | 19 ++++++++++++++--
 .../Airavata/Model/Experiment/Types.php         | 23 ++++++++++++++++++++
 app/libraries/ExperimentUtilities.php           |  2 ++
 app/libraries/URPUtilities.php                  | 20 +++++++++++++++++
 app/views/partials/experiment-inputs.blade.php  |  4 +++-
 .../partials/experiment-queue-block.blade.php   | 19 +++++++++++++++-
 6 files changed, 83 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/00094b4c/app/controllers/ExperimentController.php
----------------------------------------------------------------------
diff --git a/app/controllers/ExperimentController.php b/app/controllers/ExperimentController.php
index aab0ae9..a27d02f 100755
--- a/app/controllers/ExperimentController.php
+++ b/app/controllers/ExperimentController.php
@@ -245,6 +245,9 @@ class ExperimentController extends BaseController
 
         $computeResources = CRUtilities::create_compute_resources_select($experiment->executionId,
$expVal['scheduling']->resourceHostId);
 
+        $userComputeResourcePreferences = URPUtilities::get_all_user_compute_resource_prefs();
+        $userHasComputeResourcePreference = array_key_exists($expVal['scheduling']->resourceHostId,
$userComputeResourcePreferences);
+
         $clonedExp = false; $savedExp = false;
         if( Input::has("clonedExp"))
             $clonedExp = true;
@@ -260,6 +263,8 @@ class ExperimentController extends BaseController
             "application" => $experiment->executionId,
             "autoSchedule" => $experiment->userConfigurationData->airavataAutoSchedule,
             "userDN" => $experiment->userConfigurationData->userDN,
+            "userHasComputeResourcePreference" => $userHasComputeResourcePreference,
+            "useUserCRPref" => $experiment->userConfigurationData->useUserCRPref,
             "allowedFileSize" => Config::get('pga_config.airavata')["server-allowed-file-size"],
             'experiment' => $experiment,
             "queueDefaults" => $queueDefaults,
@@ -345,13 +350,23 @@ class ExperimentController extends BaseController
 
     public function getQueueView()
     {
-        $queues = ExperimentUtilities::getQueueDatafromResourceId(Input::get("crId"));
+        $computeResourceId = Input::get("crId");
+        $queues = ExperimentUtilities::getQueueDatafromResourceId($computeResourceId);
         $queueDefaults = array("queueName" => Config::get('pga_config.airavata')["queue-name"],
             "nodeCount" => Config::get('pga_config.airavata')["node-count"],
             "cpuCount" => Config::get('pga_config.airavata')["total-cpu-count"],
             "wallTimeLimit" => Config::get('pga_config.airavata')["wall-time-limit"]
         );
-        return View::make("partials/experiment-queue-block", array("queues" => $queues,
"queueDefaults" => $queueDefaults));
+
+        $userComputeResourcePreferences = URPUtilities::get_all_user_compute_resource_prefs();
+        $userHasComputeResourcePreference = array_key_exists($computeResourceId, $userComputeResourcePreferences);
+        if ($userHasComputeResourcePreference)
+        {
+            $queueDefaults["queueName"] = $userComputeResourcePreferences[$computeResourceId]->preferredBatchQueue;
+        }
+        return View::make("partials/experiment-queue-block", array("queues" => $queues,
"queueDefaults" => $queueDefaults,
+            "useUserCRPref" => $userHasComputeResourcePreference,
+            "userHasComputeResourcePreference" => $userHasComputeResourcePreference));
     }
 
     public function browseView()

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/00094b4c/app/libraries/Airavata/Model/Experiment/Types.php
----------------------------------------------------------------------
diff --git a/app/libraries/Airavata/Model/Experiment/Types.php b/app/libraries/Airavata/Model/Experiment/Types.php
index 3e1dc12..f015ff4 100644
--- a/app/libraries/Airavata/Model/Experiment/Types.php
+++ b/app/libraries/Airavata/Model/Experiment/Types.php
@@ -98,6 +98,10 @@ class UserConfigurationDataModel {
    * @var string
    */
   public $experimentDataDir = null;
+  /**
+   * @var bool
+   */
+  public $useUserCRPref = null;
 
   public function __construct($vals=null) {
     if (!isset(self::$_TSPEC)) {
@@ -139,6 +143,10 @@ class UserConfigurationDataModel {
           'var' => 'experimentDataDir',
           'type' => TType::STRING,
           ),
+        10 => array(
+          'var' => 'useUserCRPref',
+          'type' => TType::BOOL,
+          ),
         );
     }
     if (is_array($vals)) {
@@ -169,6 +177,9 @@ class UserConfigurationDataModel {
       if (isset($vals['experimentDataDir'])) {
         $this->experimentDataDir = $vals['experimentDataDir'];
       }
+      if (isset($vals['useUserCRPref'])) {
+        $this->useUserCRPref = $vals['useUserCRPref'];
+      }
     }
   }
 
@@ -255,6 +266,13 @@ class UserConfigurationDataModel {
             $xfer += $input->skip($ftype);
           }
           break;
+        case 10:
+          if ($ftype == TType::BOOL) {
+            $xfer += $input->readBool($this->useUserCRPref);
+          } else {
+            $xfer += $input->skip($ftype);
+          }
+          break;
         default:
           $xfer += $input->skip($ftype);
           break;
@@ -316,6 +334,11 @@ class UserConfigurationDataModel {
       $xfer += $output->writeString($this->experimentDataDir);
       $xfer += $output->writeFieldEnd();
     }
+    if ($this->useUserCRPref !== null) {
+      $xfer += $output->writeFieldBegin('useUserCRPref', TType::BOOL, 10);
+      $xfer += $output->writeBool($this->useUserCRPref);
+      $xfer += $output->writeFieldEnd();
+    }
     $xfer += $output->writeFieldStop();
     $xfer += $output->writeStructEnd();
     return $xfer;

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/00094b4c/app/libraries/ExperimentUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/ExperimentUtilities.php b/app/libraries/ExperimentUtilities.php
index fb0d363..aadfcf6 100755
--- a/app/libraries/ExperimentUtilities.php
+++ b/app/libraries/ExperimentUtilities.php
@@ -283,6 +283,7 @@ class ExperimentUtilities
             $userConfigData->generateCert = 1;
             $userConfigData->userDN = $_POST["userDN"];
         }
+        $userConfigData->useUserCRPref = isset($_POST['use-user-cr-pref']) ? true : false;
 
         $applicationInputs = AppUtilities::get_application_inputs($_POST['application']);
         $experimentInputs = ExperimentUtilities::process_inputs($_POST['project'], $_POST['experiment-name'],
$applicationInputs, $experimentInputs);
@@ -1253,6 +1254,7 @@ class ExperimentUtilities
             $userConfigDataUpdated->generateCert = 1;
             $userConfigDataUpdated->userDN = $input["userDN"];
         }
+        $userConfigDataUpdated->useUserCRPref = isset($_POST['use-user-cr-pref']) ? true
: false;
 
         $experiment->userConfigurationData = $userConfigDataUpdated;
 

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/00094b4c/app/libraries/URPUtilities.php
----------------------------------------------------------------------
diff --git a/app/libraries/URPUtilities.php b/app/libraries/URPUtilities.php
index b4ceba6..c01da2b 100644
--- a/app/libraries/URPUtilities.php
+++ b/app/libraries/URPUtilities.php
@@ -100,6 +100,26 @@ class URPUtilities
         return $result;
     }
 
+    /*
+     * Get all user's compute resource preferences, keyed by compute resource id.
+     */
+    public static function get_all_user_compute_resource_prefs()
+    {
+
+        $userComputeResourcePreferencesById = array();
+        $userResourceProfile = URPUtilities::get_user_resource_profile();
+        if (!$userResourceProfile->isNull)
+        {
+            $userComputeResourcePreferences = $userResourceProfile->userComputeResourcePreferences;
+            // Put $userComputeResourcePreferences in a map keyed by computeResourceId
+            foreach( $userComputeResourcePreferences as $userComputeResourcePreference )
+            {
+                $userComputeResourcePreferencesById[$userComputeResourcePreference->computeResourceId]
= $userComputeResourcePreference;
+            }
+        }
+        return $userComputeResourcePreferencesById;
+    }
+
     public static function add_or_update_user_SRP($inputs, $update = false)
     {
         $inputs = Input::all();

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/00094b4c/app/views/partials/experiment-inputs.blade.php
----------------------------------------------------------------------
diff --git a/app/views/partials/experiment-inputs.blade.php b/app/views/partials/experiment-inputs.blade.php
index 2a67b96..69ae78c 100644
--- a/app/views/partials/experiment-inputs.blade.php
+++ b/app/views/partials/experiment-inputs.blade.php
@@ -98,7 +98,9 @@
             <div class="queue-view">
                 @if(isset($expInputs['expVal']) )
                 @include( 'partials/experiment-queue-block', array('queues'=>
-                $expInputs['expVal']['computeResource']->batchQueues, 'expVal' => $expInputs['expVal'])
)
+                $expInputs['expVal']['computeResource']->batchQueues, 'expVal' => $expInputs['expVal'],
+                'useUserCRPref' => $expInputs['useUserCRPref'],
+                'userHasComputeResourcePreference' => $expInputs['userHasComputeResourcePreference']
))
                 @endif
             </div>
         </div>

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/00094b4c/app/views/partials/experiment-queue-block.blade.php
----------------------------------------------------------------------
diff --git a/app/views/partials/experiment-queue-block.blade.php b/app/views/partials/experiment-queue-block.blade.php
index ac3e0ac..4f94e14 100644
--- a/app/views/partials/experiment-queue-block.blade.php
+++ b/app/views/partials/experiment-queue-block.blade.php
@@ -1,3 +1,12 @@
+@if ($userHasComputeResourcePreference)
+<div class="form-group">
+    <label class="control-label" for="use-user-cr-pref">
+        Use My Compute Resource Account
+            <input name="use-user-cr-pref" id="use-user-cr-pref" type="checkbox"
+            @if($useUserCRPref) checked @endif>
+    </label>
+</div>
+@endif
 <input type="hidden" id="queue-array" value="{{ htmlentities( json_encode( $queues ) )
}}"/>
 <div class="form-group required">
     @if( count( $queues) > 0 )
@@ -6,7 +15,15 @@
     "disabled" }} @endif @endif required>
     @foreach( $queues as $queue)
     <option value="{{$queue->queueName}}"
-    @if(isset($expVal) ) @if( $expVal['scheduling']->queueName == $queue->queueName
) selected @endif @endif
+    @if(isset($expVal) )
+        @if( $expVal['scheduling']->queueName == $queue->queueName )
+        selected
+        @endif
+    @else
+        @if( $queueDefaults['queueName'] == $queue->queueName )
+        selected
+        @endif
+    @endif
     >
     {{$queue->queueName}}
     </option>


Mime
View raw message