airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [airavata-django-portal] 09/13: AIRAVATA-2727 Add GroupResourceProfile and comp prefs
Date Tue, 14 Aug 2018 19:51:51 GMT
This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git

commit 4fedab0ce358985edf1d9a5bb42e2de1ab55e628
Author: Marcus Christie <machrist@iu.edu>
AuthorDate: Mon Aug 13 17:12:54 2018 -0400

    AIRAVATA-2727 Add GroupResourceProfile and comp prefs
---
 .../ComputePreference.vue                          | 26 +++++----
 .../GroupComputeResourcePreference.vue             | 68 +++++++++++++++++++---
 .../api/static/django_airavata_api/js/index.js     |  6 +-
 .../js/models/GroupComputeResourcePreference.js    |  6 +-
 .../django_airavata_api/js/service_config.js       |  2 -
 .../js/services/ComputeResourceService.js          | 56 ------------------
 6 files changed, 85 insertions(+), 79 deletions(-)

diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/ComputePreference.vue
b/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/ComputePreference.vue
index 87c72db..d3a1491 100644
--- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/ComputePreference.vue
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/ComputePreference.vue
@@ -34,7 +34,8 @@
           <div class="card-body">
             <h5 class="card-title">Policy</h5>
             <b-form-group label="Allowed Queues">
-              <div v-for="batchQueue in computeResource.batchQueues" :key="batchQueue.queueName">
+              <div v-for="batchQueue in computeResource.batchQueues" :key="batchQueue.queueName"
+                  v-if="localComputeResourcePolicy">
                 <b-form-checkbox :checked="localComputeResourcePolicy.allowedBatchQueues.includes(batchQueue.queueName)"
                   @input="batchQueueChecked(batchQueue, $event)">
                   {{ batchQueue.queueName }}
@@ -94,9 +95,17 @@
         // TODO: load the Group Resource Profile and get the compute preferences for this
host_id
       }
       if (this.host_id) {
-        this.fetchComputeResource(this.host_id);
-      } else {
-        this.fetchComputeResources();
+        const computeResourceOperation = this.fetchComputeResource(this.host_id);
+        // If no computeResourcePolicy create a new default one that allows all queues
+        if (!this.computeResourcePolicy) {
+          computeResourceOperation.then(computeResource => {
+            const defaultComputeResourcePolicy = new models.ComputeResourcePolicy();
+            defaultComputeResourcePolicy.computeResourceId = this.host_id;
+            defaultComputeResourcePolicy.groupResourceProfileId = this.id;
+            defaultComputeResourcePolicy.allowedBatchQueues = computeResource.batchQueues.map(queue
=> queue.queueName);
+            this.localComputeResourcePolicy = defaultComputeResourcePolicy;
+          })
+        }
       }
     },
     data: function () {
@@ -115,9 +124,6 @@
     },
     mixins: [VModelMixin],
     methods: {
-      fetchComputeResources: function () {
-        return DjangoAiravataAPI.utils.FetchUtils.get('/api/compute-resources/all_names_list').then((value)
=> this.computeResources = value);
-      },
       batchQueueChecked: function(batchQueue, checked) {
         if (checked) {
           this.localComputeResourcePolicy.allowedBatchQueues.push(batchQueue.queueName);
@@ -151,8 +157,8 @@
         }
       },
       fetchComputeResource: function (id) {
-        DjangoAiravataAPI.utils.FetchUtils.get("/api/compute-resources/" + encodeURIComponent(id)
+ "/").then(value => {
-          this.computeResource = value;
+        return DjangoAiravataAPI.utils.FetchUtils.get("/api/compute-resources/" + encodeURIComponent(id)
+ "/").then(value => {
+          return this.computeResource = value;
         });
       },
       save: function() {
@@ -192,7 +198,7 @@
         }
       },
       cancel: function() {
-        this.$router.back();
+        this.$router.push({ name: 'group_resource_preference', params: {id: this.id}});
       }
     },
   }
diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/GroupComputeResourcePreference.vue
b/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/GroupComputeResourcePreference.vue
index e0b182f..46b3cd3 100644
--- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/GroupComputeResourcePreference.vue
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/GroupComputeResourcePreference.vue
@@ -42,39 +42,51 @@
             <b-button class="ml-2" variant="secondary" @click="cancel">Cancel</b-button>
         </div>
     </div>
+    <b-modal id="modal-select-compute-resource" ref="modalSelectComputeResource" title="Select
Compute Resource"
+      @ok="onSelectComputeResource" :ok-disabled="modalSelectComputeResourceOkDisabled">
+      <b-form-select v-model="selectedComputeResource" :options="computeResourceOptions">
+        <template slot="first">
+          <option :value="null">Please select compute resource</option>
+        </template>
+      </b-form-select>
+    </b-modal>
   </div>
 </template>
 <script>
   import {components as comps, layouts} from 'django-airavata-common-ui'
-  import DjangoAiravataAPI from 'django-airavata-api'
+  import {models, services} from 'django-airavata-api'
 
   export default {
     name: "group-compute-resource-preference",
     props: {
       value: {
-        type: DjangoAiravataAPI.models.GroupResourceProfile,
+        type: models.GroupResourceProfile,
         default: function () {
-          return new DjangoAiravataAPI.models.GroupResourceProfile()
+          return new models.GroupResourceProfile()
         }
       },
+      id: {
+        type: String,
+      },
     },
     mounted: function () {
       if (this.value.groupResourceProfileId) {
-        DjangoAiravataAPI.services.ServiceFactory.service("SharedEntities").retrieve({lookup:
this.value.groupResourceProfileId})
+        services.ServiceFactory.service("SharedEntities").retrieve({lookup: this.value.groupResourceProfileId})
           .then(sharedEntity => this.sharedEntity = sharedEntity);
-      } else if (this.$route.params.id) {
-        // TODO: switch to using props to get the id param
-        DjangoAiravataAPI.services.ServiceFactory.service("GroupResourceProfiles").retrieve({lookup:
this.$route.params.id})
+      } else if (this.id) {
+        services.ServiceFactory.service("GroupResourceProfiles").retrieve({lookup: this.id})
           .then(grp => this.data = grp);
-        DjangoAiravataAPI.services.ServiceFactory.service("SharedEntities").retrieve({lookup:
this.$route.params.id})
+        services.ServiceFactory.service("SharedEntities").retrieve({lookup: this.id})
           .then(sharedEntity => this.sharedEntity = sharedEntity);
       }
+      services.ComputeResourceService.namesList()
+        .then(names => this.computeResources = names);
     },
     data: function () {
       let data = this.value.clone();
       return {
         data: data,
-        service: DjangoAiravataAPI.services.ServiceFactory.service("GroupResourceProfiles"),
+        service: services.ServiceFactory.service("GroupResourceProfiles"),
         sharedEntity: null,
         computePreferencesFields: [
           {
@@ -88,6 +100,8 @@
             key: 'action',
           },
         ],
+        computeResources: null,
+        selectedComputeResource: null,
       }
     },
 
@@ -95,6 +109,24 @@
       "share-button": comps.ShareButton,
       "list-layout": layouts.ListLayout,
     },
+    computed: {
+      modalSelectComputeResourceOkDisabled: function() {
+        return this.selectedComputeResource == null;
+      },
+      computeResourceOptions: function() {
+        const currentPrefs = this.data.computePreferences ? this.data.computePreferences.map(computePreference
=> computePreference.computeResourceId) : [];
+        const options = this.computeResources ? this.computeResources
+          .filter(comp => !currentPrefs.includes(comp.host_id))
+          .map(comp => {
+            return {
+              value: comp.host_id,
+              text: comp.host 
+            }
+          }) : [];
+        options.sort((a, b) => a.text.toLowerCase().localeCompare(b.text.toLowerCase()));
+        return options;
+      },
+    },
     methods: {
       saveGroupResourceProfile: function () {
         var persist = null;
@@ -133,6 +165,24 @@
       },
       cancel: function() {
         this.$router.push('/group-resource-profiles');
+      },
+      createComputePreference: function() {
+        this.$refs.modalSelectComputeResource.show();
+      },
+      onSelectComputeResource: function() {
+        const computeResourcePreference = new models.GroupComputeResourcePreference();
+        const computeResourceId = this.selectedComputeResource;
+        computeResourcePreference.computeResourceId = computeResourceId;
+        this.$router.push({
+          name: 'compute_preference', params: {
+            value: computeResourcePreference,
+            id: this.data.groupResourceProfileId,
+            host_id: computeResourceId,
+            groupResourceProfile: this.data,
+            computeResourcePolicy: null,
+            batchQueueResourcePolicies: null,
+          }
+        });
       }
     },
   }
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/index.js b/django_airavata/apps/api/static/django_airavata_api/js/index.js
index 1db9ad4..bb428d1 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/index.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/index.js
@@ -3,11 +3,13 @@ import ApplicationInterfaceDefinition from './models/ApplicationInterfaceDefinit
 import ApplicationModule from './models/ApplicationModule'
 import BatchQueue from './models/BatchQueue'
 import BatchQueueResourcePolicy from './models/BatchQueueResourcePolicy'
+import ComputeResourcePolicy from './models/ComputeResourcePolicy'
 import DataType from './models/DataType'
 import Experiment from './models/Experiment'
 import ExperimentState from './models/ExperimentState'
 import FullExperiment from './models/FullExperiment'
 import Group from './models/Group'
+import GroupComputeResourcePreference from './models/GroupComputeResourcePreference'
 import GroupPermission from './models/GroupPermission'
 import GroupResourceProfile from './models/GroupResourceProfile'
 import InputDataObjectType from './models/InputDataObjectType'
@@ -45,11 +47,13 @@ exports.models = {
     ApplicationModule,
     BatchQueue,
     BatchQueueResourcePolicy,
+    ComputeResourcePolicy,
     DataType,
     Experiment,
     ExperimentState,
     FullExperiment,
     Group,
+    GroupComputeResourcePreference,
     GroupPermission,
     GroupResourceProfile,
     InputDataObjectType,
@@ -71,7 +75,7 @@ exports.services = {
     GroupService,
     GroupResourceProfileService,
     UserProfileService,
-    ComputeResourceService,
+    ComputeResourceService: ServiceFactory.service("ComputeResources"),
     CloudJobSubmissionService,
     GlobusJobSubmissionService,
     LocaJobSubmissionService,
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/models/GroupComputeResourcePreference.js
b/django_airavata/apps/api/static/django_airavata_api/js/models/GroupComputeResourcePreference.js
index 3a69495..1dacbc5 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/models/GroupComputeResourcePreference.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/models/GroupComputeResourcePreference.js
@@ -4,7 +4,11 @@ import BaseModel from './BaseModel'
 const FIELDS = [
      'computeResourceId',
      'groupResourceProfileId',
-     'overridebyAiravata',
+     {
+         name: 'overridebyAiravata',
+         type: 'boolean',
+         default: true,
+     },
      'loginUserName',
      'preferredJobSubmissionProtocol',
      'preferredDataMovementProtocol',
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/service_config.js b/django_airavata/apps/api/static/django_airavata_api/js/service_config.js
index ae7b0cf..86074ed 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/service_config.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/service_config.js
@@ -51,12 +51,10 @@ export default {
             name: "names",
             url: "/api/compute-resources/all_names/",
             requestType: 'get',
-            modelClass: Object,
         }, {
             name: "namesList",
             url: "/api/compute-resources/all_names_list/",
             requestType: 'get',
-            modelClass: Array,
         }],
         modelClass: ApplicationDeploymentDescription,
     },
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/services/ComputeResourceService.js
b/django_airavata/apps/api/static/django_airavata_api/js/services/ComputeResourceService.js
deleted file mode 100644
index 1bf029c..0000000
--- a/django_airavata/apps/api/static/django_airavata_api/js/services/ComputeResourceService.js
+++ /dev/null
@@ -1,56 +0,0 @@
-import FetchUtils from '../utils/FetchUtils'
-
-let defaultValue = {
-    hostName: 'Hi',
-    hostAliases: [''],
-    ipAddresses: [''],
-    resourceDescription: '',
-    maxMemoryPerNode: 0,
-    batchQueues: [{
-        queueDescription: '',
-        maxRunTime: 0,
-        maxNodes: 0,
-        maxProcessors: 0,
-        maxJobsInQueue: 0,
-        maxMemory: 0,
-        cpuPerNode: 0,
-        defaultNodeCount: 0,
-        defaultCPUCount: 0,
-        defaultWalltime: 0,
-        queueSpecificMacros: '',
-        isDefaultQueue: false
-    }],
-    fileSystems: {
-        0: '',
-        1: '',
-        2: '',
-        3: '',
-        4: ''
-    },
-    jobSubmissionInterfaces: [],
-    dataMovementInterfaces: [{
-        dataMovementInterfaceId: 0,
-        dataMovementProtocol: 3,
-        priorityOrder: null
-    }],
-    gatewayUsageReporting: false,
-    gatewayUsageModuleLoadCommand: null,
-    gatewayUsageExecutable: null
-}
-
-class ComputeResourceService {
-    constructor() {
-        this.data=null
-    }
-
-    list() {
-        return FetchUtils.get('/api/compute-resources/all_names_list')
-    }
-
-     retrieve(id) {
-        this.data=null
-        return  FetchUtils.get('/api/compute-resource/' + encodeURIComponent(id) + '/')
-    }
-}
-
-export default new ComputeResourceService()
\ No newline at end of file


Mime
View raw message