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> = [];
26 deploymentDescText: string = '-';
27 isSimpleDeployment = true;
30 public wizardStepsService: WizardStepsService,
31 public cephServiceService: CephServiceService,
32 private dimlessBinary: DimlessBinaryPipe,
33 public hostService: HostService,
34 private osdService: OsdService
39 let dataDeviceCapacity = 0;
41 let walDeviceCapacity = 0;
43 let dbDeviceCapacity = 0;
45 this.isSimpleDeployment = this.osdService.isDeployementModeSimple;
46 const hostContext = new CdTableFetchDataContext(() => undefined);
47 this.hostService.list(hostContext.toParams(), 'true').subscribe((resp: object[]) => {
49 this.hostsCount = this.hosts.length;
50 _.forEach(this.hosts, (hostKey) => {
51 this.totalCPUs = this.totalCPUs + hostKey['cpu_count'];
53 this.totalMemory = this.totalMemory + hostKey['memory_total_kb'] * 1024;
55 this.totalMemory = this.dimlessBinary.transform(this.totalMemory);
58 if (this.osdService.osdDevices['data']) {
59 dataDevices = this.osdService.osdDevices['data']?.length;
60 dataDeviceCapacity = this.osdService.osdDevices['data']['capacity'];
63 if (this.osdService.osdDevices['wal']) {
64 walDevices = this.osdService.osdDevices['wal']?.length;
65 walDeviceCapacity = this.osdService.osdDevices['wal']['capacity'];
68 if (this.osdService.osdDevices['db']) {
69 dbDevices = this.osdService.osdDevices['db']?.length;
70 dbDeviceCapacity = this.osdService.osdDevices['db']['capacity'];
73 if (this.isSimpleDeployment) {
74 this.osdService.getDeploymentOptions().subscribe((optionsObj) => {
75 if (!_.isEmpty(optionsObj)) {
76 Object.keys(optionsObj.options).forEach((option) => {
78 this.osdService.selectedFormValues &&
79 this.osdService.selectedFormValues.get('deploymentOption').value === option
81 this.deploymentDescText = optionsObj.options[option].desc;
88 this.totalDevices = dataDevices + walDevices + dbDevices;
89 this.osdService.osdDevices['totalDevices'] = this.totalDevices;
90 this.totalCapacity = dataDeviceCapacity + walDeviceCapacity + dbDeviceCapacity;