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:
Madhu Rajanna 2019-01-17 11:48:18 +05:30
parent 15b5b0112e
commit fa78c00535
4 changed files with 29 additions and 29 deletions

View File

@ -57,7 +57,7 @@ func main() {
os.Exit(1) os.Exit(1)
} }
driver := cephfs.NewCephFSDriver() driver := cephfs.NewDriver()
driver.Run(*driverName, *nodeID, *endpoint, *volumeMounter, cp) driver.Run(*driverName, *nodeID, *endpoint, *volumeMounter, cp)
os.Exit(0) os.Exit(0)

View File

@ -30,8 +30,8 @@ const (
Version = "1.0.0" Version = "1.0.0"
) )
type cephfsDriver struct { type driver struct {
driver *csicommon.CSIDriver cd *csicommon.CSIDriver
is *identityServer is *identityServer
ns *nodeServer ns *nodeServer
@ -39,12 +39,12 @@ type cephfsDriver struct {
} }
var ( var (
driver *cephfsDriver cephDriver *driver
DefaultVolumeMounter string DefaultVolumeMounter string
) )
func NewCephFSDriver() *cephfsDriver { func NewDriver() *driver {
return &cephfsDriver{} return &driver{}
} }
func NewIdentityServer(d *csicommon.CSIDriver) *identityServer { 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) glog.Infof("Driver: %v version: %v", driverName, Version)
// Configuration // Configuration
@ -92,25 +92,25 @@ func (fs *cephfsDriver) Run(driverName, nodeId, endpoint, volumeMounter string,
// Initialize default library driver // Initialize default library driver
fs.driver = csicommon.NewCSIDriver(driverName, Version, nodeId) fs.cd = csicommon.NewCSIDriver(driverName, Version, nodeId)
if fs.driver == nil { if fs.cd == nil {
glog.Fatalln("Failed to initialize CSI driver") 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, 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, csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER,
}) })
// Create gRPC servers // Create gRPC servers
fs.is = NewIdentityServer(fs.driver) fs.is = NewIdentityServer(fs.cd)
fs.ns = NewNodeServer(fs.driver) fs.ns = NewNodeServer(fs.cd)
fs.cs = NewControllerServer(fs.driver, cachePersister) fs.cs = NewControllerServer(fs.cd, cachePersister)
server := csicommon.NewNonBlockingGRPCServer() server := csicommon.NewNonBlockingGRPCServer()
server.Start(endpoint, fs.is, fs.cs, fs.ns) server.Start(endpoint, fs.is, fs.cs, fs.ns)

View File

@ -35,8 +35,8 @@ const (
rbdDefaultUserID = rbdDefaultAdminID rbdDefaultUserID = rbdDefaultAdminID
) )
type rbd struct { type driver struct {
driver *csicommon.CSIDriver cd *csicommon.CSIDriver
ids *identityServer ids *identityServer
ns *nodeServer ns *nodeServer
@ -47,8 +47,8 @@ var (
version = "1.0.0" version = "1.0.0"
) )
func GetRBDDriver() *rbd { func GetDriver() *driver {
return &rbd{} return &driver{}
} }
func NewIdentityServer(d *csicommon.CSIDriver) *identityServer { func NewIdentityServer(d *csicommon.CSIDriver) *identityServer {
@ -79,34 +79,34 @@ func NewNodeServer(d *csicommon.CSIDriver, containerized bool) (*nodeServer, err
}, nil }, 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 var err error
glog.Infof("Driver: %v version: %v", driverName, version) glog.Infof("Driver: %v version: %v", driverName, version)
// Initialize default library driver // Initialize default library driver
rbd.driver = csicommon.NewCSIDriver(driverName, version, nodeID) r.cd = csicommon.NewCSIDriver(driverName, version, nodeID)
if rbd.driver == nil { if r.cd == nil {
glog.Fatalln("Failed to initialize CSI Driver.") 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_CREATE_DELETE_VOLUME,
csi.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME, csi.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME,
csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT, csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT,
csi.ControllerServiceCapability_RPC_LIST_SNAPSHOTS, 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 // Create GRPC servers
rbd.ids = NewIdentityServer(rbd.driver) r.ids = NewIdentityServer(r.cd)
rbd.ns, err = NewNodeServer(rbd.driver, containerized) r.ns, err = NewNodeServer(r.cd, containerized)
if err != nil { if err != nil {
glog.Fatalf("failed to start node server, err %v\n", err) glog.Fatalf("failed to start node server, err %v\n", err)
} }
rbd.cs = NewControllerServer(rbd.driver, cachePersister) r.cs = NewControllerServer(r.cd, cachePersister)
rbd.cs.LoadExDataFromMetadataStore() r.cs.LoadExDataFromMetadataStore()
s := csicommon.NewNonBlockingGRPCServer() s := csicommon.NewNonBlockingGRPCServer()
s.Start(endpoint, rbd.ids, rbd.cs, rbd.ns) s.Start(endpoint, r.ids, r.cs, r.ns)
s.Wait() s.Wait()
} }

View File

@ -56,7 +56,7 @@ func main() {
os.Exit(1) os.Exit(1)
} }
driver := rbd.GetRBDDriver() driver := rbd.GetDriver()
driver.Run(*driverName, *nodeID, *endpoint, *containerized, cp) driver.Run(*driverName, *nodeID, *endpoint, *containerized, cp)
os.Exit(0) os.Exit(0)