MigrateStoragePoolVolume requests that Incus prepares for a storage volume migration.
(pool string, volume api.StorageVolumePost)
| 462 | |
| 463 | // MigrateStoragePoolVolume requests that Incus prepares for a storage volume migration. |
| 464 | func (r *ProtocolIncus) MigrateStoragePoolVolume(pool string, volume api.StorageVolumePost) (Operation, error) { |
| 465 | if !r.HasExtension("storage_api_remote_volume_handling") { |
| 466 | return nil, errors.New("The server is missing the required \"storage_api_remote_volume_handling\" API extension") |
| 467 | } |
| 468 | |
| 469 | // Quick check. |
| 470 | if !volume.Migration { |
| 471 | return nil, errors.New("Can't ask for a rename through MigrateStoragePoolVolume") |
| 472 | } |
| 473 | |
| 474 | var req any |
| 475 | var path string |
| 476 | |
| 477 | srcVolParentName, srcVolSnapName, srcIsSnapshot := api.GetParentAndSnapshotName(volume.Name) |
| 478 | if srcIsSnapshot { |
| 479 | err := r.CheckExtension("storage_api_remote_volume_snapshot_copy") |
| 480 | if err != nil { |
| 481 | return nil, err |
| 482 | } |
| 483 | |
| 484 | // Set the actual name of the snapshot without delimiter. |
| 485 | req = api.StorageVolumeSnapshotPost{ |
| 486 | Name: srcVolSnapName, |
| 487 | Migration: volume.Migration, |
| 488 | Target: volume.Target, |
| 489 | } |
| 490 | |
| 491 | path = api.NewURL().Path("storage-pools", pool, "volumes", "custom", srcVolParentName, "snapshots", srcVolSnapName).String() |
| 492 | } else { |
| 493 | req = volume |
| 494 | path = api.NewURL().Path("storage-pools", pool, "volumes", "custom", volume.Name).String() |
| 495 | } |
| 496 | |
| 497 | // Send the request |
| 498 | op, _, err := r.queryOperation("POST", path, req, "") |
| 499 | if err != nil { |
| 500 | return nil, err |
| 501 | } |
| 502 | |
| 503 | return op, nil |
| 504 | } |
| 505 | |
| 506 | func (r *ProtocolIncus) tryMigrateStoragePoolVolume(source InstanceServer, pool string, req api.StorageVolumePost, urls []string) (RemoteOperation, error) { |
| 507 | if len(urls) == 0 { |
nothing calls this directly
no test coverage detected