1 import { Component, OnInit } from '@angular/core';
3 import _ from 'lodash';
5 import { CephServiceService } from '~/app/shared/api/ceph-service.service';
6 import { HostService } from '~/app/shared/api/host.service';
7 import { OsdService } from '~/app/shared/api/osd.service';
8 import { CdTableFetchDataContext } from '~/app/shared/models/cd-table-fetch-data-context';
9 import { CephServiceSpec } from '~/app/shared/models/service.interface';
10 import { DimlessBinaryPipe } from '~/app/shared/pipes/dimless-binary.pipe';
11 import { WizardStepsService } from '~/app/shared/services/wizard-steps.service';
14 selector: 'cd-create-cluster-review',
15 templateUrl: './create-cluster-review.component.html',
16 styleUrls: ['./create-cluster-review.component.scss']
18 export class CreateClusterReviewComponent implements OnInit {
23 services: Array<CephServiceSpec> = [];
28 public wizardStepsService: WizardStepsService,
29 public cephServiceService: CephServiceService,
30 private dimlessBinary: DimlessBinaryPipe,
31 public hostService: HostService,
32 private osdService: OsdService
37 let dataDeviceCapacity = 0;
39 let walDeviceCapacity = 0;
41 let dbDeviceCapacity = 0;
43 const hostContext = new CdTableFetchDataContext(() => undefined);
44 this.hostService.list(hostContext.toParams(), 'true').subscribe((resp: object[]) => {
46 this.hostsCount = this.hosts.length;
47 _.forEach(this.hosts, (hostKey) => {
48 this.totalCPUs = this.totalCPUs + hostKey['cpu_count'];
50 this.totalMemory = this.totalMemory + hostKey['memory_total_kb'] * 1024;
52 this.totalMemory = this.dimlessBinary.transform(this.totalMemory);
55 if (this.osdService.osdDevices['data']) {
56 dataDevices = this.osdService.osdDevices['data']?.length;
57 dataDeviceCapacity = this.osdService.osdDevices['data']['capacity'];
60 if (this.osdService.osdDevices['wal']) {
61 walDevices = this.osdService.osdDevices['wal']?.length;
62 walDeviceCapacity = this.osdService.osdDevices['wal']['capacity'];
65 if (this.osdService.osdDevices['db']) {
66 dbDevices = this.osdService.osdDevices['db']?.length;
67 dbDeviceCapacity = this.osdService.osdDevices['db']['capacity'];
70 this.totalDevices = dataDevices + walDevices + dbDevices;
71 this.osdService.osdDevices['totalDevices'] = this.totalDevices;
72 this.totalCapacity = dataDeviceCapacity + walDeviceCapacity + dbDeviceCapacity;