@raise_if_no_orchestrator
@handle_orchestrator_error('host')
- @host_task('add', {'hostname': '{hostname}'})
+ @host_task('create', {'hostname': '{hostname}'})
def create(self, hostname):
orch_client = OrchClient.instance()
self._check_orchestrator_host_op(orch_client, hostname, True)
@raise_if_no_orchestrator
@handle_orchestrator_error('host')
- @host_task('remove', {'hostname': '{hostname}'})
+ @host_task('delete', {'hostname': '{hostname}'})
def delete(self, hostname):
orch_client = OrchClient.instance()
self._check_orchestrator_host_op(orch_client, hostname, False)
import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
+import { Router } from '@angular/router';
import { I18n } from '@ngx-translate/i18n-polyfill';
import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
import { HostService } from '../../../shared/api/host.service';
-import { OrchestratorService } from '../../../shared/api/orchestrator.service';
import { CriticalConfirmationModalComponent } from '../../../shared/components/critical-confirmation-modal/critical-confirmation-modal.component';
import { ActionLabelsI18n } from '../../../shared/constants/app.constants';
import { Icons } from '../../../shared/enum/icons.enum';
import { Permissions } from '../../../shared/models/permissions';
import { CephShortVersionPipe } from '../../../shared/pipes/ceph-short-version.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';
import { URLBuilderService } from '../../../shared/services/url-builder.service';
columns: Array<CdTableColumn> = [];
hosts: Array<object> = [];
isLoadingHosts = false;
- orchestratorAvailable = false;
cdParams = { fromLink: '/hosts' };
tableActions: CdTableAction[];
selection = new CdTableSelection();
private actionLabels: ActionLabelsI18n,
private modalService: BsModalService,
private taskWrapper: TaskWrapperService,
- private orchService: OrchestratorService
+ private router: Router,
+ private depCheckerService: DepCheckerService
) {
this.permissions = this.authStorageService.getPermissions();
this.tableActions = [
{
- name: this.actionLabels.ADD,
+ name: this.actionLabels.CREATE,
permission: 'create',
icon: Icons.add,
- routerLink: () => this.urlBuilder.getAdd(),
- disable: () => !this.orchestratorAvailable,
- disableDesc: () => this.getDisableDesc()
+ click: () => {
+ this.depCheckerService.checkOrchestratorOrModal(
+ this.actionLabels.CREATE,
+ this.i18n('Host'),
+ () => {
+ this.router.navigate([this.urlBuilder.getCreate()]);
+ }
+ );
+ }
},
{
- name: this.actionLabels.REMOVE,
+ name: this.actionLabels.DELETE,
permission: 'delete',
icon: Icons.destroy,
- click: () => this.deleteHostModal(),
- disable: () => !this.orchestratorAvailable || !this.selection.hasSelection,
- disableDesc: () => this.getDisableDesc()
+ click: () => {
+ this.depCheckerService.checkOrchestratorOrModal(
+ this.actionLabels.DELETE,
+ this.i18n('Host'),
+ () => this.deleteHostModal()
+ );
+ },
+ disable: () => !this.selection.hasSelection
}
];
}
pipe: this.cephShortVersionPipe
}
];
-
- this.orchService.status().subscribe((data: { available: boolean }) => {
- this.orchestratorAvailable = data.available;
- });
}
updateSelection(selection: CdTableSelection) {
initialState: {
itemDescription: 'Host',
itemNames: [hostname],
- actionDescription: 'remove',
+ actionDescription: 'delete',
submitActionObservable: () =>
this.taskWrapper.wrapTaskAroundCall({
- task: new FinishedTask('host/remove', { hostname: hostname }),
- call: this.hostService.remove(hostname)
+ task: new FinishedTask('host/delete', { hostname: hostname }),
+ call: this.hostService.delete(hostname)
})
}
});
}
);
}
-
- getDisableDesc() {
- if (!this.orchestratorAvailable) {
- return this.i18n('Host operation is disabled because orchestrator is unavailable');
- }
-
- return undefined;
- }
}
from orchestrator import InventoryFilter, DeviceLightLoc, Completion
from orchestrator import ServiceDescription, DaemonDescription
from orchestrator import OrchestratorClientMixin, raise_if_exception, OrchestratorError
+from orchestrator import HostSpec
from .. import mgr
from ..tools import wraps
class HostManger(ResourceManager):
@wait_api_result
- def list(self):
+ def list(self) -> List[HostSpec]:
return self.api.get_hosts()
- def get(self, hostname):
- hosts = [host for host in self.list() if host.name == hostname]
+ def get(self, hostname: str) -> Optional[HostSpec]:
+ hosts = [host for host in self.list() if host.hostname == hostname]
return hosts[0] if hosts else None
@wait_api_result
- def add(self, hostname):
- return self.api.add_host(hostname)
+ def add(self, hostname: str):
+ return self.api.add_host(HostSpec(hostname))
@wait_api_result
- def remove(self, hostname):
+ def remove(self, hostname: str):
return self.api.remove_host(hostname)