:type orch_hosts: list of HostSpec
:return list of dict
"""
- _ceph_hosts = copy.deepcopy(ceph_hosts)
- orch_hostnames = {host.hostname for host in orch_hosts}
-
- # hosts in both Ceph and Orchestrator
- for ceph_host in _ceph_hosts:
- if ceph_host['hostname'] in orch_hostnames:
- ceph_host['sources']['orchestrator'] = True
- orch_hostnames.remove(ceph_host['hostname'])
+ hosts = copy.deepcopy(ceph_hosts)
+ orch_hosts_map = {
+ host.hostname: {
+ 'labels': host.labels
+ }
+ for host in orch_hosts
+ }
+
+ # Hosts in both Ceph and Orchestrator
+ for host in hosts:
+ hostname = host['hostname']
+ if hostname in orch_hosts_map:
+ host['labels'] = orch_hosts_map[hostname]['labels']
+ host['sources']['orchestrator'] = True
+ orch_hosts_map.pop(hostname)
# Hosts only in Orchestrator
- orch_sources = {'ceph': False, 'orchestrator': True}
- _orch_hosts = [dict(hostname=hostname, ceph_version='', services=[], sources=orch_sources)
- for hostname in orch_hostnames]
- _ceph_hosts.extend(_orch_hosts)
- return _ceph_hosts
+ orch_hosts_only = [
+ dict(hostname=hostname,
+ ceph_version='',
+ labels=orch_hosts_map[hostname]['labels'],
+ services=[],
+ sources={
+ 'ceph': False,
+ 'orchestrator': True
+ }) for hostname in orch_hosts_map
+ ]
+ hosts.extend(orch_hosts_only)
+ return hosts
def get_hosts(from_ceph=True, from_orchestrator=True):
- """get hosts from various sources"""
+ """
+ Get hosts from various sources.
+ """
ceph_hosts = []
if from_ceph:
- ceph_hosts = [merge_dicts(server, {'sources': {'ceph': True, 'orchestrator': False}})
- for server in mgr.list_servers()]
+ ceph_hosts = [
+ merge_dicts(server, {
+ 'labels': [],
+ 'sources': {
+ 'ceph': True,
+ 'orchestrator': False
+ }
+ }) for server in mgr.list_servers()
+ ]
if from_orchestrator:
orch = OrchClient.instance()
if orch.available():
@ApiController('/host', Scope.HOSTS)
class Host(RESTController):
-
def list(self, sources=None):
if sources is None:
return get_hosts()
import { FinishedTask } from '../../../shared/models/finished-task';
import { Permissions } from '../../../shared/models/permissions';
import { CephShortVersionPipe } from '../../../shared/pipes/ceph-short-version.pipe';
+import { JoinPipe } from '../../../shared/pipes/join.pipe';
import { AuthStorageService } from '../../../shared/services/auth-storage.service';
import { DepCheckerService } from '../../../shared/services/dep-checker.service';
import { TaskWrapperService } from '../../../shared/services/task-wrapper.service';
private authStorageService: AuthStorageService,
private hostService: HostService,
private cephShortVersionPipe: CephShortVersionPipe,
+ private joinPipe: JoinPipe,
private i18n: I18n,
private urlBuilder: URLBuilderService,
private actionLabels: ActionLabelsI18n,
flexGrow: 3,
cellTemplate: this.servicesTpl
},
+ {
+ name: this.i18n('Labels'),
+ prop: 'labels',
+ flexGrow: 1,
+ pipe: this.joinPipe
+ },
{
name: this.i18n('Version'),
prop: 'ceph_version',