The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/4782
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) ===
From 29cd57e720dba7de5e171743cb2a3d578515c629 Mon Sep 17 00:00:00 2001 From: Christian Brauner <christian.brau...@ubuntu.com> Date: Fri, 13 Jul 2018 14:08:32 +0200 Subject: [PATCH 1/5] storage volumes: add snapshot entpoints Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com> --- lxd/storage_volumes_snapshot.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 lxd/storage_volumes_snapshot.go diff --git a/lxd/storage_volumes_snapshot.go b/lxd/storage_volumes_snapshot.go new file mode 100644 index 000000000..bf22cd952 --- /dev/null +++ b/lxd/storage_volumes_snapshot.go @@ -0,0 +1,39 @@ +package main + +import ( + "fmt" + "net/http" +) + +var storagePoolVolumeSnapshotsTypeCmd = Command{ + name: "storage-pools/{pool}/volumes/{type}/{name}/snapshots", + post: storagePoolVolumeSnapshotsTypePost, + get: storagePoolVolumeSnapshotsTypeGet, +} + +var storagePoolVolumeSnapshotTypeCmd = Command{ + name: "storage-pools/{pool}/volumes/{type}/{name}/snapshots/{snapshotName}", + post: storagePoolVolumeSnapshotTypePost, + get: storagePoolVolumeSnapshotTypeGet, + delete: storagePoolVolumeSnapshotTypeDelete, +} + +func storagePoolVolumeSnapshotsTypePost(d *Daemon, r *http.Request) Response { + return NotImplemented(fmt.Errorf("Creating storage pool volume snapshots is not implemented")) +} + +func storagePoolVolumeSnapshotsTypeGet(d *Daemon, r *http.Request) Response { + return NotImplemented(fmt.Errorf("Retrieving storage pool volume snapshots is not implemented")) +} + +func storagePoolVolumeSnapshotTypePost(d *Daemon, r *http.Request) Response { + return NotImplemented(fmt.Errorf("Updating storage pool volume snapshots is not implemented")) +} + +func storagePoolVolumeSnapshotTypeGet(d *Daemon, r *http.Request) Response { + return NotImplemented(fmt.Errorf("Retrieving a storage pool volume snapshot is not implemented")) +} + +func storagePoolVolumeSnapshotTypeDelete(d *Daemon, r *http.Request) Response { + return NotImplemented(fmt.Errorf("Deleting storage pool volume snapshots is not implemented")) +} From ce59c1fe84b67e8e6583a2df3779b8993e9449a1 Mon Sep 17 00:00:00 2001 From: Christian Brauner <christian.brau...@ubuntu.com> Date: Fri, 13 Jul 2018 14:18:52 +0200 Subject: [PATCH 2/5] api: add StorageVolumeSnapshot struct Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com> --- shared/api/storage_pool_volume_snapshot.go | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 shared/api/storage_pool_volume_snapshot.go diff --git a/shared/api/storage_pool_volume_snapshot.go b/shared/api/storage_pool_volume_snapshot.go new file mode 100644 index 000000000..2bb3f5e32 --- /dev/null +++ b/shared/api/storage_pool_volume_snapshot.go @@ -0,0 +1,11 @@ +package api + +import () + +// StorageVolumeSnapshot represents a LXD storage volume snapshot +// +// API extension: storage_api_volume_snapshots +type StorageVolumeSnapshot struct { + Name string `json:"name" yaml:"name"` + Type string `json:"type" yaml:"type"` +} From 3e5f831afc52936696d44cfff19ed51205d964e8 Mon Sep 17 00:00:00 2001 From: Christian Brauner <christian.brau...@ubuntu.com> Date: Fri, 13 Jul 2018 14:19:11 +0200 Subject: [PATCH 3/5] api: add StorageVolumeSnapshotPost struct Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com> --- shared/api/storage_pool_volume_snapshot.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/shared/api/storage_pool_volume_snapshot.go b/shared/api/storage_pool_volume_snapshot.go index 2bb3f5e32..c3d3cf2c8 100644 --- a/shared/api/storage_pool_volume_snapshot.go +++ b/shared/api/storage_pool_volume_snapshot.go @@ -2,6 +2,14 @@ package api import () +// StorageVolumeSnapshotPost represents the fields required to rename/move a LXD storage volume snapshot +// +// API extension: storage_api_volume_snapshots +type StorageVolumeSnapshotPost struct { + Name string `json:"name" yaml:"name"` + Type string `json:"type" yaml:"type"` +} + // StorageVolumeSnapshot represents a LXD storage volume snapshot // // API extension: storage_api_volume_snapshots From 335af7976195f22aa62e32ac0ccf06cc01deb487 Mon Sep 17 00:00:00 2001 From: Christian Brauner <christian.brau...@ubuntu.com> Date: Fri, 13 Jul 2018 14:19:28 +0200 Subject: [PATCH 4/5] api: add StorageVolumeSnapshotsPost struct Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com> --- shared/api/storage_pool_volume_snapshot.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/shared/api/storage_pool_volume_snapshot.go b/shared/api/storage_pool_volume_snapshot.go index c3d3cf2c8..8ce31e191 100644 --- a/shared/api/storage_pool_volume_snapshot.go +++ b/shared/api/storage_pool_volume_snapshot.go @@ -2,6 +2,14 @@ package api import () +// StorageVolumeSnapshotsPost represents the fields available for a new LXD storage volume snapshot +// +// API extension: storage_api_volume_snapshots +type StorageVolumeSnapshotsPost struct { + Name string `json:"name" yaml:"name"` + Type string `json:"type" yaml:"type"` +} + // StorageVolumeSnapshotPost represents the fields required to rename/move a LXD storage volume snapshot // // API extension: storage_api_volume_snapshots From 6f59a5cb82430419a32a90d7f8438f07ab5c94ba Mon Sep 17 00:00:00 2001 From: Christian Brauner <christian.brau...@ubuntu.com> Date: Fri, 13 Jul 2018 14:45:21 +0200 Subject: [PATCH 5/5] client: add CreateStoragePoolVolumeSnapshot() Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com> --- client/interfaces.go | 3 +++ client/lxd_storage_volumes.go | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/client/interfaces.go b/client/interfaces.go index f44f0e4b8..2a5884deb 100644 --- a/client/interfaces.go +++ b/client/interfaces.go @@ -197,6 +197,9 @@ type ContainerServer interface { MoveStoragePoolVolume(pool string, source ContainerServer, sourcePool string, volume api.StorageVolume, args *StoragePoolVolumeMoveArgs) (op RemoteOperation, err error) MigrateStoragePoolVolume(pool string, volume api.StorageVolumePost) (op Operation, err error) + // Storage volume snapshot functions ("storage_api_volume_snapshots" API extension) + CreateStoragePoolVolumeSnapshot(pool string, volume string, snapshot api.StorageVolumeSnapshot) (err error) + // Cluster functions ("cluster" API extensions) GetCluster() (cluster *api.Cluster, ETag string, err error) UpdateCluster(cluster api.ClusterPut, ETag string) (op Operation, err error) diff --git a/client/lxd_storage_volumes.go b/client/lxd_storage_volumes.go index e0f5fb8d7..10fa22b93 100644 --- a/client/lxd_storage_volumes.go +++ b/client/lxd_storage_volumes.go @@ -94,6 +94,29 @@ func (r *ProtocolLXD) CreateStoragePoolVolume(pool string, volume api.StorageVol return nil } +// CreateStoragePoolVolumeSnapshot defines a new storage volume +func (r *ProtocolLXD) CreateStoragePoolVolumeSnapshot(pool string, volume string, snapshot api.StorageVolumeSnapshot) error { + if !r.HasExtension("storage_api_volume_snapshots") { + return fmt.Errorf("The server is missing the required \"storage_api_volume_snapshots\" API extension") + } + + // Send the request + path := fmt.Sprintf("/storage-pools/%s/volumes/%s/%s-snapshots", + url.QueryEscape(pool), + url.QueryEscape(snapshot.Type), + url.QueryEscape(volume), + url.QueryEscape(snapshot.Type)) + if r.clusterTarget != "" { + path += fmt.Sprintf("?target=%s", r.clusterTarget) + } + _, _, err := r.query("POST", path, volume, "") + if err != nil { + return err + } + + return nil +} + // MigrateStoragePoolVolume requests that LXD prepares for a storage volume migration func (r *ProtocolLXD) MigrateStoragePoolVolume(pool string, volume api.StorageVolumePost) (Operation, error) { if !r.HasExtension("storage_api_remote_volume_handling") {
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel