]> mj.ucw.cz Git - bex.git/commitdiff
Working almost complete benq and rudimentary bq
authorMartin Mares <mj@ucw.cz>
Sun, 30 Oct 2011 14:12:23 +0000 (15:12 +0100)
committerMartin Mares <mj@ucw.cz>
Sun, 30 Oct 2011 14:12:23 +0000 (15:12 +0100)
BEX.cf [new file with mode: 0644]
lib/BEX/Config.pm [new file with mode: 0644]

diff --git a/BEX.cf b/BEX.cf
new file mode 100644 (file)
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 (file)
index 0000000..456dc85
--- /dev/null
@@ -0,0 +1,50 @@
+# Batch EXecutor 2.0 -- Configuration
+# (c) 2011 Martin Mares <mj@ucw.cz>
+
+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;