ScaleIO - API source code update

This commit tracks all human-generated code for API source updates.
This commit is contained in:
Vladimir Vivien
2017-10-13 22:57:37 -04:00
parent 7b588817ca
commit 3fb3cc7122
14 changed files with 455 additions and 154 deletions

View File

@@ -60,12 +60,11 @@ func (p *sioPlugin) GetPluginName() string {
}
func (p *sioPlugin) GetVolumeName(spec *volume.Spec) (string, error) {
source, err := getVolumeSourceFromSpec(spec)
attribs, err := getVolumeSourceAttribs(spec)
if err != nil {
return "", err
}
return source.VolumeName, nil
return attribs.volName, nil
}
func (p *sioPlugin) CanSupport(spec *volume.Spec) bool {
@@ -81,29 +80,33 @@ func (p *sioPlugin) NewMounter(
spec *volume.Spec,
pod *api.Pod,
_ volume.VolumeOptions) (volume.Mounter, error) {
sioSource, err := getVolumeSourceFromSpec(spec)
// extract source info from either ScaleIOVolumeSource or ScaleIOPersistentVolumeSource type
attribs, err := getVolumeSourceAttribs(spec)
if err != nil {
glog.Error(log("failed to extract ScaleIOVolumeSource from spec: %v", err))
return nil, err
return nil, errors.New(log("mounter failed to extract volume attributes from spec: %v", err))
}
secretName, secretNS, err := getSecretAndNamespaceFromSpec(spec, pod)
if err != nil {
return nil, errors.New(log("failed to get secret name or secretNamespace: %v", err))
}
return &sioVolume{
pod: pod,
spec: spec,
source: sioSource,
namespace: pod.Namespace,
volSpecName: spec.Name(),
volName: sioSource.VolumeName,
podUID: pod.UID,
readOnly: sioSource.ReadOnly,
fsType: sioSource.FSType,
plugin: p,
pod: pod,
spec: spec,
secretName: secretName,
secretNamespace: secretNS,
volSpecName: spec.Name(),
volName: attribs.volName,
podUID: pod.UID,
readOnly: attribs.readOnly,
fsType: attribs.fsType,
plugin: p,
}, nil
}
// NewUnmounter creates a representation of the volume to unmount
// The specName param can be used to carry the namespace value (if needed) using format:
// specName = [<namespace>nsSep]<somevalue> where the specname is pre-pended with the namespace
func (p *sioPlugin) NewUnmounter(specName string, podUID types.UID) (volume.Unmounter, error) {
glog.V(4).Info(log("Unmounter for %s", specName))
@@ -156,22 +159,25 @@ func (p *sioPlugin) GetAccessModes() []api.PersistentVolumeAccessMode {
var _ volume.DeletableVolumePlugin = &sioPlugin{}
func (p *sioPlugin) NewDeleter(spec *volume.Spec) (volume.Deleter, error) {
sioSource, err := getVolumeSourceFromSpec(spec)
attribs, err := getVolumeSourceAttribs(spec)
if err != nil {
glog.Error(log("deleter failed to extract source from spec: %v", err))
glog.Error(log("deleter failed to extract volume attributes from spec: %v", err))
return nil, err
}
namespace := spec.PersistentVolume.Spec.ClaimRef.Namespace
secretName, secretNS, err := getSecretAndNamespaceFromSpec(spec, nil)
if err != nil {
return nil, errors.New(log("failed to get secret name or secretNamespace: %v", err))
}
return &sioVolume{
spec: spec,
source: sioSource,
namespace: namespace,
volSpecName: spec.Name(),
volName: sioSource.VolumeName,
plugin: p,
readOnly: sioSource.ReadOnly,
spec: spec,
secretName: secretName,
secretNamespace: secretNS,
volSpecName: spec.Name(),
volName: attribs.volName,
plugin: p,
readOnly: attribs.readOnly,
}, nil
}
@@ -189,13 +195,26 @@ func (p *sioPlugin) NewProvisioner(options volume.VolumeOptions) (volume.Provisi
return nil, errors.New("option parameters missing")
}
namespace := options.PVC.Namespace
// Supports ref of name of secret a couple of ways:
// options.Parameters["secretRef"] for backward compat, or
// options.Parameters["secretName"]
secretName := configData[confKey.secretName]
if secretName == "" {
secretName = configData["secretName"]
configData[confKey.secretName] = secretName
}
secretNS := configData[confKey.secretNamespace]
if secretNS == "" {
secretNS = options.PVC.Namespace
}
return &sioVolume{
configData: configData,
plugin: p,
options: options,
namespace: namespace,
volSpecName: options.PVName,
configData: configData,
plugin: p,
options: options,
secretName: secretName,
secretNamespace: secretNS,
volSpecName: options.PVName,
}, nil
}