From 89597b5c5875f17e6c82395f388b083a35c6fb11 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 30 Oct 2011 15:12:23 +0100 Subject: [PATCH] Working almost complete benq and rudimentary bq --- BEX.cf | 12 ++++++++++++ lib/BEX/Config.pm | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 BEX.cf create mode 100644 lib/BEX/Config.pm diff --git a/BEX.cf b/BEX.cf new file mode 100644 index 0000000..f749911 --- /dev/null +++ b/BEX.cf @@ -0,0 +1,12 @@ +# Configuration of the Batch EXecutor +# This is a Perl script, which can set anything in the BEX::Config package + +package BEX::Config; + +%machines = ( + 'albireo' => {}, + 'localhost' => {}, + 'home' => ['albireo', 'localhost'], +); + +42; diff --git a/lib/BEX/Config.pm b/lib/BEX/Config.pm new file mode 100644 index 0000000..456dc85 --- /dev/null +++ b/lib/BEX/Config.pm @@ -0,0 +1,50 @@ +# Batch EXecutor 2.0 -- Configuration +# (c) 2011 Martin Mares + +use strict; +use warnings; + +package BEX::Config; + +# This file specifies default values, which can be overridden in BEX.cf + +# A hash of all known machines and groups +# 'name' => { } for a machine +# 'name' => ['a','b','c'] for a group containing specified machines/subgroups +our %machines = ( +); + +# Various utility functions + +sub parse_machine_list(@); + +sub parse_machine_list(@) { + my %set = (); + for my $m (@_) { + if ($m eq '*') { + for my $mm (keys %machines) { + if (ref($machines{$mm}) eq 'HASH') { + $set{$mm} = 1; + } + } + next; + } + my $op = 1; + if ($m =~ s{^!}{}) { $op = 0; } + my $v = $machines{$m}; + if (!defined $v) { + die "Unknown machine or class: $m\n"; + } elsif (ref($v) eq 'HASH') { + $set{$m} = $op; + } elsif (ref($v) eq 'ARRAY') { + for my $mm (parse_machine_list(@$v)) { + $set{$mm} = $op; + } + } + } + return sort grep { $set{$_} } keys %set; +} + +require 'BEX.cf'; + +42; -- 2.39.2