2020-03-05 16:30:24 +00:00
|
|
|
const State = require('../State')
|
|
|
|
|
|
|
|
class CommandState extends State {
|
|
|
|
static get services() {
|
|
|
|
return [...super.services, 'output']
|
|
|
|
}
|
|
|
|
|
|
|
|
async apply() {
|
|
|
|
const cmd = `${this._config.cmd}`
|
|
|
|
await this._host.run(cmd)
|
|
|
|
}
|
|
|
|
|
|
|
|
async check() {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
async reverse() {
|
|
|
|
if ( this._config.reverse ) {
|
|
|
|
const cmd = `${this._config.reverse}`
|
|
|
|
await this._host.run(cmd)
|
2020-03-05 17:48:38 +00:00
|
|
|
} else {
|
|
|
|
this.output.warn(`No reversal command specified for Command State. Nothing was changed. (Host: ${this._host.name})`)
|
2020-03-05 16:30:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-15 14:11:10 +00:00
|
|
|
failure_message() {
|
|
|
|
return `Failed to execute the command "${this._config.cmd}" on host "${this._host.name}."`
|
|
|
|
}
|
|
|
|
|
|
|
|
check_message() {
|
|
|
|
return `The command check was not successful.`
|
|
|
|
}
|
2020-03-05 16:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = exports = CommandState
|