import { Permission } from '~/app/shared/models/permissions';
import { Host } from '~/app/shared/models/host.interface';
-import { CephServiceSpec } from '~/app/shared/models/service.interface';
+import { CephServiceSpec, CephServiceSpecUpdate } from '~/app/shared/models/service.interface';
import { AuthStorageService } from '~/app/shared/services/auth-storage.service';
import { CephServiceService } from '~/app/shared/api/ceph-service.service';
import { NvmeofService } from '~/app/shared/api/nvmeof.service';
deletionMessage: $localize`Removing <strong>${hostname}</strong> will detach it from the gateway group and stop handling new I/O requests. Active connections may be disrupted.<br><br>You can re-add this node later if required.`
},
submitActionObservable: () => {
- const updatedSpec = _.cloneDeep(this.serviceSpec);
- updatedSpec.placement.hosts = updatedSpec.placement.hosts.filter((h) => h !== hostname);
- delete updatedSpec.status;
- if (updatedSpec['events']) {
- delete updatedSpec['events'];
+ const updatedSpec = this.buildRemoveGatewaySpecPayload(hostname);
+ if (!updatedSpec) {
+ return of(null);
}
return this.taskWrapper
.wrapTaskAroundCall({
});
}
+ private buildRemoveGatewaySpecPayload(hostname: string): CephServiceSpecUpdate | null {
+ if (!this.serviceSpec) {
+ this.notificationService.show(
+ NotificationType.error,
+ $localize`Service specification is missing.`
+ );
+ return null;
+ }
+
+ const { status, ...updatedSpec } = _.cloneDeep(this.serviceSpec);
+
+ if (updatedSpec['events']) {
+ delete updatedSpec['events'];
+ }
+
+ if (!updatedSpec.placement) {
+ updatedSpec.placement = {};
+ }
+
+ if ('locations' in updatedSpec.placement) {
+ delete updatedSpec.placement.locations;
+ }
+
+ const currentHosts = updatedSpec.placement.hosts || [];
+ updatedSpec.placement.hosts = currentHosts.filter((h: string) => h !== hostname);
+ return updatedSpec;
+ }
+
ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();
const allUsedHostnames = new Set<string>();
groupList.forEach((group: CephServiceSpec) => {
- const hosts = group.placement?.hosts || (group.spec as any)?.placement?.hosts || [];
+ const hosts = group.placement?.hosts || group.spec?.placement?.hosts || [];
hosts.forEach((hostname: string) => allUsedHostnames.add(hostname));
});
this.hosts = [];
} else {
const placementHosts =
- this.serviceSpec.placement?.hosts || (this.serviceSpec.spec as any)?.placement?.hosts || [];
+ this.serviceSpec.placement?.hosts || this.serviceSpec.spec?.placement?.hosts || [];
const currentGroupHosts = new Set<string>(placementHosts);
this.hosts = (hostList || []).filter((host: Host) => {
certificate?: CephServiceCertificate;
spec: CephServiceAdditionalSpec;
placement: CephServicePlacement;
+ events?: string[];
}
// Type for service spec update payload (excludes read-only status field)
export type CephServiceSpecUpdate = Omit<CephServiceSpec, 'status'>;
export interface CephServiceAdditionalSpec {
+ placement?: CephServicePlacement;
backend_service: string;
api_user: string;
api_password: string;
placement?: string;
hosts?: string[];
label?: string | string[];
+ locations?: Record<string, string[]>;
}
export interface QatSepcs {