(s *state.State, r *http.Request, requestProjectName string, projectName string, poolName string, req *api.StorageVolumesPost)
| 1032 | } |
| 1033 | |
| 1034 | func doCustomVolumeRefresh(s *state.State, r *http.Request, requestProjectName string, projectName string, poolName string, req *api.StorageVolumesPost) response.Response { |
| 1035 | pool, err := storagePools.LoadByName(s, poolName) |
| 1036 | if err != nil { |
| 1037 | return response.SmartError(err) |
| 1038 | } |
| 1039 | |
| 1040 | var srcProjectName string |
| 1041 | if req.Source.Project != "" { |
| 1042 | srcProjectName, err = project.StorageVolumeProject(s.DB.Cluster, req.Source.Project, db.StoragePoolVolumeTypeCustom) |
| 1043 | if err != nil { |
| 1044 | return response.SmartError(err) |
| 1045 | } |
| 1046 | } |
| 1047 | |
| 1048 | run := func(op *operations.Operation) error { |
| 1049 | reverter := revert.New() |
| 1050 | defer reverter.Fail() |
| 1051 | |
| 1052 | if req.Source.Name == "" { |
| 1053 | return errors.New("No source volume name supplied") |
| 1054 | } |
| 1055 | |
| 1056 | err = pool.RefreshCustomVolume(projectName, srcProjectName, req.Name, req.Description, req.Config, req.Source.Pool, req.Source.Name, !req.Source.VolumeOnly, req.Source.RefreshExcludeOlder, op) |
| 1057 | if err != nil { |
| 1058 | return err |
| 1059 | } |
| 1060 | |
| 1061 | reverter.Success() |
| 1062 | return nil |
| 1063 | } |
| 1064 | |
| 1065 | op, err := operations.OperationCreate(s, requestProjectName, operations.OperationClassTask, operationtype.VolumeCopy, nil, nil, run, nil, nil, r) |
| 1066 | if err != nil { |
| 1067 | return response.InternalError(err) |
| 1068 | } |
| 1069 | |
| 1070 | return operations.OperationResponse(op) |
| 1071 | } |
| 1072 | |
| 1073 | func doVolumeCreateOrCopy(s *state.State, r *http.Request, requestProjectName string, projectName string, poolName string, req *api.StorageVolumesPost) response.Response { |
| 1074 | pool, err := storagePools.LoadByName(s, poolName) |
no test coverage detected
searching dependent graphs…