Sun-Fire-X4500-hc-topology.xmlgen revision 184cd04c26b064536977dfbb913a1240eaf6f708
#!/usr/local/bin/perl
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"
#
use Getopt::Std;
my $sys_supported = {"name" => "Sun-Fire-X4500",
"prop_name" => "sfx4500",
"num_bays" => "48"};
$IFILE = "filehandle";
$OFILE = "filehandle";
sub Usage()
{
print STDERR "Usage: xml-gen -p <platform> -i <input_xml_file> -o <output_xml_file>\n";
}
sub calc_sfx_prop
{
my $name = shift;
my $hdd = shift;
my $sid = shift;
printf OFILE "\n";
printf OFILE " <propgroup name='%s-properties'", $name;
printf OFILE " version='1' name-stability='Private'";
printf OFILE " data-stability='Private' >\n";
printf OFILE " <propval name='fru-update-action'";
printf OFILE " type='string' value='ipmi:fru gid=3 hdd=%d' />\n", $hdd;
printf OFILE " <propval name='indicator-name-0'";
printf OFILE " type='string' value='+PRSNT' />\n";
printf OFILE " <propval name='indicator-action-0'";
printf OFILE " type='string' value='ipmi:state sid=%d amask=0x0001' />\n",
$sid;
printf OFILE " <propval name='indicator-name-1'";
printf OFILE " type='string' value='-PRSNT' />\n";
printf OFILE " <propval name='indicator-action-1'";
printf OFILE " type='string' value='ipmi:state sid=%d dmask=0x0001' />\n",
$sid;
printf OFILE " <propval name='indicator-name-2'";
printf OFILE " type='string' value='+OK2RM' />\n";
printf OFILE " <propval name='indicator-action-2'";
printf OFILE " type='string' value='ipmi:state sid=%d amask=0x0008' />\n",
$sid;
printf OFILE " <propval name='indicator-name-3'";
printf OFILE " type='string' value='-OK2RM' />\n";
printf OFILE " <propval name='indicator-action-3'";
printf OFILE " type='string' value='ipmi:state sid=%d dmask=0x0008' />\n",
$sid;
printf OFILE " <propval name='indicator-name-4'";
printf OFILE " type='string' value='+FAULT' />\n";
printf OFILE " <propval name='indicator-action-4'";
printf OFILE " type='string' value='ipmi:state sid=%d amask=0x0002' />\n",
$sid;
printf OFILE " <propval name='indicator-name-5'";
printf OFILE " type='string' value='-FAULT' />\n";
printf OFILE " <propval name='indicator-action-5'";
printf OFILE " type='string' value='ipmi:state sid=%d dmask=0x0002' />\n",
$sid;
printf OFILE " <propval name='indicator-rule-";
printf OFILE "states-0' type='string' value='absent>present' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "actions-0' type='string' value='+PRSNT&amp;+OK2RM' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "states-1' type='string' value='present>configured' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "actions-1' type='string' value='+PRSNT&amp;-OK2RM' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "states-2' type='string' value='configured>unconfigured' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "actions-2' type='string' value='+OK2RM' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "states-3' type='string' value='unconfigured>configured' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "actions-3' type='string' value='-OK2RM' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "states-4' type='string' value='unconfigured>absent' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "actions-4' type='string' value='-OK2RM&amp;-PRSNT' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "states-5' type='string' value='configured>absent' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "actions-5' type='string' value='-OK2RM&amp;-PRSNT' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "states-6' type='string' value='present>absent' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "actions-6' type='string' value='-OK2RM&amp;-PRSNT' />\n";
printf OFILE " </propgroup>\n";
printf OFILE "\n";
}
sub calc_nodes
{
my @pci0=(1, 2, 0);
my @pci1=(4, 3, 8, 7, 2, 1);
for ($cnt = 0; $cnt < $sys_supported->{"num_bays"}; $cnt++) {
$hdd = $cnt;
$sid = 90 + $cnt;
$d = (($cnt/12) + (($cnt & 1) << 2));
$index = (($cnt >> 2) % 3);
$p0 = $pci0[$index];
$index = (($cnt >> 1) % 6);
$p1 = $pci1[$index];
printf OFILE "\n";
printf OFILE " <node instance='%d'>\n", $cnt;
printf OFILE "\n";
printf OFILE " <propgroup name='protocol'";
printf OFILE " version='1' name-stability='Private'";
printf OFILE " data-stability='Private' >\n";
printf OFILE " <propval name='ASRU' ";
printf OFILE "type='fmri' value=";
printf OFILE "'dev:////pci@%d,0/pci1022,7458@%d", $p0, $p1;
printf OFILE "/pci11ab,11ab\@1' />\n";
printf OFILE " <propval name='label'";
printf OFILE " type='string' value='bay%d' />\n", $cnt;
printf OFILE " </propgroup>\n";
printf OFILE " <propgroup name='io'";
printf OFILE " version='1' name-stability='Private'";
printf OFILE " data-stability='Private' >\n";
printf OFILE " <propval name='ap-path'";
printf OFILE " type='string'";
printf OFILE " value='/devices/pci@%d,0/pci1022,7458@%d", $p0, $p1;
printf OFILE "/pci11ab,11ab\@1:%d' />\n", $d;
printf OFILE " </propgroup>\n";
calc_sfx_prop($sys_supported->{"prop_name"}, $hdd, $sid);
printf OFILE " <propgroup name='binding'";
printf OFILE " version='1' name-stability='Private'";
printf OFILE " data-stability='Private' >\n";
printf OFILE " <propval name='occupant-path'";
printf OFILE " type='string'";
printf OFILE " value='/pci@%d,0/pci1022,7458@%d", $p0, $p1;
printf OFILE "/pci11ab,11ab\@1/disk@%d,0' />\n", $d;
printf OFILE " </propgroup>\n";
printf OFILE "\n";
printf OFILE " </node>\n";
printf OFILE "\n";
}
}
$ok = getopts("p:i:o:h", \%options);
if ($options{'h'}) {
Usage();
exit (1);
}
$platform = $options{'p'};
$input_file = $options{'i'};
$output_file = $options{'o'};
if (!$platform || !$input_file || !$output_file) {
Usage();
exit (1);
}
open(IFILE, "< $input_file") || die("$input_file cannot be opened.");
open(OFILE, "> $output_file") || die("$output_file cannot be opened.");
while ($line = <IFILE>) {
chomp($line);
if ($line ne "</topology>") {
print OFILE "$line\n";
} else {
last;
}
}
print OFILE " <!--xml-gen internal storage-->\n";
printf OFILE " <range name='bay' min='0' max='%d'>\n", $sys_supported->{"num_bays"};
calc_nodes(0);
printf OFILE " <dependents grouping='children'>\n";
printf OFILE " <range name='disk' min='0'";
printf OFILE " max='1'>\n";
printf OFILE " <enum-method name='disk'";
printf OFILE " version='1' />\n";
printf OFILE " </range>\n";
printf OFILE " </dependents>\n";
printf OFILE "\n";
printf OFILE " </range>\n";
print OFILE "$line\n";
while ($line = <IFILE>) {
print OFILE $line;
}
close OFILE;
close IFILE;