/perl/dev/Migration/namespace-00001.pl
Perl | 127 lines | 64 code | 20 blank | 43 comment | 11 complexity | 46a5417c338866d1b7a3907a72127223 MD5 | raw file
- #!/usr/bin/perl
- #<<BEGIN PATTERN METADATA>>
- #META-CATEGORY = Migration
- #META-REVISION = 1.0.0
- #META-TITLE = Check volume name spaces
- #META-DESCRIPTION = Volumes involved in data migrations must have the NFS name space or the nbackup portion of the migration will fail. This pattern verifies the name spaces on all of the volumes and notifies you of any volumes ineligible to migrate. Note that this is only a failure if one of the volumes you intend to migrate is identified.
- #META-PRODUCT = NetWare
- #META-OS = SUSE
- #META-DISTRO = NW
- #META-ARCH = All
- #META-LINK-TID = http://www.suse.com/support/kb/doc.php?id=7001767
- #<<END PATTERN METADATA>>
- ##############################################################################
- # Copyright (C) 2009 Novell, Inc.
- ##############################################################################
- #
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation; version 2 of the License.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- #
- # Authors/Contributors:
- # Tregaron Bayly (tbayly@novell.com)
- # Creation Date: 12 Jun 2009
- # Modification Date: 2009 Sep 02
- ##############################################################################
- ##############################################################################
- # Module Definition
- ##############################################################################
- use strict;
- use warnings;
- use SDP::Core;
- use SDP::NetWare;
- ##############################################################################
- # Overriden (eventually or in part) from SDP::Core Module
- ##############################################################################
- $META_CATEGORY = "Migration";
- $PRIMARY_LINK = "META-LINK-TID";
- @PATTERN_RESULTS = (
- PROPERTY_NAME_CATEGORY."=$META_CATEGORY",
- PROPERTY_NAME_PATTERN_ID."=$PATTERN_ID",
- PROPERTY_NAME_PRIMARY_LINK."=$PRIMARY_LINK",
- PROPERTY_NAME_OVERALL."=$GSTATUS",
- PROPERTY_NAME_OVERALL_INFO."=None"
- );
- sub get_ineligible_volumes {
- my $target_name_space = $_[0];
- my $file = "config.txt";
- my $section = "Storage Device Configuration";
- my @output = ();
- my %volumes = ();
- if (SDP::Core::get_section($file, $section, \@output)) {
- my $in_name_spaces = 0;
- foreach $_ (@output) {
- if ( /Name Spaces Loaded$/ ) {
- $in_name_spaces = 1;
- }
- elsif ($_ eq "") {
- $in_name_spaces = 0;
- }
- elsif ($in_name_spaces == 1 && !($_ =~ /^-+/)) {
- my ($vol, $namespace) = split (/\s+/, $_);
- if ($volumes{$vol}) { $volumes{$vol} = $volumes{$vol} . " $namespace"; }
- else { $volumes{$vol} = $namespace; }
- }
- }
- }
- else {
- SDP::Core::update_status(STATUS_ERROR, "ELEMENT", "Cannot find \"$section\" section in $file");
- }
- @output = ();
- while( my ($k, $v) = each %volumes ) {
- unless ($v =~ $target_name_space) {
- push (@output, $k);
- }
- }
- return @output;
- }
- ##############################################################################
- # Main Program Execution
- ##############################################################################
- sub main {
- SDP::Core::process_options();
- SDP::Core::initialize_status(STATUS_SUCCESS, "Volumes have the correct namespace");
- my $list = "";
- my @no_nfs_volumes = get_ineligible_volumes("NFS");
- if ($#no_nfs_volumes >= 0) {
- foreach $_ (@no_nfs_volumes) {
- $list .= " $_";
- }
- SDP::Core::update_status(STATUS_WARNING, "ELEMENT", "The following volumes do not have the NFS name space loaded and are ineligible for data migration:$list");
- }
- else {
- SDP::Core::update_status(STATUS_SUCCESS, "ELEMENT", "All volumes on the server have the NFS namespace loaded and are eligible for data migration");
- }
- SDP::Core::print_pattern_results();
- }
- main();
- exit;