]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/placement.pipe.ts
import ceph pacific 16.2.5
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cluster / services / placement.pipe.ts
CommitLineData
adb31ebb
TL
1import { Pipe, PipeTransform } from '@angular/core';
2
f67539c2 3import _ from 'lodash';
adb31ebb
TL
4
5@Pipe({
6 name: 'placement'
7})
8export class PlacementPipe implements PipeTransform {
adb31ebb
TL
9 /**
10 * Convert the placement configuration into human readable form.
11 * The output is equal to the column 'PLACEMENT' in 'ceph orch ls'.
12 * @param serviceSpec The service specification to process.
13 * @return The placement configuration as human readable string.
14 */
15 transform(serviceSpec: object | undefined): string {
16 if (_.isUndefined(serviceSpec)) {
f67539c2 17 return $localize`no spec`;
adb31ebb
TL
18 }
19 if (_.get(serviceSpec, 'unmanaged', false)) {
f67539c2 20 return $localize`unmanaged`;
adb31ebb
TL
21 }
22 const kv: Array<any> = [];
23 const hosts: Array<string> = _.get(serviceSpec, 'placement.hosts');
24 const count: number = _.get(serviceSpec, 'placement.count');
25 const label: string = _.get(serviceSpec, 'placement.label');
26 const hostPattern: string = _.get(serviceSpec, 'placement.host_pattern');
27 if (_.isArray(hosts)) {
28 kv.push(...hosts);
29 }
30 if (_.isNumber(count)) {
f67539c2 31 kv.push($localize`count:${count}`);
adb31ebb
TL
32 }
33 if (_.isString(label)) {
f67539c2 34 kv.push($localize`label:${label}`);
adb31ebb
TL
35 }
36 if (_.isString(hostPattern)) {
b3b6e05e 37 kv.push(hostPattern);
adb31ebb
TL
38 }
39 return kv.join(';');
40 }
41}