You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by ar...@apache.org on 2010/10/28 20:03:55 UTC

svn commit: r1028405 - /incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux/ManagementNode.pm

Author: arkurth
Date: Thu Oct 28 18:03:55 2010
New Revision: 1028405

URL: http://svn.apache.org/viewvc?rev=1028405&view=rev
Log:
VCL-413
Added ManagementNode.pm.  It is not yet functional.  It will eventually allow the management node's Linux OS to be controlled using the code in Linux.pm.

Added:
    incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux/ManagementNode.pm   (with props)

Added: incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux/ManagementNode.pm
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux/ManagementNode.pm?rev=1028405&view=auto
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux/ManagementNode.pm (added)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux/ManagementNode.pm Thu Oct 28 18:03:55 2010
@@ -0,0 +1,174 @@
+#!/usr/bin/perl -w
+###############################################################################
+# $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.
+###############################################################################
+
+=head1 NAME
+
+VCL::Module::OS::Linux::ManagementNode.pm
+
+=head1 SYNOPSIS
+
+ Needs to be written
+
+=head1 DESCRIPTION
+
+ This module provides VCL support for the management node's Linux operating
+ system.
+
+=cut
+
+##############################################################################
+package VCL::Module::OS::Linux::ManagementNode;
+
+# Specify the lib path using FindBin
+use FindBin;
+use lib "$FindBin::Bin/../../../..";
+
+# Configure inheritance
+use base qw(VCL::Module::OS::Linux);
+
+# Specify the version of this module
+our $VERSION = '2.00';
+
+# Specify the version of Perl to use
+use 5.008000;
+
+use strict;
+use warnings;
+use diagnostics;
+
+use VCL::utils;
+
+##############################################################################
+
+=head1 OBJECT METHODS
+
+=cut
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 initialize
+
+ Parameters  : 
+ Returns     : 
+ Description :
+
+=cut
+
+sub initialize {
+	my $self = shift;
+	unless (ref($self) && $self->isa('VCL::Module')) {
+		notify($ERRORS{'CRITICAL'}, 0, "subroutine can only be called as an object method");
+		return;
+	}
+	
+	my $management_node_hostname = $self->data->get_management_node_hostname() || return;
+	my $management_node_short_name = $self->data->get_management_node_short_name() || return;
+	my $management_node_ip_address = $self->data->get_management_node_ipaddress() || return;
+	
+	$self->data->set_computer_hostname($management_node_hostname);
+	$self->data->set_computer_node_name($management_node_short_name);
+	$self->data->set_computer_short_name($management_node_short_name);
+	$self->data->set_computer_ip_address($management_node_ip_address);
+	
+	#print "\n\n" . format_data($self->data->get_request_data()) . "\n\n";
+	return 1;
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 execute
+
+ Parameters  : $command, $display_output (optional)
+ Returns     : array
+ Description :
+
+=cut
+
+sub execute {
+	my $self = shift;
+	unless (ref($self) && $self->isa('VCL::Module')) {
+		notify($ERRORS{'CRITICAL'}, 0, "subroutine can only be called as an object method");
+		return;
+	}
+	
+	# Get the command argument
+	my $command = shift;
+	if (!$command) {
+		notify($ERRORS{'WARNING'}, 0, "command argument was not specified");
+		return;
+	}
+	
+	# Get 2nd display output argument if supplied, or set default value
+	my $display_output = shift || '0';
+	
+	
+	# Run the command
+	my ($exit_status, $output) = run_command($command, $display_output);
+	if (defined($exit_status) && defined($output)) {
+		if ($display_output) {
+			notify($ERRORS{'OK'}, 0, "executed command: '$command', exit status: $exit_status, output:\n" . join("\n", @$output));
+		}
+		return ($exit_status, $output);
+	}
+	else {
+		notify($ERRORS{'WARNING'}, 0, "failed to run command on management node: $command");
+		return;
+	}
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 copy_file_to
+
+ Parameters  : $source, $destination
+ Returns     : array
+ Description : Copies file(s) from the management node to the Linux computer.
+
+=cut
+
+sub copy_file_to {
+	my $self = shift;
+	if (ref($self) !~ /VCL::Module/i) {
+		notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a function, it must be called as a class method");
+		return;
+	}
+	
+	# Get the source and destination arguments
+	my ($source, $destination) = @_;
+	if (!$source || !$destination) {
+		notify($ERRORS{'WARNING'}, 0, "source and destination arguments were not specified");
+		return;
+	}
+	
+	$destination =~ s/.*://g;
+	return $self->copy_file($source, $destination);
+}
+
+
+#/////////////////////////////////////////////////////////////////////////////
+
+1;
+__END__
+
+=head1 SEE ALSO
+
+L<http://cwiki.apache.org/VCL/>
+
+=cut

Propchange: incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux/ManagementNode.pm
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux/ManagementNode.pm
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id