Author: fapeeler
Date: Wed May 5 20:07:38 2010
New Revision: 941458
URL: http://svn.apache.org/viewvc?rev=941458&view=rev
Log:
VCL-224
Removed all instances of IDENTITY_* keys.
The ssh identity keys are now pulled from the databae and access via the %ENV
hash
or through the DataStructure.pm module.
Modified:
incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux/Ubuntu.pm
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/esx.pm
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/esxthin.pm
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm
incubator/vcl/trunk/managementnode/lib/VCL/utils.pm
Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux/Ubuntu.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux/Ubuntu.pm?rev=941458&r1=941457&r2=941458&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux/Ubuntu.pm
(original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux/Ubuntu.pm Wed
May 5 20:07:38 2010
@@ -203,7 +203,7 @@ sub delete_user {
# Use userdel to delete the user
my $user_delete_command = "/usr/sbin/userdel $user_login_id";
- my @user_delete_results = run_ssh_command($computer_node_name,
$IDENTITY_bladerhel, $user_delete_command, "root");
+ my @user_delete_results = run_ssh_command($computer_node_name,
$management_node_keys, $user_delete_command, "root");
foreach my $user_delete_line (@{$user_delete_results[1]}) {
if ($user_delete_line =~ /currently logged in/) {
notify($ERRORS{'WARNING'}, 0, "user not deleted,
$user_login_id currently logged in");
Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/esx.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/esx.pm?rev=941458&r1=941457&r2=941458&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/esx.pm
(original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/esx.pm Wed
May 5 20:07:38 2010
@@ -749,13 +749,14 @@ sub node_status {
$image_os_type = $self->data->get_image_os_type;
$vmclient_shortname = $self->data->get_computer_short_name;
$request_forimaging = $self->data->get_request_forimaging();
+ $identity_keys = $self->data->get_management_node_keys;
} ## end else [ if (ref($self) !~ /esx/i)
notify($ERRORS{'OK'}, 0, "Entering node_status, checking status of
$vmclient_shortname");
notify($ERRORS{'DEBUG'}, 0, "request_for_imaging: $request_forimaging");
notify($ERRORS{'DEBUG'}, 0, "requeseted image name:
$requestedimagename");
- my ($hostnode, $identity);
+ my ($hostnode);
# Create a hash to store status components
my %status;
@@ -770,17 +771,12 @@ sub node_status {
if ($vmhost_type eq "blade") {
$hostnode = $1 if ($vmhost_hostname =~ /([-_a-zA-Z0-9]*)(\.?)/);
- $identity = $IDENTITY_bladerhel; #if($vm{vmhost}{imagename}
=~ /^(rhel|rh3image|rh4image|fc|rhfc)/);
}
else {
#using FQHN
$hostnode = $vmhost_hostname;
- $identity = $IDENTITY_linux_lab if ($vmhost_imagename =~
/^(realmrhel)/);
}
- if (!$identity) {
- notify($ERRORS{'CRITICAL'}, 0, "could not set ssh identity
variable for image $vmhost_imagename type= $vmhost_type host=
$vmhost_hostname");
- }
# Check if node is pingable
notify($ERRORS{'DEBUG'}, 0, "checking if $vmclient_shortname is
pingable");
@@ -812,8 +808,7 @@ sub node_status {
notify($ERRORS{'DEBUG'}, 0, "SSH good, trying to query image
name");
$status{ssh} = 1;
- my $identity = $IDENTITY_bladerhel;
- my @sshcmd = run_ssh_command($vmclient_shortname, $identity,
"cat currentimage.txt");
+ my @sshcmd = run_ssh_command($vmclient_shortname,
$identity_keys, "cat currentimage.txt");
$status{currentimage} = $sshcmd[1][0];
notify($ERRORS{'DEBUG'}, 0, "Image name:
$status{currentimage}");
Modified:
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/esxthin.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/esxthin.pm?rev=941458&r1=941457&r2=941458&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/esxthin.pm
(original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/esxthin.pm
Wed May 5 20:07:38 2010
@@ -1376,13 +1376,14 @@ sub node_status {
$image_os_type = $self->data->get_image_os_type;
$vmclient_shortname = $self->data->get_computer_short_name;
$request_forimaging = $self->data->get_request_forimaging();
+ $identity_keys = $self->data->get_management_node_keys;
} ## end else [ if (ref($self) !~ /esxthin/i)
notify($ERRORS{'OK'}, 0, "Entering node_status, checking status of
$vmclient_shortname");
notify($ERRORS{'DEBUG'}, 0, "request_for_imaging: $request_forimaging");
notify($ERRORS{'DEBUG'}, 0, "requeseted image name:
$requestedimagename");
- my ($hostnode, $identity);
+ my ($hostnode);
# Create a hash to store status components
my %status;
@@ -1397,17 +1398,12 @@ sub node_status {
if ($vmhost_type eq "blade") {
$hostnode = $1 if ($vmhost_hostname =~ /([-_a-zA-Z0-9]*)(\.?)/);
- $identity = $IDENTITY_bladerhel; #if($vm{vmhost}{imagename}
=~ /^(rhel|rh3image|rh4image|fc|rhfc)/);
}
else {
#using FQHN
$hostnode = $vmhost_hostname;
- $identity = $IDENTITY_linux_lab if ($vmhost_imagename =~
/^(realmrhel)/);
}
- if (!$identity) {
- notify($ERRORS{'CRITICAL'}, 0, "could not set ssh identity
variable for image $vmhost_imagename type= $vmhost_type host=
$vmhost_hostname");
- }
# Check if node is pingable
notify($ERRORS{'DEBUG'}, 0, "checking if $vmclient_shortname is
pingable");
@@ -1439,8 +1435,7 @@ sub node_status {
notify($ERRORS{'DEBUG'}, 0, "SSH good, trying to query image
name");
$status{ssh} = 1;
- my $identity = $IDENTITY_bladerhel;
- my @sshcmd = run_ssh_command($vmclient_shortname, $identity,
"cat currentimage.txt");
+ my @sshcmd = run_ssh_command($vmclient_shortname,
$identity_keys, "cat currentimage.txt");
$status{currentimage} = $sshcmd[1][0];
notify($ERRORS{'DEBUG'}, 0, "Image name:
$status{currentimage}");
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=941458&r1=941457&r2=941458&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm
(original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm
Wed May 5 20:07:38 2010
@@ -109,6 +109,8 @@ sub load {
my $request_id = $self->data->get_request_id;
my $reservation_id = $self->data->get_reservation_id;
my $persistent = $self->data->get_request_forimaging;
+
+ my $management_node_keys = $self->data->get_management_node_keys();
my $image_id = $self->data->get_image_id;
my $image_os_name = $self->data->get_image_os_name;
@@ -145,9 +147,11 @@ sub load {
my $vmclient_privateIPaddress = $self->data->get_computer_ip_address;
my $vmclient_publicIPaddress =
$self->data->get_computer_private_ip_address;
my $vmclient_OSname = $self->data->get_image_os_name;
+
# Assemble a consistent prefix for notify messages
my $notify_prefix = "req=$request_id, res=$reservation_id:";
+
#$VMWARErepository
#if (!($vm{vmhost}{ok})) {
#not ok to proceed
@@ -162,10 +166,9 @@ sub load {
#$vm{"vmclient"}{"project"} = "vcl" if
(!defined($vm{"vmclient"}{"project"}));
- my ($hostnode, $identity);
+ my ($hostnode);
if ($host_type eq "blade") {
$hostnode = $1 if ($vmhost_hostname =~ /([-_a-zA-Z0-9]*)(\.?)/);
- $identity = $IDENTITY_bladerhel;
# assign2project is only for blades - and not all blades
#if
(VCL::Module::Provisioning::xCAT::_assign2project($hostnode, $project)) {
@@ -180,15 +183,13 @@ sub load {
else {
#using FQHN
$hostnode = $vmhost_hostname;
- $identity = $IDENTITY_linux_lab if ($vmhost_imagename =~
/^(realmrhel)/);
}
- if (!(defined($identity))) {
+ if (!(defined($management_node_keys))) {
notify($ERRORS{'CRITICAL'}, 0, "identity variiable not
definted, setting to blade identity file vmhost variable set to
$vmhost_imagename");
- $identity = $IDENTITY_bladerhel;
}
- notify($ERRORS{'OK'}, 0, "identity file set $identity vmhost imagename
$vmhost_imagename bladekey $IDENTITY_bladerhel");
+ notify($ERRORS{'OK'}, 0, "identity file set $management_node_keys
vmhost imagename $vmhost_imagename bladekey ");
#setup flags
my $baseexists = 0;
my $dirstructure = 0;
@@ -234,7 +235,7 @@ sub load {
notify($ERRORS{'OK'}, 0, "owning exclusive lock on
$tmplockfile");
notify($ERRORS{'OK'}, 0, "listing datestore
$datastorepath ");
undef @sshcmd;
- @sshcmd = run_ssh_command($hostnode, $identity, "ls -1
$datastorepath", "root");
+ @sshcmd = run_ssh_command($hostnode,
$management_node_keys, "ls -1 $datastorepath", "root");
if (!defined(@{$sshcmd[1]})) {
notify($ERRORS{'CRITICAL'}, 0, "failed to list
data store contents $datastorepath on vm host");
insertloadlog($reservation_id,
$vmclient_computerid, "failed", "failed to list data store contents
$datastorepath on vm host");
@@ -274,7 +275,7 @@ sub load {
notify($ERRORS{'DEBUG'}, 0,
"requestedimagenamebase and persistent are both true, attempting to detect
status for move of base image instead of full copy");
#Confirm base is not inuse then simply rename
the directory to match our needs
my $okforMOVE = 0;
- my @sshcmd = run_ssh_command($hostnode,
$identity, "vmware-cmd -l", "root");
+ my @sshcmd = run_ssh_command($hostnode,
$management_node_keys, "vmware-cmd -l", "root");
foreach my $vm (@{$sshcmd[1]}) {
chomp($vm);
next if ($vm =~ /Warning:/);
@@ -287,7 +288,7 @@ sub load {
$localmyvmdir =~ s/(\s+)/\\ /g;
notify($ERRORS{'OK'}, 0, "my
vmx $localmyvmx");
- my @sshcmd_1 =
run_ssh_command($hostnode, $identity, "vmware-cmd $localmyvmx getstate");
+ my @sshcmd_1 =
run_ssh_command($hostnode, $management_node_keys, "vmware-cmd $localmyvmx
getstate");
foreach my $l (@{$sshcmd_1[1]})
{
if ($l =~ /= off/) {
#Good
@@ -335,7 +336,7 @@ sub load {
notify($ERRORS{'DEBUG'}, 0, "file size
$myvmdkfilesize of $requestedimagename");
notify($ERRORS{'OK'}, 0, "checking space on
$hostnode $vmhost_vmpath");
undef @sshcmd;
- @sshcmd = run_ssh_command($hostnode, $identity,
"df -k $vmhost_vmpath", "root");
+ @sshcmd = run_ssh_command($hostnode,
$management_node_keys, "df -k $vmhost_vmpath", "root");
foreach my $l (@{$sshcmd[1]}) {
next if ($l =~ /Warning: Permanently/);
next if ($l =~ /^Filesystem/);
@@ -350,7 +351,7 @@ sub load {
notify($ERRORS{'OK'}, 0, "detected space issue on $hostnode, attempting to free
up space");
#remove stuff
my %vmlist = ();
- my @sshcmd_1 =
run_ssh_command($hostnode, $identity, "vmware-cmd -l", "root");
+ my @sshcmd_1 =
run_ssh_command($hostnode, $management_node_keys, "vmware-cmd -l", "root");
my $i;
foreach my $r
(@{$sshcmd_1[1]}) {
$i++;
@@ -366,7 +367,7 @@ sub load {
foreach my $v
(keys %vmlist) {
#handle
any spaces in the path
$vmlist{$v}{path} =~ s/(\s+)/\\ /g;
- my
@sshcmd_2 = run_ssh_command($hostnode, $identity, "vmware-cmd -q
$vmlist{$v}{path} getstate", "root");
+ my
@sshcmd_2 = run_ssh_command($hostnode, $management_node_keys, "vmware-cmd -q
$vmlist{$v}{path} getstate", "root");
foreach
$a (@{$sshcmd_2[1]}) {
next if ($a =~ /^Warning: /);
chomp($a);
@@ -381,7 +382,7 @@ sub load {
} ##
end foreach $a (@{$sshcmd_2[1]})
} ## end
foreach my $v (keys %vmlist)
notify($ERRORS{'OK'}, 0, "ls datastorepath $datastorepath ");
- my @sshcmd_3 =
run_ssh_command($hostnode, $identity, "ls -1 $datastorepath", "root");
+ my @sshcmd_3 =
run_ssh_command($hostnode, $management_node_keys, "ls -1 $datastorepath",
"root");
foreach my $d
(@{$sshcmd_3[1]}) {
next if
($d =~ /Warning: /);
@@ -406,7 +407,7 @@ sub load {
elsif ($vmlist{$v}{state} eq "off") {
#$save = 0;
notify($ERRORS{'DEBUG'}, 0, "VM is off, it will NOT be saved:
$vmlist{$v}{path}");
-
if (defined(run_ssh_command($hostnode, $identity, "vmware-cmd
-s unregister $vmlist{$v}{path}", "root"))) {
+
if (defined(run_ssh_command($hostnode, $management_node_keys,
"vmware-cmd -s unregister $vmlist{$v}{path}", "root"))) {
notify($ERRORS{'DEBUG'}, 0, "unregistered
$vmlist{$v}{path}");
}
}
@@ -424,7 +425,7 @@ sub load {
}
else {
notify($ERRORS{'OK'}, 0, "disk cleanup - REMOVING $datastorepath/$d");
-
if (defined(run_ssh_command($hostnode, $identity, "/bin/rm -rf
$datastorepath/$d\*", "root"))) {
+
if (defined(run_ssh_command($hostnode, $management_node_keys, "/bin/rm -rf
$datastorepath/$d\*", "root"))) {
notify($ERRORS{'DEBUG'}, 0, "disk cleanup - REMOVED
$datastorepath/$d\*");
}
}
#else not save
@@ -439,10 +440,10 @@ sub load {
} # start foreach df -k
if ($vmprofile_vmdisk eq "localdisk") {
notify($ERRORS{'OK'}, 0, "copying base
image files $requestedimagename to $hostnode");
- if
(run_scp_command("$VMWAREREPOSITORY/$requestedimagename",
"$hostnode:\"$datastorepath/$mybasedirname\"", $identity)) {
+ if
(run_scp_command("$VMWAREREPOSITORY/$requestedimagename",
"$hostnode:\"$datastorepath/$mybasedirname\"", $management_node_keys)) {
#recheck host server for files
- the scp output is not being captured
undef @sshcmd;
- @sshcmd =
run_ssh_command($hostnode, $identity, "ls -1 $datastorepath", "root");
+ @sshcmd =
run_ssh_command($hostnode, $management_node_keys, "ls -1 $datastorepath",
"root");
foreach my $l (@{$sshcmd[1]}) {
if ($l =~ /denied|No
such/) {
notify($ERRORS{'CRITICAL'}, 0, "node $hostnode output @{ $sshcmd[1] }");
@@ -474,7 +475,7 @@ sub load {
my $dstDir =
"$datastorepath/$mybasedirname";
#create a clone -
- if (_vmwareclone($hostnode,
$identity, $srcDisk, $dstDisk, $dstDir)) {
+ if (_vmwareclone($hostnode,
$management_node_keys, $srcDisk, $dstDisk, $dstDir)) {
$baseexists = 1;
insertloadlog($reservation_id, $vmclient_computerid, "transfervm", "cloning
base image files");
}
@@ -512,13 +513,13 @@ sub load {
#clean-up
#make sure vm is off, it should be
undef @sshcmd;
- @sshcmd = run_ssh_command($hostnode, $identity, "vmware-cmd
$myvmx getstate", "root");
+ @sshcmd = run_ssh_command($hostnode, $management_node_keys,
"vmware-cmd $myvmx getstate", "root");
foreach my $l (@{$sshcmd[1]}) {
if ($l =~ /= off/) {
#good
}
elsif ($l =~ /= on/) {
- my @sshcmd_1 = run_ssh_command($hostnode,
$identity, "vmware-cmd $myvmx stop hard", "root");
+ my @sshcmd_1 = run_ssh_command($hostnode,
$management_node_keys, "vmware-cmd $myvmx stop hard", "root");
foreach my $a (@{$sshcmd_1[1]}) {
next if ($a =~ /Warning:/);
if ($a =~ /= 1/) {
@@ -533,7 +534,7 @@ sub load {
} ## end foreach my $l (@{$sshcmd[1]})
#if registered - unregister vm
undef @sshcmd;
- @sshcmd = run_ssh_command($hostnode, $identity, "vmware-cmd -s
unregister $myvmx", "root");
+ @sshcmd = run_ssh_command($hostnode, $management_node_keys,
"vmware-cmd -s unregister $myvmx", "root");
foreach my $l (@{$sshcmd[1]}) {
if ($l =~ /No such virtual machine/) {
#not registered
@@ -545,7 +546,7 @@ sub load {
}
#delete directory -- clean slate
# if in persistent mode - imaging or otherwise we may not want
to rm this directory
- if (defined(run_ssh_command($hostnode, $identity, "/bin/rm -rf
$vmhost_vmpath/$myvmdir", "root"))) {
+ if (defined(run_ssh_command($hostnode, $management_node_keys,
"/bin/rm -rf $vmhost_vmpath/$myvmdir", "root"))) {
notify($ERRORS{'OK'}, 0, "success rm -rf
$vmhost_vmpath/$myvmdir on $hostnode ");
}
@@ -704,10 +705,10 @@ sub load {
#scp vmx file to vmdir on vmhost
insertloadlog($reservation_id, $vmclient_computerid, "vmconfigcopy",
"transferring vmx file to $hostnode");
- if (run_scp_command($tmpdir, "$hostnode:\"$vmhost_vmpath\"",
$identity)) {
+ if (run_scp_command($tmpdir, "$hostnode:\"$vmhost_vmpath\"",
$management_node_keys)) {
my $copied = 0;
undef @sshcmd;
- @sshcmd = run_ssh_command($hostnode, $identity, "ls -1
$vmhost_vmpath/$myvmdir;chmod 755 $myvmx", "root");
+ @sshcmd = run_ssh_command($hostnode, $management_node_keys, "ls
-1 $vmhost_vmpath/$myvmdir;chmod 755 $myvmx", "root");
foreach my $l (@{$sshcmd[1]}) {
if ($l =~ /$myvmdir.vmx/) {
notify($ERRORS{'OK'}, 0, "successfully copied
vmx file to $hostnode");
@@ -739,7 +740,7 @@ sub load {
#register vmx on vmhost
my $registered = 0;
undef @sshcmd;
- @sshcmd = run_ssh_command($hostnode, $identity, "vmware-cmd -s register
$myvmx", "root");
+ @sshcmd = run_ssh_command($hostnode, $management_node_keys, "vmware-cmd
-s register $myvmx", "root");
foreach my $l (@{$sshcmd[1]}) {
if ($l =~ /No such virtual machine/) {
#not registered
@@ -776,7 +777,7 @@ sub load {
}
undef @sshcmd;
- @sshcmd = run_ssh_command($hostnode, $identity, "vmware-cmd $myvmx
start", "root");
+ @sshcmd = run_ssh_command($hostnode, $management_node_keys, "vmware-cmd
$myvmx start", "root");
for my $l (@{$sshcmd[1]}) {
next if ($l =~ /Warning:/);
#if successful -- this cmd does not appear to return any ouput
so anything could be a failure
@@ -802,7 +803,7 @@ sub load {
sleep 20;
my ($s1, $s2, $s3, $s4, $s5) = 0; #setup stage flags
undef @sshcmd;
- @sshcmd = run_ssh_command($hostnode, $identity, "vmware-cmd $myvmx
getstate", "root");
+ @sshcmd = run_ssh_command($hostnode, $management_node_keys, "vmware-cmd
$myvmx getstate", "root");
notify($ERRORS{'OK'}, 0, "checking state of vm $computer_shortname");
for my $l (@{$sshcmd[1]}) {
next if ($l =~ /Warning:/);
@@ -955,6 +956,7 @@ sub capture {
# Store some hash variables into local variables
my $request_id = $self->data->get_request_id;
my $reservation_id = $self->data->get_reservation_id;
+ my $management_node_keys = $self->data->get_management_node_keys();
my $image_id = $self->data->get_image_id;
my $image_os_name = $self->data->get_image_os_name;
@@ -976,15 +978,13 @@ sub capture {
my $host_type = $self->data->get_vmhost_type;
my $vmhost_imagename = $self->data->get_vmhost_image_name;
- my ($hostIdentity, $hostnodename);
+ my ( $hostnodename);
if ($host_type eq "blade") {
$hostnodename = $1 if ($vmhost_hostname =~
/([-_a-zA-Z0-9]*)(\.?)/);
- $hostIdentity = $IDENTITY_bladerhel;
}
else {
#using FQHN
$hostnodename = $vmhost_hostname;
- $hostIdentity = $IDENTITY_linux_lab if ($vmhost_imagename =~
/^(realmrhel)/);
}
# Assemble a consistent prefix for notify messages
my $notify_prefix = "req=$request_id, res=$reservation_id:";
@@ -1067,7 +1067,7 @@ sub capture {
#copy vmdk files
# confirm they were copied
notify($ERRORS{'OK'}, 0, "attemping to copy vmdk files to
$VMWAREREPOSITORY");
- if
(run_scp_command("$hostnodename:\"$vmhost_vmpath/$vmx_directory/*.vmdk\"",
"$VMWAREREPOSITORY/$image_name", $hostIdentity)) {
+ if
(run_scp_command("$hostnodename:\"$vmhost_vmpath/$vmx_directory/*.vmdk\"",
"$VMWAREREPOSITORY/$image_name", $management_node_keys)) {
if (open(LISTFILES, "ls -s1
$VMWAREREPOSITORY/$image_name |")) {
my @list = <LISTFILES>;
close(LISTFILES);
@@ -1145,11 +1145,11 @@ sub capture {
#remove dir from vmhost
#everything appears to have
worked
#remove image files from
vmhost
- if (defined(run_ssh_command($hostnodename,
$hostIdentity, "vmware-cmd -s unregister $vmx_path"))) {
+ if (defined(run_ssh_command($hostnodename,
$management_node_keys, "vmware-cmd -s unregister $vmx_path"))) {
notify($ERRORS{'OK'}, 0, "unregistered
$vmx_path");
}
- if (defined(run_ssh_command($hostnodename,
$hostIdentity, "/bin/rm -rf $vmhost_vmpath/$vmx_directory", "root"))) {
+ if (defined(run_ssh_command($hostnodename,
$management_node_keys, "/bin/rm -rf $vmhost_vmpath/$vmx_directory", "root"))) {
notify($ERRORS{'OK'}, 0, "removed
vmhost_vmpath/$vmx_directory");
}
#set file premissions on images to 644
@@ -1180,7 +1180,7 @@ sub capture {
# create directory
- my @mvdir = run_ssh_command($hostnodename, $hostIdentity,
"/bin/mv $vmprofile_datastorepath/$vmx_directory
$vmprofile_datastorepath/$image_name", "root");
+ my @mvdir = run_ssh_command($hostnodename,
$management_node_keys, "/bin/mv $vmprofile_datastorepath/$vmx_directory
$vmprofile_datastorepath/$image_name", "root");
for my $l (@{$mvdir[1]}) {
notify($ERRORS{'OK'}, 0, "possible error @{ $mvdir[1]
}");
}
@@ -1188,7 +1188,7 @@ sub capture {
#if ESX user vmkfstools to rename the image
if ($vmtype_name =~ /vmwareESX/) {
my $cmd = "vmkfstools -E
$vmprofile_datastorepath/$image_name/$vmx_directory.vmdk
$vmprofile_datastorepath/$image_name/$image_name.vmdk";
- my @retarr = run_ssh_command($hostnodename,
$hostIdentity, $cmd, "root");
+ my @retarr = run_ssh_command($hostnodename,
$management_node_keys, $cmd, "root");
foreach my $r (@{$retarr[1]}) {
#if any output could mean trouble - this
command provides no no response if successful
notify($ERRORS{'OK'}, 0, "possible problem
renaming vm @{ $retarr[1] }") if ($r);
@@ -1198,12 +1198,12 @@ sub capture {
#TODO add check to confirm
notify($ERRORS{'OK'}, 0, "looks like vm is renamed");
#cleanup - unregister, and remove vm dir on vmhost local disk
- my @cleanup = run_ssh_command($hostnodename, $hostIdentity,
"vmware-cmd -s unregister $vmx_path", "root");
+ my @cleanup = run_ssh_command($hostnodename,
$management_node_keys, "vmware-cmd -s unregister $vmx_path", "root");
foreach my $c (@{$cleanup[1]}) {
notify($ERRORS{'OK'}, 0, "vm successfully
unregistered") if ($c =~ /1/);
}
#remove vmx directoy from our local datastore
- if (defined(run_ssh_command($hostnodename, $hostIdentity,
"/bin/rm -rf $vmhost_vmpath/$vmx_directory", "root"))) {
+ if (defined(run_ssh_command($hostnodename,
$management_node_keys, "/bin/rm -rf $vmhost_vmpath/$vmx_directory", "root"))) {
notify($ERRORS{'OK'}, 0, "success removed
$vmhost_vmpath/$vmx_directory from $hostnodename");
}
@@ -1323,6 +1323,8 @@ sub control_VM {
my $vmhost_shortname = $1 if ($vmhost_fullhostname =~
/([-_a-zA-Z0-9]*)(\.?)/);
my $vmhost_imagename = $self->data->get_vmhost_image_name;
my $vmhost_type = $self->data->get_vmhost_type;
+ my $management_node_keys = $self->data->get_management_node_keys();
+
my ($myvmdir, $myvmx, $mybasedirname, $myimagename);
@@ -1343,7 +1345,7 @@ sub control_VM {
$myimagename = $currentimage;
}
- my ($hostnode, $identity);
+ my ($hostnode);
if ($vmhost_type eq "blade") {
if (defined($vmhost_shortname)) {
@@ -1352,17 +1354,14 @@ sub control_VM {
else {
$hostnode = $1 if ($vmhost_shortname =~
/([-_a-zA-Z0-9]*)(\.?)/);
}
- $identity = $IDENTITY_bladerhel;
} ## end if ($vmhost_type eq "blade")
else {
#using FQHN
$hostnode = $vmhost_fullhostname;
- $identity = $IDENTITY_linux_lab if ($vmhost_imagename =~
/^(realmrhel)/);
}
if (!$identity) {
notify($ERRORS{'WARNING'}, 0, "could not set ssh identity
variable for image $vmhost_imagename type= $vmhost_type host=
$vmhost_fullhostname");
notify($ERRORS{'OK'}, 0, "setting to default identity
key");
- $identity = $IDENTITY_bladerhel;
}
#setup flags
my $baseexists = 0;
@@ -1372,7 +1371,7 @@ sub control_VM {
if ($vmtype =~ /vmware|vmwareGSX|vmwareESX/) {
#common checks
notify($ERRORS{'OK'}, 0, "checking for base image on $hostnode
$datastorepath");
- @sshcmd = run_ssh_command($hostnode, $identity, "ls -1
$datastorepath", "root");
+ @sshcmd = run_ssh_command($hostnode, $management_node_keys, "ls
-1 $datastorepath", "root");
if (!...@sshcmd) {
notify($ERRORS{'WARNING'}, 0, "failed to run ssh
command: ls -1 $datastorepath");
return 0;
@@ -1380,7 +1379,7 @@ sub control_VM {
notify($ERRORS{'OK'}, 0, "@{ $sshcmd[1] }");
foreach my $l (@{$sshcmd[1]}) {
if ($l =~ /denied|No such/) {
- notify($ERRORS{'CRITICAL'}, 0, "node $hostnode
output @{ $sshcmd[1] } $identity $hostnode");
+ notify($ERRORS{'CRITICAL'}, 0, "node $hostnode
output @{ $sshcmd[1] } $management_node_keys $hostnode");
return 0;
}
if ($l =~ /Warning: Permanently/) {
@@ -1409,7 +1408,7 @@ sub control_VM {
##find the correct vmx file for this node -- if running
undef @sshcmd;
- @sshcmd = run_ssh_command($hostnode, $identity,
"vmware-cmd -l", "root");
+ @sshcmd = run_ssh_command($hostnode,
$management_node_keys, "vmware-cmd -l", "root");
if (!...@sshcmd) {
notify($ERRORS{'WARNING'}, 0, "failed to run
ssh command: vmware-cmd -l");
return 0;
@@ -1426,7 +1425,7 @@ sub control_VM {
$l_myvmdir =~ s/(\s+)/\\ /g;
notify($ERRORS{'OK'}, 0, "my vmx
$l_myvmx");
- my @sshcmd_1 =
run_ssh_command($hostnode, $identity, "vmware-cmd $l_myvmx getstate");
+ my @sshcmd_1 =
run_ssh_command($hostnode, $management_node_keys, "vmware-cmd $l_myvmx
getstate");
if (!...@sshcmd_1) {
notify($ERRORS{'WARNING'}, 0,
"failed to run ssh command: vmware-cmd $l_myvmx getstate");
return 0;
@@ -1436,7 +1435,7 @@ sub control_VM {
#good - move on
}
elsif ($l =~ /= on/) {
- my @sshcmd_2 =
run_ssh_command($hostnode, $identity, "vmware-cmd $l_myvmx stop hard");
+ my @sshcmd_2 =
run_ssh_command($hostnode, $management_node_keys, "vmware-cmd $l_myvmx stop
hard");
if (!...@sshcmd_2) {
notify($ERRORS{'WARNING'}, 0, "failed to run ssh command: vmware-cmd $l_myvmx
stop hard");
return 0;
@@ -1456,7 +1455,7 @@ sub control_VM {
elsif ($l =~ /= stuck/) {
#list processes for vmx
and kill pid
notify($ERRORS{'OK'},
0, "vm reported in stuck state, attempting to kill process");
- my @ssh_pid =
run_ssh_command($hostnode, $identity, "vmware-cmd -q $l_myvmx getpid");
+ my @ssh_pid =
run_ssh_command($hostnode, $management_node_keys, "vmware-cmd -q $l_myvmx
getpid");
if (!...@ssh_pid) {
notify($ERRORS{'WARNING'}, 0, "failed to run ssh command: vmware-cmd -q
$l_myvmx getpid");
return 0;
@@ -1465,7 +1464,7 @@ sub control_VM {
if ($p =~
/(\D*)(\s*)([0-9]*)/) {
notify($ERRORS{'OK'}, 0, "vm pid= $3");
my
$vmpid = $3;
- if
(defined(run_ssh_command($hostnode, $identity, "kill -9 $vmpid"))) {
+ if
(defined(run_ssh_command($hostnode, $management_node_keys, "kill -9 $vmpid"))) {
notify($ERRORS{'OK'}, 0, "killed $vmpid $l_myvmx");
}
}
@@ -1477,7 +1476,7 @@ sub control_VM {
} ## end foreach my $l (@{$sshcmd_1[1]})
#unregister
undef @sshcmd_1;
- @sshcmd_1 = run_ssh_command($hostnode,
$identity, "vmware-cmd -s unregister $l_myvmx ");
+ @sshcmd_1 = run_ssh_command($hostnode,
$management_node_keys, "vmware-cmd -s unregister $l_myvmx ");
if (!...@sshcmd_1) {
notify($ERRORS{'WARNING'}, 0,
"failed to run ssh command: vmware-cmd -s unregister $l_myvmx");
return 0;
@@ -1489,7 +1488,7 @@ sub control_VM {
} ## end foreach my $l (@{$sshcmd[1]})
if ($control eq "remove") {
#delete directory -- clean slate
- if (defined(run_ssh_command($hostnode,
$identity, "/bin/rm -rf $l_myvmdir", "root"))) {
+ if (defined(run_ssh_command($hostnode,
$management_node_keys, "/bin/rm -rf $l_myvmdir", "root"))) {
notify($ERRORS{'OK'}, 0, "removed
$l_myvmdir from $hostnode");
return 1;
}
@@ -1503,7 +1502,7 @@ sub control_VM {
if ($vmison) {
notify($ERRORS{'OK'}, 0, "turning off $myvmx");
undef @sshcmd;
- @sshcmd = run_ssh_command($hostnode, $identity,
"vmware-cmd $myvmx stop hard", "root");
+ @sshcmd = run_ssh_command($hostnode,
$management_node_keys, "vmware-cmd $myvmx stop hard", "root");
if (!...@sshcmd) {
notify($ERRORS{'WARNING'}, 0, "failed
to run ssh command: vmware-cmd $myvmx stop hard");
return 0;
@@ -1517,7 +1516,7 @@ sub control_VM {
sleep 15;
#confirm
undef @sshcmd;
- @sshcmd = run_ssh_command($hostnode, $identity,
"vmware-cmd $myvmx getstate", "root");
+ @sshcmd = run_ssh_command($hostnode,
$management_node_keys, "vmware-cmd $myvmx getstate", "root");
if (!...@sshcmd) {
notify($ERRORS{'WARNING'}, 0, "failed
to run ssh command: vmware-cmd $myvmx getstate7");
return 0;
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=941458&r1=941457&r2=941458&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm
(original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm
Wed May 5 20:07:38 2010
@@ -262,7 +262,7 @@ sub load {
my $maxload = 1;
while ($maxload) {
notify($ERRORS{'DEBUG'}, 0, "running
'nodeset all stat' to determine number of nodes currently being loaded");
- if (open(NODESET,
"$XCAT_ROOT/sbin/nodeset all stat \| egrep \'install\|image\' 2>&1 | ")) {
+ if (open(NODESET,
"$XCAT_ROOT/bin/nodeset all stat \| egrep \'install\|image\' 2>&1 | ")) {
my @nodesetout = <NODESET>;
close(NODESET);
my $ld = @nodesetout;
Modified: incubator/vcl/trunk/managementnode/lib/VCL/utils.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=941458&r1=941457&r2=941458&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/utils.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/utils.pm Wed May 5 20:07:38 2010
@@ -209,10 +209,6 @@ our @EXPORT = qw(
$ETHDEVICE
$GATEWAY
$FQDN
- $IDENTITY_bladerhel
- $IDENTITY_wxp
- $IDENTITY_linux_lab
- $IDENTITY_solaris_lab
$IPCONFIGURATION
$jabPass
$jabPort
@@ -261,7 +257,6 @@ INIT {
our ($IPCONFIGURATION, $DNSserver, $GATEWAY, $NETMASK, $ETHDEVICE) = 0;
our ($LINUX_IMAGE, $THROTTLE);
our ($CORE_IMAGEREPOSITORY, $WIN_IMAGEREPOSITORY,
$LINUX_IMAGEREPOSITORY);
- our ($IDENTITY_linux_lab, $IDENTITY_solaris_lab, $IDENTITY_wxp,
$IDENTITY_newwxp, $IDENTITY_bladerhel);
our ($VMWARETYPE, $VMWARE_DISK,$VMWARE_MAC_ETH0_GENERATED,
$VMWARE_MAC_ETH1_GENERATED);
our ($WINDOWS_ROOT_PASSWORD);
our ($XMLRPC_USER, $XMLRPC_PASS, $XMLRPC_URL);
@@ -479,20 +474,6 @@ INIT {
$THROTTLE = $1;
}
- #ssh private keys
- if ($l =~ /^IDENTITY_blade_linux=(.*)/) {
- $IDENTITY_bladerhel = $1;
- }
- if ($l =~ /^IDENTITY_blade_win=(.*)/) {
- $IDENTITY_wxp = $1;
- }
- if ($l =~ /^IDENTITY_solaris_lab=(.*)/) {
- $IDENTITY_solaris_lab = $1;
- }
- if ($l =~ /^IDENTITY_linux_lab=(.*)/) {
- $IDENTITY_linux_lab = $1;
- }
-
#vmware settings
# localdisk
if ($l =~ /^VMWARE_DISK=(localdisk|networkdisk)/) {
@@ -541,17 +522,6 @@ INIT {
$THROTTLE = 0;
}
- if (!$IDENTITY_bladerhel) {
-
- }
- if (!$IDENTITY_wxp) {
-
- }
- if (!$IDENTITY_solaris_lab) {
- }
- if (!$IDENTITY_linux_lab) {
- }
-
if (!$WINDOWS_ROOT_PASSWORD) {
$WINDOWS_ROOT_PASSWORD = "clOudy";
}
@@ -623,9 +593,7 @@ our ($MYSQL_SSL, $MYSQL_SSL_CERT);
our ($IPCONFIGURATION, $DNSserver, $GATEWAY, $NETMASK, $ETHDEVICE);
our ($LINUX_IMAGE, $THROTTLE);
our ($FQDN);
-our ($IDENTITY_linux_lab, $IDENTITY_solaris_lab, $IDENTITY_wxp,
$IDENTITY_bladerhel);
our ($VMWARE_DISK);
-our $IDENTITY_newwxp = "$FindBin::Bin/../lib/VCL/newwinxp_blade.key";
our $XCATROOT = "/opt/xcat";
our $TOOLS = "$FindBin::Bin/../tools";
our $VMWAREREPOSITORY = "/install/vmware_images";
@@ -1419,10 +1387,9 @@ sub setstaticaddress {
}
- my $identity;
+ my $identity = $ENV{management_node_info}{keys};
my @sshcmd;
if ($image_os_type =~ /linux/i) {
- $identity = $IDENTITY_bladerhel;
#create local tmp file
# down interface
#copy tmpfile to /etc/sysconfig/network-scripts/ifcfg-eth1
@@ -1641,13 +1608,12 @@ sub getdynamicaddress {
notify($ERRORS{'WARNING'}, 0, "private IP address not found for
$node, possible issue with regex");
}
- my $identity;
+ my $identity_keys = $ENV{management_node_info}{keys};
my $dynaIPaddress = 0;
my $ip_address;
if ($image_os_type =~ /windows/i) {
- $identity = $IDENTITY_wxp;
- @sshcmd = run_ssh_command($node, $identity, "ipconfig", "root");
+ @sshcmd = run_ssh_command($node, $identity_keys, "ipconfig",
"root");
for my $l (@{$sshcmd[1]}) {
# skip class a,b,c private addresses
next if ($l !~ /IP(.*)?Address[\s\.:]*([\d\.]*)/);
@@ -1660,9 +1626,9 @@ sub getdynamicaddress {
} ## end if ($osname =~ /windows/)
elsif ($image_os_type =~ /linux/) {
- $identity = $IDENTITY_bladerhel;
+ #$identity = $ENV{management_node_info}{keys};
undef @sshcmd;
- @sshcmd = run_ssh_command($node, $identity, "/sbin/ifconfig
\|grep inet", "root");
+ @sshcmd = run_ssh_command($node, $identity_keys,
"/sbin/ifconfig \|grep inet", "root");
for my $l (@{$sshcmd[1]}) {
# skip class a,b,c private addresses
next if ($l !~ /inet addr:([\d\.]*)/);
@@ -1774,16 +1740,8 @@ sub check_connection {
my $ret_val = "no";
$dbh = getnewdbh() if !$dbh;
- my $identity;
- if ($image_os_type =~ /windows/i) {
- $identity = $IDENTITY_wxp;
- }
- elsif ($image_os_type =~ /linux/i) {
- $identity = $IDENTITY_bladerhel;
- }
- else {
- $identity = $IDENTITY_bladerhel;
- }
+ my $identity_keys = $ENV{management_node_info}{keys};
+
# Figure out number of loops for log messates
my $maximum_loops = $time_limit * 2;
my $loop_count = 0;
@@ -1828,7 +1786,7 @@ sub check_connection {
$shortnodename = $1 if ($nodename =~
/([-_a-zA-Z0-9]*)\./);
if ($image_os_type =~ /windows/i) {
undef @SSHCMD;
- @SSHCMD =
run_ssh_command($shortnodename, $identity, "netstat -an", "root", 22, 1);
+ @SSHCMD =
run_ssh_command($shortnodename, $identity_keys, "netstat -an", "root", 22, 1);
foreach my $line (@{$SSHCMD[1]}) {
#check for rdp and ssh
connections
# rdp:3389,ssh:22
@@ -1866,7 +1824,7 @@ sub check_connection {
# 2:simply check who ouput
my @lines;
undef @SSHCMD;
- @SSHCMD =
run_ssh_command($shortnodename, $identity, "netstat -an", "root", 22, 1);
+ @SSHCMD =
run_ssh_command($shortnodename, $identity_keys, "netstat -an", "root", 22, 1);
foreach my $line (@{$SSHCMD[1]}) {
if ($line =~ /Connection
refused|Permission denied/) {
chomp($line);
@@ -1894,7 +1852,7 @@ sub check_connection {
} #foreach
#who; too make sure we didn't miss
it through netstat
undef @SSHCMD;
- @SSHCMD =
run_ssh_command($shortnodename, $identity, "who", "root");
+ @SSHCMD =
run_ssh_command($shortnodename, $identity_keys, "who", "root");
foreach my $w (@{$SSHCMD[1]}) {
if ($w =~ /$user/) {
$break = 1;
@@ -1907,19 +1865,8 @@ sub check_connection {
} ## end elsif ($image_os_type =~ /linux/) [ if
($osname =~ /windows/)
} ## end if ($type =~ /blade|virtualmachine/)
elsif ($type eq "lab") {
- my $identity;
- if ($osname =~ /sun4x_/) {
- $identity = $IDENTITY_solaris_lab;
- }
- elsif ($osname =~ /rhel/) {
- $identity = $IDENTITY_linux_lab;
- }
- else {
- #if all else fails
- $identity = $IDENTITY_solaris_lab;
- }
undef @SSHCMD;
- @SSHCMD = run_ssh_command($nodename, $identity,
"netstat -an", "vclstaff", 24, 1);
+ @SSHCMD = run_ssh_command($nodename,
$identity_keys, "netstat -an", "vclstaff", 24, 1);
foreach my $line (@{$SSHCMD[1]}) {
chomp($line);
if ($line =~ /Connection
refused|Permission denied/) {
@@ -2001,17 +1948,7 @@ sub isconnected {
notify($ERRORS{'OK'}, 0, "image_os_type not set") if
(!defined($image_os_type));
notify($ERRORS{'OK'}, 0, "ipaddress not set") if (!defined($ipaddress));
- my $identity;
-
- if ($image_os_type =~ /windows/i) {
- $identity = $IDENTITY_wxp;
- }
- elsif ($image_os_type =~ /linux/i) {
- $identity = $IDENTITY_bladerhel;
- }
- else {
- $identity = $IDENTITY_bladerhel;
- }
+ my $identity= $ENV{management_node_info}{keys};
my @netstat;
my @SSHCMD;
@@ -2071,18 +2008,6 @@ sub isconnected {
return 0;
} ## end if ($type =~ /blade|virtualmachine/)
elsif ($type eq "lab") {
- my $identity;
- if ($osname =~ /sun4x_/) {
- $identity = $IDENTITY_solaris_lab;
- }
- elsif ($osname =~ /realmrhel/) {
- $identity = $IDENTITY_linux_lab;
- }
- else {
- #if all else fails
- notify($ERRORS{'OK'}, 0, "osname $osname not found
setting identity file to default");
- $identity = $IDENTITY_solaris_lab;
- }
undef @SSHCMD;
@SSHCMD = run_ssh_command($nodename, $identity, "netstat -an",
"vclstaff", 24, 1);
foreach my $line (@{$SSHCMD[1]}) {
@@ -2692,7 +2617,7 @@ sub _getcurrentimage {
my ($package, $filename, $line, $sub) = caller(0);
notify($ERRORS{'WARNING'}, 0, "node is not defined") if
(!(defined($node)));
# TODO - loop through the available ssh keys to figure out which one
works
- my $identity = $IDENTITY_bladerhel;
+ my $identity = $ENV{management_node_info}{keys};
my @sshcmd = run_ssh_command($node, $identity, "cat currentimage.txt");
foreach my $s (@{$sshcmd[1]}) {
if ($s =~ /Warning: /) {
@@ -2770,17 +2695,7 @@ sub _sshd_status {
return "off";
}
- my $identity;
-
- if ($image_os_type =~ /windows/i) {
- $identity = $IDENTITY_wxp;
- }
- elsif ($image_os_type =~ /linux/i) {
- $identity = $IDENTITY_bladerhel;
- }
- else {
- $identity = $IDENTITY_bladerhel;
- }
+ my $identity = $ENV{management_node_info}{keys};
my @sshcmd = run_ssh_command($node, $identity, "uname -s", "root");
@@ -2815,13 +2730,7 @@ sub _machine_os {
notify($ERRORS{'OK'}, 0, "ssh port not open cannot check $node
OS");
return 0;
}
- my $identity;
- if (defined($imagename)) {
- $identity = $IDENTITY_bladerhel if ($imagename =~
/^(rhel|rh3image|fc|rh|esx)/);
- }
- else {
- $identity = $IDENTITY_wxp;
- }
+ my $identity = $ENV{management_node_info}{keys};
my @sshcmd = run_ssh_command($node, $identity, "uname -s", "root");
foreach my $l (@{$sshcmd[1]}) {
if ($l =~ /CYGWIN_NT-5\.1/) {
@@ -2874,7 +2783,7 @@ sub _is_user_added {
if ($image_os_type =~ /linux/i) {
undef @SSHCMD;
- @SSHCMD = run_ssh_command($node, $IDENTITY_bladerhel,
"cat /etc/passwd", "root");
+ @SSHCMD = run_ssh_command($node,
$ENV{management_node_info}{keys}, "cat /etc/passwd", "root");
foreach $l (@{$SSHCMD[1]}) {
return 1 if ($l =~ /$user/);
}
@@ -3108,29 +3017,20 @@ sub notify_via_wall {
else {
notify($ERRORS{'WARNING'}, 0, "could not open tmp file $!");
}
+ my $identity_keys = $ENV{management_node_info}{keys};
if ($type eq "blade") {
#this is only going to be rhel
- if (run_scp_command("/tmp/wall.$hostname",
"$hostname:/root/wall.txt", $IDENTITY_bladerhel)) {
+ if (run_scp_command("/tmp/wall.$hostname",
"$hostname:/root/wall.txt", $identity_keys)) {
unlink "/tmp/wall.$hostname";
- if (run_ssh_command($hostname, $IDENTITY_bladerhel, "
cat /root/wall.txt \| wall; /bin/rm -v /root/wall.txt", "root")) {
+ if (run_ssh_command($hostname, $identity_keys, " cat
/root/wall.txt \| wall; /bin/rm -v /root/wall.txt", "root")) {
notify($ERRORS{'OK'}, 0, "successfully sent
wall notification to $hostname");
return 1;
}
}
} ## end if ($type eq "blade")
elsif ($type eq "lab") {
- if ($OSname =~ /sun4x_/) {
- $identity = $IDENTITY_solaris_lab;
- }
- elsif ($OSname =~ /rhel/) {
- $identity = $IDENTITY_linux_lab;
- }
- else {
- #all else fails
- $identity = $IDENTITY_solaris_lab;
- }
-
- if (run_scp_command("/tmp/wall.$hostname",
"vclsta...@$hostname:/home/vclstaff/wall.txt", $identity, 24)) {
+
+ if (run_scp_command("/tmp/wall.$hostname",
"vclsta...@$hostname:/home/vclstaff/wall.txt", $identity_keys, 24)) {
unlink "/tmp/wall.$hostname";
}
else {
@@ -3138,7 +3038,7 @@ sub notify_via_wall {
}
if ($OSname =~ /sun4x_/) {
- if (run_ssh_command($hostname, $identity, "wall -a
/home/vclstaff/wall.txt; /bin/rm -v /home/vclstaff/wall.txt", "vclstaff",
"24")) {
+ if (run_ssh_command($hostname, $identity_keys, "wall -a
/home/vclstaff/wall.txt; /bin/rm -v /home/vclstaff/wall.txt", "vclstaff",
"24")) {
notify($ERRORS{'OK'}, 0, "successfully sent
wall notification to $hostname");
return 1;
}
@@ -3147,7 +3047,7 @@ sub notify_via_wall {
}
}
elsif ($OSname =~ /rhel/) {
- if (run_ssh_command($hostname, $identity, "cat
/home/vclstaff/wall.txt \| wall ; /bin/rm -v /home/vclstaff/wall.txt",
"vclstaff", "24")) {
+ if (run_ssh_command($hostname, $identity_keys, "cat
/home/vclstaff/wall.txt \| wall ; /bin/rm -v /home/vclstaff/wall.txt",
"vclstaff", "24")) {
notify($ERRORS{'OK'}, 0, "successfully sent
wall notification to $hostname");
return 1;
}
@@ -3263,7 +3163,7 @@ sub notify_via_msg {
my $command = "msg $user /TIME:180 '$message'";
- if (run_ssh_command($node, $IDENTITY_wxp, $command)) {
+ if (run_ssh_command($node, $ENV{management_node_info}{keys}, $command))
{
notify($ERRORS{'OK'}, 0, "successfully sent message to Windows
user $user on $node");
return 1;
}
@@ -3467,6 +3367,7 @@ sub changelinuxpassword {
my @ssh;
my $l;
+ my $identity_keys = $ENV{management_node_info}{keys};
if ($account eq "root") {
@@ -3486,11 +3387,11 @@ sub changelinuxpassword {
if (open(TMP, ">$tmpfile")) {
print TMP
"$account:$passwd:13061:0:99999:7:::\n";
close(TMP);
- if (run_ssh_command($node, $IDENTITY_bladerhel,
"cat /etc/shadow \|grep -v $account >> $tmpfile", "root")) {
+ if (run_ssh_command($node, $identity_keys, "cat
/etc/shadow \|grep -v $account >> $tmpfile", "root")) {
notify($ERRORS{'DEBUG'}, 0, "collected
/etc/shadow file from $node");
- if (run_scp_command($tmpfile,
"$node:/etc/shadow", $IDENTITY_bladerhel)) {
+ if (run_scp_command($tmpfile,
"$node:/etc/shadow", $identity_keys)) {
notify($ERRORS{'DEBUG'}, 0,
"copied updated /etc/shadow file to $node");
- if (run_ssh_command($node,
$IDENTITY_bladerhel, "chmod 600 /etc/shadow", "root")) {
+ if (run_ssh_command($node,
$identity_keys, "chmod 600 /etc/shadow", "root")) {
notify($ERRORS{'DEBUG'}, 0, "updated permissions to 600 on /etc/shadow file on
$node");
unlink $tmpfile;
return 1;
@@ -3504,7 +3405,7 @@ sub changelinuxpassword {
else {
notify($ERRORS{'WARNING'}, 0,
"failed to copy contents of shadow file on $node ");
}
- } ## end if (run_ssh_command($node,
$IDENTITY_bladerhel...
+ } ## end if (run_ssh_command($node,
$identity_keys...
else {
notify($ERRORS{'WARNING'}, 0, "failed
to copy contents of shadow file on $node ");
unlink $tmpfile;
@@ -3520,7 +3421,7 @@ sub changelinuxpassword {
else {
#actual user
#push it through passwd cmd stdin
- my @sshcmd = run_ssh_command($node, $IDENTITY_bladerhel, "echo
$passwd \| /usr/bin/passwd -f $account --stdin", "root");
+ my @sshcmd = run_ssh_command($node, $identity_keys, "echo
$passwd \| /usr/bin/passwd -f $account --stdin", "root");
foreach my $l (@{$sshcmd[1]}) {
if ($l =~ /authentication tokens updated successfully/)
{
notify($ERRORS{'OK'}, 0, "successfully changed
local password account $account");
@@ -3677,15 +3578,8 @@ sub collectsshkeys {
}
#what identity do we use
- my $key;
- if ($type =~ /lab/) {
- if ($osname =~ /rhel/) {
- $key = $IDENTITY_linux_lab;
- }
- else {
- $key = $IDENTITY_solaris_lab;
- }
- }
+ my $key = $ENV{management_node_info}{keys};
+
#send fetch keys flag to node
my @sshcmd = run_ssh_command($ipaddress, $key, "echo fetch >
/home/vclstaff/clientdata; echo 1 > /home/vclstaff/flag", "vclstaff", "24");
foreach my $l (@{$sshcmd[1]}) {
@@ -3943,16 +3837,8 @@ sub check_uptime {
notify($ERRORS{'WARNING'}, $log, "type is not defined") if
(!(defined($type)));
if ($type eq "lab") {
- my $identity;
- if ($OSname =~ /sun4x/) {
- $identity = $IDENTITY_solaris_lab;
- }
- elsif ($OSname =~ /rhel/) {
- $identity = $IDENTITY_linux_lab;
- }
- else {
- return (0, "failure : OSname not match");
- }
+ my $identity = $ENV{management_node_info}{keys};
+
my @sshcmd = run_ssh_command($node, $identity, "uptime",
"vclstaff", "24");
my $l;
foreach $l (@{$sshcmd[1]}) {
@@ -5047,35 +4933,7 @@ sub get_request_info {
my $imagerevision_imagename =
$request_info{reservation}{$reservation_id}{imagerevision}{imagename};
my $image_os_type =
$request_info{reservation}{$reservation_id}{image}{OS}{type};
- my $identity_file_path;
- if($computer_type =~ /blade|virtualmachine/){
- if($image_os_type =~ /windows/i){
- $identity_file_path = $IDENTITY_wxp;
- }
- elsif ($image_os_type =~ /linux/i){
- $identity_file_path = $IDENTITY_bladerhel;
- }
- else{
- notify($ERRORS{'WARNING'}, 0,
"computer_type=$computer_type is of an unknown or unusual
image_os_type=$image_os_type type=$computer_type");
- }
- }
- elsif($computer_type eq "lab"){
- if ($imagerevision_imagename =~ /realmrh|i386_linux26/)
{
- $identity_file_path = $IDENTITY_linux_lab;
- }
- elsif ($imagerevision_imagename =~ /sun/) {
- $identity_file_path = $IDENTITY_solaris_lab;
- }
- elsif ($imagerevision_imagename =~ /^mpls/) {
- notify($ERRORS{'OK'}, 0, "MPLS reservation:
$request_id:$reservation_id");
- }
- else {
- notify($ERRORS{'WARNING'}, 0, "unsupported
image type: '$imagerevision_imagename'");
- }
- }
- else{
- notify($ERRORS{'WARNING'}, 0, "computer=$computer_id is
of an unknown or unusual type=$computer_type");
- }
+ my $identity_file_path = $ENV{management_node_info}{keys};
$request_info{reservation}{$reservation_id}{image}{IDENTITY} =
$identity_file_path;
@@ -9742,17 +9600,7 @@ sub disablesshd {
}
my @lines;
my $l;
- my $identity;
- if ($osname =~ /sun4x_/) {
- $identity = $IDENTITY_solaris_lab;
- }
- elsif ($osname =~ /rhel/) {
- $identity = $IDENTITY_linux_lab;
- }
- else {
- #if all else fails
- $identity = $IDENTITY_solaris_lab;
- }
+ my $identity = $ENV{management_node_info}{keys};
# create clientdata file
my $clientdata = "/tmp/clientdata.$hostname";
if (open(CLIENTDATA, ">$clientdata")) {