From vcl-commits-returnmelissaswanson@example.com Wed Jul 01 20:10:05 2009 Return-Path: <vcl-commits-returnmelissaswanson@example.com> Delivered-To: melissaswanson@example.com Received: (qmail 36796 invoked from network); 1 Jul 2009 20:10:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 1 Jul 2009 20:10:05 -0000 Received: (qmail 80535 invoked by uid 500); 1 Jul 2009 20:10:16 -0000 Delivered-To: melissaswanson@example.com Received: (qmail 80503 invoked by uid 500); 1 Jul 2009 20:10:16 -0000 Mailing-List: contact melissaswanson@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:melissaswanson@example.com> List-Unsubscribe: <mailto:melissaswanson@example.com> List-Post: <mailto:melissaswanson@example.com> List-Id: <vcl-commits.incubator.apache.org> Reply-To: melissaswanson@example.com Delivered-To: mailing list melissaswanson@example.com Received: (qmail 80493 invoked by uid 99); 1 Jul 2009 20:10:16 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Jul 2009 20:10:16 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Jul 2009 20:10:13 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id AC456238888E; Wed, 1 Jul 2009 20:09:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r790356 - /incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm Date: Wed, 01 Jul 2009 20:09:53 -0000 To: melissaswanson@example.com From: melissaswanson@example.com X-Mailer: svnmailer-1.0.8 Message-Id: <melissaswanson@example.com> X-Virus-Checked: Checked by ClamAV on apache.org Author: fapeeler Date: Wed Jul 1 20:09:53 2009 New Revision: 790356 URL: http://svn.apache.org/viewvc?rev=790356&view=rev Log: VCL-173 copied power_* routines from xcat.pm module Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm?rev=790356&r1=790355&r2=790356&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm Wed Jul 1 20:09:53 2009 @@ -3012,6 +3012,262 @@ #///////////////////////////////////////////////////////////////////////////// +=head2 power_reset + + Parameters : $computer_node_name (optional) + Returns : + Description : + +=cut + +sub power_reset { + my $argument_1 = shift; + my $argument_2 = shift; + + my $computer_node_name; + + # Check if subroutine was called as an object method + if (ref($argument_1) =~ /xcat/i) { + my $self = $argument_1; + + $computer_node_name = $argument_2; + + # Check if computer argument was specified + # If not, use computer node name in the data object + if (!$computer_node_name) { + $computer_node_name = $self->data->get_computer_node_name(); + } + } ## end if (ref($argument_1) =~ /xcat/i) + else { + # Subroutine was not called as an object method, 2 arguments must be specified + $computer_node_name = $argument_1; + } + + # Check if computer was determined + if (!$computer_node_name) { + notify($ERRORS{'WARNING'}, 0, "computer could not be determined from arguments"); + return; + } + + # Turn computer off + my $off_attempts = 0; + while (!power_off($computer_node_name)) { + $off_attempts++; + + if ($off_attempts == 3) { + notify($ERRORS{'WARNING'}, 0, "failed to turn $computer_node_name off, rpower status not is off after 3 attempts"); + return; + } + + sleep 2; + } ## end while (!power_off($computer_node_name)) + + # Turn computer on + my $on_attempts = 0; + while (!power_on($computer_node_name)) { + $on_attempts++; + + if ($on_attempts == 3) { + notify($ERRORS{'WARNING'}, 0, "failed to turn $computer_node_name on, rpower status not is on after 3 attempts"); + return; + } + + sleep 2; + } ## end while (!power_on($computer_node_name)) + + notify($ERRORS{'OK'}, 0, "successfully reset power on $computer_node_name"); + return 1; +} ## end sub power_reset + +#///////////////////////////////////////////////////////////////////////////// + +=head2 power_on + + Parameters : $computer_node_name (optional) + Returns : + Description : + +=cut + +sub power_on { + my $argument_1 = shift; + my $argument_2 = shift; + + my $computer_node_name; + + # Check if subroutine was called as an object method + if (ref($argument_1) =~ /xcat/i) { + my $self = $argument_1; + + $computer_node_name = $argument_2; + + # Check if computer argument was specified + # If not, use computer node name in the data object + if (!$computer_node_name) { + $computer_node_name = $self->data->get_computer_node_name(); + } + } ## end if (ref($argument_1) =~ /xcat/i) + else { + # Subroutine was not called as an object method, 2 arguments must be specified + $computer_node_name = $argument_1; + } + + # Check if computer was determined + if (!$computer_node_name) { + notify($ERRORS{'WARNING'}, 0, "computer could not be determined from arguments"); + return; + } + + # Turn computer on + my $on_attempts = 0; + my $power_status = 'unknown'; + while ($power_status !~ /on/) { + $on_attempts++; + + if ($on_attempts == 3) { + notify($ERRORS{'WARNING'}, 0, "failed to turn $computer_node_name on, rpower status not is on after 3 attempts"); + return; + } + + _rpower($computer_node_name, 'on'); + + # Wait up to 1 minute for the computer power status to be on + if (wait_for_on($computer_node_name, 1)) { + last; + } + + $power_status = power_status($computer_node_name); + } ## end while ($power_status !~ /on/) + + notify($ERRORS{'OK'}, 0, "successfully powered on $computer_node_name"); + return 1; +} ## end sub power_on + +#///////////////////////////////////////////////////////////////////////////// + +=head2 power_off + + Parameters : $computer_node_name (optional) + Returns : + Description : + +=cut + +sub power_off { + my $argument_1 = shift; + my $argument_2 = shift; + + my $computer_node_name; + + # Check if subroutine was called as an object method + if (ref($argument_1) =~ /xcat/i) { + my $self = $argument_1; + + $computer_node_name = $argument_2; + + # Check if computer argument was specified + # If not, use computer node name in the data object + if (!$computer_node_name) { + $computer_node_name = $self->data->get_computer_node_name(); + } + } ## end if (ref($argument_1) =~ /xcat/i) + else { + # Subroutine was not called as an object method, 2 arguments must be specified + $computer_node_name = $argument_1; + } + + # Check if computer was determined + if (!$computer_node_name) { + notify($ERRORS{'WARNING'}, 0, "computer could not be determined from arguments"); + return; + } + + # Turn computer off + my $power_status = 'unknown'; + my $off_attempts = 0; + while ($power_status !~ /off/) { + $off_attempts++; + + if ($off_attempts == 3) { + notify($ERRORS{'WARNING'}, 0, "failed to turn $computer_node_name off, rpower status not is off after 3 attempts"); + return; + } + + # Attempt to run rpower <node> off + _rpower($computer_node_name, 'off'); + + # Wait up to 1 minute for the computer power status to be off + if (wait_for_off($computer_node_name, 1)) { + last; + } + + $power_status = power_status($computer_node_name); + } ## end while ($power_status !~ /off/) + + notify($ERRORS{'OK'}, 0, "successfully powered off $computer_node_name"); + return 1; +} ## end sub power_off + +#///////////////////////////////////////////////////////////////////////////// + +=head2 power_status + + Parameters : $computer_node_name (optional) + Returns : + Description : + +=cut + +sub power_status { + my $argument_1 = shift; + my $argument_2 = shift; + + my $computer_node_name; + + # Check if subroutine was called as an object method + if (ref($argument_1) =~ /xcat/i) { + my $self = $argument_1; + + $computer_node_name = $argument_2; + + # Check if computer argument was specified + # If not, use computer node name in the data object + if (!$computer_node_name) { + $computer_node_name = $self->data->get_computer_node_name(); + } + } ## end if (ref($argument_1) =~ /xcat/i) + else { + # Subroutine was not called as an object method, 2 arguments must be specified + $computer_node_name = $argument_1; + } + + # Check if computer was determined + if (!$computer_node_name) { + notify($ERRORS{'WARNING'}, 0, "computer could not be determined from arguments"); + return; + } + + # Call rpower to determine power status + my $rpower_stat = _rpower($computer_node_name, 'stat'); + notify($ERRORS{'DEBUG'}, 0, "retrieved power status of $computer_node_name: $rpower_stat"); + + if (!$rpower_stat) { + notify($ERRORS{'WARNING'}, 0, "failed to determine power status, rpower subroutine returned $rpower_stat"); + return; + } + elsif ($rpower_stat =~ /^(on|off)$/i) { + return lc($1); + } + else { + notify($ERRORS{'WARNING'}, 0, "failed to determine power status, unexpected output returned from rpower: $rpower_stat"); + return; + } +} ## end sub power_status + + + +#///////////////////////////////////////////////////////////////////////////// + initialize() if (!$XCAT_ROOT); #///////////////////////////////////////////////////////////////////////////// From vcl-commits-returnmelissaswanson@example.com Thu Jul 02 14:07:50 2009 Return-Path: <vcl-commits-returnmelissaswanson@example.com> Delivered-To: melissaswanson@example.com Received: (qmail 9297 invoked from network); 2 Jul 2009 14:07:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 2 Jul 2009 14:07:50 -0000 Received: (qmail 68402 invoked by uid 500); 2 Jul 2009 14:08:00 -0000 Delivered-To: melissaswanson@example.com Received: (qmail 68373 invoked by uid 500); 2 Jul 2009 14:08:00 -0000 Mailing-List: contact melissaswanson@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:melissaswanson@example.com> List-Unsubscribe: <mailto:melissaswanson@example.com> List-Post: <mailto:melissaswanson@example.com> List-Id: <vcl-commits.incubator.apache.org> Reply-To: melissaswanson@example.com Delivered-To: mailing list melissaswanson@example.com Received: (qmail 68363 invoked by uid 99); 2 Jul 2009 14:08:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Jul 2009 14:08:00 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Jul 2009 14:07:52 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2AC6023888CD; Thu, 2 Jul 2009 14:07:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r790598 - in /incubator/vcl/trunk/managementnode/bin: cygwin-sshd-config.sh gen-node-key.sh Date: Thu, 02 Jul 2009 14:07:32 -0000 To: melissaswanson@example.com From: melissaswanson@example.com X-Mailer: svnmailer-1.0.8 Message-Id: <melissaswanson@example.com> X-Virus-Checked: Checked by ClamAV on apache.org Author: arkurth Date: Thu Jul 2 14:07:31 2009 New Revision: 790598 URL: http://svn.apache.org/viewvc?rev=790598&view=rev Log: VCL-164 Added cygwin-sshd-config.sh and gen-node-key.sh scripts. These scripts perform all the steps necessary to allow a management node to access a computer via SSH using a key. Added: incubator/vcl/trunk/managementnode/bin/cygwin-sshd-config.sh incubator/vcl/trunk/managementnode/bin/gen-node-key.sh Added: incubator/vcl/trunk/managementnode/bin/cygwin-sshd-config.sh URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/bin/cygwin-sshd-config.sh?rev=790598&view=auto ============================================================================== --- incubator/vcl/trunk/managementnode/bin/cygwin-sshd-config.sh (added) +++ incubator/vcl/trunk/managementnode/bin/cygwin-sshd-config.sh Thu Jul 2 14:07:31 2009 @@ -0,0 +1,238 @@ +############################################################################## +# $Id: $ +############################################################################## +# 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. +############################################################################### +# DESCRIPTION +# Configures the Cygwin SSHD service installed in a Windows image. +# Cygwin and the sshd component must be installed prior to running this script. +# This script should be run on a node which has been installed with a base +# image. After running this script, gen-node-key.sh should be run on a +# management node. +# This script does the following: +# * Stops any running sshd processes and servicies +# * Deletes an existing sshd user account if it exists +# * Deletes existing /etc/ssh* files +# * Sets the correct owner and permissions on several files and directories +# * Recreates the /etc/passwd and /etc/group files +# * Configures the correct system mount points +# * Runs ssh-host-config +# * Sets the following options in /etc/sshd_config: +# LogLevel=VERBOSE +# MaxAuthTries=12 +# PasswordAuthentication=yes +# Banner=none +# UsePrivilegeSeparation=yes +# StrictModes=no +# LoginGraceTime=10 +# Compression=no +# * Configures the sshd service to log to /var/log/sshd.log +# * Grants the log on as a service permission to root +# * Configures the sshd service to run as root +# * Configures the firewall to allow port 22 +# * Starts the sshd service + +# ----------------------------------------------------------------------------- +# Name : set_config +# Parameters : [config_file] [keyword] [value] +# Returns : always 1 +# Description : Finds and sets the keyword to the value specified in an SSH +# configuration file. This function should work with ssh_config +# and sshd_config files. +# Example: set_config /etc/ssh_config Compression no +# This should find the line in ssh_config beginning with either of +# the following: +# # Compression <existing value> +# Compression <existing value> +# And change the line to: +# Compression no +function set_config { + if [ $# -ne 3 ] + then + echo "usage: set_config [config_file] [keyword] [value]" + exit 1 + fi + + config_file=$1 + keyword=$2 + value=$3 + + echo Setting $keyword to $value in $config_file + sed -i -r -e "s/^[ #]*($keyword).*/\1 $value/" $config_file + grep -i -r "^[ #]*$keyword" $config_file + echo ---------- + + return 1; +} + +# ----------------------------------------------------------------------------- + +if [ $# -ne 1 ] +then + echo "Usage: $0 '<root password>'" + exit 1 +fi +PASSWORD=$1 + +echo Stopping sshd service if it is running +net stop sshd 2>/dev/null +echo ---------- + +echo Deleting sshd service if it already exists +$SYSTEMROOT/system32/sc.exe delete sshd +echo ---------- + +echo Deleting the sshd user if it already exists +net user sshd /DELETE +echo ---------- + +echo Deleting '/etc/ssh*' +rm -fv /etc/ssh* +echo ---------- + +echo Deleting /var/log/sshd.log if it exists +rm -fv /var/log/sshd.log +echo ---------- + +echo Setting root:Administrators as owner of '/etc' and '/var' +chown -R root:Administrators /etc /var +echo ---------- + +echo Adding ug+rwx permissions to '/etc' and '/var' +chmod -v ug+rwx /etc /var +echo ---------- + +echo Adding read permission on /etc/passwd and /etc/group +chmod -v +r /etc/passwd /etc/group +echo ---------- + +echo Adding ug+w permission on /etc/passwd and /etc/group +chmod -v ug+w /etc/passwd /etc/group +echo ---------- + +echo Recreating /etc/group +mkgroup -l > /etc/group +echo ---------- + +echo Recreating /etc/passwd +mkpasswd -l > /etc/passwd +echo ---------- + +echo Configuring mount points +umount -u /usr/bin 2>/dev/nul +mount -f -s -b C:/cygwin/bin /usr/bin +umount -u /usr/lib 2>/dev/nul +mount -f -s -b C:/cygwin/lib /usr/lib +umount -u / 2>/dev/nul +mount -f -s -b C:/cygwin / +echo ---------- + +echo Adding execute permission on /var +chmod -v +x /var +echo ---------- + +echo Running ssh-host-config +ssh-host-config -y +echo ---------- + +echo Creating /var/empty directory if it does not exist +mkdir /var/empty 2>/dev/NULL +echo ---------- + +echo Setting root:Administrators as owner of /var/empty +chown -Rv root:Administrators /var/empty +echo ---------- + +echo Setting permissions to 755 on /var/empty +chmod -Rv 755 /var/empty +echo ---------- + +echo Setting permissions to 775 on /var/log +chmod -Rv 775 /var/log +echo ---------- + +echo Creating /var/log/sshd.log file if it does not exist +touch /var/log/sshd.log +echo ---------- + +echo Setting root:Administrators as owner of '/etc/ssh*' and /var/log/sshd.log +chown -Rv root:Administrators /etc/ssh* /var/log/sshd.log +echo ---------- + +echo Setting permissions to ug+rw on '/etc/ssh*' and /var/log/sshd.log +chmod -Rv ug+rw /etc/ssh* /var/log/sshd.log +echo ---------- + +echo Setting permissions to 600 on '/etc/ssh*key' +chmod -v 600 /etc/ssh*key +echo ---------- + +echo Setting permissions to ug+rwx on /etc +chmod -v ug+rwx /etc +echo ---------- + +echo Configuring /etc/sshd_config +set_config '/etc/sshd_config' 'LogLevel' 'VERBOSE' +set_config '/etc/sshd_config' 'MaxAuthTries' '12' +set_config '/etc/sshd_config' 'PasswordAuthentication' 'yes' +set_config '/etc/sshd_config' 'Banner' 'none' +set_config '/etc/sshd_config' 'UsePrivilegeSeparation' 'yes' +set_config '/etc/sshd_config' 'StrictModes' 'no' +set_config '/etc/sshd_config' 'LoginGraceTime' '10' +set_config '/etc/sshd_config' 'Compression' 'no' + +echo Configuring the sshd service to log to /var/log/sshd.log +reg.exe ADD "HKLM\SYSTEM\CurrentControlSet\Services\sshd\Parameters" /v AppArgs /d "-D -e" /t REG_SZ /f +echo ---------- + +echo Configuring the sshd service to use the root account: $PASSWORD +$SYSTEMROOT/system32/sc.exe config sshd obj= ".\root" password= "$PASSWORD" +echo ---------- + +# Assemble the paths secedit needs +secedit_exe="C:\\WINDOWS\\system32\\secedit.exe" +secedit_inf='C:\\WINDOWS\\security\\templates\\root_logon_service.inf' +secedit_db="C:\\WINDOWS\\security\\Database\\root_logon_service.sdb" +secedit_log="C:\\WINDOWS\\security\\Logs\\root_logon_service.log" + +# Create the security template file +echo Creating the security template to grant root the right to logon as a service +cat >$secedit_inf <<EOF +[Privilege Rights] +SeServiceLogonRight = root +[Version] +signature="\$WINDOWS NT\$" +EOF + +unix2dos $secedit_inf + +echo Running secedit.exe to grant root the right to logon as a service +cmd.exe /c $secedit_exe /configure /cfg "$secedit_inf" /db $secedit_db /log $secedit_log /verbose +echo ---------- + +echo Configuring firewall port 22 exception +netsh firewall set portopening name = "Cygwin SSHD" protocol = TCP port = 22 mode = ENABLE profile = ALL scope = ALL +echo ---------- + +echo Starting the sshd service +net start sshd +echo ---------- + +echo /var/log/sshd.log ending: +tail -n 10 /var/log/sshd.log +echo ---------- + +echo Done Added: incubator/vcl/trunk/managementnode/bin/gen-node-key.sh URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/bin/gen-node-key.sh?rev=790598&view=auto ============================================================================== --- incubator/vcl/trunk/managementnode/bin/gen-node-key.sh (added) +++ incubator/vcl/trunk/managementnode/bin/gen-node-key.sh Thu Jul 2 14:07:31 2009 @@ -0,0 +1,100 @@ +############################################################################## +# $Id: $ +############################################################################## +# 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. +############################################################################### +# DESCRIPTION +# Configures a VCL management node to be able to control a remote node using SSH +# keys. The IP address or hostname of a remote node which has already been +# configured to respond to SSH must be supplied as an argument. This script does +# the following: +# * Generates an 1024 bit RSA SSH public/private key pair if it doesn't already +# exist. Location: +# Private key: /etc/vcl/vcl.key +# Public key: /etc/vcl/vcl.key.pub +# * Configures the ssh_config file on the management node to use the following +# options: +# StrictHostKeyChecking=no +# * Removes any existing entries in the known_hosts file for the node specified +# * Adds the current host key of the node specified to the known_hosts file +# * Adds the vcl.key.pub public key to the authorized_keys file on the specified +# host +# * Configures the sshd_config file on the specified host with the following +# options: +# PermitRootLogin=no +# PasswordAuthentication=no +# * Restarts the sshd service on the specified node + +if [ $# -ne 1 ] +then + echo "Usage: $0 <node>" + exit 1 +fi +NODE=$1 + +# Check if vcl.key already exists, create it if it doesn't +echo ---------- +if [ -f '/etc/vcl/vcl.key' ]; +then + echo SSH key already exists on this management node: '/etc/vcl/vcl.key' +else + echo Creating SSH keys on management node: '/etc/vcl/vcl.key(.pub)' + mkdir -p /etc/vcl + ssh-keygen -t rsa -f /etc/vcl/vcl.key -N '' -b 1024 -C 'root on VCL management node' + echo "IdentityFile /etc/vcl/vcl.key" >> /etc/ssh/ssh_config +fi +echo ---------- + +echo Setting StrictHostKeyChecking to no in ssh_config on this management node +sed -i -r -e "s/^[ #]*(StrictHostKeyChecking).*/\1 no/" /etc/ssh/ssh_config +grep -i -r "^[ #]*StrictHostKeyChecking" /etc/ssh/ssh_config +echo ---------- + +# Remove existing entries for the node from known_hosts for the node specified by the argument +if [ `grep -ic $NODE /root/.ssh/known_hosts` -ne 0 ]; +then + echo Removing $C entries for $NODE from '/root/.ssh/known_hosts' + sed -i -r -e "s/.*$NODE.*//" /root/.ssh/known_hosts +else + echo Entry does not exist for $NODE in '/root/.ssh/known_hosts' +fi +echo ---------- + +echo Scanning host key for $NODE and adding it to '/root/.ssh/known_hosts' +ssh-keyscan -t rsa $NODE >> /root/.ssh/known_hosts + +echo Copying public key to authorized_keys on $NODE +ssh-copy-id -i /etc/vcl/vcl.key.pub $NODE +echo ---------- + +echo Setting PermitRootLogin to no in sshd_config on $NODE +ssh -i /etc/vcl/vcl.key root@$NODE 'sed -i -r -e "s/^[ #]*(PermitRootLogin).*/\1 no/" /etc/sshd_config' +ssh -i /etc/vcl/vcl.key root@$NODE 'grep "^[ #]*PermitRootLogin" /etc/sshd_config' +echo ---------- + +echo Setting PasswordAuthentication to no in sshd_config on $NODE +ssh -i /etc/vcl/vcl.key root@$NODE 'sed -i -r -e "s/^[ #]*(PasswordAuthentication).*/\1 no/" /etc/sshd_config' +ssh -i /etc/vcl/vcl.key root@$NODE 'grep "^[ #]*PasswordAuthentication" /etc/sshd_config' +echo ---------- + +echo Restarting the sshd service on $NODE +ssh -i /etc/vcl/vcl.key root@$NODE 'net stop sshd ; net start sshd' +echo ---------- + +echo Done, the following command should work: +echo "ssh -i /etc/vcl/vcl.key $NODE" + +exit 0 \ No newline at end of file From vcl-commits-returnmelissaswanson@example.com Mon Jul 06 19:35:13 2009 Return-Path: <vcl-commits-returnmelissaswanson@example.com> Delivered-To: melissaswanson@example.com Received: (qmail 27104 invoked from network); 6 Jul 2009 19:35:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 6 Jul 2009 19:35:13 -0000 Received: (qmail 18800 invoked by uid 500); 6 Jul 2009 19:35:23 -0000 Delivered-To: melissaswanson@example.com Received: (qmail 18770 invoked by uid 500); 6 Jul 2009 19:35:23 -0000 Mailing-List: contact melissaswanson@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:melissaswanson@example.com> List-Unsubscribe: <mailto:melissaswanson@example.com> List-Post: <mailto:melissaswanson@example.com> List-Id: <vcl-commits.incubator.apache.org> Reply-To: melissaswanson@example.com Delivered-To: mailing list melissaswanson@example.com Received: (qmail 18760 invoked by uid 99); 6 Jul 2009 19:35:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Jul 2009 19:35:23 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Jul 2009 19:35:20 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2172C2388857; Mon, 6 Jul 2009 19:34:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r791580 - /incubator/vcl/trunk/mysql/vcl.sql Date: Mon, 06 Jul 2009 19:34:59 -0000 To: melissaswanson@example.com From: melissaswanson@example.com X-Mailer: svnmailer-1.0.8 Message-Id: <melissaswanson@example.com> X-Virus-Checked: Checked by ClamAV on apache.org Author: jfthomps Date: Mon Jul 6 19:34:58 2009 New Revision: 791580 URL: http://svn.apache.org/viewvc?rev=791580&view=rev Log: VCL-78 added imageid to blockComputers table Modified: incubator/vcl/trunk/mysql/vcl.sql Modified: incubator/vcl/trunk/mysql/vcl.sql URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/mysql/vcl.sql?rev=791580&r1=791579&r2=791580&view=diff ============================================================================== --- incubator/vcl/trunk/mysql/vcl.sql (original) +++ incubator/vcl/trunk/mysql/vcl.sql Mon Jul 6 19:34:58 2009 @@ -69,8 +69,10 @@ CREATE TABLE IF NOT EXISTS `blockComputers` ( `blockTimeid` mediumint(8) unsigned NOT NULL default '0', `computerid` smallint(5) unsigned NOT NULL default '0', + `imageid` smallint(5) unsigned NOT NULL default '0', PRIMARY KEY (`blockTimeid`,`computerid`), - KEY `computerid` (`computerid`) + KEY `computerid` (`computerid`), + KEY `imageid` (`imageid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -------------------------------------------------------- From vcl-commits-returnmelissaswanson@example.com Tue Jul 07 17:23:57 2009 Return-Path: <vcl-commits-returnmelissaswanson@example.com> Delivered-To: melissaswanson@example.com Received: (qmail 26395 invoked from network); 7 Jul 2009 17:23:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 7 Jul 2009 17:23:56 -0000 Received: (qmail 82332 invoked by uid 500); 7 Jul 2009 17:24:07 -0000 Delivered-To: melissaswanson@example.com Received: (qmail 82305 invoked by uid 500); 7 Jul 2009 17:24:06 -0000 Mailing-List: contact melissaswanson@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:melissaswanson@example.com> List-Unsubscribe: <mailto:melissaswanson@example.com> List-Post: <mailto:melissaswanson@example.com> List-Id: <vcl-commits.incubator.apache.org> Reply-To: melissaswanson@example.com Delivered-To: mailing list melissaswanson@example.com Received: (qmail 82295 invoked by uid 99); 7 Jul 2009 17:24:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Jul 2009 17:24:06 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Jul 2009 17:24:04 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4E5632388892; Tue, 7 Jul 2009 17:23:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r791915 - /incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod.pm Date: Tue, 07 Jul 2009 17:23:44 -0000 To: melissaswanson@example.com From: melissaswanson@example.com X-Mailer: svnmailer-1.0.8 Message-Id: <melissaswanson@example.com> X-Virus-Checked: Checked by ClamAV on apache.org Author: arkurth Date: Tue Jul 7 17:23:43 2009 New Revision: 791915 URL: http://svn.apache.org/viewvc?rev=791915&view=rev Log: VCL-23 Removed allow_remote_access() sub and added command to set the registry key to firewall_enable_rdp() and firewall_enable_rdp_private(). Removed call to allow_remote_access() in pre_capture(). This ensures that the fDenyTSConnections registry key is properly set whenever RDP is enabled. Fixed bug in filesystem_entry_exists(). It had been using ls to determine if a file exists. This fails if the file is hidden. The pagefile.sys file is an example. It was reporting that the file didn't exist even though it did. Changed sub to use cmd.exe /c dir. VCL-65 Added get_volume_list() sub. Added call to get_volume_list() from disable_pagefile(). It now attempts to delete a pagefile.sys file from all drives instead of just C:. Images containing multiple partitions may contain pagefiles on other drives. Not removing these causes images to be larger than necessary. Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod.pm Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod.pm URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod.pm?rev=791915&r1=791914&r2=791915&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod.pm Tue Jul 7 17:23:43 2009 @@ -309,16 +309,6 @@ =item * - Allow users to connect remotely (this does not enable RDP, but allows general remote access) - -=cut - - if (!$self->allow_remote_access()) { - notify($ERRORS{'WARNING'}, 0, "unable to allow users to connect remotely"); - } - -=item * - Disable RDP access from any IP address =cut @@ -1105,22 +1095,22 @@ return; } - # Replace backslashes with forward slashes - $path =~ s/\\+/\//; + # Replace any backslashes or forward slashes with \\ + $path =~ s/[\\\/]+/\\/g; - # Assemble the ls command and execute it - my $ls_command = "ls -lad \"$path\""; - my ($ls_exit_status, $ls_output) = run_ssh_command($computer_node_name, $management_node_keys, $ls_command, '', '', 1); - if (defined($ls_exit_status) && $ls_exit_status == 0) { - notify($ERRORS{'DEBUG'}, 0, "filesystem entry exists on $computer_node_name: $path"); + # Assemble the dir command and execute it + my $dir_command = "cmd.exe /c dir /a /b /s \"$path\""; + my ($dir_exit_status, $dir_output) = run_ssh_command($computer_node_name, $management_node_keys, $dir_command, '', '', 1); + if ((defined($dir_exit_status) && $dir_exit_status == 0) || (defined($dir_output) && grep(/$path/i, @$dir_output))) { + notify($ERRORS{'DEBUG'}, 0, "filesystem entry exists on $computer_node_name: $path, dir output:\n" . join("\n", @$dir_output)); return 1; } - elsif (defined($ls_exit_status) && $ls_exit_status == 2) { - notify($ERRORS{'DEBUG'}, 0, "filesystem entry does NOT exist on $computer_node_name: $path\noutput:\n" . join("\n", @$ls_output)); + elsif ((defined($dir_exit_status) && $dir_exit_status == 1) || (defined($dir_output) && grep(/file not found/i, @$dir_output))) { + notify($ERRORS{'DEBUG'}, 0, "filesystem entry does NOT exist on $computer_node_name: $path\noutput:\n" . join("\n", @$dir_output)); return 0; } - elsif ($ls_exit_status) { - notify($ERRORS{'WARNING'}, 0, "failed to determine if filesystem entry exists on $computer_node_name: $path, exit status: $ls_exit_status, output:\n@{$ls_output}"); + elsif ($dir_exit_status) { + notify($ERRORS{'WARNING'}, 0, "failed to determine if filesystem entry exists on $computer_node_name: $path, exit status: $dir_exit_status, output:\n@{$dir_output}"); return; } else { @@ -1769,11 +1759,23 @@ notify($ERRORS{'WARNING'}, 0, "failed to reboot computer after disabling pagefile"); return; } - - # Attempt to delete the pagefile - if (!$self->delete_file("C:/pagefile.sys")) { - notify($ERRORS{'WARNING'}, 0, "failed to delete pagefile.sys"); - return; + + # Attempt to delete the pagefile from all drives + # A pagefile may reside on drives other than C: if additional volumes are configured in the image + my @volume_list = $self->get_volume_list(); + if (!@volume_list || !(grep(/c/, @volume_list))) { + @volume_list = ('c'); + } + + # Loop through the drive letters and attempt to delete pagefile.sys on each drive + for my $drive_letter (@volume_list) { + if ($self->delete_file("$drive_letter:/pagefile.sys")) { + notify($ERRORS{'DEBUG'}, 0, "deleted pagefile.sys on all $drive_letter:"); + } + else { + notify($ERRORS{'WARNING'}, 0, "failed to delete pagefile.sys on all $drive_letter:"); + return; + } } return 1; @@ -4118,44 +4120,6 @@ #///////////////////////////////////////////////////////////////////////////// -=head2 allow_remote_access - - Parameters : - Returns : 1 if succeeded, 0 otherwise - Description : - -=cut - -sub allow_remote_access { - my $self = shift; - if (ref($self) !~ /windows/i) { - notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a function, it must be called as a class method"); - return; - } - - # Set the registry key that allows users to connect remotely - # This key is configured by the "Allow users to connect remotely to this computer" checkbox - my $registry_string .= <<EOF; -Windows Registry Editor Version 5.00 - -[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Terminal Server] -"fDenyTSConnections"=dword:00000000 -EOF - - # Import the string into the registry - if ($self->import_registry_string($registry_string)) { - notify($ERRORS{'OK'}, 0, "set registry key to allow users to connect remotely"); - } - else { - notify($ERRORS{'WARNING'}, 0, "failed to set registry key to allow users to connect remotely"); - return; - } - - return 1; -} - -#///////////////////////////////////////////////////////////////////////////// - =head2 firewall_enable_rdp Parameters : @@ -4178,6 +4142,11 @@ my $computer_node_name = $self->data->get_computer_node_name(); my $netsh_command; + + # Set the key to allow remote connections whenever enabling RDP + # Include this in the SSH command along with the netsh.exe commands rather than calling it separately for faster execution + $netsh_command .= 'reg.exe ADD "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Terminal Server" /t REG_DWORD /v fDenyTSConnections /d 0 /f ; '; + $netsh_command .= "netsh.exe firewall set portopening"; $netsh_command .= " name = \"Remote Desktop\""; $netsh_command .= " protocol = TCP"; @@ -4231,6 +4200,10 @@ my $netsh_command; + # Set the key to allow remote connections whenever enabling RDP + # Include this in the SSH command along with the netsh.exe commands rather than calling it separately for faster execution + $netsh_command .= 'reg.exe ADD "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Terminal Server" /t REG_DWORD /v fDenyTSConnections /d 0 /f ; '; + # Get the public interface name # Add command to disable RDP on public interface if its name is found my $public_interface_name = $self->get_public_interface_name(); @@ -7389,6 +7362,56 @@ #///////////////////////////////////////////////////////////////////////////// +=head2 get_volume_list + + Parameters : None + Returns : If successful: array containing volume drive letters + If failed: false + Description : + +=cut + +sub get_volume_list { + my $self = shift; + unless (ref($self) && $self->isa('VCL888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Module')) { + notify($ERRORS{'CRITICAL'}, 0, "subroutine can only be called as a VCL888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Module module object method"); + return; + } + + my $management_node_keys = $self->data->get_management_node_keys(); + my $computer_node_name = $self->data->get_computer_node_name(); + + # Echo the diskpart script to a temp file on the node + my $for_command = 'for i in `ls /cygdrive 2>/dev/null`; do echo $i; done;'; + my ($for_exit_status, $for_output) = run_ssh_command($computer_node_name, $management_node_keys, $for_command, '', '', 1); + if (defined($for_exit_status) && $for_exit_status == 0) { + notify($ERRORS{'OK'}, 0, "retrieved drive letter list under /cygdrive:\n" . join("\n", @$for_output)); + } + elsif ($for_exit_status) { + notify($ERRORS{'WARNING'}, 0, "failed to retrieve drive letter list under /cygdrive, exit status: $for_exit_status, output:\n@{$for_output}"); + return; + } + else { + notify($ERRORS{'WARNING'}, 0, "failed to run SSH command to retrieve drive letter list under /cygdrive"); + return; + } + + my @drive_letters; + for my $for_output_line (@$for_output) { + if ($for_output_line =~ /^[a-z]$/) { + push @drive_letters, $for_output_line; + } + else { + notify($ERRORS{'WARNING'}, 0, "unexpected output from for command: $for_output_line"); + } + } + + return @drive_letters; +} + + +#///////////////////////////////////////////////////////////////////////////// + 1; __END__ From vcl-commits-returnmelissaswanson@example.com Wed Jul 08 14:02:27 2009 Return-Path: <vcl-commits-returnmelissaswanson@example.com> Delivered-To: melissaswanson@example.com Received: (qmail 412 invoked from network); 8 Jul 2009 14:02:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 8 Jul 2009 14:02:27 -0000 Received: (qmail 50193 invoked by uid 500); 8 Jul 2009 14:02:37 -0000 Delivered-To: melissaswanson@example.com Received: (qmail 50159 invoked by uid 500); 8 Jul 2009 14:02:37 -0000 Mailing-List: contact melissaswanson@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:melissaswanson@example.com> List-Unsubscribe: <mailto:melissaswanson@example.com> List-Post: <mailto:melissaswanson@example.com> List-Id: <vcl-commits.incubator.apache.org> Reply-To: melissaswanson@example.com Delivered-To: mailing list melissaswanson@example.com Received: (qmail 50149 invoked by uid 99); 8 Jul 2009 14:02:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Jul 2009 14:02:37 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Jul 2009 14:02:33 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BEE0E2388866; Wed, 8 Jul 2009 14:02:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r792143 - /incubator/vcl/trunk/mysql/vcl.sql Date: Wed, 08 Jul 2009 14:02:12 -0000 To: melissaswanson@example.com From: melissaswanson@example.com X-Mailer: svnmailer-1.0.8 Message-Id: <melissaswanson@example.com> X-Virus-Checked: Checked by ClamAV on apache.org Author: arkurth Date: Wed Jul 8 14:02:12 2009 New Revision: 792143 URL: http://svn.apache.org/viewvc?rev=792143&view=rev Log: VCL-175 Updated VCL database schema. Configured virtualswitch0 and virtualswitch1 columns in vmprofile to not be null. Set default values: virtualswitch0 = VMnet0, virtualswitch1, VMnet2. Modified: incubator/vcl/trunk/mysql/vcl.sql Modified: incubator/vcl/trunk/mysql/vcl.sql URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/mysql/vcl.sql?rev=792143&r1=792142&r2=792143&view=diff ============================================================================== --- incubator/vcl/trunk/mysql/vcl.sql (original) +++ incubator/vcl/trunk/mysql/vcl.sql Wed Jul 8 14:02:12 2009 @@ -998,8 +998,8 @@ `nasshare` varchar(128) default NULL, `datastorepath` varchar(128) NOT NULL, `vmpath` varchar(128) default NULL, - `virtualswitch0` varchar(80) default NULL, - `virtualswitch1` varchar(80) default NULL, + `virtualswitch0` varchar(80) NOT NULL default 'VMnet0', + `virtualswitch1` varchar(80) NOT NULL default 'VMnet2', `vmdisk` enum('localdisk','networkdisk') NOT NULL default 'localdisk', `username` varchar(32) NULL default NULL, `password` varchar(128) NULL default NULL, From vcl-commits-returnmelissaswanson@example.com Wed Jul 08 14:12:35 2009 Return-Path: <vcl-commits-returnmelissaswanson@example.com> Delivered-To: melissaswanson@example.com Received: (qmail 30443 invoked from network); 8 Jul 2009 14:12:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 8 Jul 2009 14:12:35 -0000 Received: (qmail 64089 invoked by uid 500); 8 Jul 2009 14:12:45 -0000 Delivered-To: melissaswanson@example.com Received: (qmail 64033 invoked by uid 500); 8 Jul 2009 14:12:45 -0000 Mailing-List: contact melissaswanson@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:melissaswanson@example.com> List-Unsubscribe: <mailto:melissaswanson@example.com> List-Post: <mailto:melissaswanson@example.com> List-Id: <vcl-commits.incubator.apache.org> Reply-To: melissaswanson@example.com Delivered-To: mailing list melissaswanson@example.com Received: (qmail 63940 invoked by uid 99); 8 Jul 2009 14:12:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Jul 2009 14:12:44 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Jul 2009 14:12:42 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B2DE123888CE; Wed, 8 Jul 2009 14:12:22 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r792147 - /incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm Date: Wed, 08 Jul 2009 14:12:22 -0000 To: melissaswanson@example.com From: melissaswanson@example.com X-Mailer: svnmailer-1.0.8 Message-Id: <melissaswanson@example.com> X-Virus-Checked: Checked by ClamAV on apache.org Author: arkurth Date: Wed Jul 8 14:12:22 2009 New Revision: 792147 URL: http://svn.apache.org/viewvc?rev=792147&view=rev Log: VCL-175 Added code to configure the eth0 connection using the value of vmprofile.virtualswitch0 for VMware GSX images. VCL-176 Removed condition during load that prevented the management node from checking if a VM is responding to ssh during the first 15 iterations of a checking loop. This should speed up loads. VCL-177 Removed Windows OS post-load tasks from vmware.pm. These were being done twice because new.pm calls the OS module's post_load() subroutine after the provisioning module's load() subroutine returns. Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm?rev=792147&r1=792146&r2=792147&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm Wed Jul 8 14:12:22 2009 @@ -652,6 +652,11 @@ push(@vmxfile, "ethernet1.wakeOnPcktRcv = \"false\"\n"); } elsif ($vmtype =~ /freeserver|gsx|vmwareGSX/) { + # If $virtualswitch0 has been configured, set the custom connection type + # If it hasn't, the default bridged connection will be used + push(@vmxfile, "Ethernet0.connectionType = \"custom\"\n"); + push(@vmxfile, "Ethernet0.vnet = \"$virtualswitch0\"\n"); + push(@vmxfile, "Ethernet1.connectionType = \"custom\"\n"); push(@vmxfile, "Ethernet1.vnet = \"$virtualswitch1\"\n"); } @@ -830,18 +835,19 @@ if ($l =~ /= on/) { #good vm still on notify($ERRORS{'OK'}, 0, "vm $computer_shortname reports on"); - - if ($sloop > 15) { - my $sshd_status = _sshd_status($computer_shortname, $requestedimagename); - if ($sshd_status eq "on") { - notify($ERRORS{'OK'}, 0, "$computer_shortname now has active sshd running, maybe we missed the READY flag setting STAGE5 flag"); - $s5 = 1; - #speed this up a bit - close(TAIL); - goto VMWAREROUND2; - } - } ## end if ($sloop > 15) - + + my $sshd_status = _sshd_status($computer_shortname, $requestedimagename); + if ($sshd_status eq "on") { + notify($ERRORS{'OK'}, 0, "$computer_shortname now has active sshd running, maybe we missed the READY flag setting STAGE5 flag"); + $s5 = 1; + #speed this up a bit + close(TAIL); + goto VMWAREROUND2; + } + else { + notify($ERRORS{'OK'}, 0, "sshd is NOT active on $computer_shortname yet"); + } + } ## end if ($l =~ /= on/) elsif ($l =~ /= off/) { #good vm still on @@ -1034,51 +1040,8 @@ } insertloadlog($reservation_id, $vmclient_computerid, "info", "starting post configurations on node"); - if ($vmclient_OSname =~ /vmwarewin|vmwareesxwin/) { - if (changewindowspasswd($computer_shortname, "root")) { - notify($ERRORS{'OK'}, 0, "Successfully changed password, account $computer_shortname,root"); - } - - if (changewindowspasswd($computer_shortname, "administrator")) { - notify($ERRORS{'OK'}, 0, "Successfully changed password, account $computer_shortname,administrator"); - } - #disable remote desktop port - if (remotedesktopport($computer_shortname, "DISABLE")) { - notify($ERRORS{'OK'}, 0, "remote desktop disabled on $computer_shortname"); - } - else { - notify($ERRORS{'OK'}, 0, "remote desktop not disable on $computer_shortname"); - } - - # set sshd to auto - if (_set_sshd_startmode($computer_shortname, "auto")) { - notify($ERRORS{'OK'}, 0, "successfully set sshd service on $computer_shortname to start auto"); - } - else { - notify($ERRORS{'WARNING'}, 0, "failed to set sshd service on $computer_shortname to start auto"); - } - - #check for root logged in on console and then logoff - notify($ERRORS{'OK'}, 0, "checking for any console users $computer_shortname"); - undef @sshcmd; - @sshcmd = run_ssh_command($computer_shortname, $IDENTITY_wxp, "cmd /c qwinsta.exe", "root"); - foreach my $r (@{$sshcmd[1]}) { - if ($r =~ /([>]?)([-a-zA-Z0-9]*)\s+([a-zA-Z0-9]*)\s+ ([0-9]*)\s+([a-zA-Z]*)/) { - my $state = $5; - my $session = $2; - my $user = $3; - if ($5 =~ /Active/) { - #give it sometime to finish - just in case - sleep 7; - notify($ERRORS{'OK'}, 0, "detected $user on $session still logged on $computer_shortname $r"); - if (defined(run_ssh_command($computer_shortname, $IDENTITY_wxp, "cmd /c logoff.exe $session", "root"))) { - notify($ERRORS{'OK'}, 0, "logged off $user on $session on $computer_shortname $r"); - } - } - } ## end if ($r =~ /([>]?)([-a-zA-Z0-9]*)\s+([a-zA-Z0-9]*)\s+ ([0-9]*)\s+([a-zA-Z]*)/) - } ## end foreach my $r (@{$sshcmd[1]}) - } ## end if ($vmclient_OSname =~ /vmwarewin|vmwareesxwin/) - #ipconfiguration + + #ipconfiguration if ($IPCONFIGURATION ne "manualDHCP") { #not default setting if ($IPCONFIGURATION eq "dynamicDHCP") { From vcl-commits-returnmelissaswanson@example.com Thu Jul 09 15:20:11 2009 Return-Path: <vcl-commits-returnmelissaswanson@example.com> Delivered-To: melissaswanson@example.com Received: (qmail 42997 invoked from network); 9 Jul 2009 15:20:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 9 Jul 2009 15:20:11 -0000 Received: (qmail 93507 invoked by uid 500); 9 Jul 2009 15:20:21 -0000 Delivered-To: melissaswanson@example.com Received: (qmail 93476 invoked by uid 500); 9 Jul 2009 15:20:21 -0000 Mailing-List: contact melissaswanson@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:melissaswanson@example.com> List-Unsubscribe: <mailto:melissaswanson@example.com> List-Post: <mailto:melissaswanson@example.com> List-Id: <vcl-commits.incubator.apache.org> Reply-To: melissaswanson@example.com Delivered-To: mailing list melissaswanson@example.com Received: (qmail 93466 invoked by uid 99); 9 Jul 2009 15:20:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jul 2009 15:20:20 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jul 2009 15:20:17 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7252F23888E3; Thu, 9 Jul 2009 15:19:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r792579 - /incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm Date: Thu, 09 Jul 2009 15:19:56 -0000 To: melissaswanson@example.com From: melissaswanson@example.com X-Mailer: svnmailer-1.0.8 Message-Id: <melissaswanson@example.com> X-Virus-Checked: Checked by ClamAV on apache.org Author: arkurth Date: Thu Jul 9 15:19:56 2009 New Revision: 792579 URL: http://svn.apache.org/viewvc?rev=792579&view=rev Log: VCL-21 Added check to xCAT.pm888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4load() to make sure the image repository directory exists. This wasn't being done. If the image repository directory is a mount point and the underlying storage is down, failed reservations did not indicate the real problem in the notification messages. Also made minor change to does_image_exist(). Removed period after image name in pattern for files to check for. It was not catching all files. Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm?rev=792579&r1=792578&r2=792579&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm Thu Jul 9 15:19:56 2009 @@ -204,23 +204,41 @@ # Make sure dhcpd is started on management node if (!(_checknstartservice("dhcpd"))) { notify($ERRORS{'CRITICAL'}, 0, "dhcpd is not running or failed to restart"); + return 0; } # Make sure named is started on management node if (!(_checknstartservice("named"))) { notify($ERRORS{'CRITICAL'}, 0, "named is not running or failed to restart"); + return 0; } # Make sure xcatd is started on management node if (!(_checknstartservice("xcatd"))) { notify($ERRORS{'CRITICAL'}, 0, "xcatd is not running or failed to restart"); + return 0; } # Make sure atftpd is started on management node if (!(_checknstartservice("atftpd"))) { notify($ERRORS{'CRITICAL'}, 0, "atftpd is not running or failed to restart"); + return 0; } - + + # Make sure the image repository path can be retrieved and directory exists + my $image_repository_path = $self->_get_image_repository_path(); + if (!$image_repository_path) { + notify($ERRORS{'CRITICAL'}, 0, "unable to determine image repository path"); + return 0; + } + if (-d $image_repository_path) { + notify($ERRORS{'DEBUG'}, 0, "confirmed image repository directory exists: $image_repository_path"); + } + else { + notify($ERRORS{'CRITICAL'}, 0, "unable to confirm image repository directory exists: $image_repository_path, no output returned from ls command"); + return 0; + } + # Insert a computerloadlog record and edit nodetype.tab insertloadlog($reservation_id, $computer_id, "editnodetype", "updating nodetype file"); if ($self->_edit_nodetype($computer_node_name, $image_name, $image_os_name, $image_architecture)) { @@ -228,6 +246,7 @@ } else { notify($ERRORS{'CRITICAL'}, 0, "could not edit nodetype for $computer_node_name with $image_name"); + return 0; } # Begin reinstallation using xCAT's rinstall @@ -3177,7 +3196,7 @@ } # Execute the command - my $du_command = "du -c $image_repository_path/$image_name.* 2>&1"; + my $du_command = "du -c $image_repository_path/$image_name* 2>&1"; #notify($ERRORS{'DEBUG'}, 0, "du command: $du_command"); my $du_output = `$du_command`; From vcl-commits-returnmelissaswanson@example.com Thu Jul 09 17:44:43 2009 Return-Path: <vcl-commits-returnmelissaswanson@example.com> Delivered-To: melissaswanson@example.com Received: (qmail 4211 invoked from network); 9 Jul 2009 17:44:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 9 Jul 2009 17:44:43 -0000 Received: (qmail 87232 invoked by uid 500); 9 Jul 2009 17:44:53 -0000 Delivered-To: melissaswanson@example.com Received: (qmail 87207 invoked by uid 500); 9 Jul 2009 17:44:53 -0000 Mailing-List: contact melissaswanson@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:melissaswanson@example.com> List-Unsubscribe: <mailto:melissaswanson@example.com> List-Post: <mailto:melissaswanson@example.com> List-Id: <vcl-commits.incubator.apache.org> Reply-To: melissaswanson@example.com Delivered-To: mailing list melissaswanson@example.com Received: (qmail 87197 invoked by uid 99); 9 Jul 2009 17:44:53 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jul 2009 17:44:53 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jul 2009 17:44:50 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 52AB423888C8; Thu, 9 Jul 2009 17:44:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r792617 - /incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod.pm Date: Thu, 09 Jul 2009 17:44:29 -0000 To: melissaswanson@example.com From: melissaswanson@example.com X-Mailer: svnmailer-1.0.8 Message-Id: <melissaswanson@example.com> X-Virus-Checked: Checked by ClamAV on apache.org Author: arkurth Date: Thu Jul 9 17:44:28 2009 New Revision: 792617 URL: http://svn.apache.org/viewvc?rev=792617&view=rev Log: VCL-23 Fixed bug in filesystem_entry_exists() sub. Removed /s switch from dir command. It was returning true if a file didn't exist, but a file with a similar name exists under a subdirectory. Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod.pm Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod.pm URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod.pm?rev=792617&r1=792616&r2=792617&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod.pm Thu Jul 9 17:44:28 2009 @@ -1099,7 +1099,7 @@ $path =~ s/[\\\/]+/\\/g; # Assemble the dir command and execute it - my $dir_command = "cmd.exe /c dir /a /b /s \"$path\""; + my $dir_command = "cmd.exe /c dir /a /b \"$path\""; my ($dir_exit_status, $dir_output) = run_ssh_command($computer_node_name, $management_node_keys, $dir_command, '', '', 1); if ((defined($dir_exit_status) && $dir_exit_status == 0) || (defined($dir_output) && grep(/$path/i, @$dir_output))) { notify($ERRORS{'DEBUG'}, 0, "filesystem entry exists on $computer_node_name: $path, dir output:\n" . join("\n", @$dir_output)); From vcl-commits-returnmelissaswanson@example.com Wed Jul 15 14:30:32 2009 Return-Path: <vcl-commits-returnmelissaswanson@example.com> Delivered-To: melissaswanson@example.com Received: (qmail 32142 invoked from network); 15 Jul 2009 14:30:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 15 Jul 2009 14:30:30 -0000 Received: (qmail 85816 invoked by uid 500); 15 Jul 2009 14:30:40 -0000 Delivered-To: melissaswanson@example.com Received: (qmail 85785 invoked by uid 500); 15 Jul 2009 14:30:40 -0000 Mailing-List: contact melissaswanson@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:melissaswanson@example.com> List-Unsubscribe: <mailto:melissaswanson@example.com> List-Post: <mailto:melissaswanson@example.com> List-Id: <vcl-commits.incubator.apache.org> Reply-To: melissaswanson@example.com Delivered-To: mailing list melissaswanson@example.com Received: (qmail 85775 invoked by uid 99); 15 Jul 2009 14:30:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Jul 2009 14:30:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Jul 2009 14:30:36 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A0A7523889B4; Wed, 15 Jul 2009 14:30:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r794283 - in /incubator/vcl/trunk/managementnode/lib/VCL: DataStructure.pm Module/Provisioning/vmware.pm Module/Provisioning/xCAT.pm utils.pm Date: Wed, 15 Jul 2009 14:30:16 -0000 To: melissaswanson@example.com From: melissaswanson@example.com X-Mailer: svnmailer-1.0.8 Message-Id: <melissaswanson@example.com> X-Virus-Checked: Checked by ClamAV on apache.org Author: arkurth Date: Wed Jul 15 14:30:16 2009 New Revision: 794283 URL: http://svn.apache.org/viewvc?rev=794283&view=rev Log: VCL-167 There was a bug in the regex which was attempting to find "Offending key" and "Matching host key" lines in SSH output. Removed ^ from beginning of regex. It now finds the lines. VCL-183 Removed DataStructure.pm888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4get_computer_private_ip() sub and created a sub with the same name which only calls get_computer_private_ip_address(). This is so subs with both names exist while the rest of the code which calls either sub is transitioned to only call get_computer_private_ip_address(). Removed utils.pm888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4get_ip_address_from_hosts(). It was only being called by DataStructure.pm888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4get_computer_private_ip(). Also fixed bug in regex in get_computer_private_ip_address(). It wasn't handling computer names correctly if names had the same prefix, ie blade1g4-1 and blade1g4-14. VCL-81 Added is_management_node_process_running() sub to utils.pm. This runs pgrep to determine if a process is running on the management node. It is used to determine if another SCP process is already running to retrieve a given image from another management node. Updated does_image_exist() subs in vmware.pm and xCAT.pm. The subs now check if an SCP process is running to retrieve the image before checking if the image files exist. If running, they wait and keep checking. This will prevent does_image_exist() from returning true if a partial image exists which is actively being copied. Updated retrieve_image() subs in vmware.pm and xCAT.pm. The subs now check all partner management nodes and try to retrieve from the partner with the largest image. This will prevent retrieval from a partner which contains a partial image, which could happen if that partner is actively retrieving the same image from another partner. Modified: incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm incubator/vcl/trunk/managementnode/lib/VCL/utils.pm Modified: incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm?rev=794283&r1=794282&r2=794283&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/DataStructure.pm Wed Jul 15 14:30:16 2009 @@ -912,36 +912,6 @@ #///////////////////////////////////////////////////////////////////////////// -=head2 get_computer_private_ip - - Parameters : None - Returns : IP address string if successful, 0 if failed - Description : - -=cut - -sub get_computer_private_ip { - my $self = shift; - - # Get the computer short name from this DataStructure - my $computer_short_name = $self->get_computer_short_name(); - if (!$computer_short_name) { - notify($ERRORS{'WARNING'}, 0, "computer short name could not be retrieved"); - return 0; - } - - # Get the node's private IP address from the hosts file - if (my $computer_private_ip = get_ip_address_from_hosts($computer_short_name)) { - return $computer_private_ip; - } - else { - notify($ERRORS{'WARNING'}, 0, "unable to locate private IP address for $computer_short_name in hosts file"); - return 0; - } -} ## end sub get_computer_private_ip - -#///////////////////////////////////////////////////////////////////////////// - =head2 get_reservation_remote_ip Parameters : None @@ -1427,6 +1397,10 @@ =cut +sub get_computer_private_ip { + return get_computer_private_ip_address(@_); +} + sub get_computer_private_ip_address { my $self; my $argument = shift; @@ -1486,7 +1460,7 @@ } # Find lines containing the computer name - my @matching_computer_hosts_lines = grep(/\s$computer_name/i, @$output); + my @matching_computer_hosts_lines = grep(/\s$computer_name\s*$/i, @$output); # Extract matching lines which aren't commented out my @uncommented_computer_hosts_lines = grep(/^\s*[^#]/, @matching_computer_hosts_lines); Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm?rev=794283&r1=794282&r2=794283&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm Wed Jul 15 14:30:16 2009 @@ -2255,42 +2255,81 @@ sub does_image_exist { my $self = shift; - if (ref($self) !~ /vmware/i) { - notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a function, it must be called as a class method"); - return 0; + unless (ref($self) && $self->isa('VCL888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Module')) { + notify($ERRORS{'CRITICAL'}, 0, "subroutine can only be called as a VCL888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Module module object method"); + return; } - my $image_name = $self->data->get_image_name(); + # Get the image name, first try passed argument, then data + my $image_name = shift; + $image_name = $self->data->get_image_name() if !$image_name; if (!$image_name) { - notify($ERRORS{'CRITICAL'}, 0, "unable to determine if image exists, unable to determine image name"); - return 0; + notify($ERRORS{'WARNING'}, 0, "unable to determine image name"); + return; } - my $IMAGEREPOSITORY; - - if ($image_name =~ /^(vmware)/) { - $IMAGEREPOSITORY = "$VMWAREREPOSITORY"; + # Get the image repository path + my $image_repository_path = $self->_get_image_repository_path(); + if (!$image_repository_path) { + notify($ERRORS{'WARNING'}, 0, "image repository path could not be determined"); + return; } else { - notify($ERRORS{'CRITICAL'}, 0, "unable to determine if image exists, image name is not vmware image_name= $image_name"); - return 0; + notify($ERRORS{'DEBUG'}, 0, "image repository path: $image_repository_path"); } - - if (open(IMAGES, "/bin/ls -1 $IMAGEREPOSITORY 2>&1 |")) { - my @images = <IMAGES>; - close(IMAGES); - foreach my $i (@images) { - if ($i =~ /$image_name/) { - notify($ERRORS{'OK'}, 0, "image $image_name exists"); - return 1; - } + + # Make sure an scp process isn't currently running to retrieve the image + # This can happen if another reservation is running for the same image and the management node didn't have a copy + my $scp_wait_attempt = 0; + my $scp_wait_max_attempts = 40; + my $scp_wait_delay = 15; + while (is_management_node_process_running("scp.*$image_name")) { + $scp_wait_attempt++; + + notify($ERRORS{'OK'}, 0, "attempt $scp_wait_attempt/$scp_wait_max_attempts: scp process is running to retrieve $image_name, waiting for $scp_wait_delay seconds"); + + if ($scp_wait_attempt == $scp_wait_max_attempts) { + notify($ERRORS{'WARNING'}, 0, "attempt $scp_wait_attempt/$scp_wait_max_attempts: waited maximum amount of time for scp process to terminate to retrieve $image_name"); + return; } - } ## end if (open(IMAGES, "/bin/ls -1 $IMAGEREPOSITORY 2>&1 |"... - - notify($ERRORS{'OK'}, 0, "image $IMAGEREPOSITORY/$image_name does NOT exist"); - return 0; + + sleep $scp_wait_delay; + } + notify($ERRORS{'DEBUG'}, 0, "scp process is not running to retrieve $image_name"); + + # Run du to get the size of the image files if the image exists + my $du_command = "du -c $image_repository_path/*$image_name* 2>&1 | grep total 2>&1"; + my ($du_exit_status, $du_output) = run_command($du_command); + + # If the partner doesn't have the image, a "no such file" error should be displayed + my $image_files_exist; + if (defined(@$du_output) && grep(/no such file/i, @$du_output)) { + notify($ERRORS{'OK'}, 0, "$image_name does NOT exist"); + $image_files_exist = 0; + } + elsif (defined(@$du_output) && !grep(/\d+\s+total/i, @$du_output)) { + notify($ERRORS{'WARNING'}, 0, "du output does not contain a total line:\n" . join("\n", @$du_output)); + return; + } + elsif (!defined($du_exit_status)) { + notify($ERRORS{'WARNING'}, 0, "failed to run ssh command to determine if image $image_name exists"); + return; + } + + # Return 1 if the image size > 0 + my ($image_size) = (@$du_output[0] =~ /(\d+)\s+total/); + if ($image_size && $image_size > 0) { + my $image_size_mb = int($image_size / 1024); + notify($ERRORS{'DEBUG'}, 0, "$image_name exists in $image_repository_path, size: $image_size_mb MB"); + return 1; + } + else { + notify($ERRORS{'DEBUG'}, 0, "image does NOT exist: $image_name"); + return 0; + } } ## end sub does_image_exist + #///////////////////////////////////////////////////////////////////////////// =head2 retrieve_image @@ -2303,119 +2342,135 @@ sub retrieve_image { my $self = shift; - if (ref($self) !~ /vmware/i) { - notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a function, it must be called as a class method"); - return; + unless (ref($self) && $self->isa('VCL888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Module')) { + notify($ERRORS{'CRITICAL'}, 0, "subroutine can only be called as a VCL888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Module module object method"); + return; } - # Make sure imag library functions are enabled + # Make sure image library functions are enabled my $image_lib_enable = $self->data->get_management_node_image_lib_enable(); if (!$image_lib_enable) { notify($ERRORS{'OK'}, 0, "image library functions are disabled"); return; } - # Get the image name - my $image_name = shift; - $image_name = $self->data->get_image_name() if !$image_name; + # If an argument
{'source': 'Apache Software Foundation Public Mail Archives'}