Rename UniqueDeviceName to UniqueVolumeName
Rename UniqueDeviceName to UniqueVolumeName and move helper functions from attacherdetacher to volumehelper package. Introduce UniquePodName alias
This commit is contained in:
@@ -50,10 +50,22 @@ func (plugin *rbdPlugin) Init(host volume.VolumeHost) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (plugin *rbdPlugin) Name() string {
|
||||
func (plugin *rbdPlugin) GetPluginName() string {
|
||||
return rbdPluginName
|
||||
}
|
||||
|
||||
func (plugin *rbdPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
|
||||
volumeSource, _ := getVolumeSource(spec)
|
||||
if volumeSource == nil {
|
||||
return "", fmt.Errorf("Spec does not reference a RBD volume type")
|
||||
}
|
||||
|
||||
return fmt.Sprintf(
|
||||
"%v:%v",
|
||||
volumeSource.CephMonitors,
|
||||
volumeSource.RBDImage), nil
|
||||
}
|
||||
|
||||
func (plugin *rbdPlugin) CanSupport(spec *volume.Spec) bool {
|
||||
if (spec.Volume != nil && spec.Volume.RBD == nil) || (spec.PersistentVolume != nil && spec.PersistentVolume.Spec.RBD == nil) {
|
||||
return false
|
||||
@@ -221,3 +233,18 @@ func (plugin *rbdPlugin) execCommand(command string, args []string) ([]byte, err
|
||||
cmd := plugin.exe.Command(command, args...)
|
||||
return cmd.CombinedOutput()
|
||||
}
|
||||
|
||||
func getVolumeSource(spec *volume.Spec) (*api.RBDVolumeSource, bool) {
|
||||
var readOnly bool
|
||||
var volumeSource *api.RBDVolumeSource
|
||||
|
||||
if spec.Volume != nil && spec.Volume.RBD != nil {
|
||||
volumeSource = spec.Volume.RBD
|
||||
readOnly = volumeSource.ReadOnly
|
||||
} else {
|
||||
volumeSource = spec.PersistentVolume.Spec.RBD
|
||||
readOnly = spec.ReadOnly
|
||||
}
|
||||
|
||||
return volumeSource, readOnly
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user