From a149ba100e90416ba41e9d9205c6f23d27c4249a Mon Sep 17 00:00:00 2001 From: Ratan Gupta Date: Tue, 17 Jan 2017 00:32:32 +0530 Subject: gen_ipmi_fru.pl: construct FRU metadata For IPMI FRUs, generate a file to depict which dbus properties are implemented for a FRU, and what IPMI FRU properties those dbus properties map to. This commit defines a YAML file which helps figure out the supported dbus inteface/properties for a FRU, and what the corresponding IPMI FRU properties are. Change-Id: I26de1aa26e3a74fd8cc95bb0d479d9b036eb5683 Signed-off-by: Ratan Gupta --- fru-types.yaml | 85 ++++++++++ gen_ipmi_fru.pl | 69 ++++++-- inventory-gen.yaml | 450 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 594 insertions(+), 10 deletions(-) create mode 100644 fru-types.yaml create mode 100644 inventory-gen.yaml diff --git a/fru-types.yaml b/fru-types.yaml new file mode 100644 index 0000000..bba9fe6 --- /dev/null +++ b/fru-types.yaml @@ -0,0 +1,85 @@ +PROC: + xyz.openbmc_project.Inventory.Decorator.Asset: + BuildDate: + IPMIFruSection: Board + IPMIFruProperty: "Mfg Date" + Manufacturer: + IPMIFruSection: Board + IPMIFruProperty: "Manufacturer" + PartNumber: + IPMIFruSection: Board + IPMIFruProperty: "Part Number" + SerialNumber: + IPMIFruSection: Board + IPMIFruProperty: "Serial Number" + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFruSection: Board + IPMIFruProperty: "Product Name" + +CORE: + +SYS: + xyz.openbmc_project.Inventory.Decorator.Asset: + BuildDate: + IPMIFruSection: Product + IPMIFruProperty: "Mfg Date" + Manufacturer: + IPMIFruSection: Product + IPMIFruProperty: "Manufacturer" + PartNumber: + IPMIFruSection: Product + IPMIFruProperty: "Part Number" + SerialNumber: + IPMIFruSection: Product + IPMIFruProperty: "Serial Number" + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFruSection: Product + IPMIFruProperty: "Product Name" + xyz.openbmc_project.Inventory.Revision: + Version: + IPMIFruSection: Product + IPMIFruProperty: "Version" + +DIMM: + xyz.openbmc_project.Inventory.Decorator.Asset: + BuildDate: + IPMIFruSection: Product + IPMIFruProperty: "Mfg Date" + Manufacturer: + IPMIFruSection: Product + IPMIFruProperty: "Manufacturer" + PartNumber: + IPMIFruSection: Product + IPMIFruProperty: "Part Number" + SerialNumber: + IPMIFruSection: Product + IPMIFruProperty: "Serial Number" + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFruSection: Product + IPMIFruProperty: "Product Name" + xyz.openbmc_project.Inventory.Revision: + Version: + IPMIFruSection: Product + IPMIFruProperty: "Version" + +MEMBUFF: + xyz.openbmc_project.Inventory.Decorator.Asset: + BuildDate: + IPMIFruSection: Board + IPMIFruProperty: "Mfg Date" + Manufacturer: + IPMIFruSection: Board + IPMIFruProperty: "Manufacturer" + PartNumber: + IPMIFruSection: Board + IPMIFruProperty: "Part Number" + SerialNumber: + IPMIFruSection: Board + IPMIFruProperty: "Serial Number" + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFruSection: Board + IPMIFruProperty: "Product Name" diff --git a/gen_ipmi_fru.pl b/gen_ipmi_fru.pl index 34b19ee..760082f 100755 --- a/gen_ipmi_fru.pl +++ b/gen_ipmi_fru.pl @@ -10,15 +10,19 @@ use YAML::XS 'LoadFile'; # For loading and reading of YAML file # Globals my $serverwizFile = ""; my $debug = 0; +my $outputFile = ""; +my $metaDataFile = ""; # Command line argument parsing GetOptions( "i=s" => \$serverwizFile, # string +"m=s" => \$metaDataFile, # string +"o=s" => \$outputFile, # string "d" => \$debug, ) or printUsage(); -if (($serverwizFile eq "")) +if (($serverwizFile eq "") or ($outputFile eq "") or ($metaDataFile eq "")) { printUsage(); } @@ -26,37 +30,82 @@ if (($serverwizFile eq "")) my $targetObj = Targets->new; $targetObj->loadXML($serverwizFile); -#open the mrw xml Fetch the FRU id,type,object path from the mrw. +#open the mrw xml and the metaData file for the fru. +#Fetch the FRU id,type,object path from the mrw. +#Get the metadata for that fru from the metadata file. +#Merge the data into the outputfile + +open(my $fh, '>', $outputFile) or die "Could not open file '$outputFile' $!"; +my $fruTypeConfig = LoadFile($metaDataFile); + +my @interestedTypes = keys %{$fruTypeConfig}; +my %types; +@types{@interestedTypes} = (); my @inventory = Inventory::getInventory($targetObj); for my $item (@inventory) { my $isFru = 0, my $fruID = 0, my $fruType = ""; - my $isChildFru = 0; - - #Fetch the fruid. + #Fetch the FRU ID. if (!$targetObj->isBadAttribute($item->{TARGET}, "FRU_ID")) { $fruID = $targetObj->getAttribute($item->{TARGET}, "FRU_ID"); $isFru = 1; } - - #Fech the fru type. + # Fetch the FRU Type. if (!$targetObj->isBadAttribute($item->{TARGET}, "TYPE")) { $fruType = $targetObj->getAttribute($item->{TARGET}, "TYPE"); } - #skip those entries whose type is NA and is not fru. - next if ( $fruType eq 'NA' or not($isFru) or $fruType eq 'BMC'); + #Skip if we're not interested + next if (not $isFru or not exists $types{$fruType}); printDebug ("FRUID => $fruID, FRUType => $fruType, ObjectPath => $item->{OBMC_NAME}"); + print $fh $fruID.":"; + print $fh "\n"; + + writeToFile($fruType,$item->{OBMC_NAME},$fruTypeConfig,$fh); + } +close $fh; + #------------------------------------END OF MAIN----------------------- +#Get the metdata for the incoming frutype from the loaded config file. +#Write the FRU data into the output file + +sub writeToFile +{ + my $fruType = $_[0];#fru type + my $instancePath = $_[1];#instance Path + my $fruTypeConfig = $_[2];#loaded config file (frutypes) + my $fh = $_[3];#file Handle + #walk over all the fru types and match for the incoming type + print $fh " ".$instancePath.":"; + print $fh "\n"; + my $interfaces = $fruTypeConfig->{$fruType}; + #Walk over all the interfaces as it needs to be written + while ( my ($interface,$properties) = each %{$interfaces}) { + print $fh " ".$interface.":"; + print $fh "\n"; + #walk over all the properties as it needs to be written + while ( my ($dbusProperty,$metadata) = each %{$properties}) { + #will write property named "Property" first then + #other properties. + print $fh " ".$dbusProperty.":"; + print $fh "\n"; + for my $key (sort keys %{$metadata}) { + print $fh " $key: "."$metadata->{$key}"; + print $fh "\n"; + } + } + } +} + # Usage sub printUsage { print " - $0 -i [MRW filename] [OPTIONS] + $0 -i [MRW filename] -m [MetaData filename] -o [Output filename] [OPTIONS] Options: -d = debug mode \n"; diff --git a/inventory-gen.yaml b/inventory-gen.yaml new file mode 100644 index 0000000..c1ddb40 --- /dev/null +++ b/inventory-gen.yaml @@ -0,0 +1,450 @@ +0: + /system: + xyz.openbmc_project.Inventory.Decorator.Asset: + Manufacturer: + IPMIFRUProperty: Manufacturer + IPMIFruSection: Product + BuildDate: + IPMIFRUProperty: Mfg Date + IPMIFruSection: Product + SerialNumber: + IPMIFRUProperty: Serial Number + IPMIFruSection: Product + PartNumber: + IPMIFRUProperty: Part Number + IPMIFruSection: Product + xyz.openbmc_project.Inventory.Revision: + Version: + IPMIFRUProperty: Version + IPMIFruSection: Product + xyz.openbmc_project.Inventory.Item: + Present: + PrettyName: + IPMIFRUProperty: Product Name + IPMIFruSection: Product +0: + /system/chassis: +0: + /system/chassis/motherboard/dimm0: + xyz.openbmc_project.Inventory.Decorator.Asset: + PartNumber: + IPMIFRUProperty: Part Number + IPMIFruSection: Product + SerialNumber: + IPMIFRUProperty: Serial Number + IPMIFruSection: Product + Manufacturer: + IPMIFRUProperty: Manufacturer + IPMIFruSection: Product + BuildDate: + IPMIFRUProperty: Mfg Date + IPMIFruSection: Product + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFRUProperty: Product Name + IPMIFruSection: Product + Present: + xyz.openbmc_project.Inventory.Revision: + Version: + IPMIFRUProperty: Version + IPMIFruSection: Product +0: + /system/chassis/motherboard/dimm1: + xyz.openbmc_project.Inventory.Decorator.Asset: + PartNumber: + IPMIFRUProperty: Part Number + IPMIFruSection: Product + SerialNumber: + IPMIFRUProperty: Serial Number + IPMIFruSection: Product + Manufacturer: + IPMIFRUProperty: Manufacturer + IPMIFruSection: Product + BuildDate: + IPMIFRUProperty: Mfg Date + IPMIFruSection: Product + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFRUProperty: Product Name + IPMIFruSection: Product + Present: + xyz.openbmc_project.Inventory.Revision: + Version: + IPMIFRUProperty: Version + IPMIFruSection: Product +0: + /system/chassis/motherboard/dimm10: + xyz.openbmc_project.Inventory.Decorator.Asset: + PartNumber: + IPMIFRUProperty: Part Number + IPMIFruSection: Product + SerialNumber: + IPMIFRUProperty: Serial Number + IPMIFruSection: Product + Manufacturer: + IPMIFRUProperty: Manufacturer + IPMIFruSection: Product + BuildDate: + IPMIFRUProperty: Mfg Date + IPMIFruSection: Product + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFRUProperty: Product Name + IPMIFruSection: Product + Present: + xyz.openbmc_project.Inventory.Revision: + Version: + IPMIFRUProperty: Version + IPMIFruSection: Product +0: + /system/chassis/motherboard/dimm11: + xyz.openbmc_project.Inventory.Decorator.Asset: + PartNumber: + IPMIFRUProperty: Part Number + IPMIFruSection: Product + SerialNumber: + IPMIFRUProperty: Serial Number + IPMIFruSection: Product + Manufacturer: + IPMIFRUProperty: Manufacturer + IPMIFruSection: Product + BuildDate: + IPMIFRUProperty: Mfg Date + IPMIFruSection: Product + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFRUProperty: Product Name + IPMIFruSection: Product + Present: + xyz.openbmc_project.Inventory.Revision: + Version: + IPMIFRUProperty: Version + IPMIFruSection: Product +0: + /system/chassis/motherboard/dimm12: + xyz.openbmc_project.Inventory.Decorator.Asset: + PartNumber: + IPMIFRUProperty: Part Number + IPMIFruSection: Product + SerialNumber: + IPMIFRUProperty: Serial Number + IPMIFruSection: Product + Manufacturer: + IPMIFRUProperty: Manufacturer + IPMIFruSection: Product + BuildDate: + IPMIFRUProperty: Mfg Date + IPMIFruSection: Product + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFRUProperty: Product Name + IPMIFruSection: Product + Present: + xyz.openbmc_project.Inventory.Revision: + Version: + IPMIFRUProperty: Version + IPMIFruSection: Product +0: + /system/chassis/motherboard/dimm13: + xyz.openbmc_project.Inventory.Decorator.Asset: + PartNumber: + IPMIFRUProperty: Part Number + IPMIFruSection: Product + SerialNumber: + IPMIFRUProperty: Serial Number + IPMIFruSection: Product + Manufacturer: + IPMIFRUProperty: Manufacturer + IPMIFruSection: Product + BuildDate: + IPMIFRUProperty: Mfg Date + IPMIFruSection: Product + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFRUProperty: Product Name + IPMIFruSection: Product + Present: + xyz.openbmc_project.Inventory.Revision: + Version: + IPMIFRUProperty: Version + IPMIFruSection: Product +0: + /system/chassis/motherboard/dimm14: + xyz.openbmc_project.Inventory.Decorator.Asset: + PartNumber: + IPMIFRUProperty: Part Number + IPMIFruSection: Product + SerialNumber: + IPMIFRUProperty: Serial Number + IPMIFruSection: Product + Manufacturer: + IPMIFRUProperty: Manufacturer + IPMIFruSection: Product + BuildDate: + IPMIFRUProperty: Mfg Date + IPMIFruSection: Product + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFRUProperty: Product Name + IPMIFruSection: Product + Present: + xyz.openbmc_project.Inventory.Revision: + Version: + IPMIFRUProperty: Version + IPMIFruSection: Product +0: + /system/chassis/motherboard/dimm15: + xyz.openbmc_project.Inventory.Decorator.Asset: + PartNumber: + IPMIFRUProperty: Part Number + IPMIFruSection: Product + SerialNumber: + IPMIFRUProperty: Serial Number + IPMIFruSection: Product + Manufacturer: + IPMIFRUProperty: Manufacturer + IPMIFruSection: Product + BuildDate: + IPMIFRUProperty: Mfg Date + IPMIFruSection: Product + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFRUProperty: Product Name + IPMIFruSection: Product + Present: + xyz.openbmc_project.Inventory.Revision: + Version: + IPMIFRUProperty: Version + IPMIFruSection: Product +0: + /system/chassis/motherboard/dimm2: + xyz.openbmc_project.Inventory.Decorator.Asset: + PartNumber: + IPMIFRUProperty: Part Number + IPMIFruSection: Product + SerialNumber: + IPMIFRUProperty: Serial Number + IPMIFruSection: Product + Manufacturer: + IPMIFRUProperty: Manufacturer + IPMIFruSection: Product + BuildDate: + IPMIFRUProperty: Mfg Date + IPMIFruSection: Product + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFRUProperty: Product Name + IPMIFruSection: Product + Present: + xyz.openbmc_project.Inventory.Revision: + Version: + IPMIFRUProperty: Version + IPMIFruSection: Product +0: + /system/chassis/motherboard/dimm3: + xyz.openbmc_project.Inventory.Decorator.Asset: + PartNumber: + IPMIFRUProperty: Part Number + IPMIFruSection: Product + SerialNumber: + IPMIFRUProperty: Serial Number + IPMIFruSection: Product + Manufacturer: + IPMIFRUProperty: Manufacturer + IPMIFruSection: Product + BuildDate: + IPMIFRUProperty: Mfg Date + IPMIFruSection: Product + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFRUProperty: Product Name + IPMIFruSection: Product + Present: + xyz.openbmc_project.Inventory.Revision: + Version: + IPMIFRUProperty: Version + IPMIFruSection: Product +0: + /system/chassis/motherboard/dimm4: + xyz.openbmc_project.Inventory.Decorator.Asset: + PartNumber: + IPMIFRUProperty: Part Number + IPMIFruSection: Product + SerialNumber: + IPMIFRUProperty: Serial Number + IPMIFruSection: Product + Manufacturer: + IPMIFRUProperty: Manufacturer + IPMIFruSection: Product + BuildDate: + IPMIFRUProperty: Mfg Date + IPMIFruSection: Product + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFRUProperty: Product Name + IPMIFruSection: Product + Present: + xyz.openbmc_project.Inventory.Revision: + Version: + IPMIFRUProperty: Version + IPMIFruSection: Product +0: + /system/chassis/motherboard/dimm5: + xyz.openbmc_project.Inventory.Decorator.Asset: + PartNumber: + IPMIFRUProperty: Part Number + IPMIFruSection: Product + SerialNumber: + IPMIFRUProperty: Serial Number + IPMIFruSection: Product + Manufacturer: + IPMIFRUProperty: Manufacturer + IPMIFruSection: Product + BuildDate: + IPMIFRUProperty: Mfg Date + IPMIFruSection: Product + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFRUProperty: Product Name + IPMIFruSection: Product + Present: + xyz.openbmc_project.Inventory.Revision: + Version: + IPMIFRUProperty: Version + IPMIFruSection: Product +0: + /system/chassis/motherboard/dimm6: + xyz.openbmc_project.Inventory.Decorator.Asset: + PartNumber: + IPMIFRUProperty: Part Number + IPMIFruSection: Product + SerialNumber: + IPMIFRUProperty: Serial Number + IPMIFruSection: Product + Manufacturer: + IPMIFRUProperty: Manufacturer + IPMIFruSection: Product + BuildDate: + IPMIFRUProperty: Mfg Date + IPMIFruSection: Product + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFRUProperty: Product Name + IPMIFruSection: Product + Present: + xyz.openbmc_project.Inventory.Revision: + Version: + IPMIFRUProperty: Version + IPMIFruSection: Product +0: + /system/chassis/motherboard/dimm7: + xyz.openbmc_project.Inventory.Decorator.Asset: + PartNumber: + IPMIFRUProperty: Part Number + IPMIFruSection: Product + SerialNumber: + IPMIFRUProperty: Serial Number + IPMIFruSection: Product + Manufacturer: + IPMIFRUProperty: Manufacturer + IPMIFruSection: Product + BuildDate: + IPMIFRUProperty: Mfg Date + IPMIFruSection: Product + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFRUProperty: Product Name + IPMIFruSection: Product + Present: + xyz.openbmc_project.Inventory.Revision: + Version: + IPMIFRUProperty: Version + IPMIFruSection: Product +0: + /system/chassis/motherboard/dimm8: + xyz.openbmc_project.Inventory.Decorator.Asset: + PartNumber: + IPMIFRUProperty: Part Number + IPMIFruSection: Product + SerialNumber: + IPMIFRUProperty: Serial Number + IPMIFruSection: Product + Manufacturer: + IPMIFRUProperty: Manufacturer + IPMIFruSection: Product + BuildDate: + IPMIFRUProperty: Mfg Date + IPMIFruSection: Product + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFRUProperty: Product Name + IPMIFruSection: Product + Present: + xyz.openbmc_project.Inventory.Revision: + Version: + IPMIFRUProperty: Version + IPMIFruSection: Product +0: + /system/chassis/motherboard/dimm9: + xyz.openbmc_project.Inventory.Decorator.Asset: + PartNumber: + IPMIFRUProperty: Part Number + IPMIFruSection: Product + SerialNumber: + IPMIFRUProperty: Serial Number + IPMIFruSection: Product + Manufacturer: + IPMIFRUProperty: Manufacturer + IPMIFruSection: Product + BuildDate: + IPMIFRUProperty: Mfg Date + IPMIFruSection: Product + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFRUProperty: Product Name + IPMIFruSection: Product + Present: + xyz.openbmc_project.Inventory.Revision: + Version: + IPMIFRUProperty: Version + IPMIFruSection: Product +0: + /system/chassis/motherboard/cpu0: + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFRUProperty: Product Name + IPMIFruSection: Board + Present: + xyz.openbmc_project.Inventory.Decorator.Asset: + SerialNumber: + IPMIFRUProperty: Serial Number + IPMIFruSection: Board + PartNumber: + IPMIFRUProperty: Part Number + IPMIFruSection: Board + BuildDate: + IPMIFRUProperty: Mfg Date + IPMIFruSection: Board + Manufacturer: + IPMIFRUProperty: Manufacturer + IPMIFruSection: Board +0: + /system/chassis/motherboard/cpu1: + xyz.openbmc_project.Inventory.Item: + PrettyName: + IPMIFRUProperty: Product Name + IPMIFruSection: Board + Present: + xyz.openbmc_project.Inventory.Decorator.Asset: + SerialNumber: + IPMIFRUProperty: Serial Number + IPMIFruSection: Board + PartNumber: + IPMIFRUProperty: Part Number + IPMIFruSection: Board + BuildDate: + IPMIFRUProperty: Mfg Date + IPMIFruSection: Board + Manufacturer: + IPMIFRUProperty: Manufacturer + IPMIFruSection: Board -- cgit v1.2.1