-
Notifications
You must be signed in to change notification settings - Fork 139
/
manager.go
41 lines (32 loc) · 998 Bytes
/
manager.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
package csi
import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
longhornclient "github.com/longhorn/longhorn-manager/client"
)
type Manager struct {
ids *IdentityServer
ns *NodeServer
cs *ControllerServer
}
func init() {}
func GetCSIManager() *Manager {
return &Manager{}
}
func (m *Manager) Run(driverName, nodeID, endpoint, identityVersion, managerURL string) error {
logrus.Infof("CSI Driver: %v version: %v, manager URL %v", driverName, identityVersion, managerURL)
// Longhorn API Client
clientOpts := &longhornclient.ClientOpts{Url: managerURL}
apiClient, err := longhornclient.NewRancherClient(clientOpts)
if err != nil {
return errors.Wrap(err, "Failed to initialize Longhorn API client")
}
// Create GRPC servers
m.ids = NewIdentityServer(driverName, identityVersion)
m.ns = NewNodeServer(apiClient, nodeID)
m.cs = NewControllerServer(apiClient, nodeID)
s := NewNonBlockingGRPCServer()
s.Start(endpoint, m.ids, m.cs, m.ns)
s.Wait()
return nil
}