summaryrefslogtreecommitdiff
path: root/lib/oxidized/input/cli.rb
blob: 8daddac998a7d53e5236249c46ea9ce26d0a1dcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module Oxidized
  class Input
    module CLI
  
      def initialize
        @post_login = []
        @pre_logout = []
      end

      def get
        @post_login.each { |command, block| block ? block.call : (cmd command) }
        d = @node.model.get
        disconnect
        d
      end

      def disconnect_cli
        @pre_logout.each { |command, block| block ? block.call : (cmd command) }
      end
  
      def post_login _post_login=nil, &block
        unless @exec
          @post_login << [_post_login, block]
        end
      end
  
      def pre_logout _pre_logout=nil, &block
        unless @exec
          @pre_logout <<  [_pre_logout, block]
        end
      end
    end
  end
end