exposed new UIRouter API to get all hosts
Fixes: https://tracker.ceph.com/issues/67413
Signed-off-by: Naman Munet <nmunet@redhat.com>
(cherry picked from commit
ec3e4abeeb7feebd996681a7d8d4e950de5cf518)
Conflicts:
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/nvmeof-listeners-form/nvmeof-listeners-form.component.ts (file deleted)
src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-form/cephfs-form.component.ts (resolved conflicts)
@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 { 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',
this.form.get('name').setValue(this.currentVolumeName);
});
} 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`);
+ }
}