Skip to content

Commit

Permalink
Merge pull request #4650 from deNBI/fix/resource-scale
Browse files Browse the repository at this point in the history
Fix/resource scale
  • Loading branch information
eKatchko authored May 3, 2022
2 parents 8bdc603 + ced4416 commit d97cd53
Show file tree
Hide file tree
Showing 8 changed files with 15,811 additions and 15,486 deletions.
30,120 changes: 15,182 additions & 14,938 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/app/pipe-module/pipe-module.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { HasStatusPipe, StatusInListPipe } from './pipes/has-status.pipe';
import { IsPiApprovedPipe } from './pipes/is-pi-approved';
import { FloorIntegerPipe } from './pipes/floor-integer.pipe';
import { InAllowedPipe } from './pipes/in-allowed.pipe';
import { NoCoresPipe, NoRamPipe, NoVMsPipe } from './pipes/ressources';

/**
* Pipemodule
Expand All @@ -21,6 +22,9 @@ import { InAllowedPipe } from './pipes/in-allowed.pipe';
IsPiApprovedPipe,
FloorIntegerPipe,
InAllowedPipe,
NoVMsPipe,
NoCoresPipe,
NoRamPipe,
],
exports: [
FlavorCounterPipe,
Expand All @@ -31,6 +35,9 @@ import { InAllowedPipe } from './pipes/in-allowed.pipe';
IsPiApprovedPipe,
FloorIntegerPipe,
InAllowedPipe,
NoVMsPipe,
NoCoresPipe,
NoRamPipe,
],
imports: [CommonModule],
})
Expand Down
43 changes: 43 additions & 0 deletions src/app/pipe-module/pipes/ressources.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// eslint-disable-next-line max-classes-per-file
import { Pipe, PipeTransform } from '@angular/core';
import { ApplicationRessourceUsage } from '../../applications/application-ressource-usage/application-ressource-usage';

/**
* Pipe which compares status.
*/
@Pipe({
name: 'noVMsPipe',
})
export class NoVMsPipe implements PipeTransform {
transform(ressources: ApplicationRessourceUsage, additional_vms: number = 0): boolean {
if (additional_vms > 0) {
return ressources.used_vms + additional_vms > ressources.number_vms;
} else {
return ressources.used_vms >= ressources.number_vms;
}
}
}

/**
* Pipe which compares status.
*/
@Pipe({
name: 'noCoresPipe',
})
export class NoCoresPipe implements PipeTransform {
transform(ressources: ApplicationRessourceUsage): boolean {
return ressources.cores_used >= ressources.cores_total;
}
}

/**
* Pipe which compares status.
*/
@Pipe({
name: 'noRamPipe',
})
export class NoRamPipe implements PipeTransform {
transform(ressources: ApplicationRessourceUsage): boolean {
return ressources.ram_used >= ressources.ram_total;
}
}
60 changes: 10 additions & 50 deletions src/app/virtualmachines/addvm.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,62 +83,22 @@
<div *ngIf="client_available && projectDataLoaded">
<app-resource-overview [ressourceUsage]="selectedProjectRessources"> </app-resource-overview>
<div
class="alert alert-primary"
role="alert"
class="alert alert-warning"
*ngIf="
selectedProject &&
selectedProjectRessources?.used_vms >= selectedProjectRessources?.number_vms &&
((selectedProjectRessources | noVMsPipe) ||
(selectedProjectRessources | noRamPipe) ||
(selectedProjectRessources | noCoresPipe)) &&
client_available &&
client_checked
"
>
The limit for virtual machines has been reached for this project. Your principal investigator can
request more resources if necessary.
</div>
<div
class="alert alert-primary"
role="alert"
*ngIf="
selectedProject &&
selectedProjectRessources?.cores_used < selectedProjectRessources?.cores_total &&
!(selectedProjectRessources.ram_used < selectedProjectRessources.ram_total) &&
flavors_loaded &&
flavors.length === 0 &&
!selectedFlavor
"
>
There is not enough ram available for this project to start a new machine. Your principal investigator
can request more resources if necessary.
</div>
<div
class="alert alert-primary"
role="alert"
*ngIf="
selectedProject &&
!(selectedProjectRessources?.cores_used < selectedProjectRessources?.cores_total) &&
selectedProjectRessources.ram_used < selectedProjectRessources.ram_total &&
flavors_loaded &&
flavors.length === 0 &&
!selectedFlavor
"
>
There are too few cores available for this project to start a new machine. Your principal investigator
can request more resources if necessary.
</div>
<div
class="alert alert-primary"
role="alert"
*ngIf="
selectedProject &&
selectedProjectRessources?.cores_used < selectedProjectRessources?.cores_total &&
selectedProjectRessources.ram_used < selectedProjectRessources.ram_total &&
flavors_loaded &&
flavors.length === 0 &&
!selectedFlavor
"
>
There are too few cores and not enough ram available for this project to start a new machine. Your
principal investigator can request more resources if necessary.
The following limit/limits has/have been reached:
<div *ngIf="selectedProjectRessources | noVMsPipe">- Amount of VMs</div>
<div *ngIf="selectedProjectRessources | noCoresPipe">- Amount of cores</div>
<div *ngIf="selectedProjectRessources | noRamPipe">- Amount of RAM</div>
<br />
An admin of your project can request more resources if necessary.
</div>
<div
*ngIf="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,56 +100,23 @@
[showAdditionalRes]="true"
></app-resource-overview>
<accordion class="col">
<div>
<div class="alert alert-primary" role="alert" *ngIf="selectedProject && vm_limit_reached">
The limit for virtualmachines is too low for your project to start a new cluster. Your principal
investigator can request more resources if necessary.
</div>
<div
class="alert alert-primary"
role="alert"
*ngIf="
selectedProject &&
cores_limit_reached &&
!ram_limit_reached &&
flavors_loaded &&
flavors_usable.length === 0 &&
!selectedFlavor
"
>
There are too few cores available for this project to start a new machine. Your principal
investigator can request more resources if necessary.
</div>
<div
class="alert alert-primary"
role="alert"
*ngIf="
selectedProject &&
!cores_limit_reached &&
ram_limit_reached &&
flavors_loaded &&
flavors_usable.length === 0 &&
!selectedFlavor
"
>
There is not enough ram available for this project to start a new machine. Your principal
investigator can request more resources if necessary.
</div>
<div
class="alert alert-primary"
role="alert"
*ngIf="
selectedProject &&
cores_limit_reached &&
ram_limit_reached &&
flavors_loaded &&
flavors_usable.length === 0 &&
!selectedFlavor
"
>
There are too few cores and not enough ram available for this project to start a new machine. Your
principal investigator can request more resources if necessary.
</div>
<div
class="alert alert-warning"
*ngIf="
selectedProject &&
((selectedProjectRessources | noVMsPipe: 2) ||
(selectedProjectRessources | noRamPipe) ||
(selectedProjectRessources | noCoresPipe)) &&
client_available &&
client_checked
"
>
The following limit/limits has/have been reached:
<div *ngIf="selectedProjectRessources | noVMsPipe">- Amount of VMs</div>
<div *ngIf="selectedProjectRessources | noCoresPipe">- Amount of cores</div>
<div *ngIf="selectedProjectRessources | noRamPipe">- Amount of RAM</div>
<br />
An admin of your project can request more resources if necessary.
</div>
</accordion>

Expand Down
Loading

0 comments on commit d97cd53

Please sign in to comment.