@@ -14,7 +14,6 @@ import (
1414 "github.com/FuturFusion/migration-manager/internal/server/auth"
1515 "github.com/FuturFusion/migration-manager/internal/server/response"
1616 "github.com/FuturFusion/migration-manager/internal/server/util"
17- "github.com/FuturFusion/migration-manager/internal/source"
1817 "github.com/FuturFusion/migration-manager/internal/transaction"
1918 "github.com/FuturFusion/migration-manager/shared/api"
2019 "github.com/FuturFusion/migration-manager/shared/api/event"
@@ -40,12 +39,6 @@ var instanceOverrideCmd = APIEndpoint{
4039 Put : APIEndpointAction {Handler : instanceOverridePut , AccessHandler : allowPermission (auth .ObjectTypeServer , auth .EntitlementCanEdit )},
4140}
4241
43- var instanceResetBackgroundImportCmd = APIEndpoint {
44- Path : "instances/{uuid}/:reset-background-import" ,
45-
46- Post : APIEndpointAction {Handler : instanceResetBackgroundImport , AccessHandler : allowPermission (auth .ObjectTypeServer , auth .EntitlementCanEdit )},
47- }
48-
4942// swagger:operation GET /1.0/instances instances instances_get
5043//
5144// Get the instances
@@ -456,77 +449,3 @@ func instanceOverrideDelete(d *Daemon, r *http.Request) response.Response {
456449
457450 return response .EmptySyncResponse
458451}
459-
460- // swagger:operation POST /1.0/instances/{uuid}/:reset-background-import instances instance_reset_background_import
461- //
462- // Reactivates instance background import support
463- //
464- // Resets background import verification for an instance whose source reports background import support, but could not be verified..
465- //
466- // ---
467- // produces:
468- // - application/json
469- // responses:
470- // "200":
471- // $ref: "#/responses/EmptySyncResponse"
472- // "400":
473- // $ref: "#/responses/BadRequest"
474- // "403":
475- // $ref: "#/responses/Forbidden"
476- // "500":
477- // $ref: "#/responses/InternalServerError"
478- func instanceResetBackgroundImport (d * Daemon , r * http.Request ) response.Response {
479- uuidString := r .PathValue ("uuid" )
480-
481- instanceUUID , err := uuid .Parse (uuidString )
482- if err != nil {
483- return response .BadRequest (err )
484- }
485-
486- var apiInstance api.Instance
487- err = transaction .Do (r .Context (), func (ctx context.Context ) error {
488- inst , err := d .instance .GetByUUID (ctx , instanceUUID )
489- if err != nil {
490- return err
491- }
492-
493- src , err := d .source .GetByName (ctx , inst .Source )
494- if err != nil {
495- return err
496- }
497-
498- is , err := source .NewVMSource (src .ToAPI ())
499- if err != nil {
500- return err
501- }
502-
503- err = is .Connect (ctx )
504- if err != nil {
505- return err
506- }
507-
508- supported , err := is .GetBackgroundImport (ctx , inst .UUID )
509- if err != nil {
510- return err
511- }
512-
513- if ! supported {
514- return fmt .Errorf ("Instance %q (%q) on source %q does not have background import support" , inst .UUID , inst .Properties .Location , src .Name )
515- }
516-
517- err = d .instance .ResetBackgroundImport (ctx , inst )
518- if err != nil {
519- return err
520- }
521-
522- apiInstance = inst .ToAPI ()
523- return nil
524- })
525- if err != nil {
526- return response .SmartError (err )
527- }
528-
529- d .logHandler .SendLifecycle (r .Context (), event .NewInstanceEvent (event .InstanceModified , r , apiInstance , apiInstance .UUID ))
530-
531- return response .EmptySyncResponse
532- }
0 commit comments