airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [airavata-django-portal] 02/03: AIRAVATA-2876 Filter out compute resource not in a GroupResourceProfile
Date Mon, 17 Sep 2018 17:08:35 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 ca89bc4720069b72dadba50e39a730de46220d4c
Author: Marcus Christie <machrist@iu.edu>
AuthorDate: Mon Sep 17 12:54:58 2018 -0400

    AIRAVATA-2876 Filter out compute resource not in a GroupResourceProfile
---
 .../applications/ApplicationDeploymentsList.vue    | 45 ++++++++++++++++++++--
 1 file changed, 42 insertions(+), 3 deletions(-)

diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationDeploymentsList.vue
b/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationDeploymentsList.vue
index 8e856f2..c3f25fc 100644
--- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationDeploymentsList.vue
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationDeploymentsList.vue
@@ -21,8 +21,8 @@
         </b-table>
       </template>
     </list-layout>
-    <compute-resources-modal ref="modalSelectComputeResource" @selected="onSelectComputeResource"
:excluded-resource-ids="excludedComputeResourceIds"
-    />
+    <compute-resources-modal ref="modalSelectComputeResource" @selected="onSelectComputeResource"
:compute-resource-names="selectableComputeResourceNames"
+      :excluded-resource-ids="excludedComputeResourceIds" />
   </div>
 </template>
 
@@ -50,7 +50,8 @@ export default {
   },
   data() {
     return {
-      computeResourceNames: null
+      computeResourceNames: null,
+      groupResourceProfiles: null
     };
   },
   computed: {
@@ -72,6 +73,40 @@ export default {
         }
       ];
     },
+    selectableComputeResourceNames() {
+      // Only allow selecting a compute resource for a new deployment if that
+      // compute resource exists in a GroupResourceProfile
+      if (this.computeResourceNames && this.groupResourceProfiles) {
+        // Create a set of all computeResourceIds in GroupResourceProfiles
+        const groupResourceProfileCompResources = {};
+        for (const groupResourceProfile of this.groupResourceProfiles) {
+          for (const computePreference of groupResourceProfile.computePreferences) {
+            groupResourceProfileCompResources[
+              computePreference.computeResourceId
+            ] = null;
+          }
+        }
+        const result = [];
+        // Filter compute resources based on existence in groupResourceProfileCompResources
+        for (const computeResourceId in this.computeResourceNames) {
+          if (
+            this.computeResourceNames.hasOwnProperty(computeResourceId) &&
+            groupResourceProfileCompResources.hasOwnProperty(computeResourceId)
+          ) {
+            const computeResourceName = this.computeResourceNames[
+              computeResourceId
+            ];
+            result.push({
+              host_id: computeResourceId,
+              host: computeResourceName
+            });
+          }
+        }
+        return result;
+      } else {
+        return [];
+      }
+    },
     excludedComputeResourceIds() {
       return this.deployments.map(dep => dep.computeHostId);
     }
@@ -80,6 +115,10 @@ export default {
     services.ComputeResourceService.names().then(
       names => (this.computeResourceNames = names)
     );
+    services.GroupResourceProfileService.list().then(
+      groupResourceProfiles =>
+        (this.groupResourceProfiles = groupResourceProfiles)
+    );
   },
   methods: {
     getComputeResourceName(computeResourceId) {


Mime
View raw message