You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by jf...@apache.org on 2008/12/12 19:20:18 UTC

svn commit: r726079 [2/32] - in /incubator/vcl/tags/import: ./ managementnode/ managementnode/bin/ managementnode/etc/ managementnode/etc/vcl/ managementnode/legacy_vcl_vbs_scripts/ managementnode/lib/ managementnode/lib/VCL/ managementnode/lib/VCL/Mod...

Added: incubator/vcl/tags/import/managementnode/bin/vclclientd
URL: http://svn.apache.org/viewvc/incubator/vcl/tags/import/managementnode/bin/vclclientd?rev=726079&view=auto
==============================================================================
--- incubator/vcl/tags/import/managementnode/bin/vclclientd (added)
+++ incubator/vcl/tags/import/managementnode/bin/vclclientd Fri Dec 12 10:20:10 2008
@@ -0,0 +1,1014 @@
+#!/usr/bin/perl -w
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+##############################################################################
+# $Id: vclclientd 1954 2008-12-12 14:46:02Z arkurth $
+##############################################################################
+
+=head1 NAME
+
+vclclientd
+
+=head1 SYNOPSIS
+
+ perl vclclientd
+
+=head1 DESCRIPTION
+
+ This is the executable module for running the VCL client daemon on Linux lab
+ machines.
+
+=cut
+
+##############################################################################
+
+use strict;
+use Getopt::Long;
+use diagnostics;
+use Symbol;
+use POSIX;
+
+$|=1; # turning off autoflush
+
+# -- DEVELOPMENT testing
+#my $PIDFILE = "/var/run/vcldev.pid";
+#our $LOG = "/var/log/vcldev.log";
+
+# GLOBALS
+our $HOME = "/home/vclstaff";
+our $VCLFLAG = "$HOME/flag";
+our $CLIENTDATA = "$HOME/clientdata";
+our $PIDFILE ="/var/run/vclclientd.pid";
+our %children               = ();       # keys are current child process IDs
+our $children               = 0;        # current number of children
+our $LOG = "/var/log/vclclientd.log";
+our %ERRORS=('DEPENDENT'=>4,'UNKNOWN'=>3,'OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'MAILMASTERS'=>5);
+our $opt_d='';
+
+Getopt::Long::Configure('bundling', 'no_ignore_case');
+GetOptions('d|debug' => \$opt_d );
+if(!$opt_d){
+    #daemonize
+    &daemonize;
+}
+
+
+sub daemonize {                                                 
+   chdir '/'    or die "Can't chdir to /: $!";
+   defined(my $pid = fork) or die "Can't fork $!";
+   exit if $pid;
+   #production
+   $0 = "vclclientd";
+   print "Created process $$ renamed to $0 ...\n";
+   setsid  or die "Can't start a new session: $!";
+   open STDIN, '/dev/null' or die "Can't read /dev/null $!";
+   open STDOUT, '>>$LOG' or die "Can't write $LOG $!";
+   open STDERR, '>>$LOG' or die "Can't write $LOG $!";
+   umask 0;
+   open(PIDFILE, ">$PIDFILE"); # so I can kill myself easily
+   print PIDFILE $$;
+   close(PIDFILE);
+
+}
+
+
+#------- Subroutine declarations -------
+sub main();                   # main calls primary subroutines
+sub flag;
+sub processdata;
+sub startsshd;
+sub makedatestring;
+sub reboot;
+sub fetch;
+sub store;
+sub sshdstatus;
+sub createnewssh_config_vcl;
+sub restartsshd;
+
+sub REAPER {                        # takes care of dead children
+       $SIG{CHLD} = \&REAPER;
+       my $pid = wait;
+       if(exists $children{$pid}){
+        $children--;
+        notify($ERRORS{'OK'},"$pid -- child process exiting, deleting $pid ");
+        delete $children{$pid};
+       }
+       else{
+          notify($ERRORS{'OK'},"$pid -- sub process exiting");
+       }
+       
+}
+
+sub HUNTSMAN {                      # signal handler for SIGINT
+   local($SIG{CHLD}) = 'IGNORE';   # we're going to kill our child processes
+   kill 'INT' => keys %children;
+   notify($ERRORS{'OK'},"$$ -- process exiting");
+   exit;                           # clean up with dignity
+}
+
+# Install signal handlers.
+$SIG{CHLD} = \&REAPER;
+$SIG{INT}  = \&HUNTSMAN;
+$SIG{QUIT} = \&HUNTSMAN;
+$SIG{HUP} = \&HUNTSMAN;
+$SIG{TERM} = \&HUNTSMAN;
+
+main();
+
+sub main () {
+    #preplogfile;
+    #my @hostinfo = hostname;
+    #make sure vclstaff owns authorized_keys and log file
+   if(open(AUTHFILE,"chown vclstaff:root /home/vclstaff/authorized_keys 2>&1 |")){
+      notify($ERRORS{'OK'},"main: setting vclstaff ownership of /home/vclstaff/authorized_keys");
+      close(AUTHFILE);
+   }
+   if(open(LOGFILE,"chown vclstaff:root /var/log/vclclientd.log 2>&1 |")){
+      notify($ERRORS{'OK'},"main: setting vclstaff ownership of /var/log/vclclientd.log");
+      close(LOGFILE);
+   }     
+   if(!(-r "/etc/users.local.admin")){
+      notify($ERRORS{'OK'},"main: /etc/users.local.admin does not exist creating");
+      if(open(COPY, "/bin/cp /etc/users.local /etc/users.local.admin |")){
+         close(COPY);
+         if(-r "/etc/users.local.admin"){
+            notify($ERRORS{'OK'},"main: /etc/users.local.admin exist now");
+         }
+      }
+
+   }
+   #on startup check to see if someone has rebooted us. this is a hack
+   #we just need to figure out if this a reboot or a restart
+   #for now we are just going to look at the output of last -- there has
+   #to be a better way
+   if(open(LAST,"/usr/bin/last 2>&1 |")){
+      my @last =<LAST>;
+      close(LAST);
+      if($last[0] =~ /reboot/ || $last[1] =~ /reboot/){
+       if( -r "$CLIENTDATA"){
+           if(open(CLD, "$CLIENTDATA")){
+             my @file = <CLD>;
+              close(CLD);
+             if($file[0] =~ /new/){
+                if(open(FLAG, ">$VCLFLAG")){
+                   print FLAG 1;
+                   close(FLAG);
+                    notify($ERRORS{'OK'},"main: possibly a reboot setting flag to 1 for reinitializing");
+                 }#flag
+             }#new
+          }#CLD
+          else{
+              notify($ERRORS{'OK'},"main: could not open $CLIENTDATA");
+          }
+       }# readable
+      }# last -- reboot
+   }
+
+   
+    while(1){
+       if( flag ){
+             notify($ERRORS{'OK'},"main: flag is set proceed to process");
+             #make sure clientdata is readable
+             if(-r $CLIENTDATA){
+                #process data
+                if(open(CLIENTDATA,"$CLIENTDATA")){
+                   my %request=();
+                   my @lines = <CLIENTDATA>;
+                   close(CLIENTDATA);
+                   $request{"state"}=$lines[0];
+                   $request{"unityid"}=$lines[1];
+                   $request{"remoteIP"}=$lines[2];
+                   chomp($request{"state"});
+                   chomp($request{"unityid"});
+                   chomp($request{"remoteIP"});
+
+                   make_new_child(%request) if($request{"state"} =~ /new|timeout|delete/);
+                   reboot() if($request{"state"} =~ /reboot/);
+                   fetch() if($request{"state"} =~ /fetch/);
+                   store() if($request{"state"} =~ /store/);
+                }
+                else{
+                   notify($ERRORS{'OK'},"main: could not open $CLIENTDATA: $!");
+                   
+                }
+             }  #if -r
+          } #if flag
+          else{
+            #check for any hung children
+            #kill fork process and reset flag? does this create a race condition
+            #could keep track of killed processes in children hash when number exceeds X (reboot machine?)
+            #notify($ERRORS{'OK'},"main: number of children  $children");
+             foreach my $p (keys %children) {
+                next if($p=~ /hung/);
+                notify($ERRORS{'OK'},"main: pid = $p");
+                $children{"hungtries"}{"count"}+=1;
+                if(open(KILL,"kill -9 $p 2>&1 |")){
+                   notify($ERRORS{'OK'},"main: stopping forked process in an attempt to reset");
+                   my $k = <KILL>;
+                   close(KILL);
+                   if($k =~ /No such process/){
+                      #not found maybe I was too guick to judge
+                      #let it ride
+                   }
+                   else{
+                      if($children{"hungtries"}{"count"} > 4){
+                         notify($ERRORS{'OK'},"main: hung process attempts are greater than 4 rebooting");
+                         reboot();
+                      }
+                      if(open(ECHO,"echo 1 > /home/vclstaff/flag |")){
+                        notify($ERRORS{'OK'},"main: attempt to reset initiated");
+                        close(ECHO);
+                      }
+                   }
+                }
+             }
+
+          }
+          sleep 5;
+      } #while
+}
+sub flag {
+    if(!(-e $VCLFLAG)){
+       # warning flag does not exist
+       #create it and continue
+       if(open(FLAG, ">$VCLFLAG")){
+          print FLAG 0;
+          notify($ERRORS{'OK'}, "had to create $VCLFLAG");
+          close(FLAG);
+          if(open(LOGFILE,"chown vclstaff:root /home/vclstaff/flag 2>&1 |")){
+              notify($ERRORS{'OK'},"main: setting vclstaff ownership of /home/vclstaff/flag");
+              close(LOGFILE);
+           }
+          if(open(LOGFILE,"chmod 640 /home/vclstaff/flag 2>&1 |")){
+             notify($ERRORS{'OK'},"main: setting 640 perms /home/vclstaff/flag");
+             close(LOGFILE);
+          }
+       }
+       else{
+          notify($ERRORS{'OK'},"could not create $VCLFLAG $! will try to delete");
+          unlink $VCLFLAG;
+          return 0;
+       }
+    }
+    my @lines;
+    # VCLFLAG file exists, check contents
+    if(open(FLAG, "$VCLFLAG")){
+       @lines = <FLAG>;
+       close(FLAG);
+       # clear flag
+       if(open(FLAG, ">$VCLFLAG")){
+          print FLAG 0;
+          close(FLAG);
+       }
+       else{
+          unlink $VCLFLAG;
+       }  
+       return $lines[0];
+    }
+    else{
+       notify($ERRORS{'OK'},"flag: could not open $VCLFLAG $!");
+       return 0;
+    }
+}
+sub make_new_child {
+   my (%request_data) = @_; 
+   my $pid;
+   my $sigset;
+               
+   # block signal for fork
+   $sigset = POSIX::SigSet->new(SIGINT);
+   sigprocmask(SIG_BLOCK, $sigset) or die "Can't block SIGINT for fork: $!\n";
+   #die "fork: $!" unless defined ($pid = fork);
+FORK: {       
+   if ($pid = fork) {
+      # Parent records the child's birth
+      # and returns.
+      sigprocmask(SIG_UNBLOCK, $sigset) or die "Can't unblock SIGINT for fork: $!\n";
+      
+      $children{$pid} = 1;
+      $children++;
+      notify($ERRORS{'OK'},"vclclientd current number of forked kids: $children");
+      return;
+   } elsif(defined $pid) {
+      # Child can *not* return from this subroutine.
+      $SIG{INT} = 'DEFAULT';
+      # make SIGINT kill us as it did before unblock signals
+      sigprocmask(SIG_UNBLOCK, $sigset) or die "Can't unblock SIGINT for fork: $!\n";
+
+      notify($ERRORS{'OK'},"processdata: new request child process $request_data{state} $request_data{unityid},$request_data{remoteIP}   ");
+     #do something that may take a long time or needs to be monitored
+     #based on the case lets do something
+     if($request_data{state} =~ /new/){ 
+        notify($ERRORS{'OK'},"processdata: new request  $request_data{unityid},$request_data{remoteIP}   ");
+         if(new_state($request_data{unityid},$request_data{remoteIP})){
+            notify($ERRORS{'OK'},"processdata: connection for $request_data{unityid}\@$request_data{remoteIP} successfully opened");
+         }
+     }
+     elsif($request_data{"state"} =~ /timeout|deleted/){
+        if(timeout_state($request_data{unityid},$request_data{remoteIP})){
+          notify($ERRORS{'OK'},"vclclientd: connection for $request_data{unityid}\@$request_data{remoteIP} successfully terminated");
+        }
+     }
+
+     exit;
+   } elsif ($! =~ /No more process/){
+       sleep 5;
+       redo FORK;
+   }
+   else {
+       # strange error
+      die "Can't fork: $!\n";
+   }
+ }
+}
+sub new_state {
+   my ($user,$remoteIP) =@_;
+   # assumuption user and IP are valid
+   # add user to users.local, sshd_config_vcl
+   # on acknowledgemment turn on sshd on port 22
+   my @file;
+   my $line;
+   my ($userset,$remoteIPset) = 0;
+   #test for sshd_config_vcl
+   if(!(-r "$HOME/sshd_config_vcl")){
+      #hrmm. were did sshd_config_vcl go
+      #let try to create another from the orignal
+      if(createnewssh_config_vcl){
+         notify($ERRORS{'OK'},"new_state: sshd_config_vcl missing created a new one");
+      }
+      else{
+         notify($ERRORS{'OK'},"new_state: sshd_config_vcl missing failed to create a new one");
+         return 0;
+      }
+
+   }
+   if(open(CONFIG,"$HOME/sshd_config_vcl")){
+        @file = <CONFIG>;
+       close(CONFIG);
+       foreach $line (@file){
+           if($line =~ /AllowUsers/){
+            $line = "AllowUsers $user\n";
+            $userset=1;
+            notify($ERRORS{'OK'},"new_state: adding AllowUsers $user to sshd_config_vcl");
+           }
+        }
+       if(!$userset){
+          push @file, "AllowUsers $user\n";
+          notify($ERRORS{'OK'},"new_state: hrmm, had to add AllowUsers $user to sshd_config_vcl");
+       }
+       if(open(CONFIG,">$HOME/sshd_config_vcl")){
+              print CONFIG @file;
+              close(CONFIG);
+        }
+   }                           
+   # append to users.local
+   if(open(USERSLOCAL,"/etc/users.local")){
+      my @users = <USERSLOCAL>;
+      close(USERSLOCAL);
+      push @users,"\n$user\n";
+      if(open(USERSLOCAL,">/etc/users.local")){
+            print USERSLOCAL @users;
+            notify($ERRORS{'OK'},"new_state: adding $user to users.local");
+            close(USERSLOCAL);
+      }
+    }
+   else{
+      notify($ERRORS{'WARNING'},"new_state: could not open /etc/users.local $!");
+      return 0;
+   }
+   #start sshd
+   if(startsshd){
+      notify($ERRORS{'OK'},"new_state: startsshd returned and successful");
+      return 1;
+   }
+   return 0;
+}
+sub timeout_state{
+    # time to close non-admin ssh sessions and clean up users.local,
+    # sshd_config_vcl
+   my ($user,$remoteIP) =@_;
+   my $os = lc($^O);
+   #notify($ERRORS{'OK'},"timeout_state: OSname is $os");
+   my @file;
+   my $l;
+   my $sshd_admin_pid =0;
+   my ($pgrep,$pkill);
+
+   # get admin pid
+   if($os eq "solaris"){
+      $pgrep="/bin/pgrep";
+      $pkill="/bin/pkill";
+
+     if(open(SSH,"/local/openssh/etc/sshd.admin.pid")){
+         @file = <SSH>; 
+         close(SSH);
+         $sshd_admin_pid=$file[0];
+         notify($ERRORS{'OK'},"timeout_state: sshd_admin_pid set $sshd_admin_pid");
+       }
+       else{
+          notify($ERRORS{'OK'},"timeout_state: could not open /local/openssh/etc/sshd.admin.pid $!");
+       }
+   }
+   elsif($os eq "linux"){
+      $pgrep="/usr/bin/pgrep";
+      $pkill="/usr/bin/pkill";
+     if(open(SSH,"ps -ef \| grep /usr/sbin/sshd |")){
+         @file = <SSH>; 
+         close(SSH);
+         $sshd_admin_pid=$file[0];
+         foreach $l (@file){
+            chomp ($l);
+             next if($l =~ /grep/);
+             if($l =~ /(\/usr\/sbin\/sshd$)/){
+                my $blah;
+                ($blah,$sshd_admin_pid,$blah) = split(/\s+/,$l,3);
+                  notify($ERRORS{'OK'},"timeout_state: sshd_admin_pid set $sshd_admin_pid");
+             }
+         }
+       }
+       else{
+          notify($ERRORS{'OK'},"timeout_state: execute ps -ef $!");
+       }
+   }
+   else{
+          notify($ERRORS{'OK'},"timeout_state: $os not supported");
+          # we'll just let this ride and get a restart
+   }
+   # clean up users.local
+   # collect members of users.admin,users.base, and users.cluster
+   my @users_admin;
+   my @users_base;
+   my @users_cluster;
+   my $u;
+   #this one should exist
+   if(open(USERSLOCAL,"cat /etc/users.local.admin > /etc/users.local |")){
+       close(USERSLOCAL);
+       notify($ERRORS{'OK'},"timeout_state: dumped contents of /etc/users.local.admin /etc/users.local");
+   }
+   if(-r "/etc/users.local.base"){
+      if(open(USERSLOCAL,"cat /etc/users.local.base >> /etc/users.local |")){
+         close(USERSLOCAL);
+         notify($ERRORS{'OK'},"timeout_state: dumped contents of /etc/users.local.base /etc/users.local");
+      }
+   }
+   if(-r "/etc/users.local.cluster"){
+      if(open(USERSLOCAL,"cat /etc/users.local.cluster >> /etc/users.local |")){
+         close(USERSLOCAL);
+         notify($ERRORS{'OK'},"timeout_state: dumped contents of /etc/users.local.cluster /etc/users.local");
+      }
+   }
+   
+    
+    if(open(USERSLOCAL,"/etc/users.local")){
+       @users_admin=<USERSLOCAL>;
+       close(USERSLOCAL);
+    }
+    # check users.local add vclstaff if is does not exist
+    my $vclstaff=0; 
+    my $i;
+    for $i (@users_admin){
+      $vclstaff =1 if($i =~ "vclstaff");
+
+    }
+    
+    if(!$vclstaff){
+       push @users_admin, "\nvclstaff\n";
+       if(open(USERSLOCAL,"> /etc/users.local")){
+         print USERSLOCAL @users_admin;
+         close(USERSLOCAL);
+       }
+    }
+   # clean up our sshd_config_vcl
+   my @SSH;
+   my $s;
+   if(open(SSHDCONFIG, "$HOME/sshd_config_vcl")){
+      @SSH = <SSHDCONFIG>;
+      close(SSHDCONFIG);
+      foreach $s (@SSH){
+         if($s =~ s/AllowUsers $user/AllowUsers/g){
+             notify($ERRORS{'OK'},"timeout_state: $user\@$remoteIP removed from sshd_config_vcl");
+         }
+      }
+      # write back out to sshd_config_vcl
+      if(open(SSHDCONFIG, ">$HOME/sshd_config_vcl")){
+         print SSHDCONFIG @SSH;
+         close (SSHDCONFIG);
+      }
+      else{
+          notify($ERRORS{'OK'},"timeout_state: could not open $HOME/sshd_config_vcl for writing");
+      }
+   }
+
+   #kill off any user processes
+   if(open(PKILL, "$pkill -9 -U $user 2>&1 |")){
+      my @pkill=<PKILL>;
+      close(PKILL);
+      notify($ERRORS{'OK'},"timeout_state: stopped user processes");
+      #check for user
+      notify($ERRORS{'OK'},"timeout_state: confirming user processes are stopped");
+      if(open(PGREP, "ps -ef \| grep $user|")){
+         my @pgrep=<PGREP>;
+         close(PGREP);
+         foreach my $pid (@pgrep){
+            next if($pid =~ /grep/);
+            my($userblah,$userpid) = split(/\s+/,$pid,3);
+            if($userpid){
+               if(open(KILL, "kill -9 $userpid |")){
+                  notify($ERRORS{'OK'},"timeout_state: killed user process $userpid");
+                  close(KILL);
+               }
+            }
+         }
+      }
+   }
+   notify($ERRORS{'OK'},"timeout_state: checking for all sshd processes");
+   # use pgrep to get all sshd pids
+   if(open(PGREP,"ps -ef \|grep sshd 2>&1|")){
+       my @pfile = <PGREP>;
+       close(PGREP);
+       foreach $l (@pfile){
+         next if($l =~ /grep/);
+         next if($l =~ /ps -ef/);
+         notify($ERRORS{'OK'},"timeout_state: pgrep sshd = $l");
+
+          my ($b,$sshpid);
+          ($b,$b,$sshpid,$b) = split(/\s+/,$l,4) if($os eq "solaris");
+          ($b,$sshpid) = split(/\s+/,$l,3) if($os eq "linux");
+          next if($sshpid == $sshd_admin_pid);
+          if(open(KILL, "kill -9 $sshpid |")){
+             notify($ERRORS{'OK'},"timeout_state: killed sshd process $sshpid");
+             close(KILL);
+          }
+       }
+       notify($ERRORS{'OK'},"timeout_state: checking if I accidentially killed all sshd processes");
+      # did we kill all sshd sessions?
+       if(open(PGREP,"ps -ef \|grep sshd \|grep -v grep |")){
+         notify($ERRORS{'OK'},"timeout_state: executed ps -ef \|grep sshd \|grep -v grep");
+          @file = <PGREP>;
+          notify($ERRORS{'OK'},"timeout_state: @file");
+          close(PGREP);
+          if(!($file[0])){
+             notify($ERRORS{'OK'},"timeout_state: killed all sshd processes, will try to restart");
+             if(open(SSHD,"/etc/inet.d/sshd start |")){
+                @file = <SSHD>;
+                close(SSHD);
+                notify($ERRORS{'OK'},"timeout_state: sshd admin restarted @file");
+             }
+          }
+       }
+   }
+   else{
+       notify($ERRORS{'WARNING'},"timeout_state: could not execute /usr/bin/pgrep sshd");
+       
+   }
+   notify($ERRORS{'OK'},"timeout_state: looking for sshd_config_vcl");
+   #look for sshd_config_vcl in case we killed the sshd_admin pid
+   if(open(SSH,"ps -ef \| grep /usr/sbin/sshd |")){
+      my @sshfile = <SSH>;
+      close(SSH);
+      foreach $l (@sshfile) {
+         if($l =~ /(\/home\/vclstaff\/sshd_config_vcl\/)/){
+            # for some reason sshd with the vcl config file did not get stopped  
+            #initiate a restart/reload  
+            notify($ERRORS{'OK'},"timeout_state: sshd_config_vcl not stopped for some reason, prhaps the wrong sshd pid");
+            my ($b,$sshpid) = split(/\s+/,$l,3);
+            if($sshpid == $sshd_admin_pid){
+               notify($ERRORS{'OK'},"timeout_state: killed the wrong sshd pid");
+               #kill this pid
+               if(open(KILL, "kill -9 $sshpid |")){
+                  notify($ERRORS{'OK'},"timeout_state: killed sshd process $l");
+                  close(KILL);
+               }
+            
+               #stop and start sshd service.
+               if(open(SSHSTOP,"/etc/inet.d/sshd stop |")){
+                  @file = <SSHSTOP>;
+                  close(SSHSTOP);
+                  notify($ERRORS{'OK'},"timeout_state: sshd admin stopped @file");
+                  if(open(SSHSTART, "/etc/inet.d/sshd start |")){
+                     @file=<SSHSTART>;
+                     close(SSHSTART);
+                     notify($ERRORS{'OK'},"timeout_state: sshd admin started @file");
+                  }
+               }
+            }
+         }
+      }
+   }
+
+   if(sshdstatus){
+      notify($ERRORS{'OK'},"timeout_state: sshd core process is running");
+   }
+   else{
+      notify($ERRORS{'CRITICAL'},"timeout_state: sshd is not running or could not be restarted");
+
+   }
+   return 1;
+}
+sub reboot {
+   #simply reboot the client when called
+   my $os = lc($^O);
+   my $reboot;
+   if($os eq "solaris"){
+      $reboot = "/usr/sbin/shutdown -y -g 0 -i 6";
+   }
+   else{
+      $reboot = "/sbin/shutdown -r now";
+   }
+   notify($ERRORS{'OK'},"reboot: starting reboot sequence");
+   if(open(REBOOT,"$reboot 2>&1 |")){
+      my @reboot=<REBOOT>;
+      close(REBOOT);
+      notify($ERRORS{'OK'},"reboot: @reboot");
+      return 1;
+   }
+
+}
+sub fetch {
+   #collect host ssh keys and save for MN to pick up
+   notify($ERRORS{'OK'},"fetch: copying ssh keys to $HOME");
+   my $os = lc($^O);
+   my $sshdir;
+   if($os eq "solaris"){
+      $sshdir = "/local/openssh/etc";
+   }
+   else{
+      $sshdir = "/etc/ssh/";
+   }
+
+   if(open(CP, "/bin/cp $sshdir/ssh_host\* $HOME 2>&1 |")){
+      my @cp=<CP>;
+      close(CP);
+      if(@cp){
+         notify($ERRORS{'OK'},"fetch: copy problems - @cp");
+      }
+
+      if(open(CHOWN,"/bin/chown vclstaff $HOME/ssh_host\* 2>&1 |")){
+         my @chown=<CHOWN>;
+         close(CHOWN);
+         if(@chown){
+            notify($ERRORS{'OK'},"fetch: chown problems - @cp");
+         }
+      }
+   }
+   notify($ERRORS{'OK'},"fetch: fetch complete");
+   return 1;
+}
+sub store {
+   # take host ssh keys stored in my home directory and place them into the /etc/sshd directory
+   #create an orig directory in $sshdir
+   #copy original keys to orig dir
+   #cp given keys to proper location
+   #set correct ownership and premissions on keys
+   #unlink/remove locally stored keys from vclstaff dir
+   my $os = lc($^O);
+   my $sshdir;
+   if($os eq "solaris"){
+      $sshdir = "/local/openssh/etc";
+   }
+   else{
+      $sshdir = "/etc/ssh";
+   }    
+   notify($ERRORS{'OK'},"store: copying ssh keys to $sshdir");
+
+   my %filelist;
+   $filelist{"dsa"}="ssh_host_dsa_key";
+   $filelist{"dsapub"}="ssh_host_dsa_key.pub";
+   $filelist{"rsa"}="ssh_host_rsa_key"; 
+   $filelist{"rsapub"}="ssh_host_rsa_key.pub";
+   $filelist{"key"}="ssh_host_key";
+   $filelist{"keypub"}="ssh_host_key.pub";
+
+    if(!(-d "$sshdir/origkeys")){
+       if(mkdir("$sshdir/origkeys", 755)){
+         notify($ERRORS{'OK'},"store: mkdir successfully created $sshdir/origkeys");
+       }
+       else{
+          notify($ERRORS{'OK'},"store: mkdir $sshdir/origkeys $! ");
+       }
+    }
+    else{
+     #hrmm $sshdir/origkeys already exists
+    }
+    #copy system generated keys to orig dir
+    #copy stored keys to ssh dir
+    #set perms,ownership,unlink local copy
+    foreach my $f(sort keys %filelist) {
+       if(!(-f "$HOME/$filelist{$f}")){
+          notify($ERRORS{'OK'},"store: does not exist $HOME/$filelist{$f}");
+          next;
+       }
+       if(open(CP,"/bin/cp $sshdir/$filelist{$f} $sshdir/origkeys 2>&1 |")){
+          my @cp=<CP>;
+          close(CP);
+          if(@cp){
+             notify($ERRORS{'OK'},"store: copy orig keys problem on $filelist{$f} - @cp");
+          }
+       }
+       #copy given keys to ssh dir
+       if(open(CP,"/bin/cp $HOME/$filelist{$f} $sshdir/$filelist{$f} 2>&1 |")){
+          my @cp=<CP>;
+          close(CP);
+          if(@cp){
+             notify($ERRORS{'OK'},"store: copy given keys problem on $filelist{$f} - @cp");
+          }
+          else{
+            notify($ERRORS{'OK'},"store: copied $filelist{$f} to $sshdir");
+            if(open(CHOWN, "/bin/chown root:root $sshdir/$filelist{$f} 2>&1 |")){
+               close(CHOWN);
+            }
+            my $p;
+            if($f =~ /pub/){
+               $p = 644;
+            }
+            else{
+               $p = 600;
+            }
+            if(open(CHMOD, "/bin/chmod $p $sshdir/$filelist{$f} 2>&1|")){
+               my @chmod=<CHMOD>;
+               close(CHMOD);
+               if(@chmod){
+                  notify($ERRORS{'OK'},"store: chmod problem on $filelist{$f} - @chmod");
+               }
+            }#chmod
+          }#else no cp problems
+       }#CP
+       #unlink
+       if(unlink "$HOME/$filelist{$f}"){
+         notify($ERRORS{'OK'},"store: deleted $HOME/$filelist{$f}");
+       }
+       else{
+         notify($ERRORS{'OK'},"store: unable to delete $HOME/$filelist{$f}");
+       }
+     }#foreach
+     #restart sshd
+     if(restartsshd){
+        notify($ERRORS{'OK'},"store: sshd restarted");
+        return 1;
+     }
+     else{
+         notify($ERRORS{'OK'},"store: sshd restart failed");
+         return 0;
+     }
+    return 1;
+}
+
+sub restartsshd {
+   my $os = lc($^O);
+   notify($ERRORS{'OK'},"restartsshd: attempting to restart sshd on $os");
+   if($os eq "solaris"){
+      if(open(STOP,"/bin/pkill -f sshd_admin.cfg  2>&1 |")){
+         my @stop=<STOP>;
+         close(STOP);
+         foreach my $r (@stop) {
+            if($r =~ /failed/i){
+               notify($ERRORS{'WARNING'},"restartsshd: sshd stop failed @stop");
+            }
+         }
+         if(open(START,"/etc/init.d/sshd start 2>&1 |")){
+            my @start=<START>;
+            close(START);
+            foreach my $r (@start) {
+               #notify($ERRORS{'OK'},"restartsshd: output $r");
+               if($r =~ /failed/i){
+                  notify($ERRORS{'WARNING'},"restartsshd: sshd start failed @start");
+               } 
+               return 1 if($r =~ /ok/i);               
+            }
+         }#if start
+      } # pkill
+   }
+   elsif($os =~ /linux/){
+      if(open(RESTART,"/etc/init.d/sshd restart 2>&1 |")){
+         my @restart=<RESTART>;
+         close(RESTART);
+         foreach my $r (@restart) {
+           if($r =~ /failed/i){
+               notify($ERRORS{'WARNING'},"restartsshd: sshd restart failed $r @restart");
+            }
+            if($r =~ /Starting/){
+               return 1 if($r =~ /ok/i);
+            }
+         }
+      }
+   }
+  return 1; 
+}
+sub startsshd {                                             
+   my @lines;
+   #figure out OS solaris or linux
+   my $os= lc($^O);
+   my @output;
+   my $l;
+   if($os eq "solaris"){ 
+       if(open(SSHD,"/local/openssh/sbin/sshd -f $HOME/sshd_config_vcl 2>&1 |")){
+          notify($ERRORS{'OK'},"startsshd: starting sshd");
+          @output = <SSHD>;
+          close(SSHD);
+         foreach $l (@output){
+             notify($ERRORS{'OK'},"startsshd output: $l");
+         }
+         return 1;
+       }
+       else{
+          notify($ERRORS{'OK'},"startsshd: could not execute /local/openssh/sbin/sshd -f $HOME/sshd_config_vcl $!");
+          return 0;
+       }
+   }
+   elsif($os eq "linux"){
+      if(open(SSHD, "/usr/sbin/sshd -f $HOME/sshd_config_vcl |")){
+          notify($ERRORS{'OK'},"startsshd: starting sshd");
+          @output = <SSHD>;
+          close(SSHD);
+         foreach $l (@output){
+             notify($ERRORS{'OK'},"startsshd output: $l");
+         }
+         return 1;
+       }
+       else{
+          notify($ERRORS{'OK'},"startsshd: could not execute /usr/sbin/sshd -f $HOME/sshd_config_vcl $!");
+          return 0;
+       }
+      }
+}
+sub notify {
+       my ($error,$string) = @_;
+       my $currenttime = makedatestring;
+       if(open(LOGIT, ">>$LOG")){
+          if( !$error ){
+             print LOGIT "$currenttime - $$: $string\n";
+             close(LOGIT);
+             return;
+          }
+          if ($error == 2 ) {  #CRITICAL something bad happened, exiting
+             print LOGIT  "\n$string\n"; 
+             print LOGIT "exiting\n";
+             close(LOGIT);
+             exit;
+          }
+          elsif( $error == 1 ){
+             # WARNING should prompt admin to
+             # continue or exit
+             # need to disable for cron
+             print LOGIT "\n---- WARNING ---- \n$string\n";
+             close(LOGIT);
+          }
+          # mail us, this is to be used for cron jobs
+          elsif( $error == 5 ){
+             print LOGIT "\n---- sending mail -- $currenttime - - $$ $string\n";
+             my $from = "root";
+             my $to = "fapeeler\@engr.ncsu.edu";
+             my $subject = "PROBLEM -- $0";
+             my $mailer = Mail::Mailer->new("sendmail");
+             if($mailer->open({From => $from,
+                           To => $to,
+                           Subject => $subject,
+             })){
+                print $mailer "vclclientd $currenttime - - process $$ \n\n\n$string";
+                $mailer->close();
+              }
+             return 1;
+             }
+          }
+}
+sub makedatestring {
+       my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime( );
+      $year += 1900; 
+      $mon++;
+      my $datestring = sprintf("%04d-%02d-%02d %02d:%02d:%02d",$year,$mon,$mday,$hour,$min,$sec);
+      return $datestring;
+}
+sub sshdstatus {
+   my $os = lc($^O);
+   if($os eq "solaris"){
+      my $sshd_admin_pid;
+      if(open(SSH,"/local/openssh/etc/sshd.admin.pid")){
+         my @file = <SSH>; 
+         close(SSH);
+         chomp($file[0]);
+         $sshd_admin_pid=$file[0];
+       }
+       else{
+          notify($ERRORS{'OK'},"sshdstatus: could not open /local/openssh/etc/sshd.admin.pid $!");
+          return 0;
+       }
+
+      if(open(STAT,"/bin/pgrep -f sshd  2>&1 |")){
+         my @stat=<STAT>;
+         close(STAT);
+         foreach my $r (@stat) {
+            if($r =~ /$sshd_admin_pid/){
+               #notify($ERRORS{'OK'},"sshdstatus: sshd is running");
+               return 1;
+            }
+         }
+         notify($ERRORS{'OK'},"sshdstatus: sshd is NOT running trying to restart");
+         if(open(START,"/etc/init.d/sshd start 2>&1 |")){
+            my @start=<START>;
+            close(START);
+            foreach my $r (@start) {
+               if($r =~ /failed/i){
+                  notify($ERRORS{'WARNING'},"store: sshd start failed @start");
+                  return 0;
+               }
+            }
+         }#if start
+      }#STAT
+         return 1;
+   } #os=solaris
+   elsif($os =~ /linux/){
+      my $sshd_admin_pid;
+      if(open(SSH,"/var/run/sshd.pid")){
+         my @file = <SSH>; 
+         close(SSH);
+         chomp($file[0]);
+         $sshd_admin_pid=$file[0];
+       }
+       else{
+          notify($ERRORS{'WARNING'},"sshdstatus: could not open /var/run/sshd.pid $!");
+          return 0;
+       }
+      my $running=0;
+      if(open(SSH,"pgrep -f sshd 2>&1|")){
+         my @lines = <SSH>;
+         close(SSH);
+         foreach my $l (@lines){
+            if($l =~ /$sshd_admin_pid/){
+               #ok it's running
+               $running=1; #not that this matters
+               return 1;
+            }
+        }
+      }#if pgrep
+      if(!$running){
+        #start sshd
+        notify($ERRORS{'WARNING'},"sshdstatus: not running trying to restart");
+        if(open(STAT,"/etc/init.d/sshd start 2>&1 |")){
+           my @stat = <STAT>;
+           close(STAT);
+           foreach my $s (@stat) {
+             if($s =~ /ok/i){
+                notify($ERRORS{'OK'},"sshdstatus: restarted core sshd process, @stat");
+                return 1;
+             }
+           }
+           #in case I don't return in above check
+           notify($ERRORS{'OK'},"sshdstatus: restart attempt may of had issues, @stat");
+           return 0;
+        }#if sshd start
+       }#if ! running
+      }#elsif linux
+}
+sub createnewssh_config_vcl {
+   #check for .orig from /etc/ssh dir
+   #if orig then just need to add port 22 and AllowUsers directive
+   my ($port22,$AU,$port24)=0;
+   my @file;
+   if(-e "/etc/sshd/sshd_config.orig"){
+         #good slurp it in
+      if(open(CONFIG,"$HOME/sshd_config_vcl")){
+       @file = <CONFIG>;
+       close(CONFIG);
+       foreach my $line (@file){
+           #check for port 22 and AllowUsers
+          if($line =~ /^Port 22/){
+             $port22=1;
+          }
+          if($line =~ /^AllowUsers/){
+             $AU=1;
+          }
+          if($line =~ s/^Port 24/Port 22/g){
+             $port22=1;
+          }
+       }
+      }
+   }
+   else{
+    #ok /etc/sshd/sshd_config.orig does not exist
+    #try to create from the /etc/sshd/sshd_config
+
+   }
+   #write out to $HOME/sshd_config_vcl
+   if(open(SC,">$HOME/sshd_config_vcl")){
+      print SC @file;
+      close(SC);
+   }
+   else{
+      notify($ERRORS{'CRITICAL'},"createnewssh_config_vcl: sshd_config_vcl was reported to not exists, in repairing I failed to create a new $HOME/sshd_config_vcl $!");
+      return 0;
+   }
+}

Added: incubator/vcl/tags/import/managementnode/bin/vcld
URL: http://svn.apache.org/viewvc/incubator/vcl/tags/import/managementnode/bin/vcld?rev=726079&view=auto
==============================================================================
--- incubator/vcl/tags/import/managementnode/bin/vcld (added)
+++ incubator/vcl/tags/import/managementnode/bin/vcld Fri Dec 12 10:20:10 2008
@@ -0,0 +1,750 @@
+#!/usr/bin/perl -w
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+##############################################################################
+# $Id: vcld 1951 2008-12-12 13:48:10Z arkurth $
+##############################################################################
+
+=head1 NAME
+
+VCL::vcld - VCL daemon module
+
+=head1 SYNOPSIS
+
+ perl vcld
+
+=head1 DESCRIPTION
+
+ This is the executable module for running the VCL management node daemon.
+
+=cut
+
+##############################################################################
+package VCL::vcld;
+
+# Specify the lib path using FindBin
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+
+# Configure inheritance
+use base qw();
+
+# Specify the version of this module
+our $VERSION = '2.00';
+
+# Specify the version of Perl to use
+use 5.008000;
+
+use strict;
+use warnings;
+use diagnostics;
+
+use Symbol;
+use POSIX;
+use Getopt::Long;
+use English;
+
+use VCL::utils;
+use VCL::DataStructure;
+
+##############################################################################
+# Turn on autoflush
+$| = 1;
+
+# Get the command line options
+our $opt_d = '';
+Getopt::Long::Configure('bundling', 'no_ignore_case');
+GetOptions('d|debug' => \$opt_d,
+			  'h|help'  => \&help);
+
+# Call daemonize if -d (debug) wasn't specified
+if (!$opt_d) {
+	&daemonize;
+}
+
+# Variables to store child process information
+our %child_pids = ();    # keys are current child process IDs
+our $child_count = 0;     # current number of children
+
+# Install signal handlers
+$SIG{CHLD} = \&REAPER;
+$SIG{INT}  = \&HUNTSMAN;
+$SIG{QUIT} = \&HUNTSMAN;
+$SIG{HUP}  = \&HUNTSMAN;
+$SIG{TERM} = \&HUNTSMAN;
+
+# Call main subroutine
+&main();
+
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 main
+
+ Parameters  : 
+ Returns     : 
+ Description : Main VCL daemon engine subroutine. Queries database for request
+               and passes off data to make_new_child() to begin processing.
+
+=cut
+
+sub main () {
+	preplogfile($LOGFILE);
+
+	#===========================================================================
+	# BEGIN NEW CODE
+	# This section does some prep work before looping
+	my ($package, $filename, $line, $sub) = caller(0);
+
+	# Set the vcld environment variable to 0 so other subroutines know if this is the vcld or child process
+	$ENV{vcld} = 1;
+	notify($ERRORS{'OK'}, $LOGFILE, "vcld environment variable set to $ENV{vcld} for this process");
+
+	# Rename this process
+	rename_vcld_process();
+
+	# Create a hash to store all of the program state information
+	my %info;
+
+	# Get the management node info from the database
+	# get_management_node_info() will determine the hostname
+	if ($info{managementnode} = get_management_node_info()) {
+		notify($ERRORS{'OK'}, $LOGFILE, "retrieved management node information from database");
+	}
+	else {
+		notify($ERRORS{'CRITICAL'}, $LOGFILE, "unable to retieve management node information from database");
+		exit;
+	}
+
+	# Define local variables from the management node hash for code simplicity
+	my $management_node_id       = $info{managementnode}{id};
+	my $management_node_hostname = $info{managementnode}{hostname};
+
+	# Set environment variables for global management node information
+	$ENV{management_node_id} = $management_node_id;
+	notify($ERRORS{'OK'}, $LOGFILE, "management_node_id environment variable set: $management_node_id");
+
+	# Get the management node checkin interval from the database if defined
+	# Otherwise, the default is 12 seconds
+	my $management_node_checkin_interval = 12;
+	if (defined $info{managementnode}{checkininterval}) {
+		$management_node_checkin_interval = $info{managementnode}{checkininterval};
+	}
+	notify($ERRORS{'OK'}, $LOGFILE, "management node checkin interval is $management_node_checkin_interval seconds");
+	notify($ERRORS{'OK'}, $LOGFILE, "vcld started on $management_node_hostname");
+
+	#===========================================================================
+	while (1) {
+		SLEEP:
+		
+		delete $ENV{request_id};
+		delete $ENV{reservation_id};
+		delete $ENV{state};
+		
+		sleep $management_node_checkin_interval;
+
+		#===========================================================================
+		# Update lastcheckin for this management node
+		my $lastcheckin_timestamp = update_lastcheckin($management_node_id);
+		if ($lastcheckin_timestamp) {
+			notify($ERRORS{'DEBUG'}, $LOGFILE, "lastcheckin time updated for management node $management_node_id: $lastcheckin_timestamp");
+			# Update the local hash info to reflect the new timestamp
+			$info{managementnode}{lastcheckin} = $lastcheckin_timestamp;
+		}
+		else {
+			notify($ERRORS{'CRITICAL'}, $LOGFILE, "could not update lastcheckin for management node $management_node_id");
+		}
+
+		# Get all the requests assigned to this management node
+		# get_management_node_requests() gets a subset of the information available
+		if ($info{request} = {get_management_node_requests($management_node_id)}) {
+			#notify($ERRORS{'DEBUG'}, $LOGFILE, "retieved request information for management node $management_node_id");
+		}
+		else {
+			notify($ERRORS{'CRITICAL'}, $LOGFILE, "could not retieve request information for management node $management_node_id");
+		}
+
+		# See if there's anything to do
+		my $request_count = scalar keys %{$info{request}};
+		#notify($ERRORS{'DEBUG'}, $LOGFILE, "number of requests assigned to management node $management_node_id: $request_count");
+
+		#===========================================================================
+		# Loop through the requests assigned to this management node
+		REQUEST: foreach my $request_id (keys %{$info{request}}) {
+			#notify($ERRORS{'DEBUG'}, $LOGFILE, "management node $management_node_id has been assigned request id: $request_id");
+
+			# Store some request data into a local variables
+			my $request_state_name     = $info{request}{$request_id}{state}{name};
+			my $request_laststate_name = $info{request}{$request_id}{laststate}{name};
+			my $request_start          = $info{request}{$request_id}{start};
+			my $request_end            = $info{request}{$request_id}{end};
+			my $request_preload        = $info{request}{$request_id}{preload};
+			
+			$ENV{request_id}     = $request_id;
+			$ENV{reservation_id}     = 0;
+			$ENV{state}     = $request_state_name;
+
+			# Make sure the request state is valid
+			if ($request_state_name !~ /inuse|reserved|deleted|timeout|reclaim|reload|new|tomaintenance|image|imageprep|makeproduction|imageinuse|complete|failed|pending|maintenance|tovmhostinuse/) {
+				notify($ERRORS{'WARNING'}, $LOGFILE, "assigned request in unsupported state: $request_state_name");
+				next REQUEST;
+			}
+
+			# Don't process requests that are already pending
+			if ($request_state_name =~ /^(pending|maintenance)/) {
+				next REQUEST;
+			}
+
+			#===========================================================================
+			# Loop through the reservations associated with this request
+			RESERVATION: foreach my $reservation_id (keys %{$info{request}{$request_id}{reservation}}) {
+				$ENV{reservation_id} = $reservation_id;
+				
+				# Check to see if the reservation is still in the hash before proceeding
+				# If request was deleted from database, it was also removed from this hash
+				if (!defined($info{request}{$request_id}{reservation}{$reservation_id})) {
+					#notify($ERRORS{'DEBUG'}, $LOGFILE, "reservation was deleted");
+					next RESERVATION;
+				}
+
+				# Store reservation variables into local variable
+				my $reservation_lastcheck = $info{request}{$request_id}{reservation}{$reservation_id}{lastcheck};
+
+				# Perform steps common to all states
+				#notify($ERRORS{'DEBUG'}, $LOGFILE, "assigned reservation in state: $request_state_name");
+
+				# The request_info hash stores all the information for this request
+				my %request_info;
+
+				# Figure out the status of this reservation based on reservation times and the request state
+				# check_time_result can be: start, preload, end, poll, old, remove, 0
+				my $check_time_result = check_time($request_start, $request_end, $reservation_lastcheck, $request_state_name, $request_laststate_name);
+				#notify($ERRORS{'DEBUG'}, 0, "check_time returned \'$check_time_result\'");
+
+				# Do nothing if check_time returned 0
+				# Check this before querying for the large set of request data
+				if (!$check_time_result) {
+					# do nothing - disabled debug output too much info for large numbr of requests
+					#notify($ERRORS{'DEBUG'}, $LOGFILE, "request will not be processed");
+					next RESERVATION;
+				}
+				elsif ($check_time_result eq "old") {
+					# Only complain
+					notify($ERRORS{'WARNING'}, $LOGFILE, "this is an old request");
+					next RESERVATION;
+				}
+				elsif ($check_time_result eq "remove") {
+					# Remove the request and associated reservations from database
+					# This also removes rows from computerloadlog table for associated reservations
+					if (delete_request($request_id)) {
+						notify($ERRORS{'OK'}, $LOGFILE, "request deleted");
+					}
+					else {
+						notify($ERRORS{'WARNING'}, $LOGFILE, "unable to delete rows from request, reservation, and computerloadlog tables for request");
+					}
+
+					# Remove the request key from the hash
+					delete $info{request}{$request_id};
+					next RESERVATION;
+				} ## end elsif ($check_time_result eq "remove")  [ if (!$check_time_result)
+				elsif ($check_time_result eq "preload" && $request_preload) {
+					# Preload flag has already been set, don't process preload request again
+					notify($ERRORS{'DEBUG'}, $LOGFILE, "preload request has already been processed");
+					next RESERVATION;
+				}
+				
+				# Make sure reservation is not currently being processed
+				if (reservation_being_processed($reservation_id)) {
+					notify($ERRORS{'WARNING'}, $LOGFILE, "reservation $reservation_id is already being processed");
+					next RESERVATION;
+				}
+				else {
+					notify($ERRORS{'DEBUG'}, $LOGFILE, "reservation $reservation_id is NOT already being processed");
+				}
+
+				# Get the full set of database data for this request
+				if (%request_info = get_request_info($request_id)) {
+					notify($ERRORS{'DEBUG'}, $LOGFILE, "retieved request information from database");
+
+					# Set request variables that may have changed by other processes to their original values
+					# They may change if this is a cluster reservation
+					$request_info{state}{name}     = $request_state_name;
+					$request_info{laststate}{name} = $request_laststate_name;
+					$request_info{preload}         = $request_preload;
+				}
+				else {
+					notify($ERRORS{'WARNING'}, $LOGFILE, "could not retieve request information from database");
+					next RESERVATION;
+				}
+
+				# Add the check_time result to the hash
+				$request_info{CHECKTIME} = $check_time_result;
+
+				# Get a new data structure object
+				my $data_structure;
+				eval {$data_structure = new VCL::DataStructure({request_data => \%request_info, reservation_id => $reservation_id});};
+				if (my $e = Exception::Class::Base->caught()) {
+					notify($ERRORS{'CRITICAL'}, 0, "unable to create DataStructure object" . $e->message);
+					next RESERVATION;
+				}
+
+				# Check if preload was returned by check_time and that preload flag is 0
+				# The preload flag will be set to 1 by new.pm module after it's done
+				if ($check_time_result =~ /preload/ && !($request_info{preload})) {
+					notify($ERRORS{'OK'}, $LOGFILE, "request start time within 25-35 minute window and preload flag is 0, processing preload request");
+					$request_info{PRELOADONLY} = 1;
+				}
+
+				# Add the reservation ID to be processed to the hash
+				$request_info{RESERVATIONID} = $reservation_id;
+
+				# Wait for a short amount of time before making new child
+				# This is to give processes a chance to start before subsequent processes
+				#   check for conflicts such as overlapping computer reservations
+				notify($ERRORS{'DEBUG'}, $LOGFILE, "sleeping for 2 seconds before updating state to pending");
+				sleep 2;
+
+				# Update the request state to pending, laststate to next state
+				# Pending is set now so vcld doesn't try to process it again
+				# The previous state is already in the hash as the laststate value
+				# This will be passed to the next module so it knows where it came from
+				my $is_parent_reservation = $data_structure->is_parent_reservation();
+				if ($is_parent_reservation && update_request_state($request_id, "pending", $request_state_name)) {
+					notify($ERRORS{'OK'}, $LOGFILE, "request state updated to pending, laststate $request_state_name");
+				}
+				elsif (!$is_parent_reservation) {
+					notify($ERRORS{'OK'}, $LOGFILE, "child reservation: request state NOT updated to pending");
+				}
+				else {
+					notify($ERRORS{'CRITICAL'}, $LOGFILE, "request state could not be updated to pending, reservation not processed");
+					next RESERVATION;
+				}
+				
+				# Insert a computerloadlog entry to indicate processing has begin for this reservation
+				my $computer_id = $data_structure->get_computer_id();
+				if (insertloadlog($reservation_id, $computer_id, "begin", "beginning to process, state is $request_state_name")) {
+					notify($ERRORS{'OK'}, $LOGFILE, "inserted 'begin' entry into computerloadlog for reservation $reservation_id");
+				}
+				else {
+					notify($ERRORS{'CRITICAL'}, $LOGFILE, "failed to insert 'begin' entry into computerloadlog for reservation $reservation_id");
+				}
+
+				# Make a new child process, passing it the request/reservation info
+				make_new_child({request_info => \%request_info, data_structure => $data_structure});
+
+			} ## end foreach my $reservation_id (keys %{$info{request...
+		} ## end foreach my $request_id (keys %{$info{request}})
+		
+		delete $ENV{request_id};
+		delete $ENV{reservation_id};
+		delete $ENV{state};
+
+		#===========================================================================
+		# Get all the block requests assigned to this management node
+		my $blockrequest_data = get_management_node_blockrequests($management_node_id);
+		if (!defined $blockrequest_data) {
+			notify($ERRORS{'CRITICAL'}, $LOGFILE, "could not retrieve block request information for management node $management_node_id");
+			next;
+		}
+		elsif (!$blockrequest_data) {
+			#notify($ERRORS{'OK'}, 0, "there are 0 block requests assigned to management node $management_node_id");
+			next;
+		}
+
+		#notify($ERRORS{'CRITICAL'}, $LOGFILE, "\$blockrequest_data", $blockrequest_data);
+		#next;
+
+		# Loop through the block requests assigned to this management node
+		BLOCKREQUEST: foreach my $blockrequest_id (keys %{$blockrequest_data}) {
+			#notify($ERRORS{'DEBUG'}, $LOGFILE, "checking block request id=$blockrequest_id");
+
+			BLOCKTIME: foreach my $blocktime_id (keys %{$blockrequest_data->{$blockrequest_id}{blockTimes}}) {
+				#notify($ERRORS{'DEBUG'}, $LOGFILE, "checking block time id=$blocktime_id");
+
+				# Get a new data structure object
+				my $data_structure;
+				eval {$data_structure = new VCL::DataStructure({blockrequest_data => $blockrequest_data, blockrequest_id => $blockrequest_id, blocktime_id => $blocktime_id});};
+				if (my $e = Exception::Class::Base->caught()) {
+					notify($ERRORS{'CRITICAL'}, 0, "unable to create DataStructure object" . $e->message);
+					next;
+				}
+
+				# Store some block request data into a local variables
+				my $blockrequest_name       = $data_structure->get_blockrequest_name();
+				my $blockrequest_expire     = $data_structure->get_blockrequest_expire();
+				my $blockrequest_processing = $data_structure->get_blockrequest_processing();
+				my $blocktime_start         = $data_structure->get_blocktime_start();
+				my $blocktime_end           = $data_structure->get_blocktime_end();
+				my $blocktime_processed     = $data_structure->get_blocktime_processed();
+				my $blocktime_id            = $data_structure->get_blocktime_id();
+
+				#use VCL::blockrequest;
+				#$data_structure->set_blockrequest_mode('start');
+				#my $br_start = VCL::blockrequest->new({%{$blockrequest_data->{$blockrequest_id}}, data_structure => $data_structure});
+				#notify($ERRORS{'OK'}, $LOGFILE, "***** Starting start process *****");
+				#$br_start->process();
+				#exit;
+				#notify($ERRORS{'OK'}, $LOGFILE, "***** DONE WITH START *****");
+				#sleep 5;
+				#$data_structure->set_blockrequest_mode('end');
+				#my $br_end = VCL::blockrequest->new({%{$blockrequest_data->{$blockrequest_id}}, data_structure => $data_structure});
+				#notify($ERRORS{'OK'}, $LOGFILE, "***** Starting end process *****");
+				#$br_end->process();
+				#notify($ERRORS{'OK'}, $LOGFILE, "***** DONE WITH END *****");
+				#exit;
+
+				# Check if the block request is already being processed
+				if ($blockrequest_processing) {
+					#notify($ERRORS{'DEBUG'}, $LOGFILE, "block request $blockrequest_id '$blockrequest_name' is already being processed");
+					next BLOCKREQUEST;
+				}
+				else {
+					#notify($ERRORS{'OK'}, $LOGFILE, "block request $blockrequest_id '$blockrequest_name' is not currently being processed");
+				}
+
+				# Check block request start, end and expire time
+				my $blockrequest_mode = check_blockrequest_time($blocktime_start, $blocktime_end, $blockrequest_expire);
+
+				# check_blockrequest_time will return 0 if nothing needs to be done and undefined if an error occurred
+				if (!defined $blockrequest_mode) {
+					notify($ERRORS{'CRITICAL'}, $LOGFILE, "error occurred checking block request $blockrequest_id '$blockrequest_name' status");
+					next;
+				}
+				elsif (!$blockrequest_mode) {
+					#notify($ERRORS{'DEBUG'}, $LOGFILE, "block request $blockrequest_id will not be processed at this time");
+					next;
+				}
+				else {
+					#notify($ERRORS{'DEBUG'}, $LOGFILE, "block request $blockrequest_id will be processed, mode: $blockrequest_mode");
+				}
+
+				if ($blockrequest_mode eq 'start' && $blocktime_processed) {
+					#notify($ERRORS{'DEBUG'}, $LOGFILE, "block request $blockrequest_id '$blockrequest_name' blocktime_id $blocktime_id has already been processed");
+					next BLOCKREQUEST;
+				}
+
+				# Start processing block request
+				$data_structure->set_blockrequest_mode($blockrequest_mode);
+
+				# Attempt to set the blockRequest processing column to 1
+				if (update_blockrequest_processing($blockrequest_id, 1)) {
+					notify($ERRORS{'OK'}, $LOGFILE, "block request $blockrequest_id '$blockrequest_name' processing set to 1");
+
+					# Make a new child process, passing it the request/reservation info
+					make_new_child({data_structure => $data_structure, request_info => $blockrequest_data->{$blockrequest_id}});
+				}
+				else {
+					notify($ERRORS{'CRITICAL'}, $LOGFILE, "unable to set block request $blockrequest_id '$blockrequest_name' processing to 1");
+					next;
+				}
+			} ## end foreach my $blocktime_id (keys %{$blockrequest_data...
+
+		} ## end foreach my $blockrequest_id (keys %{$blockrequest_data...
+	} ## end while (1)
+} ## end sub main ()
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 make_new_child
+
+ Parameters  : 
+ Returns     : 
+ Description :
+
+=cut
+
+sub make_new_child {
+	my ($args) = @_;
+
+	my $request_data   = $args->{request_info};
+	my $data_structure = $args->{data_structure};
+	$data_structure = 0 if !$data_structure;
+
+	# Assemble a consistent prefix for notify messages
+	my $request_id     = $request_data->{id};
+	my $reservation_id = $request_data->{RESERVATIONID};
+
+	# Get the state name
+	my $state;
+	my $state_module;
+	if ($data_structure) {
+		$state        = $data_structure->get_state_name();
+		$state_module = "VCL::$state";
+	}
+	else {
+		$state        = $request_data->{state}{name};
+		$state_module = "VCL::$state";
+	}
+
+	# The timeout and deleted states have been combined into reclaim.pm
+	if ($state =~ /^(timeout|deleted)$/) {
+		notify($ERRORS{'OK'}, $LOGFILE, "request will be processed by reclaim.pm");
+		$state_module = "VCL::reclaim";
+	}
+
+	# The imageinuse state is now handled by inuse.pm
+	if ($state =~ /^(imageinuse)$/) {
+		notify($ERRORS{'OK'}, $LOGFILE, "request will be processed by inuse.pm");
+		$state_module = "VCL::inuse";
+	}
+
+	# The tomaintenance state is handled by new.pm
+	if ($state =~ /^(tomaintenance|imageprep|reload|tovmhostinuse)$/) {
+		notify($ERRORS{'OK'}, $LOGFILE, "request will be processed by new.pm");
+		$state_module = "VCL::new";
+	}
+
+	notify($ERRORS{'OK'}, $LOGFILE, "creating new process");
+
+	eval "use $state_module";
+	if (!$EVAL_ERROR) {
+		notify($ERRORS{'OK'}, $LOGFILE, "loaded $state_module module");
+	}
+	else {
+		notify($ERRORS{'WARNING'}, $LOGFILE, "$state_module module could not be loaded");
+	}
+
+	# For testing purposes on Windows
+	if ($^O =~ /win/i) {
+		# Set the request_id and reservation_id environment variables
+		$ENV{request_id}     = $request_id;
+		$ENV{reservation_id} = $reservation_id;
+
+		# Set the vcld environment variable to 0 so other subroutines know if this is the vcld or child process
+		$ENV{vcld} = 0;
+		notify($ERRORS{'OK'}, $LOGFILE, "vcld environment variable set to $ENV{vcld} for this process");
+
+		my $kid;
+		if ($kid = ($state_module)->new({%{$request_data}, data_structure => $data_structure})) {
+			notify($ERRORS{'OK'}, $LOGFILE, "$state object created and initialized");
+			# Set the request_id and reservation_id environment variables
+			$kid->process();
+		}
+		else {
+			notify($ERRORS{'CRITICAL'}, $LOGFILE, "$state object could not be created and initialized");
+			switch_state($request_data, 'failed', '', 'failed', 1);
+		}
+
+		# Set the request_id and reservation_id environment variables
+		delete $ENV{request_id};
+		delete $ENV{reservation_id};
+		delete $ENV{state};
+
+		# Restore the vcld environment variable to 1
+		$ENV{vcld} = 1;
+		
+		# Only return from make_new_child if running on Windows for testing without actually forking
+		return;
+	} ## end if ($^O =~ /win/i)
+
+	# Build a signal set using POSIX::SigSet->new, contains only the SIGINT signal
+	my $sigset = POSIX::SigSet->new(SIGINT);
+	
+	# Pass the POSIX::SigSet object to sigprocmask with the SIG_BLOCK flag to delay SIGINT signal delivery
+	sigprocmask(SIG_BLOCK, $sigset) or die "can't block SIGINT for fork: $!\n";
+
+	FORK: {
+		my $pid;
+		if ($pid = fork) {
+			# If here, this is the parent process
+			
+			# Restore delivery of SIGINT signal for the parent process
+			sigprocmask(SIG_UNBLOCK, $sigset) or die "can't unblock SIGINT for fork: $!\n";
+			
+			# Parent process records the child's PID and returns
+			$child_count++;
+			$child_pids{$pid} = 1;
+			notify($ERRORS{'OK'}, $LOGFILE, "current number of forked kids: $child_count");
+			return;
+		}
+		elsif (defined $pid) {
+			# If here, this is the child process
+			# Child must *NOT* return from this subroutine after this point. It must exit.
+			# If child returns it will become a parent process and spawn off its own children
+			
+			# Configure the SIGINT signal to kill this process normally
+			$SIG{INT} = 'DEFAULT';
+			
+			# Unblock the SIGINT signal
+			sigprocmask(SIG_UNBLOCK, $sigset) or die "can't unblock SIGINT for fork: $!\n";
+
+			# Set the vcld environment variable to 0 so other subroutines know if this is the vcld or child process
+			$ENV{vcld} = 0;
+			notify($ERRORS{'OK'}, $LOGFILE, "vcld environment variable set to $ENV{vcld} for this process");
+
+			# Set the request_id and reservation_id environment variables
+			$ENV{request_id}     = $request_id;
+			$ENV{reservation_id} = $reservation_id if $reservation_id;
+			$ENV{state}          = $state;
+
+			# Create a new VCL state object, passing it the reservation data
+			if (my $state_object = ($state_module)->new({%{$request_data}, data_structure => $data_structure})) {
+				notify($ERRORS{'OK'}, $LOGFILE, "$state_module object created and initialized");
+				
+				# Call the state object's process() subroutine
+				$state_object->process();
+			}
+			else {
+				notify($ERRORS{'CRITICAL'}, $LOGFILE, "$state_module object could not be created and initialized, $!");
+				switch_state($request_data, 'failed', '', 'failed', 1);
+			}
+			
+			exit;
+			
+		} ## end elsif (defined $pid)  [ if ($pid = fork)
+		
+		elsif ($! =~ /No more process/) {
+			sleep 5;
+			redo FORK;
+		}
+		
+		else {
+			# strange error
+			die "can't fork: $!\n";
+		}
+	} ## end FORK:
+} ## end sub make_new_child
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 HUNTSMAN
+
+ Parameters  : 
+ Returns     : 
+ Description :
+
+=cut
+
+sub HUNTSMAN {   
+	# Temporarily override the the SIGCHLD signal handler
+	# Set SIGCHLD handler to IGNORE, meaning nothing happens when a child process exits
+	local ($SIG{CHLD}) = 'IGNORE';
+	
+	# Send SIGINT to child processes
+	kill 'INT' => keys %child_pids;
+	
+	notify($ERRORS{'OK'}, $LOGFILE, "vcld process exiting, pid=$$");
+	exit;
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 REAPER
+
+ Parameters  : None
+ Returns     : Undefined
+ Description : The REAPER subroutine gets called whenever a child process
+               stops running or exits. This occurs because the subroutine is
+					configured as the handler for SIGCHLD signals. The system will
+					send a SIGCHLD signal whenever a child process stops running
+					or exits.
+               
+					The REAPER subroutine manages the child PID hash when a VCL .
+					state process exits. It also captures the exit code of the
+					child process which died and makes sure the special $?
+					variable is set to this value.
+
+=cut
+
+sub REAPER {
+	# Save the information saved in $? before proceeding
+	# This is done to save the exit status of the child process which died
+	# If you don't save it, wait() will overwrite it
+	my $child_exit_status = $? >> 8;
+	my $signal_number = $? & 127;
+	my $dumped_core = $? & 128;
+	
+	# Configure the REAPER() subroutine to handle SIGCHLD signals
+	$SIG{CHLD} = \&REAPER;
+	
+	# Wait for a child process to terminate
+	# Should have already happened since this subroutine is only called when CHLD signals are sent
+	my $dead_pid = wait;
+	
+	# Check if the child PID hash contains the pid of the process which just died
+	if (exists $child_pids{$dead_pid}) {
+		# Child which died was a VCL state process since its pid is in the hash
+		$child_count--;
+		delete $child_pids{$dead_pid};
+		notify($ERRORS{'OK'}, $LOGFILE, "VCL state process exited, pid=$dead_pid");
+	}
+	else {
+		# Child which died was some other process
+		notify($ERRORS{'DEBUG'}, $LOGFILE, "child process exited, pid=$dead_pid");
+	}
+	
+	# Set the special $? variable back to the exit status of the child which died
+	# This is useful when utilities such as SSH are run in other places in the code
+	# The code which called the utility can check the exit status to see if it was successful
+	$? = $child_exit_status;
+	
+	return;
+} ## end sub REAPER
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 daemonize
+
+ Parameters  : 
+ Returns     : 
+ Description :
+
+=cut
+
+sub daemonize {
+	chdir '/' or die "Can't chdir to /: $!";
+	defined(my $pid = fork) or die "Can't fork $!";
+	exit if $pid;
+	#development
+	#$0 = "vcldev";
+	#production
+	#$0 = "vcld";
+	$0 = $PROCESSNAME;
+	print "Created process $$ renamed to $0 ...\n";
+	setsid or die "Can't start a new session: $!";
+	open STDIN,  '/dev/null'  or die "Can't read /dev/null $!";
+	open STDOUT, ">>$LOGFILE" or die "Can't write $LOGFILE $!";
+	open STDERR, ">>$LOGFILE" or die "Can't write $LOGFILE $!";
+	setsid or die "Can't start a new session: $!";
+	umask 0;
+	open(PIDFILE, ">" . $PIDFILE) or notify($ERRORS{'WARNING'}, $LOGFILE, "unable to open PID file: $PIDFILE, $!");    # so I can kill myself easily
+	print PIDFILE $$;
+	close(PIDFILE);
+} ## end sub daemonize
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 help
+
+ Parameters  : 
+ Returns     : 
+ Description :
+
+=cut
+
+sub help {
+	my $message = <<"END";
+--------------------------------------------
+
+vcld is intented to run in daemon mode.
+
+Please read the INSTALLATION file in the source directory.
+END
+
+	print $message;
+	exit;
+} ## end sub help

Added: incubator/vcl/tags/import/managementnode/bin/vcld_cron_check
URL: http://svn.apache.org/viewvc/incubator/vcl/tags/import/managementnode/bin/vcld_cron_check?rev=726079&view=auto
==============================================================================
--- incubator/vcl/tags/import/managementnode/bin/vcld_cron_check (added)
+++ incubator/vcl/tags/import/managementnode/bin/vcld_cron_check Fri Dec 12 10:20:10 2008
@@ -0,0 +1,13 @@
+#!/bin/bash
+##############################################################################
+# $Id: vcld_cron_check 1951 2008-12-12 13:48:10Z arkurth $
+##############################################################################
+
+email=
+if ! /etc/init.d/vcld.start status &> /dev/null; then
+   if /etc/init.d/vcld.start start &> /dev/null; then
+  	 echo "restarted vcld on `hostname`" |mail -s "vcld restarted" $email 
+   else
+	echo "restart of vcld failed on `hostname`" |mail -s "vcld restart failed" $email
+   fi
+fi

Propchange: incubator/vcl/tags/import/managementnode/bin/vcld_cron_check
------------------------------------------------------------------------------
    svn:executable = 

Added: incubator/vcl/tags/import/managementnode/etc/vcl/vcld.conf
URL: http://svn.apache.org/viewvc/incubator/vcl/tags/import/managementnode/etc/vcl/vcld.conf?rev=726079&view=auto
==============================================================================
--- incubator/vcl/tags/import/managementnode/etc/vcl/vcld.conf (added)
+++ incubator/vcl/tags/import/managementnode/etc/vcl/vcld.conf Fri Dec 12 10:20:10 2008
@@ -0,0 +1,239 @@
+##############################################################################
+# $Id: vcld.conf 1949 2008-12-12 13:35:49Z arkurth $
+##############################################################################
+# NAME
+# vcld.conf
+# 
+# AUTHOR
+# Aaron Peeler, aaron_peeler@ncsu.edu
+# Andy Kurth, andy_kurth@ncsu.edu
+# 
+# DESCRIPTION
+# This file contains configuration values for a VCL management node daemon.
+# It contains senistive information and should have appropriate permissions.
+# Please read the README file.  For use license and copyright information
+# see the LICENSE and COPYRIGHT files.
+#
+# FORMAT
+# The format is assumed to be key=value.  Lines should not contain spaces.
+# 
+# SEE ALSO
+# http://vcl.ncsu.edu
+# vcl_help@ncsu.edu
+# 
+# COPYRIGHT AND LICENSE
+# Copyright (C) 2004-2008 by NC State University. All Rights Reserved.
+# 
+# Virtual Computing Laboratory
+# North Carolina State University
+# Raleigh, NC, USA 27695
+# 
+# For use license and copyright information see LICENSE and COPYRIGHT files
+# included in the source files.
+
+
+# processname: name to call VCL daemon process
+# Default: vcld
+processname=vcld
+
+# FQDN: DNS name of the management node
+# Example: mgtnode1.hpc.ncsu.edu
+FQDN=
+
+# log: log file location
+# Default: /var/log/vcld.log
+# If left undefined it will be named according to the above processname
+# i.e. /var/log/$PROCESSNAME.log
+log=/var/log/vcld.log
+
+# pidfile: process id file location 
+# Default: /var/run/vcld.pid
+# If left undefined it will be named according to the above processname
+# i.e. /var/run/$PROCESSNAME.pid
+pidfile=/var/run/vcld.pid
+
+
+
+# Database connection information
+
+# database: name of MySQL database (required)
+database=vcl
+
+# server: IP address or FQDN of the database server (required)
+server=
+
+# LockerWrtUser: MySQL user account name with write privileges (required)
+LockerWrtUser=vcl-wrt
+
+# wrtPass: MySQL password of the above LockerWrtUser (required)
+# Any length is supported by MySQL
+# Must be a string of characters: A-Z a-z 0-9
+wrtPass=
+
+# LockerRdUser: MySQL user account name with write privileges (optional)
+LockerRdUser=vcl-rd
+
+# rdPass: MySQL password of the above LockerRdUser (optional)
+# Any length is supported by MySQL
+# Must be a string of characters: A-Z a-z 0-9
+rdPass=
+
+
+# enable_mysql_ssl: Determines if SSL is used for MySQL connections
+# Useful in open networks or large distributed configurations
+# Note: Perl's DBD-mysql module must be compiled with the --ssl option
+#       It is not turned on by default
+# Values: no|yes
+# Default: no
+enable_mysql_ssl=no
+
+#mysql_ssl_cert: Path to MySQL certificate file
+mysql_ssl_cert=/etc/vcl/cert/my_ca.crt
+
+
+# sysadmin: system administrator email list
+# list of email addresses to be used for critical notices regarding failures or problems
+# optional, but not recommended to leave blank
+# Format: comma delimited list
+# Example: john_doe@ncsu.edu,sysadmins@vcl.ncsu.edu
+sysadmin=
+
+
+# shared mailbox - 
+#   address of a shared mailbox for copies of all notices sent to users
+#   optional
+#   leave empty or comment out to disable
+#   depending on user base this mailbox can grow quite large
+# 
+# users are sent email notices regarding their reservations for new
+# reservations, upcoming timeouts and image creations 
+sharedmailbox=
+
+# default url for end-user notifications if not listed in affilation
+# database table - this is usually the core www site address
+DEFAULTURL=http://vcl.your.domain
+
+# default from email address for end-user notifications if not listed in
+# affilation
+# database table - normally this would be a list or a help system - but
+# could be your email address(your address not recommeded for large
+# setups)
+DEFAULTHELPEMAIL=help@your.domain.com
+
+#IM support - jabber only at this time
+#jabber - dependiences on Net::Jabber.pm perl modules
+# for information on how to install Net::Jabber.pm modules see documentation
+jabber=no
+
+# jabber variables
+# ignore if jabber=no
+
+# jabServer - server IP or FQHN of jabber server
+jabServer=your.jabber.com
+
+# jabPort - jabber port - default 5222
+jabPort=5222
+
+# jabUser - registered jabber user
+jabUser=vcl
+
+# jabPass - password for jabber user
+jabPass=
+
+# jabResource - jabbber resource
+jabResource=vcl
+
+
+# path to identity keys used to log into remote resources
+# make sure the premissions are right -- 600
+
+IDENTITY_blade_linux=/etc/vcl/bladelinuxkey_id_rsa
+IDENTITY_solaris_lab=/etc/vcl/solaris_lab.key
+IDENTITY_linux_lab=/etc/vcl/linux_lab.key
+IDENTITY_blade_win=/etc/vcl/winxp_blade.key
+
+# Windows node root password
+WINDOWS_ROOT_PASSWORD=cl0udy
+
+#ip address configuration
+# for sites that use Dynamic DHCP or static address assignment.
+# default is Manual DHCP
+# options are:
+# manualDHCP -- address is statically assigned in dhcp server
+# dynamicDHCP -- address is dynamically assigned from dhcp server
+# static --   when public dhcp server is not available, assigments are made
+
+ipconfiguration=dynamicDHCP
+
+#dependiences for static assignments - required if set to static
+# DNSserver can be comma delimited up to three entries
+#DNSserver=
+#GATEWAY=
+#NETMASK=
+#ETHDEVICE=eth1
+
+# Provisioning systems
+
+# xCAT - xcat.org
+
+XCAT=yes
+
+LINUXIMAGEid=image
+
+#throttle - to limit the number concurrent bare metal loads
+# 0 or commeted out - disabled - no limit
+# any number 1 or more - number of simultanous loads
+THROTTLE=0
+
+# XCATROOT - root files for xcat, default is /opt/xcat
+XCATROOT=/opt/xcat
+
+#xcat repositories and descriptors
+# location of the image files create by partimage
+CORE_IMAGEREPOSITORY=/install/image/x86
+WIN_IMAGEREPOSITORY=/install/image/x86
+LINUX_IMAGEREPOSITORY=/install/image/x86
+
+# - xcat location of template files, this includes both the files for
+# partimage and kickstart files 
+# defaults should be fine for most setups. 
+# normally thie tmpl files are under the xcatroot path, i.e.  # /opt/xcat/install/....
+
+CORE_TMPLREPOSITORY=XCATROOT/install/image/x86
+
+# windows images
+WIN_TMPLREPOSITORY=XCATROOT/install/image/x86
+
+# kick start files
+RHAS3_TMPLREPOSITORY=XCATROOT/install/rhas3/x86
+RHAS4_TMPLREPOSITORY=XCATROOT/install/rhas4/x86
+RHFC5_TMPLREPOSITORY=XCATROOT/install/rhfc5/x86
+
+# linux image - includes image templates for rh4,rhfc5,etc
+LINUXIMAGE_TMPLREPOSITORY=XCATROOT/install/linux_image/x86
+
+#image libraries can exist on other management nodes and hold images that we might need
+#imagelibenable, yes,no enabled,disabled   
+imagelibenable=no
+
+#imageservers = comma seperated list of IP addresses of other management nodes or image libraries
+imageservers=
+
+#imagelibuser, user allowed to login via ssh
+# adduser account: useradd -d /home/vclstaff -m vclstaff
+imagelibuser=vclstaff
+
+#imagelibkey, identity key for imagelibuser
+# to setup identity key:
+# as root su - vclstaff
+# generate key: ssh-keygen -t dsa
+# press enter when prompted for passphrase 
+# append pub key to authorized_keys: cat id_dsa.pub > authorized_keys
+#exit vclstaff
+#copy /home/vclstaff/.ssh id_dsa /etc/vcl/imagelib.key
+#make sure permissions are 600 chmod 600 /etc/vcl/imagelib.key
+imagelibidkey=/etc/vcl/imagelib.key
+
+# - VMWARE vmdk image files
+# - this can be storage on the management node
+VMWARE_IMAGEREPOSITORY=/install/vmware_images

Added: incubator/vcl/tags/import/managementnode/legacy_vcl_vbs_scripts/RandPass.wsf
URL: http://svn.apache.org/viewvc/incubator/vcl/tags/import/managementnode/legacy_vcl_vbs_scripts/RandPass.wsf?rev=726079&view=auto
==============================================================================
--- incubator/vcl/tags/import/managementnode/legacy_vcl_vbs_scripts/RandPass.wsf (added)
+++ incubator/vcl/tags/import/managementnode/legacy_vcl_vbs_scripts/RandPass.wsf Fri Dec 12 10:20:10 2008
@@ -0,0 +1,44 @@
+<package>
+  <job id="CreateUser">
+   <script language="VBScript">
+
+    Option Explicit
+    Dim WshNetwork, strPass, oAdminAcct
+    Dim UserAccount
+
+    If WScript.Arguments.Count = 1 Then
+       UserAccount = WScript.Arguments.Item(0)
+    Else
+       WScript.Echo "Usage: RandPass.wsf <user_account>"
+       WScript.Quit
+    End If
+
+    Set WshNetwork = WScript.CreateObject("WScript.Network")
+    Set oAdminAcct = GetObject("WinNT://" & WshNetwork.ComputerName & "/" & UserAccount)
+
+    strPass = generateRandomPassword(15)
+     
+    oAdminAcct.SetPassword strPass
+
+    Function generateRandomPassword(strMax)
+    Dim strPass, i, r
+
+    strPass = ""
+      Randomize
+        For i = 1 to strMax
+            r = Rnd
+                If (r < .3) Then
+                      strPass = strPass & Chr (Int ((r * 26) + 1) + 64)
+    ElseIf (r > 0.5) Then
+          strPass = strPass & Chr (Int ((r * 26) + 1) + 96)
+    Else
+          strPass = strPass & CStr (Int ((r * 10) + 1))
+    End If
+      Next
+
+        generateRandomPassword = strPass
+
+        End Function
+    </script>
+  </job>
+</package>

Propchange: incubator/vcl/tags/import/managementnode/legacy_vcl_vbs_scripts/RandPass.wsf
------------------------------------------------------------------------------
    svn:executable =