-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
50 lines (40 loc) · 1.1 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"encoding/json"
"fmt"
"github.com/bm-metamorph/MetaMorph/pkg/db/models/node"
"github.com/hashicorp/go-plugin"
"github.com/manojkva/go-redfish-plugin/common"
"github.com/manojkva/go-redfish-plugin/pkg/drivers/redfish"
"os"
)
func main() {
//<TBD> check if stdout need to be restrained..
//fmt.Printf("%v\n", os.Args[1])
//fmt.Printf("%v\n", len(os.Args))
if len(os.Args) != 2 {
fmt.Println("Usage go-redfish-plugin <uuid>")
os.Exit(1)
}
uuid := os.Args[1]
//fmt.Printf("uuid %v\n", uuid)
var bmhnode redfish.BMHNode
old := os.Stdout
os.Stdout,_ = os.Open(os.DevNull)
data, err := node.Describe(uuid)
if err == nil {
err = json.Unmarshal(data, &bmhnode)
}
if err != nil {
fmt.Printf("Failed to locate node in DB for uuid %v\n", uuid)
os.Exit(1)
}
os.Stdout = old
//Get node details from db
plugin.Serve(&plugin.ServeConfig{
HandshakeConfig: common.Handshake,
Plugins: map[string]plugin.Plugin{
// "redfish": &common.RedfishPlugin{Impl: &redfish.BMHNode{}}},
"redfish": &common.RedfishPlugin{Impl: &bmhnode}},
GRPCServer: plugin.DefaultGRPCServer})
}