From 9f929c72f72b25b9c133613c9a0b6c1ce01a3de2 Mon Sep 17 00:00:00 2001 From: Ivan Milchev Date: Mon, 12 Feb 2024 16:43:35 +0100 Subject: [PATCH] migrate ipmi provider Signed-off-by: Ivan Milchev --- providers/ipmi/connection/connection.go | 14 +++++++++++--- providers/ipmi/provider/provider.go | 19 +++++++++---------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/providers/ipmi/connection/connection.go b/providers/ipmi/connection/connection.go index 8d699ab57b..c41c57769d 100644 --- a/providers/ipmi/connection/connection.go +++ b/providers/ipmi/connection/connection.go @@ -13,9 +13,10 @@ import ( ) type IpmiConnection struct { - id uint32 - Conf *inventory.Config - asset *inventory.Asset + id uint32 + parentId *uint32 + Conf *inventory.Config + asset *inventory.Asset // custom connection fields client *impi_client.IpmiClient guid string @@ -27,6 +28,9 @@ func NewIpmiConnection(id uint32, asset *inventory.Asset, conf *inventory.Config id: id, asset: asset, } + if len(asset.Connections) > 0 && asset.Connections[0].ParentConnectionId > 0 { + conn.parentId = &asset.Connections[0].ParentConnectionId + } // initialize connection if conf == nil || conf.Type != "ipmi" { @@ -72,6 +76,10 @@ func (c *IpmiConnection) ID() uint32 { return c.id } +func (c *IpmiConnection) ParentID() *uint32 { + return c.parentId +} + func (c *IpmiConnection) Asset() *inventory.Asset { return c.asset } diff --git a/providers/ipmi/provider/provider.go b/providers/ipmi/provider/provider.go index 0bf0bd7b6a..fd7e759f7a 100644 --- a/providers/ipmi/provider/provider.go +++ b/providers/ipmi/provider/provider.go @@ -133,16 +133,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba } asset.Connections[0].Id = conn.ID() - return &plugin.Runtime{ - Connection: conn, - Callback: callback, - HasRecording: req.HasRecording, - CreateResource: resources.CreateResource, - NewResource: resources.NewResource, - GetData: resources.GetData, - SetData: resources.SetData, - Upstream: upstream, - }, nil + return plugin.NewRuntime( + conn, + callback, + req.HasRecording, + resources.CreateResource, + resources.NewResource, + resources.GetData, + resources.SetData, + upstream), nil }) if err != nil { return nil, err