]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/create-cluster/create-cluster-review.component.ts
update ceph source to reef 18.2.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cluster / create-cluster / create-cluster-review.component.ts
1 import { Component, OnInit } from '@angular/core';
2
3 import _ from 'lodash';
4
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';
12
13 @Component({
14 selector: 'cd-create-cluster-review',
15 templateUrl: './create-cluster-review.component.html',
16 styleUrls: ['./create-cluster-review.component.scss']
17 })
18 export class CreateClusterReviewComponent implements OnInit {
19 hosts: object[] = [];
20 hostsCount: number;
21 totalDevices: number;
22 totalCapacity = 0;
23 services: Array<CephServiceSpec> = [];
24 totalCPUs = 0;
25 totalMemory = 0;
26
27 constructor(
28 public wizardStepsService: WizardStepsService,
29 public cephServiceService: CephServiceService,
30 private dimlessBinary: DimlessBinaryPipe,
31 public hostService: HostService,
32 private osdService: OsdService
33 ) {}
34
35 ngOnInit() {
36 let dataDevices = 0;
37 let dataDeviceCapacity = 0;
38 let walDevices = 0;
39 let walDeviceCapacity = 0;
40 let dbDevices = 0;
41 let dbDeviceCapacity = 0;
42
43 const hostContext = new CdTableFetchDataContext(() => undefined);
44 this.hostService.list(hostContext.toParams(), 'true').subscribe((resp: object[]) => {
45 this.hosts = resp;
46 this.hostsCount = this.hosts.length;
47 _.forEach(this.hosts, (hostKey) => {
48 this.totalCPUs = this.totalCPUs + hostKey['cpu_count'];
49 // convert to bytes
50 this.totalMemory = this.totalMemory + hostKey['memory_total_kb'] * 1024;
51 });
52 this.totalMemory = this.dimlessBinary.transform(this.totalMemory);
53 });
54
55 if (this.osdService.osdDevices['data']) {
56 dataDevices = this.osdService.osdDevices['data']?.length;
57 dataDeviceCapacity = this.osdService.osdDevices['data']['capacity'];
58 }
59
60 if (this.osdService.osdDevices['wal']) {
61 walDevices = this.osdService.osdDevices['wal']?.length;
62 walDeviceCapacity = this.osdService.osdDevices['wal']['capacity'];
63 }
64
65 if (this.osdService.osdDevices['db']) {
66 dbDevices = this.osdService.osdDevices['db']?.length;
67 dbDeviceCapacity = this.osdService.osdDevices['db']['capacity'];
68 }
69
70 this.totalDevices = dataDevices + walDevices + dbDevices;
71 this.osdService.osdDevices['totalDevices'] = this.totalDevices;
72 this.totalCapacity = dataDeviceCapacity + walDeviceCapacity + dbDeviceCapacity;
73 }
74 }