Cinder Volume Plugin

This commit is contained in:
Sreekanth Pothanis
2015-04-10 09:54:01 -07:00
parent a078eba5b3
commit f5da6b34ce
26 changed files with 1318 additions and 8 deletions

View File

@@ -375,6 +375,10 @@ func validateSource(source *api.VolumeSource) errs.ValidationErrorList {
numVolumes++
allErrs = append(allErrs, validateRBD(source.RBD).Prefix("rbd")...)
}
if source.Cinder != nil {
numVolumes++
allErrs = append(allErrs, validateCinderVolumeSource(source.Cinder).Prefix("cinder")...)
}
if numVolumes != 1 {
allErrs = append(allErrs, errs.NewFieldInvalid("", source, "exactly 1 volume type is required"))
}
@@ -498,6 +502,17 @@ func validateRBD(rbd *api.RBDVolumeSource) errs.ValidationErrorList {
return allErrs
}
func validateCinderVolumeSource(cd *api.CinderVolumeSource) errs.ValidationErrorList {
allErrs := errs.ValidationErrorList{}
if cd.VolumeID == "" {
allErrs = append(allErrs, errs.NewFieldRequired("volumeID"))
}
if cd.FSType == "" || (cd.FSType != "ext3" && cd.FSType != "ext4") {
allErrs = append(allErrs, errs.NewFieldRequired("fsType required and should be of type ext3 or ext4"))
}
return allErrs
}
func ValidatePersistentVolumeName(name string, prefix bool) (bool, string) {
return NameIsDNSSubdomain(name, prefix)
}
@@ -557,6 +572,10 @@ func ValidatePersistentVolume(pv *api.PersistentVolume) errs.ValidationErrorList
numVolumes++
allErrs = append(allErrs, validateISCSIVolumeSource(pv.Spec.ISCSI).Prefix("iscsi")...)
}
if pv.Spec.Cinder != nil {
numVolumes++
allErrs = append(allErrs, validateCinderVolumeSource(pv.Spec.Cinder).Prefix("cinder")...)
}
if numVolumes != 1 {
allErrs = append(allErrs, errs.NewFieldInvalid("", pv.Spec.PersistentVolumeSource, "exactly 1 volume type is required"))
}