summaryrefslogtreecommitdiffstats
path: root/lib/OpenSLX/Utils.pm
diff options
context:
space:
mode:
authorOliver Tappe2007-08-15 17:36:56 +0200
committerOliver Tappe2007-08-15 17:36:56 +0200
commitcfe31ca7acca396c4f2744114c08fc0802cef5c3 (patch)
treed7d3c8631b65547c9636ec8c0743f089531e4edf /lib/OpenSLX/Utils.pm
parentCleaned up and corrected error messages (and german translations, see (diff)
downloadcore-cfe31ca7acca396c4f2744114c08fc0802cef5c3.tar.gz
core-cfe31ca7acca396c4f2744114c08fc0802cef5c3.tar.xz
core-cfe31ca7acca396c4f2744114c08fc0802cef5c3.zip
* switched from perl-based distro-configuration files to "real" configuration
files (handled by Config::General) * removed most version specific distribution modules (only Debian-3.1 remains as it requires some special treatment). For all the other distributions, the specific info is now contained in the configuration files * added configuration files (settings.default) for every supported distribution (only Fedora is still missing some info) * added support for inclusion of (externally generated) mirror lists and automatic selection of the five best (fastest) mirrors from that list (20 are tried). For each repository, a mirror configuration file is created (in /etc/opt/openslx/distro-info/<distro>/mirrors/<repo>) after that info has been gathered. * added current mirror lists for each distribution repository to the distro-info hierarchy * updated settings.example to reflect new configuration syntax git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1322 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'lib/OpenSLX/Utils.pm')
-rw-r--r--lib/OpenSLX/Utils.pm46
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/OpenSLX/Utils.pm b/lib/OpenSLX/Utils.pm
index bc57078a..86c31ca9 100644
--- a/lib/OpenSLX/Utils.pm
+++ b/lib/OpenSLX/Utils.pm
@@ -30,12 +30,16 @@ $VERSION = 1.01;
unshiftHereDoc
string2Array
chrootInto
+ mergeHash
+ getFQDN
);
################################################################################
### Module implementation
################################################################################
use File::Basename;
+use Socket;
+use Sys::Hostname;
use OpenSLX::Basics;
@@ -230,4 +234,46 @@ sub chrootInto
return;
}
+sub mergeHash
+{
+ my $targetHash = shift;
+ my $sourceHash = shift;
+ my $fillOnly = shift || 0;
+
+ foreach my $key (keys %{$sourceHash}) {
+ my $sourceVal = $sourceHash->{$key};
+ if (ref($sourceVal) eq 'HASH') {
+ if (!exists $targetHash->{$key}) {
+ $targetHash->{$key} = {};
+ }
+ mergeHash($targetHash->{$key}, $sourceVal);
+ }
+ elsif (ref($sourceVal) eq 'ARRAY') {
+ if (!exists $targetHash->{$key}) {
+ $targetHash->{$key} = [];
+ }
+ foreach my $val (@{$sourceHash->{$key}}) {
+ my $targetVal = {};
+ push @{$targetHash->{$key}}, $targetVal;
+ mergeHash($targetVal, $sourceVal);
+ }
+ }
+ else {
+ next if $fillOnly && exists $targetHash->{$key};
+ $targetHash->{$key} = $sourceVal;
+ }
+ }
+}
+
+sub getFQDN
+{
+ my $hostName = hostname();
+
+ my $hostAddr = gethostbyname($hostName)
+ or die(_tr("unable to get address of host '%s'", $hostName));
+ my $FQDN = gethostbyaddr($hostAddr, AF_INET)
+ or die(_tr("unable to get dns-name of address '%s'", $hostAddr));
+ return $FQDN;
+}
+
1;