PageRenderTime 27ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/perl/dev/Migration/namespace-00001.pl

http://server-diagnostic-patterns.googlecode.com/
Perl | 127 lines | 64 code | 20 blank | 43 comment | 11 complexity | 46a5417c338866d1b7a3907a72127223 MD5 | raw file
  1. #!/usr/bin/perl
  2. #<<BEGIN PATTERN METADATA>>
  3. #META-CATEGORY = Migration
  4. #META-REVISION = 1.0.0
  5. #META-TITLE = Check volume name spaces
  6. #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.
  7. #META-PRODUCT = NetWare
  8. #META-OS = SUSE
  9. #META-DISTRO = NW
  10. #META-ARCH = All
  11. #META-LINK-TID = http://www.suse.com/support/kb/doc.php?id=7001767
  12. #<<END PATTERN METADATA>>
  13. ##############################################################################
  14. # Copyright (C) 2009 Novell, Inc.
  15. ##############################################################################
  16. #
  17. # This program is free software; you can redistribute it and/or modify
  18. # it under the terms of the GNU General Public License as published by
  19. # the Free Software Foundation; version 2 of the License.
  20. #
  21. # This program is distributed in the hope that it will be useful,
  22. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. # GNU General Public License for more details.
  25. #
  26. # You should have received a copy of the GNU General Public License
  27. # along with this program; if not, write to the Free Software
  28. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  29. #
  30. # Authors/Contributors:
  31. # Tregaron Bayly (tbayly@novell.com)
  32. # Creation Date: 12 Jun 2009
  33. # Modification Date: 2009 Sep 02
  34. ##############################################################################
  35. ##############################################################################
  36. # Module Definition
  37. ##############################################################################
  38. use strict;
  39. use warnings;
  40. use SDP::Core;
  41. use SDP::NetWare;
  42. ##############################################################################
  43. # Overriden (eventually or in part) from SDP::Core Module
  44. ##############################################################################
  45. $META_CATEGORY = "Migration";
  46. $PRIMARY_LINK = "META-LINK-TID";
  47. @PATTERN_RESULTS = (
  48. PROPERTY_NAME_CATEGORY."=$META_CATEGORY",
  49. PROPERTY_NAME_PATTERN_ID."=$PATTERN_ID",
  50. PROPERTY_NAME_PRIMARY_LINK."=$PRIMARY_LINK",
  51. PROPERTY_NAME_OVERALL."=$GSTATUS",
  52. PROPERTY_NAME_OVERALL_INFO."=None"
  53. );
  54. sub get_ineligible_volumes {
  55. my $target_name_space = $_[0];
  56. my $file = "config.txt";
  57. my $section = "Storage Device Configuration";
  58. my @output = ();
  59. my %volumes = ();
  60. if (SDP::Core::get_section($file, $section, \@output)) {
  61. my $in_name_spaces = 0;
  62. foreach $_ (@output) {
  63. if ( /Name Spaces Loaded$/ ) {
  64. $in_name_spaces = 1;
  65. }
  66. elsif ($_ eq "") {
  67. $in_name_spaces = 0;
  68. }
  69. elsif ($in_name_spaces == 1 && !($_ =~ /^-+/)) {
  70. my ($vol, $namespace) = split (/\s+/, $_);
  71. if ($volumes{$vol}) { $volumes{$vol} = $volumes{$vol} . " $namespace"; }
  72. else { $volumes{$vol} = $namespace; }
  73. }
  74. }
  75. }
  76. else {
  77. SDP::Core::update_status(STATUS_ERROR, "ELEMENT", "Cannot find \"$section\" section in $file");
  78. }
  79. @output = ();
  80. while( my ($k, $v) = each %volumes ) {
  81. unless ($v =~ $target_name_space) {
  82. push (@output, $k);
  83. }
  84. }
  85. return @output;
  86. }
  87. ##############################################################################
  88. # Main Program Execution
  89. ##############################################################################
  90. sub main {
  91. SDP::Core::process_options();
  92. SDP::Core::initialize_status(STATUS_SUCCESS, "Volumes have the correct namespace");
  93. my $list = "";
  94. my @no_nfs_volumes = get_ineligible_volumes("NFS");
  95. if ($#no_nfs_volumes >= 0) {
  96. foreach $_ (@no_nfs_volumes) {
  97. $list .= " $_";
  98. }
  99. 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");
  100. }
  101. else {
  102. SDP::Core::update_status(STATUS_SUCCESS, "ELEMENT", "All volumes on the server have the NFS namespace loaded and are eligible for data migration");
  103. }
  104. SDP::Core::print_pattern_results();
  105. }
  106. main();
  107. exit;