added ISCSI volume plugin to PersistentVolumeSource

This commit is contained in:
markturansky 2015-05-12 16:40:31 -04:00
parent e0092a1c23
commit 5b23fc39b2
8 changed files with 49 additions and 0 deletions

View File

@ -228,6 +228,9 @@ type PersistentVolumeSource struct {
NFS *NFSVolumeSource `json:"nfs"`
// RBD represents a Rados Block Device mount on the host that shares a pod's lifetime
RBD *RBDVolumeSource `json:"rbd"`
// ISCSIVolumeSource represents an ISCSI resource that is attached to a
// kubelet's host machine and then exposed to the pod.
ISCSI *ISCSIVolumeSource `json:"iscsi"`
}
type PersistentVolumeClaimVolumeSource struct {

View File

@ -253,6 +253,9 @@ type PersistentVolumeSource struct {
NFS *NFSVolumeSource `json:"nfs,omitempty" description:"NFS volume resource provisioned by an admin"`
// RBD represents a Rados Block Device mount on the host that shares a pod's lifetime
RBD *RBDVolumeSource `json:"rbd" description:"rados block volume that will be mounted on the host machine"`
// ISCSI represents an ISCSI Disk resource that is attached to a
// kubelet's host machine and then exposed to the pod.
ISCSI *ISCSIVolumeSource `json:"iscsi" description:"an iSCSI disk resource provisioned by an admin"`
}
type PersistentVolume struct {

View File

@ -156,6 +156,9 @@ type PersistentVolumeSource struct {
NFS *NFSVolumeSource `json:"nfs" description:"NFS volume resource provisioned by an admin"`
// RBD represents a Rados Block Device mount on the host that shares a pod's lifetime
RBD *RBDVolumeSource `json:"rbd" description:"rados block volume that will be mounted on the host machine"`
// ISCSI represents an ISCSI Disk resource that is attached to a
// kubelet's host machine and then exposed to the pod.
ISCSI *ISCSIVolumeSource `json:"iscsi" description:"an iSCSI disk resource provisioned by an admin"`
}
type PersistentVolumeClaimVolumeSource struct {

View File

@ -113,6 +113,9 @@ type PersistentVolumeSource struct {
NFS *NFSVolumeSource `json:"nfs" description:"NFS volume resource provisioned by an admin"`
// RBD represents a Rados Block Device mount on the host that shares a pod's lifetime
RBD *RBDVolumeSource `json:"rbd" description:"rados block volume that will be mounted on the host machine"`
// ISCSI represents an ISCSI Disk resource that is attached to a
// kubelet's host machine and then exposed to the pod.
ISCSI *ISCSIVolumeSource `json:"iscsi" description:"an iSCSI disk resource provisioned by an admin"`
}
type PersistentVolumeClaimVolumeSource struct {

View File

@ -2193,6 +2193,14 @@ func convert_api_VolumeSource_To_v1beta3_VolumeSource(in *api.VolumeSource, out
} else {
out.ISCSI = nil
}
if in.ISCSI != nil {
out.ISCSI = new(ISCSIVolumeSource)
if err := convert_api_ISCSIVolumeSource_To_v1beta3_ISCSIVolumeSource(in.ISCSI, out.ISCSI, s); err != nil {
return err
}
} else {
out.ISCSI = nil
}
if in.Glusterfs != nil {
out.Glusterfs = new(GlusterfsVolumeSource)
if err := convert_api_GlusterfsVolumeSource_To_v1beta3_GlusterfsVolumeSource(in.Glusterfs, out.Glusterfs, s); err != nil {

View File

@ -253,6 +253,9 @@ type PersistentVolumeSource struct {
NFS *NFSVolumeSource `json:"nfs,omitempty" description:"NFS volume resource provisioned by an admin"`
// RBD represents a Rados Block Device mount on the host that shares a pod's lifetime
RBD *RBDVolumeSource `json:"rbd" description:"rados block volume that will be mounted on the host machine"`
// ISCSI represents an ISCSI Disk resource that is attached to a
// kubelet's host machine and then exposed to the pod.
ISCSI *ISCSIVolumeSource `json:"iscsi" description:"an iSCSI disk resource provisioned by an admin"`
}
type PersistentVolume struct {

View File

@ -518,6 +518,10 @@ func ValidatePersistentVolume(pv *api.PersistentVolume) errs.ValidationErrorList
numVolumes++
allErrs = append(allErrs, validateRBD(pv.Spec.RBD).Prefix("rbd")...)
}
if pv.Spec.ISCSI != nil {
numVolumes++
allErrs = append(allErrs, validateISCSIVolumeSource(pv.Spec.ISCSI).Prefix("iscsi")...)
}
if numVolumes != 1 {
allErrs = append(allErrs, errs.NewFieldInvalid("", pv.Spec.PersistentVolumeSource, "exactly 1 volume type is required"))
}

View File

@ -39,6 +39,28 @@ func TestCanSupport(t *testing.T) {
}
}
func TestGetAccessModes(t *testing.T) {
plugMgr := volume.VolumePluginMgr{}
plugMgr.InitPlugins(ProbeVolumePlugins(), volume.NewFakeVolumeHost("/tmp/fake", nil, nil))
plug, err := plugMgr.FindPersistentPluginByName("kubernetes.io/iscsi")
if err != nil {
t.Errorf("Can't find the plugin by name")
}
if !contains(plug.GetAccessModes(), api.ReadWriteOnce) || !contains(plug.GetAccessModes(), api.ReadOnlyMany) {
t.Errorf("Expected two AccessModeTypes: %s and %s", api.ReadWriteOnce, api.ReadOnlyMany)
}
}
func contains(modes []api.AccessModeType, mode api.AccessModeType) bool {
for _, m := range modes {
if m == mode {
return true
}
}
return false
}
type fakeDiskManager struct {
attachCalled bool
detachCalled bool