<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="http://brandonhutchinson.com/mediawiki/skins/common/feed.css?97"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://brandonhutchinson.com/mediawiki/index.php5?title=Script_to_parse_cluster_table_of_contents_file&amp;action=history&amp;feed=atom</id>
		<title>Script to parse cluster table of contents file - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://brandonhutchinson.com/mediawiki/index.php5?title=Script_to_parse_cluster_table_of_contents_file&amp;action=history&amp;feed=atom"/>
		<link rel="alternate" type="text/html" href="http://brandonhutchinson.com/mediawiki/index.php5?title=Script_to_parse_cluster_table_of_contents_file&amp;action=history"/>
		<updated>2013-05-23T21:17:12Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.11.0rc1</generator>

	<entry>
		<id>http://brandonhutchinson.com/mediawiki/index.php5?title=Script_to_parse_cluster_table_of_contents_file&amp;diff=1423&amp;oldid=prev</id>
		<title>Hutch at 23:01, 12 February 2009</title>
		<link rel="alternate" type="text/html" href="http://brandonhutchinson.com/mediawiki/index.php5?title=Script_to_parse_cluster_table_of_contents_file&amp;diff=1423&amp;oldid=prev"/>
				<updated>2009-02-12T23:01:00Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 23:01, 12 February 2009&lt;/td&gt;
			&lt;/tr&gt;
		&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;When run with no arguments, the script will return a list of metaclusters to query. e.g.,&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;When run with no arguments, the script will return a list of metaclusters to query. e.g.,&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; $ '''./parse_clustertoc.pl'''&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; Usage: ./parse_clustertoc.pl metacluster&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; Usage: ./parse_clustertoc.pl metacluster&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 12:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 13:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; SUNWCrnet&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; SUNWCrnet&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; SUNWCuser&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; SUNWCuser&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; $ '''./parse_clustertoc.pl SUNWCXall'''&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt; (1054 package names follow for a Solaris 10 11/06 SPARC system)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;My Perl programming may leave much to be desired.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;My Perl programming may leave much to be desired.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Hutch</name></author>	</entry>

	<entry>
		<id>http://brandonhutchinson.com/mediawiki/index.php5?title=Script_to_parse_cluster_table_of_contents_file&amp;diff=1422&amp;oldid=prev</id>
		<title>Hutch: New page: I wrote the following Perl script to parse the Sun cluster table of contents file '''/var/sadm/system/admin/.clustertoc'''. Basically, I want to know which individual packages comprise any...</title>
		<link rel="alternate" type="text/html" href="http://brandonhutchinson.com/mediawiki/index.php5?title=Script_to_parse_cluster_table_of_contents_file&amp;diff=1422&amp;oldid=prev"/>
				<updated>2009-02-12T22:59:21Z</updated>
		
		<summary type="html">&lt;p&gt;New page: I wrote the following Perl script to parse the Sun cluster table of contents file '''/var/sadm/system/admin/.clustertoc'''. Basically, I want to know which individual packages comprise any...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;I wrote the following Perl script to parse the Sun cluster table of contents file '''/var/sadm/system/admin/.clustertoc'''. Basically, I want to know which individual packages comprise any of the Sun metaclusters. The file can be tricky to parse, as metaclusters contain both individual packages along with clusters.&lt;br /&gt;
&lt;br /&gt;
When run with no arguments, the script will return a list of metaclusters to query. e.g.,&lt;br /&gt;
&lt;br /&gt;
 Usage: ./parse_clustertoc.pl metacluster&lt;br /&gt;
 &lt;br /&gt;
 Available metaclusters:&lt;br /&gt;
 SUNWCXall&lt;br /&gt;
 SUNWCall&lt;br /&gt;
 SUNWCprog&lt;br /&gt;
 SUNWCreq&lt;br /&gt;
 SUNWCrnet&lt;br /&gt;
 SUNWCuser&lt;br /&gt;
&lt;br /&gt;
My Perl programming may leave much to be desired.&lt;br /&gt;
&lt;br /&gt;
=== Code ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/perl&lt;br /&gt;
&lt;br /&gt;
# This script parses the Sun cluster table of contents file and returns&lt;br /&gt;
# individual package names for a given metacluster. Metaclusters contain both&lt;br /&gt;
# invividual packages and clusters, so the table of contents file has to be read&lt;br /&gt;
# twice in order to convert clusters into individual packages.&lt;br /&gt;
&lt;br /&gt;
# If a command-line argument is not given, return the list of metaclusters.&lt;br /&gt;
&lt;br /&gt;
my $clustertoc=&amp;quot;/var/sadm/system/admin/.clustertoc&amp;quot;;&lt;br /&gt;
my %metaclusters;&lt;br /&gt;
my %cluster_members;&lt;br /&gt;
my %package_members;&lt;br /&gt;
my $seen_metacluster=0;&lt;br /&gt;
&lt;br /&gt;
open(CLUSTERTOC, &amp;quot;&amp;lt; $clustertoc&amp;quot;)&lt;br /&gt;
   or die &amp;quot;Couldn't open $clustertoc for reading: $!\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
# SUNWC cluster members are clusters that must be parsed to get the packages.&lt;br /&gt;
# Any other SUNW cluster member is an individual package. e.g.,&lt;br /&gt;
# SUNW_CSRMEMBER=SUNWCzfs is an additional cluster&lt;br /&gt;
# SUNW_CSRMEMBER=SUNWadmap is a package&lt;br /&gt;
&lt;br /&gt;
while(&amp;lt;CLUSTERTOC&amp;gt;) {&lt;br /&gt;
   # SUNWCmreq is an &amp;quot;internal private metacluster not installable by end users&amp;quot;&lt;br /&gt;
   next if /METACLUSTER=SUNWCmreq/;&lt;br /&gt;
   $metaclusters{$1}=1 if /METACLUSTER=(.*)/;&lt;br /&gt;
   if (defined($ARGV[0])) {&lt;br /&gt;
      # Is this the metacluster we're looking for?&lt;br /&gt;
      $seen_metacluster=1 if /METACLUSTER=$ARGV[0]/;&lt;br /&gt;
      if (/SUNW_CSRMEMBER=(SUNWC.*)/ and $seen_metacluster) {&lt;br /&gt;
         # SUNWC.* is a cluster&lt;br /&gt;
         $cluster_members{$1}=1;&lt;br /&gt;
         next;&lt;br /&gt;
      }&lt;br /&gt;
      if (/SUNW_CSRMEMBER=(SUNW.*)/ and $seen_metacluster) {&lt;br /&gt;
         # Anything else SUNW.* is an individual package&lt;br /&gt;
         $package_members{$1}=1;&lt;br /&gt;
      }&lt;br /&gt;
      # Exit the loop if we're at the end of the metacluster contents&lt;br /&gt;
      last if /^END$/ and $seen_metacluster;&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if (!defined($ARGV[0])) {&lt;br /&gt;
   print &amp;quot;Usage: $0 metacluster\n\n&amp;quot;;&lt;br /&gt;
   print &amp;quot;Available metaclusters:\n&amp;quot;;&lt;br /&gt;
   foreach (sort keys %metaclusters) {&lt;br /&gt;
      print &amp;quot;$_\n&amp;quot;;&lt;br /&gt;
   }&lt;br /&gt;
   exit 0&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# Loop through $clustertoc again, get the individual packages comprising&lt;br /&gt;
# the %cluster_members clusters.&lt;br /&gt;
open(CLUSTERTOC, &amp;quot;&amp;lt; $clustertoc&amp;quot;)&lt;br /&gt;
   or die &amp;quot;Couldn't open $clustertoc for reading: $!\n&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
my $get_packages=0;&lt;br /&gt;
&lt;br /&gt;
while(&amp;lt;CLUSTERTOC&amp;gt;) {&lt;br /&gt;
   if (/CLUSTER=(.*)/) {&lt;br /&gt;
      # Is this cluster part of our metacluster?&lt;br /&gt;
      $get_packages=1 if (exists $cluster_members{$1});&lt;br /&gt;
   }&lt;br /&gt;
   $package_members{$1}=1 if /SUNW_CSRMEMBER=(.*)/ and $get_packages;&lt;br /&gt;
   $get_packages=0 if /^END$/;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
foreach my $key(sort keys %package_members) {&lt;br /&gt;
   print &amp;quot;$key\n&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hutch</name></author>	</entry>

	</feed>