mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-17 20:00:23 +00:00
update struct names and struct fiels
it wont be meaningful to call cephfs.NewcephfsDriver() to get a new driver, it will be better if we call cephfs.GetNewDriver() which returns the cephfs driver object. same goes for rbd also Signed-off-by: Madhu Rajanna <mrajanna@redhat.com>
This commit is contained in:
parent
15b5b0112e
commit
fa78c00535
@ -57,7 +57,7 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
driver := cephfs.NewCephFSDriver()
|
||||
driver := cephfs.NewDriver()
|
||||
driver.Run(*driverName, *nodeID, *endpoint, *volumeMounter, cp)
|
||||
|
||||
os.Exit(0)
|
||||
|
@ -30,8 +30,8 @@ const (
|
||||
Version = "1.0.0"
|
||||
)
|
||||
|
||||
type cephfsDriver struct {
|
||||
driver *csicommon.CSIDriver
|
||||
type driver struct {
|
||||
cd *csicommon.CSIDriver
|
||||
|
||||
is *identityServer
|
||||
ns *nodeServer
|
||||
@ -39,12 +39,12 @@ type cephfsDriver struct {
|
||||
}
|
||||
|
||||
var (
|
||||
driver *cephfsDriver
|
||||
cephDriver *driver
|
||||
DefaultVolumeMounter string
|
||||
)
|
||||
|
||||
func NewCephFSDriver() *cephfsDriver {
|
||||
return &cephfsDriver{}
|
||||
func NewDriver() *driver {
|
||||
return &driver{}
|
||||
}
|
||||
|
||||
func NewIdentityServer(d *csicommon.CSIDriver) *identityServer {
|
||||
@ -66,7 +66,7 @@ func NewNodeServer(d *csicommon.CSIDriver) *nodeServer {
|
||||
}
|
||||
}
|
||||
|
||||
func (fs *cephfsDriver) Run(driverName, nodeId, endpoint, volumeMounter string, cachePersister util.CachePersister) {
|
||||
func (fs *driver) Run(driverName, nodeId, endpoint, volumeMounter string, cachePersister util.CachePersister) {
|
||||
glog.Infof("Driver: %v version: %v", driverName, Version)
|
||||
|
||||
// Configuration
|
||||
@ -92,25 +92,25 @@ func (fs *cephfsDriver) Run(driverName, nodeId, endpoint, volumeMounter string,
|
||||
|
||||
// Initialize default library driver
|
||||
|
||||
fs.driver = csicommon.NewCSIDriver(driverName, Version, nodeId)
|
||||
if fs.driver == nil {
|
||||
fs.cd = csicommon.NewCSIDriver(driverName, Version, nodeId)
|
||||
if fs.cd == nil {
|
||||
glog.Fatalln("Failed to initialize CSI driver")
|
||||
}
|
||||
|
||||
fs.driver.AddControllerServiceCapabilities([]csi.ControllerServiceCapability_RPC_Type{
|
||||
fs.cd.AddControllerServiceCapabilities([]csi.ControllerServiceCapability_RPC_Type{
|
||||
csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME,
|
||||
})
|
||||
|
||||
fs.driver.AddVolumeCapabilityAccessModes([]csi.VolumeCapability_AccessMode_Mode{
|
||||
fs.cd.AddVolumeCapabilityAccessModes([]csi.VolumeCapability_AccessMode_Mode{
|
||||
csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER,
|
||||
})
|
||||
|
||||
// Create gRPC servers
|
||||
|
||||
fs.is = NewIdentityServer(fs.driver)
|
||||
fs.ns = NewNodeServer(fs.driver)
|
||||
fs.is = NewIdentityServer(fs.cd)
|
||||
fs.ns = NewNodeServer(fs.cd)
|
||||
|
||||
fs.cs = NewControllerServer(fs.driver, cachePersister)
|
||||
fs.cs = NewControllerServer(fs.cd, cachePersister)
|
||||
|
||||
server := csicommon.NewNonBlockingGRPCServer()
|
||||
server.Start(endpoint, fs.is, fs.cs, fs.ns)
|
||||
|
@ -35,8 +35,8 @@ const (
|
||||
rbdDefaultUserID = rbdDefaultAdminID
|
||||
)
|
||||
|
||||
type rbd struct {
|
||||
driver *csicommon.CSIDriver
|
||||
type driver struct {
|
||||
cd *csicommon.CSIDriver
|
||||
|
||||
ids *identityServer
|
||||
ns *nodeServer
|
||||
@ -47,8 +47,8 @@ var (
|
||||
version = "1.0.0"
|
||||
)
|
||||
|
||||
func GetRBDDriver() *rbd {
|
||||
return &rbd{}
|
||||
func GetDriver() *driver {
|
||||
return &driver{}
|
||||
}
|
||||
|
||||
func NewIdentityServer(d *csicommon.CSIDriver) *identityServer {
|
||||
@ -79,34 +79,34 @@ func NewNodeServer(d *csicommon.CSIDriver, containerized bool) (*nodeServer, err
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (rbd *rbd) Run(driverName, nodeID, endpoint string, containerized bool, cachePersister util.CachePersister) {
|
||||
func (r *driver) Run(driverName, nodeID, endpoint string, containerized bool, cachePersister util.CachePersister) {
|
||||
var err error
|
||||
glog.Infof("Driver: %v version: %v", driverName, version)
|
||||
|
||||
// Initialize default library driver
|
||||
rbd.driver = csicommon.NewCSIDriver(driverName, version, nodeID)
|
||||
if rbd.driver == nil {
|
||||
r.cd = csicommon.NewCSIDriver(driverName, version, nodeID)
|
||||
if r.cd == nil {
|
||||
glog.Fatalln("Failed to initialize CSI Driver.")
|
||||
}
|
||||
rbd.driver.AddControllerServiceCapabilities([]csi.ControllerServiceCapability_RPC_Type{
|
||||
r.cd.AddControllerServiceCapabilities([]csi.ControllerServiceCapability_RPC_Type{
|
||||
csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME,
|
||||
csi.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME,
|
||||
csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT,
|
||||
csi.ControllerServiceCapability_RPC_LIST_SNAPSHOTS,
|
||||
})
|
||||
rbd.driver.AddVolumeCapabilityAccessModes([]csi.VolumeCapability_AccessMode_Mode{csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER})
|
||||
r.cd.AddVolumeCapabilityAccessModes([]csi.VolumeCapability_AccessMode_Mode{csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER})
|
||||
|
||||
// Create GRPC servers
|
||||
rbd.ids = NewIdentityServer(rbd.driver)
|
||||
rbd.ns, err = NewNodeServer(rbd.driver, containerized)
|
||||
r.ids = NewIdentityServer(r.cd)
|
||||
r.ns, err = NewNodeServer(r.cd, containerized)
|
||||
if err != nil {
|
||||
glog.Fatalf("failed to start node server, err %v\n", err)
|
||||
}
|
||||
|
||||
rbd.cs = NewControllerServer(rbd.driver, cachePersister)
|
||||
rbd.cs.LoadExDataFromMetadataStore()
|
||||
r.cs = NewControllerServer(r.cd, cachePersister)
|
||||
r.cs.LoadExDataFromMetadataStore()
|
||||
|
||||
s := csicommon.NewNonBlockingGRPCServer()
|
||||
s.Start(endpoint, rbd.ids, rbd.cs, rbd.ns)
|
||||
s.Start(endpoint, r.ids, r.cs, r.ns)
|
||||
s.Wait()
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
driver := rbd.GetRBDDriver()
|
||||
driver := rbd.GetDriver()
|
||||
driver.Run(*driverName, *nodeID, *endpoint, *containerized, cp)
|
||||
|
||||
os.Exit(0)
|
||||
|
Loading…
Reference in New Issue
Block a user