import { CephServiceService } from '~/app/shared/api/ceph-service.service';
import { HostService } from '~/app/shared/api/host.service';
import { OsdService } from '~/app/shared/api/osd.service';
-import { CellTemplate } from '~/app/shared/enum/cell-template.enum';
import { CephServiceSpec } from '~/app/shared/models/service.interface';
import { DimlessBinaryPipe } from '~/app/shared/pipes/dimless-binary.pipe';
import { WizardStepsService } from '~/app/shared/services/wizard-steps.service';
})
export class CreateClusterReviewComponent implements OnInit {
hosts: object[] = [];
- hostsByService: object;
hostsCount: number;
- serviceCount: number;
- serviceOccurrences = {};
- hostsCountPerService: object[] = [];
- uniqueServices: Set<string> = new Set();
totalDevices: number;
totalCapacity = 0;
services: Array<CephServiceSpec> = [];
let dbDevices = 0;
let dbDeviceCapacity = 0;
- this.hostsByService = {
- columns: [
- {
- prop: 'service_type',
- name: $localize`Services`,
- flexGrow: 1,
- cellTransformation: CellTemplate.badge,
- customTemplateConfig: {
- class: 'badge-dark'
- }
- },
- {
- name: $localize`Number of Hosts`,
- prop: 'hosts_per_service',
- flexGrow: 1
- }
- ]
- };
-
- this.cephServiceService.list().subscribe((resp: Array<CephServiceSpec>) => {
- this.services = resp;
- this.serviceCount = this.services.length;
-
- _.forEach(this.services, (serviceKey) => {
- this.serviceOccurrences[serviceKey['service_type']] =
- (this.serviceOccurrences[serviceKey['service_type']] || 0) + 1;
- this.uniqueServices.add(serviceKey['service_type']);
- });
-
- this.uniqueServices.forEach((serviceType) => {
- this.hostsCountPerService.push({
- service_type: serviceType,
- hosts_per_service: this.serviceOccurrences[serviceType]
- });
- });
-
- this.hostsByService['data'] = [...this.hostsCountPerService];
- });
-
this.hostService.list('true').subscribe((resp: object[]) => {
this.hosts = resp;
this.hostsCount = this.hosts.length;