common: create initial associations
Associations to the inventory item were created during the update
process but not for the initial software version.
```
common/src/device.cpp
206: co_await softwarePending->createInventoryAssociations(true);
212: co_await softwarePending->createInventoryAssociations(false);
```
Fix this in the common code.
Also reorder the calls there so the interfaces added signal gets emitted
with the correct property value.
Tested: on Tyan S8030. Association appears as expected.
Re-Tested for Patchset 3, same result.
```
Jul 23 12:19:08 s8030-bmc-30303035c0c1 phosphor-bios-software-update[32158]: [Software] enabling update of /xyz/openbmc_project/software/HostSPIFlash_3216 (adding the update interface)
Jul 23 12:19:08 s8030-bmc-30303035c0c1 phosphor-bios-software-update[32158]: HostSPIFlash_3216: set version Unknown
Jul 23 12:19:08 s8030-bmc-30303035c0c1 phosphor-bios-software-update[32158]: HostSPIFlash_3216: setting association definitions
Jul 23 12:19:08 s8030-bmc-30303035c0c1 phosphor-bios-software-update[32158]: inventory item at path /xyz/openbmc_project/inventory/system/board/chassis
Jul 23 12:19:08 s8030-bmc-30303035c0c1 phosphor-bios-software-update[32158]: found associated inventory item for HostSPIFlash: /xyz/openbmc_project/inventory/system/board/chassis
Jul 23 12:19:08 s8030-bmc-30303035c0c1 phosphor-bios-software-update[32158]: HostSPIFlash_3216: creating 'running' association to /xyz/openbmc_project/inventory/system/board/chassis
Jul 23 12:19:08 s8030-bmc-30303035c0c1 phosphor-bios-software-update[32158]: Done with initial configuration
```
```
busctl get-property xyz.openbmc_project.Software.BIOS /xyz/openbmc_project/software/HostSPIFlash_3216 xyz.openbmc_project.Association.Definitions Associations
a(sss) 1 "running" "ran_on" "/xyz/openbmc_project/inventory/system/board/chassis"
```
The signal is emitted correctly for object mapper as well
```
object path "/xyz/openbmc_project/software/HostSPIFlash_3216"
array [
dict entry(
string "xyz.openbmc_project.Association.Definitions"
array [
dict entry(
string "Associations"
variant array [
struct {
string "running"
string "ran_on"
string "/xyz/openbmc_project/inventory/system/board/chassis"
}
]
)
]
)
]
```
Change-Id: Ie3d76d3bdf445a53c578c3a827b90950fa4bda0a
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/common/src/software.cpp b/common/src/software.cpp
index 3a02763..339275a 100644
--- a/common/src/software.cpp
+++ b/common/src/software.cpp
@@ -63,16 +63,8 @@
}
catch (std::exception& e)
{
- error(e.what());
- }
-
- if (!associationDefinitions)
- {
- std::string path = objectPath;
- associationDefinitions =
- std::make_unique<SoftwareAssociationDefinitions>(
- ctx, path.c_str(),
- SoftwareAssociationDefinitions::properties_t{{}});
+ error("Failed to create association with {ERROR}", "ERROR", e.what());
+ co_return;
}
if (endpoint.empty())
@@ -99,7 +91,19 @@
assocs.push_back(assocActivating);
}
- associationDefinitions->associations(assocs);
+ if (associationDefinitions)
+ {
+ associationDefinitions->associations(assocs);
+ }
+ else
+ {
+ std::string path = objectPath;
+ associationDefinitions =
+ std::make_unique<SoftwareAssociationDefinitions>(
+ ctx, path.c_str(),
+ SoftwareAssociationDefinitions::properties_t{assocs});
+ associationDefinitions->emit_added();
+ }
co_return;
}
diff --git a/common/src/software_manager.cpp b/common/src/software_manager.cpp
index 1ff7c31..6c971e8 100644
--- a/common/src/software_manager.cpp
+++ b/common/src/software_manager.cpp
@@ -163,14 +163,26 @@
co_return;
}
- if (devices.contains(optConfig.value().objectPath))
+ auto& config = optConfig.value();
+
+ if (devices.contains(config.objectPath))
{
error("Device configured from {PATH} is already known", "PATH",
- optConfig.value().objectPath);
+ config.objectPath);
co_return;
}
- co_await initDevice(service, path, optConfig.value());
+ const bool accepted = co_await initDevice(service, path, config);
+
+ if (accepted && devices.contains(config.objectPath))
+ {
+ auto& device = devices[config.objectPath];
+
+ if (device->softwareCurrent)
+ {
+ co_await device->softwareCurrent->createInventoryAssociations(true);
+ }
+ }
co_return;
}