Skip to content

Commit

Permalink
migrate ipmi provider
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Milchev <[email protected]>
  • Loading branch information
imilchev committed Feb 12, 2024
1 parent 895dfdd commit 9f929c7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
14 changes: 11 additions & 3 deletions providers/ipmi/connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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" {
Expand Down Expand Up @@ -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
}
Expand Down
19 changes: 9 additions & 10 deletions providers/ipmi/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9f929c7

Please sign in to comment.