}
});
}
+
private checkNodesAvailability(): void {
forkJoin([this.nvmeofService.listGatewayGroups(), this.hostService.getAllHosts()]).subscribe(
([groups, hosts]: [GatewayGroup[][], any[]]) => {
groupList.forEach((group: CephServiceSpec) => {
const placementHosts = group.placement?.hosts || [];
placementHosts.forEach((hostname: string) => usedHosts.add(hostname));
+
+ const placementLabel = group.placement?.label;
+ if (placementLabel) {
+ (hosts || []).forEach((host) => {
+ if (host.labels?.includes(placementLabel)) {
+ usedHosts.add(host.hostname);
+ }
+ });
+ }
});
const availableHosts = (hosts || []).filter((host) => {
groupList.forEach((group: CephServiceSpec) => {
const hosts = group.placement?.hosts || (group.spec as any)?.placement?.hosts || [];
hosts.forEach((hostname: string) => allUsedHostnames.add(hostname));
- });
+ const label = group.placement?.label || group.spec?.placement?.label;
+ if (label) {
+ (hostList || []).forEach((host: Host) => {
+ if (host.labels?.includes(label as string)) {
+ allUsedHostnames.add(host.hostname);
+ }
+ });
+ }
+ });
this.usedHostnames = allUsedHostnames;
// Check if there are any available hosts globally (not used by any group)
this.hosts = [];
} else {
const placementHosts =
- this.serviceSpec.placement?.hosts || (this.serviceSpec.spec as any)?.placement?.hosts || [];
- const currentGroupHosts = new Set<string>(placementHosts);
-
- this.hosts = (hostList || []).filter((host: Host) => {
- return currentGroupHosts.has(host.hostname);
- });
+ this.serviceSpec.placement?.hosts || this.serviceSpec.spec?.placement?.hosts || [];
+ const placementLabel =
+ this.serviceSpec.placement?.label || this.serviceSpec.spec?.placement?.label;
+
+ if (placementHosts.length > 0) {
+ const currentGroupHosts = new Set<string>(placementHosts);
+ this.hosts = (hostList || []).filter((host: Host) => currentGroupHosts.has(host.hostname));
+ } else if (placementLabel) {
+ this.hosts = (hostList || []).filter((host: Host) =>
+ host.labels?.includes(placementLabel as string)
+ );
+ } else {
+ this.hosts = [];
+ }
}
this.count = this.hosts.length;
// placement labels take only single value
formHelper.setValue('service_type', 'mgr');
formHelper.setValue('placement', 'label');
- formHelper.setValue('label', 'foo');
+ formHelper.setValue('label', "{content: 'foo', selected: true}");
component.onSubmit();
}).pipe(
map(({ groups, hosts }) => {
const usedHosts = new Set<string>();
+
(groups?.[0] ?? []).forEach((group: CephServiceSpec) => {
- group.placement?.hosts?.forEach((hostname: string) => usedHosts.add(hostname));
+ const placementHosts = group.placement?.hosts || [];
+ const placementLabel = group.placement?.label;
+
+ placementHosts.forEach((hostname: string) => usedHosts.add(hostname));
+
+ if (placementLabel) {
+ (hosts || []).forEach((host: Host) => {
+ if (host.labels?.includes(placementLabel as string)) {
+ usedHosts.add(host.hostname);
+ }
+ });
+ }
});
+
return (hosts || []).filter((host: Host) => {
const isAvailable =
host.status === HostStatus.AVAILABLE || host.status === HostStatus.RUNNING;
if (hosts?.length) {
return allHosts.filter((host: Host) => hosts.includes(host.hostname));
- } else if (label?.length) {
- if (typeof label === 'string') {
- return allHosts.filter((host: Host) => host?.labels?.includes(label));
- }
- return allHosts.filter(
- (host: Host) =>
- host?.labels?.length === label?.length &&
- _.isEqual([...host.labels].sort(), [...label].sort())
- );
+ } else if (label) {
+ return allHosts.filter((host: Host) => host?.labels?.includes(label as string));
}
return [];
})