MCPcopy
hub / github.com/lxc/incus / doCustomVolumeRefresh

Function doCustomVolumeRefresh

cmd/incusd/storage_volumes.go:1034–1071  ·  view source on GitHub ↗
(s *state.State, r *http.Request, requestProjectName string, projectName string, poolName string, req *api.StorageVolumesPost)

Source from the content-addressed store, hash-verified

1032}
1033
1034func 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
1073func 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)

Callers 1

storagePoolVolumesPostFunction · 0.85

Calls 9

SmartErrorFunction · 0.92
StorageVolumeProjectFunction · 0.92
NewFunction · 0.92
OperationCreateFunction · 0.92
InternalErrorFunction · 0.92
OperationResponseFunction · 0.92
FailMethod · 0.80
SuccessMethod · 0.80
RefreshCustomVolumeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…