@openshift-assisted/ui-lib
Version:
React component library for the Assisted Installer UI
75 lines • 2.72 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const apis_1 = require("../services/apis");
const HostsService = {
/**
* Removes all the hosts in the list assuming
* all of them have a valid infraEnvId value.
* @param hosts
*/
removeAll(hosts) {
const promises = [];
for (const { id, infraEnvId } of hosts) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
promises.push(apis_1.HostsAPI.deregister(infraEnvId, id));
}
return Promise.all(promises);
},
update(host, params) {
apis_1.HostsAPI.abortLastGetRequest();
if (!host.infraEnvId) {
throw new Error(`Cannot update host ${host.id}, missing infraEnvId`);
}
return apis_1.HostsAPI.update(host.infraEnvId, host.id, params);
},
updateHostName(host, newHostName) {
return HostsService.update(host, { hostName: newHostName });
},
updateRole(host, newHostRole) {
return HostsService.update(host, { hostRole: newHostRole });
},
updateHostODF(host, newNodeLabels) {
return HostsService.update(host, { nodeLabels: newNodeLabels }); //need to edit that
},
updateDiskRole(host, diskId, newDiskRole) {
const params = {
disksSelectedConfig: [{ id: diskId, role: newDiskRole }],
};
if (newDiskRole === 'install') {
params.disksSkipFormatting = [{ diskId, skipFormatting: false }];
}
return HostsService.update(host, params);
},
updateFormattingDisks(host, diskIdValue, shouldSkipFormat) {
return HostsService.update(host, {
disksSkipFormatting: [{ diskId: diskIdValue, skipFormatting: shouldSkipFormat }],
});
},
delete(host) {
if (!host.infraEnvId) {
throw new Error(`Cannot delete host ${host.id}, missing infraEnvId`);
}
return apis_1.HostsAPI.deregister(host.infraEnvId, host.id);
},
reset(host) {
if (!host.infraEnvId) {
throw new Error(`Cannot reset host ${host.id}, missing infraEnvId`);
}
return apis_1.HostsAPI.reset(host.infraEnvId, host.id);
},
install(host) {
if (!host.infraEnvId) {
throw new Error(`Cannot install host ${host.id}, missing infraEnvId`);
}
return apis_1.HostsAPI.installHost(host.infraEnvId, host.id);
},
installAll(hosts) {
const promises = [];
for (const host of hosts) {
promises.push(HostsService.install(host));
}
return Promise.all(promises);
},
};
exports.default = HostsService;
//# sourceMappingURL=HostsService.js.map