feat: Inventory PhysicalHost persistence with sqlx and local sqlite db #125

Merged
letian merged 4 commits from feat/inventory_persistence into master 2025-08-31 22:49:29 +00:00
Owner
No description provided.
johnride force-pushed feat/inventory_persistence from fa4332afe1 to 35fe324f5e 2025-08-30 20:35:36 +00:00 Compare
johnride force-pushed feat/inventory_persistence from 35fe324f5e to cb4382fbb5 2025-08-30 20:49:04 +00:00 Compare
letian reviewed 2025-08-31 15:12:22 +00:00
@ -0,0 +21,4 @@
#[async_trait]
pub trait InventoryRepository: Send + Sync + 'static {
async fn save(&self, host: &PhysicalHost) -> Result<(), RepoError>;
async fn get_latest_by_id(&self, host_id: &str) -> Result<Option<PhysicalHost>, RepoError>;
Owner

should we use the Id type instead of a str here?

should we use the `Id` type instead of a str here?
letian reviewed 2025-08-31 15:26:28 +00:00
@ -0,0 +31,4 @@
#[async_trait]
impl InventoryRepository for SqliteInventoryRepository {
async fn save(&self, host: &PhysicalHost) -> Result<(), RepoError> {
let data = serde_json::to_vec(host).map_err(|e| RepoError::Serialization(e.to_string()))?;
Owner

Could this struct evolve in time and that at some point we update an existing physical host instead of just saving a new one every time?

Could this struct evolve in time and that at some point we update an existing physical host instead of just saving a new one every time?
letian reviewed 2025-08-31 15:26:36 +00:00
@ -0,0 +57,4 @@
)
.fetch_optional(&self.pool)
.await?;
todo!()
Owner

Do we still need this?

Do we still need this?
letian marked this conversation as resolved
letian added 3 commits 2025-08-31 22:45:59 +00:00
refact: Move basic types to harmony_types crate to avoid external dependencies.
All checks were successful
Run Check Script / check (pull_request) Successful in 1m15s
f9906cb419
This includes Id, IpAddress, Url and some other heavily used types
feat: automatically discover inventory (#127)
All checks were successful
Run Check Script / check (pull_request) Successful in 1m15s
701d8cfab9
## Fully automated inventory gathering now works!

Boot up harmony_inventory_agent with `cargo run -p harmony_inventory_agent`
Launch the DiscoverInventoryAgentScore , currently available this way :

`RUST_LOG=info cargo run -p example-cli -- -f Discover -y`

And you will have automatically all hosts saved to the database. Run `cargo sqlx setup` if you have not done it yet.

Co-authored-by: Ian Letourneau <ian@noma.to>
Reviewed-on: https://git.nationtech.io/NationTech/harmony/pulls/127
Co-authored-by: Jean-Gabriel Gill-Couture <jg@nationtech.io>
Co-committed-by: Jean-Gabriel Gill-Couture <jg@nationtech.io>
Reviewed-on: https://git.nationtech.io/NationTech/harmony/pulls/126
Reviewed-by: Ian Letourneau <ian@noma.to>
letian merged commit 62fa3c2b10 into master 2025-08-31 22:49:29 +00:00
letian deleted branch feat/inventory_persistence 2025-08-31 22:49:29 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: NationTech/harmony#125
No description provided.