Class: Nucleon::Action::Node::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/nucleon/action/node/status.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.describeObject


Info



10
11
12
# File 'lib/nucleon/action/node/status.rb', line 10

def self.describe
  super(:node, :status, 800)
end

Instance Method Details

#argumentsObject



31
32
33
# File 'lib/nucleon/action/node/status.rb', line 31

def arguments
  [ :status_nodes ]
end

#configureObject


Settings



17
18
19
20
21
22
23
# File 'lib/nucleon/action/node/status.rb', line 17

def configure
  super do
    register_nodes :status_nodes, []
    
    register_bool :basic
  end
end

#executeObject


Operations



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/nucleon/action/node/status.rb', line 38

def execute
  super do |local_node|
    ensure_network do
      settings[:status_nodes] = [ 'all' ] if settings[:status_nodes].empty?
      
      batch_success = network.batch(settings[:status_nodes], settings[:node_provider], settings[:parallel]) do |node|
        state       = node.state(true)
        state       = state.nil? ? :aborted : state.to_sym
        ssh_enabled = ''
        
        case state
        when :running, :active
          state = green(state.to_s)
          
          unless settings[:basic]
            result = node.cli.test :true
          
            if result.status == code.success
              ssh_enabled = '[ ' + green('connected') + ' ]'
            else
              ssh_enabled = '[ ' + red('connection failed') + ' ]'      
            end
          end
          
        when :stopped, :aborted
          state = red(state.to_s)
        end
        info(state.to_s + " #{ssh_enabled}".rstrip, { :i18n => false, :prefix_text => yellow(node.plugin_provider) + ' ' + purple(node.plugin_name) })
        true
      end
      success = network.save({ :push => true, :remote => :edit, :message => "Updating node status information.", :allow_empty => true })
      myself.status = code.batch_error unless batch_success && success
    end
  end
end

#ignoreObject




27
28
29
# File 'lib/nucleon/action/node/status.rb', line 27

def ignore
  [ :nodes ]
end