2018-02-16 19:02:43 +00:00
|
|
|
import Watchable from './watchable';
|
2019-10-25 00:52:34 +00:00
|
|
|
import addToPath from 'nomad-ui/utils/add-to-path';
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2019-10-25 00:52:34 +00:00
|
|
|
export default Watchable.extend({
|
|
|
|
setEligible(node) {
|
|
|
|
return this.setEligibility(node, true);
|
|
|
|
},
|
|
|
|
|
|
|
|
setIneligible(node) {
|
|
|
|
return this.setEligibility(node, false);
|
|
|
|
},
|
|
|
|
|
|
|
|
setEligibility(node, isEligible) {
|
|
|
|
const url = addToPath(this.urlForFindRecord(node.id, 'node'), '/eligibility');
|
|
|
|
return this.ajax(url, 'POST', {
|
|
|
|
data: {
|
|
|
|
NodeID: node.id,
|
|
|
|
Eligibility: isEligible ? 'eligible' : 'ineligible',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
2019-10-25 02:58:18 +00:00
|
|
|
|
|
|
|
// Force: -1s deadline
|
|
|
|
// No Deadline: 0 deadline
|
|
|
|
drain(node, drainSpec) {
|
|
|
|
const url = addToPath(this.urlForFindRecord(node.id, 'node'), '/drain');
|
|
|
|
return this.ajax(url, 'POST', {
|
|
|
|
data: Object.assign(
|
|
|
|
{
|
|
|
|
NodeID: node.id,
|
|
|
|
Deadline: 0,
|
|
|
|
IgnoreSystemJobs: true,
|
|
|
|
},
|
|
|
|
drainSpec
|
|
|
|
),
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
forceDrain(node, drainSpec) {
|
|
|
|
return this.drain(
|
|
|
|
node,
|
|
|
|
Object.assign({}, drainSpec, {
|
|
|
|
Deadline: -1000 * 1000000,
|
|
|
|
})
|
|
|
|
);
|
|
|
|
},
|
2019-10-25 00:52:34 +00:00
|
|
|
});
|