@handle_orchestrator_error('host')
def inventory(self, refresh=None):
return get_inventories(None, refresh)
+
+ @Endpoint('GET')
+ @ReadPermission
+ @raise_if_no_orchestrator([OrchFeature.HOST_LIST])
+ @handle_orchestrator_error('host')
+ def list(self):
+ """
+ Get all hosts.
+ This endpoint is introduced to get all the available hosts in cases where
+ service instance is not needed (ex: hosts selection in forms), and also
+ get_hosts method helps in caching the response which makes it performant.
+ """
+ return get_hosts()
import { CdValidators } from '~/app/shared/forms/cd-validators';
import { DimlessBinaryPipe } from '~/app/shared/pipes/dimless-binary.pipe';
import { HostService } from '~/app/shared/api/host.service';
-import { CdTableFetchDataContext } from '~/app/shared/models/cd-table-fetch-data-context';
+import { DaemonService } from '~/app/shared/api/daemon.service';
+import { map } from 'rxjs/operators';
+import { forkJoin } from 'rxjs';
+
@Component({
selector: 'cd-nvmeof-listeners-form',
templateUrl: './nvmeof-listeners-form.component.html',
private route: ActivatedRoute,
public activeModal: NgbActiveModal,
public formatterService: FormatterService,
- public dimlessBinaryPipe: DimlessBinaryPipe
+ public dimlessBinaryPipe: DimlessBinaryPipe,
+ private daemonService: DaemonService
) {
this.permission = this.authStorageService.getPermissions().nvmeof;
this.hostPermission = this.authStorageService.getPermissions().hosts;
}
setHosts() {
- const hostContext = new CdTableFetchDataContext(() => undefined);
- this.hostService.list(hostContext.toParams(), 'false').subscribe((resp: any[]) => {
- const nvmeofHosts = resp.filter((r) =>
- r.service_instances.some((si: any) => si.type === 'nvmeof')
- );
- this.hosts = nvmeofHosts.map((h) => ({ hostname: h.hostname, addr: h.addr }));
- });
+ forkJoin({
+ daemons: this.daemonService.list(['nvmeof']),
+ hosts: this.hostService.getAllHosts()
+ })
+ .pipe(
+ map(({ daemons, hosts }) => {
+ const hostNamesFromDaemon = daemons.map((daemon: any) => daemon.hostname);
+ return hosts.filter((host: any) => hostNamesFromDaemon.includes(host.hostname));
+ })
+ )
+ .subscribe((nvmeofHosts: any[]) => {
+ this.hosts = nvmeofHosts.map((h) => ({ hostname: h.hostname, addr: h.addr }));
+ });
}
ngOnInit() {
import { FinishedTask } from '~/app/shared/models/finished-task';
import { Permission } from '~/app/shared/models/permissions';
import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
-import { CdTableFetchDataContext } from '~/app/shared/models/cd-table-fetch-data-context';
@Component({
selector: 'cd-cephfs-form',
}
});
} else {
- const hostContext = new CdTableFetchDataContext(() => undefined);
- this.hostService.list(hostContext.toParams(), 'false').subscribe((resp: object[]) => {
+ this.hostService.getAllHosts().subscribe((resp: object[]) => {
const options: SelectOption[] = [];
_.forEach(resp, (host: object) => {
if (_.get(host, 'sources.orchestrator', false)) {
import { CdFormBuilder } from '~/app/shared/forms/cd-form-builder';
import { CdFormGroup } from '~/app/shared/forms/cd-form-group';
import { CdValidators } from '~/app/shared/forms/cd-validators';
-import { CdTableFetchDataContext } from '~/app/shared/models/cd-table-fetch-data-context';
import { FinishedTask } from '~/app/shared/models/finished-task';
import { CephServiceSpec } from '~/app/shared/models/service.interface';
import { ModalService } from '~/app/shared/services/modal.service';
this.serviceTypes = _.difference(resp, this.hiddenServices).sort();
});
- const hostContext = new CdTableFetchDataContext(() => undefined);
- this.hostService.list(hostContext.toParams(), 'false').subscribe((resp: object[]) => {
+ this.hostService.getAllHosts().subscribe((resp: object[]) => {
const options: SelectOption[] = [];
_.forEach(resp, (host: object) => {
if (_.get(host, 'sources.orchestrator', false)) {
import _ from 'lodash';
import { SelectMessages } from '~/app/shared/components/select/select-messages.model';
import { HostService } from '~/app/shared/api/host.service';
-import { CdTableFetchDataContext } from '~/app/shared/models/cd-table-fetch-data-context';
import { SelectOption } from '~/app/shared/components/select/select-option.model';
import { Observable, Subject, merge } from 'rxjs';
import { debounceTime, distinctUntilChanged, filter, map } from 'rxjs/operators';
this.zoneNames = this.zoneList.map((zone) => {
return zone['name'];
});
- const hostContext = new CdTableFetchDataContext(() => undefined);
- this.hostService.list(hostContext.toParams(), 'false').subscribe((resp: object[]) => {
+ this.hostService.getAllHosts().subscribe((resp: object[]) => {
const options: SelectOption[] = [];
_.forEach(resp, (host: object) => {
if (_.get(host, 'sources.orchestrator', false)) {
})
);
}
+
+ getAllHosts(): Observable<object[]> {
+ return this.http.get<object[]>(`${this.baseUIURL}/list`);
+ }
}