From 4d78dcdde2b0d8b1a3a8456d130dc832802142bf Mon Sep 17 00:00:00 2001 From: jeff Date: Wed, 27 Feb 2019 20:02:04 +0800 Subject: [PATCH] support volume repl config --- service/volume.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/service/volume.go b/service/volume.go index 77521f2..c269100 100644 --- a/service/volume.go +++ b/service/volume.go @@ -133,6 +133,7 @@ func (s *VolumeService) CreateVolumes(i *CreateVolumesInput) (*CreateVolumesOutp type CreateVolumesInput struct { Count *int `json:"count" name:"count" default:"1" location:"params"` Size *int `json:"size" name:"size" location:"params"` // Required + Repl *string `json:"repl" name:"repl" default:"" location:"params"` VolumeName *string `json:"volume_name" name:"volume_name" location:"params"` // VolumeType's available values: 0, 1, 2, 3, 4, 5, 10, 100, 200 VolumeType *int `json:"volume_type" name:"volume_type" default:"0" location:"params"` @@ -147,6 +148,26 @@ func (v *CreateVolumesInput) Validate() error { } } + if v.Repl != nil && *v.Repl != "" { + volumeReplValidValues := []string{"rpp-00000001", "rpp-00000002"} + volumeReplParameterValue := fmt.Sprint(*v.Repl) + + volumeReplIsValid := false + for _, value := range volumeReplValidValues { + if value == volumeReplParameterValue { + volumeReplIsValid = true + } + } + + if !volumeReplIsValid { + return errors.ParameterValueNotAllowedError{ + ParameterName: "Repl", + ParameterValue: volumeReplParameterValue, + AllowedValues: volumeReplValidValues, + } + } + } + if v.VolumeType != nil { volumeTypeValidValues := []string{"0", "1", "2", "3", "4", "5", "10", "100", "200"} volumeTypeParameterValue := fmt.Sprint(*v.VolumeType)