func getName(v interface{}, key string, required bool, err error) (string, error) {
	name, err := getLowerCaseFlag(v, key, required, err)
	if err != nil {
		return name, err
	}
	if !required && name == "" {
		return name, nil
	}
	if !util.ValidateName(name) {
		return "", fmt.Errorf("Invalid name %v", name)
	}
	return name, nil
}
func (s *Server) getDockerVolume(r *http.Request, create bool) (*Volume, error) {
	name, err := getDockerVolumeName(r)
	if err != nil {
		return nil, err
	}

	var (
		volume     *Volume
		volumeUUID string
		volumeName string
	)
	if util.ValidateUUID(name) {
		volumeUUID = name
		volume = s.loadVolume(name)
	} else if util.ValidateName(name) {
		volumeName = name
		volume = s.loadVolumeByName(name)
	} else {
		// Not valid UUID or name
		return nil, fmt.Errorf("Invalid volume name. Must be a valid UUID or only contains 0-9, a-z, understore(_) and dot(.)")
	}

	if volume == nil {
		if create {
			log.Debugf("Create a new volume %v for docker", name)

			volume, err = s.processVolumeCreate(volumeUUID, volumeName, "", s.DefaultVolumeSize, true)
			if err != nil {
				return nil, err
			}
		} else {
			return nil, fmt.Errorf("Cannot find volume %v", name)
		}
	}

	return volume, nil
}