Class: OsCtld::Commands::Logged

Inherits:
Base
  • Object
show all
Defined in:
lib/osctld/commands/logged.rb

Overview

Command template for commands that are to be logged to pool's history

When logging to history, we need to know which pool the command works with. #find should return an object that responds to `pool`, or raise exception. Base#execute is then called with the return value of #find as the first argument. If Base#execute returns success, the command will be logged.

Instance Attribute Summary

Attributes inherited from Base

#client, #client_handler, #id, #opts

Instance Method Summary collapse

Methods inherited from Base

#call_cmd, #call_cmd!, cmd, #error, #error!, #execute, handle, #handled, #indirect?, #initialize, #manipulate, #manipulation_holder, #ok, #progress, #request_stop, run, run!

Constructor Details

This class inherits a constructor from OsCtld::Commands::Base

Instance Method Details

#base_executeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/osctld/commands/logged.rb', line 11

def base_execute
  obj = find

  if obj.is_a?(Pool)
    pool = obj
  else
    pool = obj.pool
  end

  ret = execute(obj)

  if ret.is_a?(Hash) && ret[:status] && !indirect?
    History.log(pool, self.class.cmd, opts)
  end

  ret
end

#findObject

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/osctld/commands/logged.rb', line 29

def find
  raise NotImplementedError
end