Signed-off-by: cuiyili 2268260388@qq.com --- container/conserver/conserver-head.cf | 16 ++++++++++++ container/conserver/generate_conserver.rb | 30 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 container/conserver/conserver-head.cf create mode 100755 container/conserver/generate_conserver.rb
diff --git a/container/conserver/conserver-head.cf b/container/conserver/conserver-head.cf new file mode 100644 index 0000000..6648f88 --- /dev/null +++ b/container/conserver/conserver-head.cf @@ -0,0 +1,16 @@ +# This is a fairly basic configuration file that interacts with one + +default * { + logfile /srv/cci/serial/logs/&; # '&' is replaced with console name + timestamp 1hab; # write timestamps + rw *; # allow all users + type exec; + master localhost; + portbase 2000; # port numbers start at 2001 and + portinc 100; # go up by 1 (port #1 == 2001, etc) +} + +access * { + trusted 127.0.0.1; +} + diff --git a/container/conserver/generate_conserver.rb b/container/conserver/generate_conserver.rb new file mode 100755 index 0000000..1c120b1 --- /dev/null +++ b/container/conserver/generate_conserver.rb @@ -0,0 +1,30 @@ +#!/usr/bin/env ruby + +# frozen_string_literal: true + +require 'fileutils' +require 'yaml' + +lab = ENV['lab'] +system 'git clone file:///$CCI_REPOS/lab-$lab.git' + +FileUtils.cp('conserver-head.cf', 'conserver.cf') + +def generate_conserver(lab) + hostdir = "lab-#{lab}/hosts/" + return unless Dir.exist?(hostdir) + + puts hostdir + Dir.each_child(hostdir) do |host| + ipmi_ip = YAML.load_file("#{hostdir}#{host}")['ipmi_ip'] + next if ipmi_ip.nil? + + File.open('conserver.cf', 'a') do |f| + f << "console #{host} {\n" + f << " exec /usr/local/bin/ipmi.sh #{ipmi_ip}\n" + f << "}\n" + end + end +end + +generate_conserver(lab)