diff options
author | Ratan Gupta <ratagupt@in.ibm.com> | 2018-01-24 16:42:06 +0530 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2018-02-13 14:09:21 +0000 |
commit | 8b34b33ffa0c60e12284a190dd4d59fc695a4018 (patch) | |
tree | 64dae35a11a15e23088dd2698e26e74428116945 | |
parent | 98be5ace5bb25c52b1d833a6454a77c3bd2260be (diff) | |
download | phosphor-mrw-tools-8b34b33ffa0c60e12284a190dd4d59fc695a4018.tar.gz phosphor-mrw-tools-8b34b33ffa0c60e12284a190dd4d59fc695a4018.zip |
Add entityID and entityInstance in the generated YAML
EntityID will be given by the config yaml and unique
instance id would be generated for each entityID.
eg: if proc is having entityID is x and if there is
y instances of type x then this commit would generate
y unique id for type x.
Change-Id: Ie7d848d96a6f335999eb226a4267b347f0e4ab2b
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
-rw-r--r-- | gen_ipmi_fru.pl | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/gen_ipmi_fru.pl b/gen_ipmi_fru.pl index 16252bf..dab5e41 100644 --- a/gen_ipmi_fru.pl +++ b/gen_ipmi_fru.pl @@ -42,6 +42,8 @@ my @interestedTypes = keys %{$fruTypeConfig}; my %types; @types{@interestedTypes} = (); +my %entityInfoDict; + my @allAssoTypes = getAllAssociatedTypes($fruTypeConfig); my %allAssoTypesHash; @allAssoTypesHash{@allAssoTypes} = (); @@ -49,6 +51,8 @@ my %allAssoTypesHash; my @inventory = Inventory::getInventory($targetObj); for my $item (@inventory) { my $isFru = 0, my $fruID = 0, my $fruType = ""; + my $entityInstance = 1, my $entityID = 0; + #Fetch the FRUID. if (!$targetObj->isBadAttribute($item->{TARGET}, "FRU_ID")) { $fruID = $targetObj->getAttribute($item->{TARGET}, "FRU_ID"); @@ -71,6 +75,16 @@ for my $item (@inventory) { print $fh $fruID.":"; print $fh "\n"; + $entityID = $fruTypeConfig->{$fruType}->{'EntityID'}; + + if (exists $entityInfoDict{$entityID}) { + $entityInstance = $entityInfoDict{$entityID} + 1; + } + + printDebug("entityID => $entityID , entityInstance => $entityInstance"); + + $entityInfoDict{$entityID} = $entityInstance; + writeToFile($fruType,$item->{OBMC_NAME},$fruTypeConfig,$fh); #if the key(AssociatedTypes) exists and it is defined @@ -121,21 +135,31 @@ sub writeToFile 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"; + print $fh " "."entityID: ".$fruTypeConfig->{$fruType}->{'EntityID'}; + print $fh "\n"; + print $fh " "."entityInstance: "; + print $fh $entityInfoDict{$fruTypeConfig->{$fruType}->{'EntityID'}}; + print $fh "\n"; + print $fh " "."interfaces:"; + print $fh "\n"; + my $interfaces = $fruTypeConfig->{$fruType}->{'Interfaces'}; + #Walk over all the interfaces as it needs to be written while ( my ($interface,$properties) = each %{$interfaces}) { - print $fh " ".$interface.":"; + 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 " ".$dbusProperty.":"; print $fh "\n"; for my $key (sort keys %{$metadata}) { - print $fh " $key: "."$metadata->{$key}"; + print $fh " $key: "."$metadata->{$key}"; print $fh "\n"; } } |