2018-01-09 13:57:14 -05:00
|
|
|
/*
|
|
|
|
Copyright 2017 The Kubernetes Authors.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package csicommon
|
|
|
|
|
|
|
|
import (
|
2019-08-24 14:44:15 +05:30
|
|
|
"context"
|
|
|
|
|
2021-08-24 17:03:25 +02:00
|
|
|
"github.com/ceph/ceph-csi/internal/util/log"
|
2019-08-22 13:19:06 -04:00
|
|
|
|
2018-11-26 13:23:56 -05:00
|
|
|
"github.com/container-storage-interface/spec/lib/go/csi"
|
2018-01-09 13:57:14 -05:00
|
|
|
"google.golang.org/grpc/codes"
|
|
|
|
"google.golang.org/grpc/status"
|
|
|
|
)
|
|
|
|
|
2020-07-19 17:51:03 +05:30
|
|
|
// DefaultControllerServer points to default driver.
|
2018-01-09 13:57:14 -05:00
|
|
|
type DefaultControllerServer struct {
|
2023-10-19 09:41:17 +02:00
|
|
|
csi.UnimplementedControllerServer
|
2024-02-14 14:02:31 +01:00
|
|
|
csi.UnimplementedGroupControllerServer
|
2023-10-19 09:53:34 +02:00
|
|
|
Driver *CSIDriver
|
2018-01-09 13:57:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// ControllerGetCapabilities implements the default GRPC callout.
|
2020-07-19 17:51:03 +05:30
|
|
|
// Default supports all capabilities.
|
2021-06-25 16:50:31 +05:30
|
|
|
func (cs *DefaultControllerServer) ControllerGetCapabilities(
|
|
|
|
ctx context.Context,
|
2022-06-01 15:47:19 +05:30
|
|
|
req *csi.ControllerGetCapabilitiesRequest,
|
|
|
|
) (*csi.ControllerGetCapabilitiesResponse, error) {
|
2021-08-24 17:03:25 +02:00
|
|
|
log.TraceLog(ctx, "Using default ControllerGetCapabilities")
|
2021-04-09 10:59:04 +05:30
|
|
|
if cs.Driver == nil {
|
|
|
|
return nil, status.Error(codes.Unimplemented, "Controller server is not enabled")
|
|
|
|
}
|
2021-07-22 11:15:17 +05:30
|
|
|
|
2018-01-09 13:57:14 -05:00
|
|
|
return &csi.ControllerGetCapabilitiesResponse{
|
2020-10-21 13:02:19 +05:30
|
|
|
Capabilities: cs.Driver.capabilities,
|
2018-01-09 13:57:14 -05:00
|
|
|
}, nil
|
|
|
|
}
|
2024-02-05 09:35:04 +01:00
|
|
|
|
|
|
|
// GroupControllerGetCapabilities implements the default
|
|
|
|
// GroupControllerGetCapabilities GRPC callout.
|
|
|
|
func (cs *DefaultControllerServer) GroupControllerGetCapabilities(
|
|
|
|
ctx context.Context,
|
|
|
|
req *csi.GroupControllerGetCapabilitiesRequest,
|
|
|
|
) (*csi.GroupControllerGetCapabilitiesResponse, error) {
|
|
|
|
log.TraceLog(ctx, "Using default GroupControllerGetCapabilities")
|
|
|
|
if cs.Driver == nil {
|
|
|
|
return nil, status.Error(codes.Unimplemented, "Group controller server is not enabled")
|
|
|
|
}
|
|
|
|
|
|
|
|
return &csi.GroupControllerGetCapabilitiesResponse{
|
|
|
|
Capabilities: cs.Driver.groupCapabilities,
|
|
|
|
}, nil
|
|
|
|
}
|