Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/app/VMClaim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export class VMClaim {
static_bind_attempts: number;
dynamic_bind_request_id: string;
tainted: boolean;
error: boolean;
}
6 changes: 5 additions & 1 deletion src/app/scenario/scenario.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ <h5>
</tr>
</thead>
@for (vmc of vmclaims; track vmc) {
<tbody [vmclaim]="vmc" (ready)="onReady(vmc)"></tbody>
<tbody
[vmclaim]="vmc"
(ready)="onReady(vmc)"
(provisioningError)="onError()"
></tbody>
}
</table>
}
Expand Down
9 changes: 7 additions & 2 deletions src/app/scenario/scenario.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
import { Scenario } from './Scenario';
import { catchError, concatMap, delay } from 'rxjs/operators';
import { catchError, concatMap, delay, take } from 'rxjs/operators';
import { Session } from '../Session';
import { from, of } from 'rxjs';
import { ScenarioService } from '../services/scenario.service';
Expand Down Expand Up @@ -46,13 +46,18 @@ export class ScenarioComponent implements OnInit {
vmc.ready = true;
}

onError() {
this.error = true;
this.ssService.finish(this.session.id).pipe(take(1)).subscribe();
}

get isReady() {
return this.vmclaims.length > 0 && this.vmclaims.every((v) => v.ready);
}

get isDynamicallyBinding() {
const dynVmcs = this.vmclaims.filter((v) => v.bind_mode === 'dynamic');
return dynVmcs.length > 0 && dynVmcs.every((v) => !v.ready);
return dynVmcs.length > 0 && dynVmcs.every((v) => !v.ready) && !this.error;
}

close() {
Expand Down
6 changes: 5 additions & 1 deletion src/app/scenario/vmclaim.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export class VMClaimComponent implements OnChanges {
@Output()
ready: EventEmitter<string> = new EventEmitter(false);

@Output()
provisioningError: EventEmitter<boolean> = new EventEmitter(false);

private vms: Map<string, VM> = new Map();

constructor(
Expand All @@ -48,10 +51,11 @@ export class VMClaimComponent implements OnChanges {
// On every tick of the timer, call vmClaimService.get()
switchMap(() => this.vmClaimService.get(this.vmclaim.id)),
// Continue the Observable chain if vmclaim is not ready
takeWhile((s: VMClaim) => !s.ready, true),
takeWhile((s: VMClaim) => !s.ready && !s.error, true),
// Convert object to Map and emit the VMs if vmclaim is ready
concatMap((s: VMClaim) => {
this.vmclaim = s;
if (s.error) this.provisioningError.emit(true);
if (!s.ready) return [];
this.ready.emit(s.id);
return s.vm.values();
Expand Down
Loading