Ravn::CLI::
Changes
module
Command line interface to the HEAK change queue
Common preamble for all subcommands.
15 def self::preamble
16 require 'ravn/tactical'
17 require 'ravn/tactical/model'
18 require 'ravn/tactical/change'
19 require 'ravn/tactical/change_runner'
20
21 unless Ravn::Tactical::Change.table_exists?
22 exit_now!( "No Tactical database; use `ravn tactical install_db` to install one." )
23 end
24 end
display_changes( changes )
Display the specified changes
in a readable form.
115 def display_changes( changes )
116 if changes.empty?
117 prompt.say( "No pending changes." )
118 return
119 end
120
121 table = TTY::Table.new( ['ID', 'Node', 'Op', 'Time'], [] )
122
123 changes.each do |change|
124 row = [ change.id, change.node.device_id, change.type, change.created_at ]
125 self.log.debug "Adding row: %p" % [ row ]
126 table << row
127 end
128
129 prompt.say( headline_string "Pending changes:" )
130 prompt.say( table.render(:unicode, padding: [0, 1]) )
131 end
run_until_changes_are_done()
Run the ChangeRunner until there are no more changes.
135 def run_until_changes_are_done
136 Ravn::Tactical::Discovery.start
137 Ravn::Tactical::ChangeRunner.run_until_complete
138 Ravn::Tactical::Discovery.stop
139 end