From 4d85c7be667a719e3a9defe5dda4ea7d85bcc67a Mon Sep 17 00:00:00 2001 From: Ivan Chupin Date: Thu, 14 Nov 2024 13:32:01 +0000 Subject: [PATCH] nbworker add feature to reroute y-flow for switch/link evacuation process added evacuate y-flow button that replace evacuate toggle, slightly fix evacuate button logic. add new info message in toastrService regarding flow evacuation. --- .../ui/src/app/common/constants/constants.ts | 2 + .../isl/isl-detail/isl-detail.component.html | 15 +-- .../isl/isl-detail/isl-detail.component.ts | 19 ++-- .../switch-detail.component.html | 10 +- .../switch-detail/switch-detail.component.ts | 19 ++-- .../java/org/openkilda/model/FlowPath.java | 3 +- .../nbworker/bolts/MessageEncoder.java | 4 +- .../services/FlowOperationsService.java | 20 +++- .../services/FlowOperationsServiceTest.java | 98 ++++++++++++++++++- 9 files changed, 139 insertions(+), 51 deletions(-) diff --git a/src-gui/ui/src/app/common/constants/constants.ts b/src-gui/ui/src/app/common/constants/constants.ts index 614a080582b..d2206f23eaf 100644 --- a/src-gui/ui/src/app/common/constants/constants.ts +++ b/src-gui/ui/src/app/common/constants/constants.ts @@ -36,6 +36,8 @@ export const MessageObj = { bfd_flag_updated: 'BFD flag updated successfully!', flows_evacuated: 'All flows are evacuated successfully!', error_flows_evacuated: 'Error in evacuating flows!', + info_cannot_evacuate_flows_from_switch: 'Can not evacuate flows while switch is not under maintenance.', + info_cannot_evacuate_flows_from_isl: 'Can not evacuate flows while ISL is not under maintenance.', reverse_graph_no_data: 'Backward graph API did not return data.', forward_graph_no_data: 'Forward graph API did not return data.', updating_isl_bandwidth: 'Updating ISL max bandwidth', diff --git a/src-gui/ui/src/app/modules/isl/isl-detail/isl-detail.component.html b/src-gui/ui/src/app/modules/isl/isl-detail/isl-detail.component.html index 9c89bf50452..86f7d6fb121 100644 --- a/src-gui/ui/src/app/modules/isl/isl-detail/isl-detail.component.html +++ b/src-gui/ui/src/app/modules/isl/isl-detail/isl-detail.component.html @@ -242,18 +242,13 @@
- +
-
- - -
+  
diff --git a/src-gui/ui/src/app/modules/isl/isl-detail/isl-detail.component.ts b/src-gui/ui/src/app/modules/isl/isl-detail/isl-detail.component.ts index 4a42520b028..ac81ea4115f 100644 --- a/src-gui/ui/src/app/modules/isl/isl-detail/isl-detail.component.ts +++ b/src-gui/ui/src/app/modules/isl/isl-detail/isl-detail.component.ts @@ -42,7 +42,6 @@ export class IslDetailComponent implements OnInit, AfterViewInit, OnDestroy { state = ''; bfd_session_status = ''; enable_bfd = false; - evacuate = false; under_maintenance = false; loadingData = true; isBFDEdit: any = false; @@ -187,7 +186,6 @@ export class IslDetailComponent implements OnInit, AfterViewInit, OnDestroy { this.bfd_session_status = retrievedObject.bfd_session_status; this.available_bandwidth = retrievedObject.available_bandwidth; this.under_maintenance = retrievedObject.under_maintenance; - this.evacuate = retrievedObject.evacuate; this.enable_bfd = retrievedObject.enable_bfd; this.clipBoardItems = Object.assign(this.clipBoardItems, { sourceSwitchName: retrievedObject.source_switch_name, @@ -413,14 +411,13 @@ export class IslDetailComponent implements OnInit, AfterViewInit, OnDestroy { } evacuateIsl(e) { + if (!this.under_maintenance) { + this.toastr.info(MessageObj.info_cannot_evacuate_flows_from_isl, 'Can not evacuate'); + return; + } const modalRef = this.modalService.open(ModalconfirmationComponent); modalRef.componentInstance.title = 'Confirmation'; - this.evacuate = e.target.checked; - if (this.evacuate) { - modalRef.componentInstance.content = 'Are you sure you want to evacuate all flows?'; - } else { - modalRef.componentInstance.content = 'Are you sure ?'; - } + modalRef.componentInstance.content = 'Are you sure you want to evacuate all flows?'; modalRef.result.then((response) => { if (response && response == true) { const data = { @@ -429,7 +426,7 @@ export class IslDetailComponent implements OnInit, AfterViewInit, OnDestroy { dst_switch: this.dst_switch, dst_port: this.dst_port, under_maintenance: this.under_maintenance, - evacuate: e.target.checked + evacuate: true }; this.islListService.islUnderMaintenance(data).subscribe(response => { this.toastr.success(MessageObj.flows_evacuated, 'Success'); @@ -437,11 +434,7 @@ export class IslDetailComponent implements OnInit, AfterViewInit, OnDestroy { }, error => { this.toastr.error(MessageObj.error_flows_evacuated, 'Error'); }); - } else { - this.evacuate = false; } - }, error => { - this.evacuate = false; }); } diff --git a/src-gui/ui/src/app/modules/switches/switch-detail/switch-detail.component.html b/src-gui/ui/src/app/modules/switches/switch-detail/switch-detail.component.html index 96af9adcb39..24e78b6f0a9 100644 --- a/src-gui/ui/src/app/modules/switches/switch-detail/switch-detail.component.html +++ b/src-gui/ui/src/app/modules/switches/switch-detail/switch-detail.component.html @@ -108,12 +108,10 @@