-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.go
More file actions
83 lines (68 loc) · 2.84 KB
/
node.go
File metadata and controls
83 lines (68 loc) · 2.84 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package main
import (
"context"
"github.com/container-storage-interface/spec/lib/go/csi"
"k8s.io/klog/v2"
"os"
)
type NodeServer struct {
csi.NodeServer
nfs *Nfs
}
// NodeStageVolume intro: create path on host and mount storage volume at this path
func (n *NodeServer) NodeStageVolume(ctx context.Context, request *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error) {
klog.Infof("NodeStageVolume: called with args %#v", request)
return &csi.NodeStageVolumeResponse{}, nil
}
func (n *NodeServer) NodeUnstageVolume(ctx context.Context, request *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error) {
klog.Infof("NodeUnstageVolume: called with args %#v", request)
return &csi.NodeUnstageVolumeResponse{}, nil
}
// NodePublishVolume mount the volume
func (n *NodeServer) NodePublishVolume(ctx context.Context, request *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
klog.Infof("NodePublishVolume: called with args %#v", request)
err := os.MkdirAll(request.TargetPath, 775)
klog.Infoln(err)
err = n.nfs.mount("/"+request.VolumeId, request.TargetPath)
return &csi.NodePublishVolumeResponse{}, err
}
func (n *NodeServer) NodeUnpublishVolume(ctx context.Context, request *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) {
klog.Infof("NodeUnpublishVolume: called with args %#v", request)
err := n.nfs.umount(request.TargetPath)
return &csi.NodeUnpublishVolumeResponse{}, err
}
func (n *NodeServer) NodeGetVolumeStats(ctx context.Context, request *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error) {
klog.Infof("NodeGetVolumeStats: called with args %#v", request)
return &csi.NodeGetVolumeStatsResponse{}, nil
}
func (n *NodeServer) NodeExpandVolume(ctx context.Context, request *csi.NodeExpandVolumeRequest) (*csi.NodeExpandVolumeResponse, error) {
klog.Infof("NodeExpandVolume: called with args %#v", request)
return &csi.NodeExpandVolumeResponse{}, nil
}
func (n *NodeServer) NodeGetCapabilities(ctx context.Context, request *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) {
klog.Infof("NodeGetCapabilities: called with args %#v", request)
return &csi.NodeGetCapabilitiesResponse{
Capabilities: []*csi.NodeServiceCapability{
//{
// Type: &csi.NodeServiceCapability_Rpc{
// Rpc: &csi.NodeServiceCapability_RPC{
// Type: csi.NodeServiceCapability_RPC_STAGE_UNSTAGE_VOLUME,
// },
// },
//},
{
Type: &csi.NodeServiceCapability_Rpc{
Rpc: &csi.NodeServiceCapability_RPC{
Type: csi.NodeServiceCapability_RPC_SINGLE_NODE_MULTI_WRITER,
},
},
},
},
}, nil
}
func (n *NodeServer) NodeGetInfo(ctx context.Context, request *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) {
klog.Infof("NodeGetInfo: called with args %#v", request)
return &csi.NodeGetInfoResponse{
NodeId: "1",
}, nil
}