From: <sis...@sy...> - 2007-03-08 14:21:42
|
Author: arighi Date: 2007-03-08 08:21:10 -0600 (Thu, 08 Mar 2007) New Revision: 3962 Added: trunk/etc/cluster.xml trunk/sbin/si_pushoverrides Modified: trunk/Makefile trunk/systemimager.spec Log: - added si_pushoverrides command This command can be used to push files from the image server to the clients using the overrides. It uses si_pcp (rsync over SSH) to distribute files to the clients. It is also possible to define node groups and cluster topology using the configuration file /etc/systemimager/cluster.xml. The approach is totally server-driven. Typically this command can be used to distribute configuration files to the clients in a secure way, because the clients don't need to access directly to the image server. Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2007-03-08 14:19:26 UTC (rev 3961) +++ trunk/Makefile 2007-03-08 14:21:10 UTC (rev 3962) @@ -158,7 +158,7 @@ PXE_CONF_SRC = etc/pxelinux.cfg PXE_CONF_DEST = $(ETC)/systemimager/pxelinux.cfg -BINARIES := si_mkautoinstallcd si_mkautoinstalldiskette si_mkautoinstalldisk si_mkbootmedia si_psh si_pcp +BINARIES := si_mkautoinstallcd si_mkautoinstalldiskette si_mkautoinstalldisk si_mkbootmedia si_psh si_pcp si_pushoverrides SBINARIES := si_addclients si_cpimage si_getimage si_mkdhcpserver si_mkdhcpstatic si_mkautoinstallscript si_mkbootserver si_mvimage si_pushupdate si_pushinstall si_rmimage si_mkrsyncd_conf si_mkclientnetboot si_netbootmond si_imagemanip si_mkbootpackage si_monitor si_monitortk si_installbtimage CLIENT_SBINARIES := si_updateclient si_prepareclient COMMON_BINARIES = si_lsimage @@ -372,6 +372,7 @@ $(SI_INSTALL) -m 644 etc/systemimager.conf $(ETC)/systemimager/ $(SI_INSTALL) -m 644 etc/flamethrower.conf $(ETC)/systemimager/ $(SI_INSTALL) -m 644 --backup etc/bittorrent.conf $(ETC)/systemimager/ + $(SI_INSTALL) -m 644 --backup etc/cluster.xml $(ETC)/systemimager/ $(SI_INSTALL) -m 644 etc/autoinstallscript.template $(ETC)/systemimager/ $(SI_INSTALL) -m 644 etc/imagemanip.conf $(ETC)/systemimager/ $(SI_INSTALL) -m 644 etc/imagemanip.perm $(ETC)/systemimager/ Added: trunk/etc/cluster.xml =================================================================== --- trunk/etc/cluster.xml (rev 0) +++ trunk/etc/cluster.xml 2007-03-08 14:21:10 UTC (rev 3962) @@ -0,0 +1,78 @@ +<?xml version='1.0' standalone='yes'?> +<!-- + This is the main configuration file to describe the topology of + your clients and your image server informations. + + This file will be used by the following tools: + - si_psh (SystemImager distributed shell) + - si_pcp (program to distribute files to the clients) + - si_pushoverrides (SystemImager program to transfer and keep + synchronized files to the clients via overrides) +--> +<xml> + <!-- The image server hostname. --> + <master>master1</master> + <!-- + This is the global override: all the files stored into this + override will be pushed to all the clients. + --> + <base_image>all</base_image> + <!-- + Following there is an example of a "fake" group. The group + name is "Local", it uses the override in + /var/lib/systemimager/overrides/Local and it contains only + the localhost server. + --> + <group> + <name>Local</name> + <base_image>Local</base_image> + <node>localhost</node> + </group> + <!-- + This is a group that contains two nodes: node001 and + node002. The group is called "Login" and it uses the + override: + /var/lib/systemimager/overrides/RHEL4_frontend + + All the files present in this overrides will be + distributed to node001 and node002 only using + si_pushoverrides. + --> + <group> + <name>Login</name> + <base_image>SuSE10_frontend</base_image> + <node>node001</node> + <node>node002</node> + </group> + <!-- + Another example. The group Storage contains 16 nodes and + use the override: + /var/lib/systemimager/overrides/RHEL4_Storage + --> + <group> + <name>Storage</name> + <base_image>RHEL4_Storage</base_image> + <node>node1293</node> + <node>node1294</node> + <node>node1295</node> + <node>node1296</node> + <node>node1297</node> + <node>node1298</node> + <node>node1299</node> + <node>node1300</node> + <node>node1301</node> + <node>node1302</node> + <node>node1303</node> + <node>node1304</node> + <node>node1305</node> + <node>node1306</node> + <node>node1307</node> + <node>node1308</node> + </group> + <!-- + Define your custom groups here (and remember to remove + or comment the previouses if you don't want use them). + + ... + --> +</xml> Added: trunk/sbin/si_pushoverrides =================================================================== --- trunk/sbin/si_pushoverrides (rev 0) +++ trunk/sbin/si_pushoverrides 2007-03-08 14:21:10 UTC (rev 3962) @@ -0,0 +1,255 @@ +#!/usr/bin/perl -w +# +# Copyright (C) 2005 Andrea Righi <a....@ci...> +# + +use lib "USR_PREFIX/lib/systemimager/perl"; +use strict; +use Getopt::Long; +use File::Basename; +use XML::Simple; +use SystemImager::Config; +use SystemImager::HostRange; +use vars qw($config $VERSION); + +my $program_name = basename($0); + +my $VERSION = "SYSTEMIMAGER_VERSION_STRING"; + +my $version_info = << "EOF"; +$program_name (part of SystemImager) v$VERSION + +Copyright (C) 2006 Andrea Righi <a.righi\@cineca.it> + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +EOF + +my $help_info = $version_info . << "EOF"; +Usage: $program_name [OPTIONS] ... GROUP_NAME | NODE_NAME ... + +Options: + --help, -h Display this output. + + --version, -V Display version and copyright information. + + --verbose, -v Display verbose informations. + + --dry-run, -d Only show what would have been transferred + without really distributing files. + + --max, -m=NUM Set the maximum number of concurrent copies + to NUM (default=32). + + --timeout, -t=NUM Set the timeout of the sessions (default=15s). + +EOF + +Getopt::Long::Configure("posix_default"); +Getopt::Long::Configure("no_gnu_compat"); +Getopt::Long::Configure("bundling"); + +GetOptions( + "help|h" => \my $help, + "version|V" => \my $version, + "verbose|v" => \my $verbose, + "dry-run|d" => \my $dry_run, + "max|m=i" => \my $concurrents, + "timeout|t=i" => \my $timeout, +) or die($help_info); + +### BEGIN evaluate commad line options ### + +if ($help) { + print "$help_info"; + exit(0); +} + +if ($version) { + print "$version_info"; + exit(0); +} + +if ($verbose) { + $verbose = '-v'; +} else { + $verbose = ''; +} + +if ($dry_run) { + $dry_run = '-d'; +} else { + $dry_run = ''; +} + +if ($concurrents) { + $concurrents = "-m $concurrents"; +} else { + $concurrents = ''; +} + +if ($timeout) { + $timeout = "-t $timeout"; +} else { + $timeout = ''; +} + +# Parse arguments. +unless (@ARGV) { + print $help_info; + exit(1); +} + +### END evaluate command line options ### + +my $database = "/etc/systemimager/cluster.xml"; +my $overrides = $config->default_override_dir(); + +# Parse XML database. +my $xml = XMLin($database, ForceArray => 1); + +my $global_image = $xml->{'base_image'}[0]; +unless (defined($global_image)) { + die("ERROR: global base image undefined in cluster.xml!\n"); +} + +# Execute updates. +foreach my $in (@ARGV) { + my $found = 0; + foreach my $group (@{$xml->{'group'}}) { + if (($group->{'name'}[0] eq $in) or ($in eq $global_image)) { + print "*"x25 . " " . $group->{'name'}[0] . " " . "*"x25 . "\n"; + update_nodes( + $global_image, + $group->{'base_image'}[0], + @{$group->{'node'}}, + ); + $found = 1; + } else { + foreach my $node (@{$group->{'node'}}) { + if ($node eq $in) { + print "*"x25 . " $in " . "*"x25 . "\n"; + update_nodes( + $global_image, + $group->{'base_image'}[0], + $node, + ); + $found = 1; + last; + } + } + } + } + unless ($found) { + print STDERR "WARNING: \"$in\" is not a valid group or node name!\n"; + } +} + +exit(0); + +# Description: +# Wrapper to si_pcp command to push files from the overrides to the +# target nodes. +# +# Usage: +# update_nodes($global_image_name, $group_image_name, @list_of_nodes); +# +sub update_nodes +{ + my ($global_image, $group_image, @nodes) = @_; + + my $node_list = join(',', @nodes); + my $base_cmd = "si_pcp $verbose $dry_run $concurrents $timeout"; + + if (-d "$overrides/$global_image/") { + print "--- $global_image ---\n"; + system("$base_cmd -n $node_list $overrides/$global_image/ /"); + } + if (-d "$overrides/$group_image/") { + print "--- $group_image ---\n"; + system("$base_cmd -n $node_list $overrides/$group_image/ /"); + } + foreach my $node (@nodes) { + if (-d "$overrides/$node/") { + print "--- $node ---\n"; + system("$base_cmd -n $node $overrides/$node/ /"); + } + } +} + +__END__ + +=head1 NAME + +si_pushoverrides - push the overrides from the image server to the clients + +=head1 SYNOPSIS + +si_pushoverrides [OPTIONS] ... GROUP_NAME | NODE_NAME ... + +=head1 DESCRIPTION + +B<si_pushoverrides> is a tool to distribute configuration files from +the image server to the clients or group of them, using the SystemImager +overrides. + +B<si_pushoverrides> accepts a list of group or node names as arguments +and concurrently synchronizes the content of the associated overrides to +them, using a server-drien approach. + +The topology of the cluster can be defined in the configuration file +B</etc/systemimager/cluster.xml>. + +B<si_pushoverrides> transmits only the differences of the files to be +distributed. It uses rsync over SSH based backend to exploit both the +advantages of bandwidth optimization and security. + +=head1 OPTIONS + +=over 8 + +=item B<--help, -h> + +Display a short help. + +=item B<--version, -V> + +Display version and copyright information. + +=item B<--dry-run, -d> + +Only show what would have been transferred without really distributing files. + +=item B<--max, -m NUM> + +Set the maximum number of concurrent sessions to NUM (default=32). + +=item B<--timeout, -t NUM> + +Set the timeout of the sessions (default=15s). + +=head1 SEE ALSO + +systemimager(8), perldoc si_psh, perldoc si_pcp, /etc/systemimager/cluster.xml + +=head1 AUTHOR + +Andrea Righi <a....@ci...>. + +=head1 COPYRIGHT AND LICENSE + +Copyright 2003 by Andrea Righi <a....@ci...>. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +=cut + Property changes on: trunk/sbin/si_pushoverrides ___________________________________________________________________ Name: svn:executable + * Modified: trunk/systemimager.spec =================================================================== --- trunk/systemimager.spec 2007-03-08 14:19:26 UTC (rev 3961) +++ trunk/systemimager.spec 2007-03-08 14:21:10 UTC (rev 3962) @@ -329,6 +329,9 @@ http://developer.osdl.org/kees/software/imagemanip/ %changelog +* Thu Mar 08 2007 Andrea Righi <a....@ci...> +- Added si_pushoverrides command. + * Wed Feb 28 2007 Bernard Li <be...@va...> - Change perl(XML::Simple) dependency to >= 2.14 since starting with that version it correctly has the dependency for perl(XML::Parser) (Noted by Andrew M. Lyons) @@ -860,6 +863,7 @@ %config /etc/systemimager/autoinstallscript.template %config(noreplace) /etc/systemimager/rsync_stubs/* %config(noreplace) /etc/systemimager/systemimager.conf +%config(noreplace) /etc/systemimager/cluster.xml /etc/init.d/systemimager-server-rsyncd /etc/init.d/systemimager-server-netboot* /etc/init.d/systemimager-server-monitord @@ -880,6 +884,7 @@ %prefix/bin/si_mk* %prefix/bin/si_psh %prefix/bin/si_pcp +%prefix/bin/si_pushoverrides %prefix/lib/systemimager/perl/SystemImager/Server.pm %prefix/lib/systemimager/perl/SystemImager/Config.pm %prefix/lib/systemimager/perl/SystemImager/HostRange.pm |