Signed-off-by: cuiyili 2268260388@qq.com --- container/conserver/conserver-head.cf | 16 ++++++++++++ container/conserver/generate_conserver.rb | 32 +++++++++++++++++++++++ 2 files changed, 48 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..285c393 --- /dev/null +++ b/container/conserver/generate_conserver.rb @@ -0,0 +1,32 @@ +#!/usr/bin/env ruby +# SPDX-License-Identifier: MulanPSL-2.0+ +# frozen_string_literal: true + +require 'fileutils' +require 'yaml' + +lab = ENV['lab'] +system 'git clone file:///$CCI_REPOS/lab-$lab.git' + +def generate_conserver(lab) + return unless File.exist?('conserver-head.cf') + + FileUtils.cp('conserver-head.cf', 'conserver.cf') + + host_dir = "lab-#{lab}/hosts/" + return unless Dir.exist?(host_dir) + + Dir.each_child(host_dir) do |host| + ipmi_ip = YAML.load_file("#{host_dir}#{host}")['ipmi_ip'] + next if ipmi_ip.nil? + + console = <<~HEREDOC + console #{host} { + exec /usr/local/bin/ipmi.sh #{ipmi_ip}; + } + HEREDOC + File.open('conserver.cf', 'a') { |f| f << console } + end +end + +generate_conserver(lab)