[lxc-devel] [lxd/master] shared: Rename some functions
stgraber on Github
lxc-bot at linuxcontainers.org
Fri Nov 22 19:49:58 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20191122/aa9b27cb/attachment-0001.bin>
-------------- next part --------------
From 9a4ac7609a9219ae45e927a5a754d8ab9733ed00 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 22 Nov 2019 12:53:32 -0500
Subject: [PATCH 1/6] shared: Rename ContainerAction to InstanceAction
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
shared/{container.go => instance.go} | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
rename shared/{container.go => instance.go} (97%)
diff --git a/shared/container.go b/shared/instance.go
similarity index 97%
rename from shared/container.go
rename to shared/instance.go
index 034229f0e5..aa670adc6e 100644
--- a/shared/container.go
+++ b/shared/instance.go
@@ -13,14 +13,14 @@ import (
"github.com/lxc/lxd/shared/units"
)
-type ContainerAction string
+type InstanceAction string
const (
- Stop ContainerAction = "stop"
- Start ContainerAction = "start"
- Restart ContainerAction = "restart"
- Freeze ContainerAction = "freeze"
- Unfreeze ContainerAction = "unfreeze"
+ Stop InstanceAction = "stop"
+ Start InstanceAction = "start"
+ Restart InstanceAction = "restart"
+ Freeze InstanceAction = "freeze"
+ Unfreeze InstanceAction = "unfreeze"
)
func IsInt64(value string) error {
From 177e5efa1cb50630c9581758f48df458e3616e83 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 22 Nov 2019 12:54:07 -0500
Subject: [PATCH 2/6] shared: Rename KnownContainerConfigKeys to
KnownInstanceConfigKeys
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
shared/instance.go | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/shared/instance.go b/shared/instance.go
index aa670adc6e..c43c73fe16 100644
--- a/shared/instance.go
+++ b/shared/instance.go
@@ -170,10 +170,10 @@ func GetRootDiskDevice(devices map[string]map[string]string) (string, map[string
return "", nil, fmt.Errorf("No root device could be found")
}
-// KnownContainerConfigKeys maps all fully defined, well-known config keys
+// KnownInstanceConfigKeys maps all fully defined, well-known config keys
// to an appropriate checker function, which validates whether or not a
// given value is syntactically legal.
-var KnownContainerConfigKeys = map[string]func(value string) error{
+var KnownInstanceConfigKeys = map[string]func(value string) error{
"boot.autostart": IsBool,
"boot.autostart.delay": IsInt64,
"boot.autostart.priority": IsInt64,
@@ -352,7 +352,7 @@ var KnownContainerConfigKeys = map[string]func(value string) error{
// be done by the caller. User defined keys are always considered to
// be valid, e.g. user.* and environment.* keys.
func ConfigKeyChecker(key string) (func(value string) error, error) {
- if f, ok := KnownContainerConfigKeys[key]; ok {
+ if f, ok := KnownInstanceConfigKeys[key]; ok {
return f, nil
}
From 51c86cb8914a8cc9f2ad3538227796d6993c36be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 22 Nov 2019 12:54:28 -0500
Subject: [PATCH 3/6] shared: Rename ContainerGetParentAndSnapshotName to
InstanceGetParentAndSnapshotName
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
shared/instance.go | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/shared/instance.go b/shared/instance.go
index c43c73fe16..70a121c4bb 100644
--- a/shared/instance.go
+++ b/shared/instance.go
@@ -134,7 +134,7 @@ func IsDeviceID(value string) error {
}
// IsRootDiskDevice returns true if the given device representation is configured as root disk for
-// a container. It typically get passed a specific entry of api.Container.Devices.
+// a container. It typically get passed a specific entry of api.Instance.Devices.
func IsRootDiskDevice(device map[string]string) bool {
// Root disk devices also need a non-empty "pool" property, but we can't check that here
// because this function is used with clients talking to older servers where there was no
@@ -422,9 +422,9 @@ func ConfigKeyChecker(key string) (func(value string) error, error) {
return nil, fmt.Errorf("Unknown configuration key: %s", key)
}
-// ContainerGetParentAndSnapshotName returns the parent container name, snapshot
+// InstanceGetParentAndSnapshotName returns the parent container name, snapshot
// name, and whether it actually was a snapshot name.
-func ContainerGetParentAndSnapshotName(name string) (string, string, bool) {
+func InstanceGetParentAndSnapshotName(name string) (string, string, bool) {
fields := strings.SplitN(name, SnapshotDelimiter, 2)
if len(fields) == 1 {
return name, "", false
From 29b7252e98708bb22447fd64d769699d5ec3793a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 22 Nov 2019 12:54:55 -0500
Subject: [PATCH 4/6] lxc: Update for ContainerGetParentAndSnapshotName rename
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxc/move.go | 4 ++--
lxc/storage_volume.go | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lxc/move.go b/lxc/move.go
index 4d2878419f..2931e22744 100644
--- a/lxc/move.go
+++ b/lxc/move.go
@@ -116,8 +116,8 @@ func (c *cmdMove) Run(cmd *cobra.Command, args []string) error {
if shared.IsSnapshot(sourceName) {
// Snapshot rename
- srcParent, srcSnap, _ := shared.ContainerGetParentAndSnapshotName(sourceName)
- dstParent, dstSnap, dstIsSnap := shared.ContainerGetParentAndSnapshotName(destName)
+ srcParent, srcSnap, _ := shared.InstanceGetParentAndSnapshotName(sourceName)
+ dstParent, dstSnap, dstIsSnap := shared.InstanceGetParentAndSnapshotName(destName)
if srcParent != dstParent {
return fmt.Errorf("Invalid new snapshot name, parent must be the same as source")
diff --git a/lxc/storage_volume.go b/lxc/storage_volume.go
index fb2a353db7..baeb9880cb 100644
--- a/lxc/storage_volume.go
+++ b/lxc/storage_volume.go
@@ -1214,7 +1214,7 @@ func (c *cmdStorageVolumeRename) Run(cmd *cobra.Command, args []string) error {
if isSnapshot {
// Create the storage volume entry
vol := api.StorageVolumeSnapshotPost{}
- dstParentName, dstSnapName, dstIsSnap := shared.ContainerGetParentAndSnapshotName(args[2])
+ dstParentName, dstSnapName, dstIsSnap := shared.InstanceGetParentAndSnapshotName(args[2])
if dstParentName != fields[0] {
return fmt.Errorf("Invalid new snapshot name, parent volume must be the same as source")
From 60ad7b4441c4f124a47840a4426fff8bd2dd3d84 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 22 Nov 2019 12:56:23 -0500
Subject: [PATCH 5/6] lxd/containers: Update for ContainerAction rename
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/container_state.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lxd/container_state.go b/lxd/container_state.go
index b50ad72bb7..3b33c68c48 100644
--- a/lxd/container_state.go
+++ b/lxd/container_state.go
@@ -83,7 +83,7 @@ func containerStatePut(d *Daemon, r *http.Request) response.Response {
var opType db.OperationType
var do func(*operations.Operation) error
- switch shared.ContainerAction(raw.Action) {
+ switch shared.InstanceAction(raw.Action) {
case shared.Start:
opType = db.OperationContainerStart
do = func(op *operations.Operation) error {
From a4bc053d1c943787270fe6650d153e88ffe207e7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 22 Nov 2019 12:56:44 -0500
Subject: [PATCH 6/6] lxd: Update for ContainerGetParentAndSnapshotName rename
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxd/api_internal.go | 10 +++---
lxd/backup.go | 2 +-
lxd/container.go | 2 +-
lxd/container_lxc.go | 8 ++---
lxd/container_snapshot.go | 4 +--
lxd/containers_post.go | 4 +--
lxd/instance/instance_utils.go | 6 ++--
lxd/migrate_container.go | 8 ++---
lxd/migrate_storage_volumes.go | 4 +--
lxd/patches.go | 2 +-
lxd/storage/backend_lxd.go | 28 +++++++--------
lxd/storage/drivers/driver_cephfs.go | 4 +--
lxd/storage/drivers/driver_dir.go | 4 +--
lxd/storage/drivers/utils.go | 2 +-
lxd/storage/drivers/volume.go | 2 +-
lxd/storage_btrfs.go | 28 +++++++--------
lxd/storage_ceph.go | 26 +++++++-------
lxd/storage_ceph_utils.go | 18 +++++-----
lxd/storage_cephfs.go | 10 +++---
lxd/storage_dir.go | 18 +++++-----
lxd/storage_lvm.go | 20 +++++------
lxd/storage_lvm_utils.go | 6 ++--
lxd/storage_migration.go | 6 ++--
lxd/storage_migration_btrfs.go | 4 +--
lxd/storage_migration_ceph.go | 2 +-
lxd/storage_migration_zfs.go | 4 +--
lxd/storage_pools_utils.go | 2 +-
lxd/storage_volumes.go | 2 +-
lxd/storage_volumes_snapshot.go | 2 +-
lxd/storage_volumes_utils.go | 4 +--
lxd/storage_zfs.go | 52 ++++++++++++++--------------
lxd/vm_qemu.go | 2 +-
32 files changed, 148 insertions(+), 148 deletions(-)
diff --git a/lxd/api_internal.go b/lxd/api_internal.go
index ff0392ac18..934ea7ad7c 100644
--- a/lxd/api_internal.go
+++ b/lxd/api_internal.go
@@ -665,7 +665,7 @@ func internalImport(d *Daemon, r *http.Request) response.Response {
for _, od = range onDiskSnapshots {
inBackupFile := false
for _, ib := range backup.Snapshots {
- _, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(ib.Name)
+ _, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(ib.Name)
if od == snapOnlyName {
inBackupFile = true
break
@@ -750,7 +750,7 @@ func internalImport(d *Daemon, r *http.Request) response.Response {
return response.BadRequest(needForce)
}
case "lvm":
- ctName, csName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name)
+ ctName, csName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name)
ctLvmName := containerNameToLVName(fmt.Sprintf("%s/%s", project.Prefix(projectName, ctName), csName))
ctLvName := getLVName(poolName,
storagePoolVolumeAPIEndpointContainers,
@@ -778,7 +778,7 @@ func internalImport(d *Daemon, r *http.Request) response.Response {
}
onDiskPoolName := backup.Pool.Config["ceph.osd.pool_name"]
- ctName, csName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name)
+ ctName, csName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name)
ctName = project.Prefix(projectName, ctName)
snapshotName := fmt.Sprintf("snapshot_%s", csName)
@@ -793,7 +793,7 @@ func internalImport(d *Daemon, r *http.Request) response.Response {
return response.BadRequest(needForce)
}
case "zfs":
- ctName, csName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name)
+ ctName, csName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name)
snapshotName := fmt.Sprintf("snapshot-%s", csName)
exists := zfsFilesystemEntityExists(poolName,
@@ -1044,7 +1044,7 @@ func internalImport(d *Daemon, r *http.Request) response.Response {
// Recreate missing mountpoints and symlinks.
snapshotMountPoint := driver.GetSnapshotMountPoint(projectName, backup.Pool.Name,
snap.Name)
- sourceName, _, _ := shared.ContainerGetParentAndSnapshotName(snap.Name)
+ sourceName, _, _ := shared.InstanceGetParentAndSnapshotName(snap.Name)
sourceName = project.Prefix(projectName, sourceName)
snapshotMntPointSymlinkTarget := shared.VarPath("storage-pools", backup.Pool.Name, "containers-snapshots", sourceName)
snapshotMntPointSymlink := shared.VarPath("snapshots", sourceName)
diff --git a/lxd/backup.go b/lxd/backup.go
index bdaa14315d..b9557fd5b2 100644
--- a/lxd/backup.go
+++ b/lxd/backup.go
@@ -200,7 +200,7 @@ func backupCreateTarball(s *state.State, path string, b backup.Backup, c instanc
}
for _, snap := range snaps {
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name())
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name())
indexFile.Snapshots = append(indexFile.Snapshots, snapName)
}
}
diff --git a/lxd/container.go b/lxd/container.go
index f109e30d86..54ab1691d7 100644
--- a/lxd/container.go
+++ b/lxd/container.go
@@ -1626,7 +1626,7 @@ func containerDetermineNextSnapshotName(d *Daemon, c instance.Instance, defaultP
}
for _, snap := range snapshots {
- _, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name())
+ _, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name())
if snapOnlyName == pattern {
snapshotExists = true
break
diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 8c2141996d..5b03cfd138 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -3536,7 +3536,7 @@ func (c *containerLXC) Delete() error {
_, poolName, _ := c.storage.GetContainerPoolInfo()
if c.IsSnapshot() {
- cName, _, _ := shared.ContainerGetParentAndSnapshotName(c.name)
+ cName, _, _ := shared.InstanceGetParentAndSnapshotName(c.name)
if shared.PathExists(shared.VarPath("storage-pools", poolName, "containers", cName, ".importing")) {
isImport = true
}
@@ -3720,7 +3720,7 @@ func (c *containerLXC) Rename(newName string) error {
}
if c.IsSnapshot() {
- _, newSnapName, _ := shared.ContainerGetParentAndSnapshotName(newName)
+ _, newSnapName, _ := shared.InstanceGetParentAndSnapshotName(newName)
err = pool.RenameInstanceSnapshot(c, newSnapName, nil)
if err != nil {
return errors.Wrap(err, "Rename instance snapshot")
@@ -4782,7 +4782,7 @@ func (c *containerLXC) Update(args db.InstanceArgs, userRequested bool) error {
var endpoint string
if c.IsSnapshot() {
- cName, sName, _ := shared.ContainerGetParentAndSnapshotName(c.name)
+ cName, sName, _ := shared.InstanceGetParentAndSnapshotName(c.name)
endpoint = fmt.Sprintf("/1.0/containers/%s/snapshots/%s", cName, sName)
} else {
endpoint = fmt.Sprintf("/1.0/containers/%s", c.name)
@@ -4944,7 +4944,7 @@ func (c *containerLXC) Export(w io.Writer, properties map[string]string) error {
// Get the container's architecture
var arch string
if c.IsSnapshot() {
- parentName, _, _ := shared.ContainerGetParentAndSnapshotName(c.name)
+ parentName, _, _ := shared.InstanceGetParentAndSnapshotName(c.name)
parent, err := instanceLoadByProjectAndName(c.state, c.project, parentName)
if err != nil {
ctw.Close()
diff --git a/lxd/container_snapshot.go b/lxd/container_snapshot.go
index b81572a7ef..f0b37f1ff8 100644
--- a/lxd/container_snapshot.go
+++ b/lxd/container_snapshot.go
@@ -51,7 +51,7 @@ func containerSnapshotsGet(d *Daemon, r *http.Request) response.Response {
}
for _, snap := range snaps {
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(snap)
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(snap)
if project == "default" {
url := fmt.Sprintf("/%s/containers/%s/snapshots/%s", version.APIVersion, cname, snapName)
resultString = append(resultString, url)
@@ -358,7 +358,7 @@ func snapshotPost(d *Daemon, r *http.Request, sc container, containerName string
}
if reqNew.Live {
- sourceName, _, _ := shared.ContainerGetParentAndSnapshotName(containerName)
+ sourceName, _, _ := shared.InstanceGetParentAndSnapshotName(containerName)
if sourceName != reqNew.Name {
return response.BadRequest(fmt.Errorf(`Copying `+
`stateful containers requires that `+
diff --git a/lxd/containers_post.go b/lxd/containers_post.go
index 9e16d77f26..8de9aabbe1 100644
--- a/lxd/containers_post.go
+++ b/lxd/containers_post.go
@@ -560,7 +560,7 @@ func createFromCopy(d *Daemon, project string, req *api.InstancesPost) response.
}
if req.Stateful {
- sourceName, _, _ := shared.ContainerGetParentAndSnapshotName(source.Name())
+ sourceName, _, _ := shared.InstanceGetParentAndSnapshotName(source.Name())
if sourceName != req.Name {
return response.BadRequest(fmt.Errorf(`Copying stateful `+
`containers requires that source "%s" and `+
@@ -930,7 +930,7 @@ func clusterCopyContainerInternal(d *Daemon, source instance.Instance, project s
// Setup websockets
var opAPI api.Operation
if shared.IsSnapshot(req.Source.Source) {
- cName, sName, _ := shared.ContainerGetParentAndSnapshotName(req.Source.Source)
+ cName, sName, _ := shared.InstanceGetParentAndSnapshotName(req.Source.Source)
pullReq := api.InstanceSnapshotPost{
Migration: true,
diff --git a/lxd/instance/instance_utils.go b/lxd/instance/instance_utils.go
index 0cacf16868..0780843927 100644
--- a/lxd/instance/instance_utils.go
+++ b/lxd/instance/instance_utils.go
@@ -32,7 +32,7 @@ func CompareSnapshots(source Instance, target Instance) ([]Instance, []Instance,
// Generate a list of source snapshot creation dates.
for _, snap := range sourceSnapshots {
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name())
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name())
sourceSnapshotsTime[snapName] = snap.CreationDate()
}
@@ -41,7 +41,7 @@ func CompareSnapshots(source Instance, target Instance) ([]Instance, []Instance,
// the snapshot or the creation time is different on the source then add the target snapshot
// to the "to delete" list.
for _, snap := range targetSnapshots {
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name())
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name())
targetSnapshotsTime[snapName] = snap.CreationDate()
existDate, exists := sourceSnapshotsTime[snapName]
@@ -58,7 +58,7 @@ func CompareSnapshots(source Instance, target Instance) ([]Instance, []Instance,
// For each of the source snapshots, decide whether it needs to be synced or not based on
// whether it already exists in the target and whether the creation dates match.
for _, snap := range sourceSnapshots {
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name())
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name())
existDate, exists := targetSnapshotsTime[snapName]
if !exists || existDate != snap.CreationDate() {
diff --git a/lxd/migrate_container.go b/lxd/migrate_container.go
index c36df95fee..739f75cdb5 100644
--- a/lxd/migrate_container.go
+++ b/lxd/migrate_container.go
@@ -266,7 +266,7 @@ func (s *migrationSourceWs) preDumpLoop(args *preDumpLoopArgs) (bool, error) {
}
// Send the pre-dump.
- ctName, _, _ := shared.ContainerGetParentAndSnapshotName(s.instance.Name())
+ ctName, _, _ := shared.InstanceGetParentAndSnapshotName(s.instance.Name())
state := s.instance.DaemonState()
err = rsync.Send(ctName, shared.AddSlash(args.checkpointDir), &shared.WebsocketIO{Conn: s.criuConn}, nil, args.rsyncFeatures, args.bwlimit, state.OS.ExecPath)
if err != nil {
@@ -387,7 +387,7 @@ func (s *migrationSourceWs) Do(migrateOp *operations.Operation) error {
if err == nil {
for _, snap := range fullSnaps {
snapshots = append(snapshots, snapshotToProtobuf(snap))
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name())
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name())
snapshotNames = append(snapshotNames, snapName)
}
}
@@ -687,7 +687,7 @@ func (s *migrationSourceWs) Do(migrateOp *operations.Operation) error {
* no reason to do these in parallel. In the future when we're using
* p.haul's protocol, it will make sense to do these in parallel.
*/
- ctName, _, _ := shared.ContainerGetParentAndSnapshotName(s.instance.Name())
+ ctName, _, _ := shared.InstanceGetParentAndSnapshotName(s.instance.Name())
state := s.instance.DaemonState()
err = rsync.Send(ctName, shared.AddSlash(checkpointDir), &shared.WebsocketIO{Conn: s.criuConn}, nil, rsyncFeatures, bwlimit, state.OS.ExecPath)
if err != nil {
@@ -1188,7 +1188,7 @@ func migrationCompareSnapshots(sourceSnapshots []*migration.Snapshot, targetSnap
}
for _, snap := range targetSnapshots {
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name())
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name())
targetSnapshotsTime[snapName] = snap.CreationDate().Unix()
existDate, exists := sourceSnapshotsTime[snapName]
diff --git a/lxd/migrate_storage_volumes.go b/lxd/migrate_storage_volumes.go
index 90ebb3218c..a2c95321a1 100644
--- a/lxd/migrate_storage_volumes.go
+++ b/lxd/migrate_storage_volumes.go
@@ -110,7 +110,7 @@ func (s *migrationSourceWs) DoStorage(state *state.State, poolName string, volNa
}
snapshots = append(snapshots, volumeSnapshotToProtobuf(snapVolume))
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name)
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name)
snapshotNames = append(snapshotNames, snapName)
}
}
@@ -521,7 +521,7 @@ func volumeSnapshotToProtobuf(vol *api.StorageVolume) *migration.Snapshot {
config = append(config, &migration.Config{Key: &kCopy, Value: &vCopy})
}
- _, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(vol.Name)
+ _, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(vol.Name)
return &migration.Snapshot{
Name: &snapOnlyName,
diff --git a/lxd/patches.go b/lxd/patches.go
index dced0c14fb..35c936436b 100644
--- a/lxd/patches.go
+++ b/lxd/patches.go
@@ -3426,7 +3426,7 @@ func patchUpdateFromV11(_ *sql.Tx) error {
cNames := containers["default"]
for _, cName := range cNames {
- snapParentName, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(cName)
+ snapParentName, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(cName)
oldPath := shared.VarPath("containers", snapParentName, "snapshots", snapOnlyName)
newPath := shared.VarPath("snapshots", snapParentName, snapOnlyName)
if shared.PathExists(oldPath) && !shared.PathExists(newPath) {
diff --git a/lxd/storage/backend_lxd.go b/lxd/storage/backend_lxd.go
index efa698b4f3..99d47a7d60 100644
--- a/lxd/storage/backend_lxd.go
+++ b/lxd/storage/backend_lxd.go
@@ -221,7 +221,7 @@ func (b *lxdBackend) ensureInstanceSnapshotSymlink(instanceType instancetype.Typ
return err
}
- parentName, _, _ := shared.ContainerGetParentAndSnapshotName(instanceName)
+ parentName, _, _ := shared.InstanceGetParentAndSnapshotName(instanceName)
snapshotSymlink := InstancePath(instanceType, projectName, parentName, true)
volStorageName := project.Prefix(projectName, parentName)
@@ -254,7 +254,7 @@ func (b *lxdBackend) removeInstanceSnapshotSymlinkIfUnused(instanceType instance
return err
}
- parentName, _, _ := shared.ContainerGetParentAndSnapshotName(instanceName)
+ parentName, _, _ := shared.InstanceGetParentAndSnapshotName(instanceName)
snapshotSymlink := InstancePath(instanceType, projectName, parentName, true)
volStorageName := project.Prefix(projectName, parentName)
@@ -401,7 +401,7 @@ func (b *lxdBackend) CreateInstanceFromCopy(inst Instance, src Instance, snapsho
}
for _, snapshot := range snapshots {
- _, snapShotName, _ := shared.ContainerGetParentAndSnapshotName(snapshot.Name)
+ _, snapShotName, _ := shared.InstanceGetParentAndSnapshotName(snapshot.Name)
snapshotNames = append(snapshotNames, snapShotName)
}
}
@@ -537,7 +537,7 @@ func (b *lxdBackend) RefreshInstance(inst instance.Instance, src instance.Instan
// Retrieve a list of snapshots we are copying.
snapshotNames := []string{}
for _, srcSnapVol := range srcSnapVols {
- _, snapShotName, _ := shared.ContainerGetParentAndSnapshotName(srcSnapVol.Name())
+ _, snapShotName, _ := shared.InstanceGetParentAndSnapshotName(srcSnapVol.Name())
snapshotNames = append(snapshotNames, snapShotName)
}
@@ -788,7 +788,7 @@ func (b *lxdBackend) RenameInstance(inst Instance, newName string, op *operation
// Rename each snapshot DB record to have the new parent volume prefix.
for _, srcSnapshot := range snapshots {
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(srcSnapshot)
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(srcSnapshot)
newSnapVolName := drivers.GetSnapshotVolumeName(newName, snapName)
err = b.state.Cluster.StoragePoolVolumeRename(inst.Project(), srcSnapshot, newSnapVolName, volDBType, b.ID())
if err != nil {
@@ -1074,7 +1074,7 @@ func (b *lxdBackend) RenameInstanceSnapshot(inst Instance, newName string, op *o
return err
}
- parentName, oldSnapshotName, isSnap := shared.ContainerGetParentAndSnapshotName(inst.Name())
+ parentName, oldSnapshotName, isSnap := shared.InstanceGetParentAndSnapshotName(inst.Name())
if !isSnap {
return fmt.Errorf("Volume name must be a snapshot")
}
@@ -1103,7 +1103,7 @@ func (b *lxdBackend) DeleteInstanceSnapshot(inst Instance, op *operations.Operat
logger.Debug("DeleteInstanceSnapshot started")
defer logger.Debug("DeleteInstanceSnapshot finished")
- parentName, snapName, isSnap := shared.ContainerGetParentAndSnapshotName(inst.Name())
+ parentName, snapName, isSnap := shared.InstanceGetParentAndSnapshotName(inst.Name())
if !inst.IsSnapshot() || !isSnap {
return fmt.Errorf("Instance must be a snapshot")
}
@@ -1170,7 +1170,7 @@ func (b *lxdBackend) MountInstanceSnapshot(inst Instance, op *operations.Operati
volStorageName := project.Prefix(inst.Project(), inst.Name())
// Get the snapshot name.
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(inst.Name())
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(inst.Name())
return b.driver.MountVolumeSnapshot(volType, volStorageName, snapName, op)
}
@@ -1195,7 +1195,7 @@ func (b *lxdBackend) UnmountInstanceSnapshot(inst Instance, op *operations.Opera
volStorageName := project.Prefix(inst.Project(), inst.Name())
// Get the snapshot name.
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(inst.Name())
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(inst.Name())
return b.driver.UnmountVolumeSnapshot(volType, volStorageName, snapName, op)
}
@@ -1357,7 +1357,7 @@ func (b *lxdBackend) CreateCustomVolumeFromCopy(volName, desc string, config map
}
for _, snapshot := range snapshots {
- _, snapShotName, _ := shared.ContainerGetParentAndSnapshotName(snapshot.Name)
+ _, snapShotName, _ := shared.InstanceGetParentAndSnapshotName(snapshot.Name)
snapshotNames = append(snapshotNames, snapShotName)
}
}
@@ -1583,7 +1583,7 @@ func (b *lxdBackend) RenameCustomVolume(volName string, newVolName string, op *o
}
for _, srcSnapshot := range snapshots {
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(srcSnapshot.Name)
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(srcSnapshot.Name)
newSnapVolName := drivers.GetSnapshotVolumeName(newVolName, snapName)
err = b.state.Cluster.StoragePoolVolumeRename("default", srcSnapshot.Name, newSnapVolName, db.StoragePoolVolumeTypeCustom, b.ID())
if err != nil {
@@ -1716,7 +1716,7 @@ func (b *lxdBackend) DeleteCustomVolume(volName string, op *operations.Operation
logger.Debug("DeleteCustomVolume started")
defer logger.Debug("DeleteCustomVolume finished")
- _, _, isSnap := shared.ContainerGetParentAndSnapshotName(volName)
+ _, _, isSnap := shared.InstanceGetParentAndSnapshotName(volName)
if isSnap {
return fmt.Errorf("Volume name cannot be a snapshot")
}
@@ -1838,7 +1838,7 @@ func (b *lxdBackend) RenameCustomVolumeSnapshot(volName string, newSnapshotName
logger.Debug("RenameCustomVolumeSnapshot started")
defer logger.Debug("RenameCustomVolumeSnapshot finished")
- parentName, oldSnapshotName, isSnap := shared.ContainerGetParentAndSnapshotName(volName)
+ parentName, oldSnapshotName, isSnap := shared.InstanceGetParentAndSnapshotName(volName)
if !isSnap {
return fmt.Errorf("Volume name must be a snapshot")
}
@@ -1869,7 +1869,7 @@ func (b *lxdBackend) DeleteCustomVolumeSnapshot(volName string, op *operations.O
logger.Debug("DeleteCustomVolumeSnapshot started")
defer logger.Debug("DeleteCustomVolumeSnapshot finished")
- parentName, snapName, isSnap := shared.ContainerGetParentAndSnapshotName(volName)
+ parentName, snapName, isSnap := shared.InstanceGetParentAndSnapshotName(volName)
if !isSnap {
return fmt.Errorf("Volume name must be a snapshot")
}
diff --git a/lxd/storage/drivers/driver_cephfs.go b/lxd/storage/drivers/driver_cephfs.go
index 1d0071ac09..b3622e86ce 100644
--- a/lxd/storage/drivers/driver_cephfs.go
+++ b/lxd/storage/drivers/driver_cephfs.go
@@ -391,7 +391,7 @@ func (d *cephfs) CreateVolumeFromCopy(vol Volume, srcVol Volume, copySnapshots b
}
for _, srcSnapshot := range srcSnapshots {
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(srcSnapshot.name)
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(srcSnapshot.name)
// Mount the source snapshot.
err = srcSnapshot.MountTask(func(srcMountPath string, op *operations.Operation) error {
@@ -541,7 +541,7 @@ func (d *cephfs) RenameVolume(volType VolumeType, volName string, newName string
for _, snapshot := range snapshots {
// Figure out the snapshot paths.
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(snapshot.name)
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(snapshot.name)
oldCephSnapPath := filepath.Join(sourcePath, ".snap", snapName)
newCephSnapPath := filepath.Join(targetPath, ".snap", snapName)
oldPath := GetVolumeMountPath(d.name, volType, GetSnapshotVolumeName(volName, snapName))
diff --git a/lxd/storage/drivers/driver_dir.go b/lxd/storage/drivers/driver_dir.go
index 38641d5b00..9072a675a7 100644
--- a/lxd/storage/drivers/driver_dir.go
+++ b/lxd/storage/drivers/driver_dir.go
@@ -469,7 +469,7 @@ func (d *dir) copyVolume(vol Volume, srcVol Volume, srcSnapshots []Volume, op *o
// If copying snapshots is indicated, check the source isn't itself a snapshot.
if len(srcSnapshots) > 0 && !srcVol.IsSnapshot() {
for _, srcSnapshot := range srcSnapshots {
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(srcSnapshot.name)
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(srcSnapshot.name)
// Mount the source snapshot.
err = srcSnapshot.MountTask(func(srcMountPath string, op *operations.Operation) error {
@@ -607,7 +607,7 @@ func (d *dir) RenameVolume(volType VolumeType, volName string, newVolName string
for _, snapshot := range snapshots {
oldPath := snapshot.MountPath()
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(snapshot.name)
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(snapshot.name)
newPath := GetVolumeMountPath(d.name, vol.volType, GetSnapshotVolumeName(newVolName, snapName))
err := os.Rename(oldPath, newPath)
diff --git a/lxd/storage/drivers/utils.go b/lxd/storage/drivers/utils.go
index 71a496c72a..54cb77c16f 100644
--- a/lxd/storage/drivers/utils.go
+++ b/lxd/storage/drivers/utils.go
@@ -183,7 +183,7 @@ func GetVolumeMountPath(poolName string, volType VolumeType, volName string) str
// GetVolumeSnapshotDir gets the snapshot mount directory for the parent volume.
func GetVolumeSnapshotDir(poolName string, volType VolumeType, volName string) string {
- parent, _, _ := shared.ContainerGetParentAndSnapshotName(volName)
+ parent, _, _ := shared.InstanceGetParentAndSnapshotName(volName)
return shared.VarPath("storage-pools", poolName, fmt.Sprintf("%s-snapshots", string(volType)), project.Prefix("default", parent))
}
diff --git a/lxd/storage/drivers/volume.go b/lxd/storage/drivers/volume.go
index 1ac07aa453..9bfb687a44 100644
--- a/lxd/storage/drivers/volume.go
+++ b/lxd/storage/drivers/volume.go
@@ -105,7 +105,7 @@ func (v Volume) CreateMountPath() error {
// MountTask runs the supplied task after mounting the volume if needed. If the volume was mounted
// for this then it is unmounted when the task finishes.
func (v Volume) MountTask(task func(mountPath string, op *operations.Operation) error, op *operations.Operation) error {
- parentName, snapName, isSnap := shared.ContainerGetParentAndSnapshotName(v.name)
+ parentName, snapName, isSnap := shared.InstanceGetParentAndSnapshotName(v.name)
mountLockID := fmt.Sprintf("mount/%s/%s/%s", v.pool, v.volType, v.name)
umountLockID := fmt.Sprintf("umount/%s/%s/%s", v.pool, v.volType, v.name)
diff --git a/lxd/storage_btrfs.go b/lxd/storage_btrfs.go
index c598d76d89..99fa8d264d 100644
--- a/lxd/storage_btrfs.go
+++ b/lxd/storage_btrfs.go
@@ -782,7 +782,7 @@ func (s *storageBtrfs) StoragePoolVolumeRename(newName string) error {
}
for _, vol := range volumes {
- _, snapshotName, _ := shared.ContainerGetParentAndSnapshotName(vol.Name)
+ _, snapshotName, _ := shared.InstanceGetParentAndSnapshotName(vol.Name)
oldVolumeName := fmt.Sprintf("%s%s%s", s.volume.Name, shared.SnapshotDelimiter, snapshotName)
newVolumeName := fmt.Sprintf("%s%s%s", newName, shared.SnapshotDelimiter, snapshotName)
@@ -1030,7 +1030,7 @@ func (s *storageBtrfs) copySnapshot(target instance.Instance, source instance.In
sourceContainerSubvolumeName := driver.GetSnapshotMountPoint(source.Project(), s.pool.Name, sourceName)
targetContainerSubvolumeName := driver.GetSnapshotMountPoint(target.Project(), s.pool.Name, targetName)
- targetParentName, _, _ := shared.ContainerGetParentAndSnapshotName(target.Name())
+ targetParentName, _, _ := shared.InstanceGetParentAndSnapshotName(target.Name())
containersPath := driver.GetSnapshotMountPoint(target.Project(), s.pool.Name, targetParentName)
snapshotMntPointSymlinkTarget := shared.VarPath("storage-pools", s.pool.Name, "containers-snapshots", project.Prefix(target.Project(), targetParentName))
snapshotMntPointSymlink := shared.VarPath("snapshots", project.Prefix(target.Project(), targetParentName))
@@ -1109,7 +1109,7 @@ func (s *storageBtrfs) doCrossPoolContainerCopy(target instance.Instance, source
}
// create snapshot
- _, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name())
+ _, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name())
err = s.doContainerSnapshotCreate(target.Project(), fmt.Sprintf("%s/%s", target.Name(), snapOnlyName), target.Name())
if err != nil {
return err
@@ -1187,7 +1187,7 @@ func (s *storageBtrfs) ContainerCopy(target instance.Instance, source instance.I
return err
}
- _, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name())
+ _, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name())
newSnapName := fmt.Sprintf("%s/%s", target.Name(), snapOnlyName)
targetSnapshot, err := instanceLoadByProjectAndName(s.s, target.Project(), newSnapName)
if err != nil {
@@ -1462,7 +1462,7 @@ func btrfsSnapshotDeleteInternal(projectName, poolName string, snapshotName stri
os.Remove(sourceSnapshotMntPoint)
os.Remove(snapshotSubvolumeName)
- sourceName, _, _ := shared.ContainerGetParentAndSnapshotName(snapshotName)
+ sourceName, _, _ := shared.InstanceGetParentAndSnapshotName(snapshotName)
snapshotSubvolumePath := getSnapshotSubvolumePath(projectName, poolName, sourceName)
os.Remove(snapshotSubvolumePath)
if !shared.PathExists(snapshotSubvolumePath) {
@@ -1585,7 +1585,7 @@ func (s *storageBtrfs) ContainerSnapshotCreateEmpty(snapshotContainer instance.I
}
// Create the snapshot subvole path on the storage pool.
- sourceName, _, _ := shared.ContainerGetParentAndSnapshotName(snapshotContainer.Name())
+ sourceName, _, _ := shared.InstanceGetParentAndSnapshotName(snapshotContainer.Name())
snapshotSubvolumePath := getSnapshotSubvolumePath(snapshotContainer.Project(), s.pool.Name, sourceName)
snapshotSubvolumeName := driver.GetSnapshotMountPoint(snapshotContainer.Project(), s.pool.Name, snapshotContainer.Name())
if !shared.PathExists(snapshotSubvolumePath) {
@@ -1658,7 +1658,7 @@ func (s *storageBtrfs) doContainerBackupCreateOptimized(tmpPath string, backup b
}
for i, snap := range snapshots {
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name())
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name())
// Figure out previous and current subvolumes
prev := ""
@@ -1742,7 +1742,7 @@ func (s *storageBtrfs) doContainerBackupCreateVanilla(tmpPath string, backup bac
}
for _, snap := range snapshots {
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name())
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name())
// Mount the snapshot to a usable path
_, err := s.ContainerSnapshotStart(snap)
@@ -1813,7 +1813,7 @@ func (s *storageBtrfs) ContainerBackupCreate(path string, backup backup.Backup,
}
func (s *storageBtrfs) doContainerBackupLoadOptimized(info backup.Info, data io.ReadSeeker, tarArgs []string) error {
- containerName, _, _ := shared.ContainerGetParentAndSnapshotName(info.Name)
+ containerName, _, _ := shared.InstanceGetParentAndSnapshotName(info.Name)
containerMntPoint := driver.GetContainerMountPoint("default", s.pool.Name, "")
unpackDir, err := ioutil.TempDir(containerMntPoint, containerName)
@@ -2875,7 +2875,7 @@ func (s *storageBtrfs) copyVolume(sourcePool string, sourceName string, targetNa
// Ensure that the directories immediately preceding the subvolume directory exist.
if isDstSnapshot {
- volName, _, _ := shared.ContainerGetParentAndSnapshotName(targetName)
+ volName, _, _ := shared.InstanceGetParentAndSnapshotName(targetName)
customDir = driver.GetStoragePoolVolumeSnapshotMountPoint(s.pool.Name, volName)
} else {
customDir = driver.GetStoragePoolVolumeMountPoint(s.pool.Name, "")
@@ -2938,7 +2938,7 @@ func (s *storageBtrfs) doCrossPoolVolumeCopy(sourcePool string, sourceName strin
}
// create snapshot
- _, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name)
+ _, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name)
err = s.doVolumeSnapshotCreate(s.pool.Name, s.volume.Name, fmt.Sprintf("%s/%s", s.volume.Name, snapOnlyName))
if err != nil {
@@ -2995,7 +2995,7 @@ func (s *storageBtrfs) doVolumeSnapshotCreate(sourcePool string, sourceName stri
return err
}
- _, _, ok := shared.ContainerGetParentAndSnapshotName(targetName)
+ _, _, ok := shared.InstanceGetParentAndSnapshotName(targetName)
if !ok {
return err
}
@@ -3034,7 +3034,7 @@ func (s *storageBtrfs) StoragePoolVolumeSnapshotDelete() error {
return err
}
- sourceName, _, _ := shared.ContainerGetParentAndSnapshotName(s.volume.Name)
+ sourceName, _, _ := shared.InstanceGetParentAndSnapshotName(s.volume.Name)
storageVolumeSnapshotPath := driver.GetStoragePoolVolumeSnapshotMountPoint(s.pool.Name, sourceName)
empty, err := shared.PathIsEmpty(storageVolumeSnapshotPath)
if err == nil && empty {
@@ -3059,7 +3059,7 @@ func (s *storageBtrfs) StoragePoolVolumeSnapshotDelete() error {
}
func (s *storageBtrfs) StoragePoolVolumeSnapshotRename(newName string) error {
- sourceName, _, ok := shared.ContainerGetParentAndSnapshotName(s.volume.Name)
+ sourceName, _, ok := shared.InstanceGetParentAndSnapshotName(s.volume.Name)
fullSnapshotName := fmt.Sprintf("%s%s%s", sourceName, shared.SnapshotDelimiter, newName)
logger.Infof("Renaming BTRFS storage volume on storage pool \"%s\" from \"%s\" to \"%s\"", s.pool.Name, s.volume.Name, fullSnapshotName)
diff --git a/lxd/storage_ceph.go b/lxd/storage_ceph.go
index d9872487db..2b19a9134a 100644
--- a/lxd/storage_ceph.go
+++ b/lxd/storage_ceph.go
@@ -1073,7 +1073,7 @@ func (s *storageCeph) doCrossPoolContainerCopy(target instance.Instance, source
logger.Debugf("Trying to freeze the filesystem: %s: %s", msg, fsFreezeErr)
// create snapshot
- _, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name())
+ _, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name())
err = s.doContainerSnapshotCreate(target.Project(), fmt.Sprintf("%s/%s", target.Name(), snapOnlyName), target.Name())
if fsFreezeErr == nil {
msg, fsFreezeErr := shared.TryRunCommand("fsfreeze", "--unfreeze", destContainerMntPoint)
@@ -1216,11 +1216,11 @@ func (s *storageCeph) ContainerCopy(target instance.Instance, source instance.In
for i, snap := range snapshots {
prev := ""
if i > 0 {
- _, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(snapshots[i-1].Name())
+ _, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(snapshots[i-1].Name())
prev = fmt.Sprintf("snapshot_%s", snapOnlyName)
}
- _, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name())
+ _, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name())
lastSnap = fmt.Sprintf("snapshot_%s", snapOnlyName)
sourceVolumeName := fmt.Sprintf(
"%s/container_%s at snapshot_%s",
@@ -1584,7 +1584,7 @@ func (s *storageCeph) ContainerRestore(target instance.Instance, source instance
defer target.StorageStart()
}
- sourceContainerOnlyName, sourceSnapshotOnlyName, _ := shared.ContainerGetParentAndSnapshotName(sourceName)
+ sourceContainerOnlyName, sourceSnapshotOnlyName, _ := shared.InstanceGetParentAndSnapshotName(sourceName)
prefixedSourceSnapOnlyName := fmt.Sprintf("snapshot_%s", sourceSnapshotOnlyName)
err = cephRBDVolumeRestore(s.ClusterName, s.OSDPoolName,
project.Prefix(source.Project(), sourceContainerOnlyName), storagePoolVolumeTypeNameContainer,
@@ -1632,7 +1632,7 @@ func (s *storageCeph) ContainerSnapshotDelete(snapshotContainer instance.Instanc
snapshotContainerName := snapshotContainer.Name()
sourceContainerName, sourceContainerSnapOnlyName, _ :=
- shared.ContainerGetParentAndSnapshotName(snapshotContainerName)
+ shared.InstanceGetParentAndSnapshotName(snapshotContainerName)
snapshotName := fmt.Sprintf("snapshot_%s", sourceContainerSnapOnlyName)
rbdVolumeExists := cephRBDSnapshotExists(s.ClusterName, s.OSDPoolName,
@@ -1699,10 +1699,10 @@ func (s *storageCeph) ContainerSnapshotRename(c instance.Instance, newName strin
revert := true
- containerOnlyName, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(oldName)
+ containerOnlyName, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(oldName)
containerOnlyName = project.Prefix(c.Project(), containerOnlyName)
oldSnapOnlyName := fmt.Sprintf("snapshot_%s", snapOnlyName)
- _, newSnapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(newName)
+ _, newSnapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(newName)
newSnapOnlyName = fmt.Sprintf("snapshot_%s", newSnapOnlyName)
err := cephRBDVolumeSnapshotRename(s.ClusterName, s.OSDPoolName,
containerOnlyName, storagePoolVolumeTypeNameContainer, oldSnapOnlyName,
@@ -1747,7 +1747,7 @@ func (s *storageCeph) ContainerSnapshotStart(c instance.Instance) (bool, error)
revert := true
- containerOnlyName, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(containerName)
+ containerOnlyName, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(containerName)
containerOnlyName = project.Prefix(c.Project(), containerOnlyName)
// protect
@@ -1877,7 +1877,7 @@ func (s *storageCeph) ContainerSnapshotStop(c instance.Instance) (bool, error) {
logger.Debugf("Unmounted %s", containerMntPoint)
- containerOnlyName, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(containerName)
+ containerOnlyName, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(containerName)
containerOnlyName = project.Prefix(c.Project(), containerOnlyName)
cloneName := fmt.Sprintf("%s_%s_start_clone", containerOnlyName, snapOnlyName)
@@ -2712,7 +2712,7 @@ func (s *storageCeph) StoragePoolVolumeSnapshotCreate(target *api.StorageVolumeS
}
}
- sourceOnlyName, snapshotOnlyName, _ := shared.ContainerGetParentAndSnapshotName(target.Name)
+ sourceOnlyName, snapshotOnlyName, _ := shared.InstanceGetParentAndSnapshotName(target.Name)
snapshotName := fmt.Sprintf("snapshot_%s", snapshotOnlyName)
err := cephRBDSnapshotCreate(s.ClusterName, s.OSDPoolName, sourceOnlyName, storagePoolVolumeTypeNameCustom, snapshotName, s.UserName)
if err != nil {
@@ -2732,7 +2732,7 @@ func (s *storageCeph) StoragePoolVolumeSnapshotCreate(target *api.StorageVolumeS
}
func (s *storageCeph) doPoolVolumeSnapshotDelete(name string) error {
- sourceName, snapshotOnlyName, ok := shared.ContainerGetParentAndSnapshotName(name)
+ sourceName, snapshotOnlyName, ok := shared.InstanceGetParentAndSnapshotName(name)
if !ok {
return fmt.Errorf("Not a snapshot name")
}
@@ -2782,7 +2782,7 @@ func (s *storageCeph) StoragePoolVolumeSnapshotDelete() error {
func (s *storageCeph) StoragePoolVolumeSnapshotRename(newName string) error {
logger.Infof("Renaming CEPH storage volume on OSD storage pool \"%s\" from \"%s\" to \"%s\"", s.pool.Name, s.volume.Name, newName)
- sourceName, oldSnapOnlyName, ok := shared.ContainerGetParentAndSnapshotName(s.volume.Name)
+ sourceName, oldSnapOnlyName, ok := shared.InstanceGetParentAndSnapshotName(s.volume.Name)
if !ok {
return fmt.Errorf("Not a snapshot name")
}
@@ -2964,7 +2964,7 @@ func (s *storageCeph) MigrationSink(conn *websocket.Conn, op *operations.Operati
snaps, err := cephRBDVolumeListSnapshots(s.ClusterName, s.OSDPoolName, project.Prefix(args.Instance.Project(), instanceName), storagePoolVolumeTypeNameContainer, s.UserName)
if err == nil {
for _, snap := range snaps {
- snapOnlyName, _, _ := shared.ContainerGetParentAndSnapshotName(snap)
+ snapOnlyName, _, _ := shared.InstanceGetParentAndSnapshotName(snap)
if !strings.HasPrefix(snapOnlyName, "migration-send") {
continue
}
diff --git a/lxd/storage_ceph_utils.go b/lxd/storage_ceph_utils.go
index 00baa837d7..41cf3e8e97 100644
--- a/lxd/storage_ceph_utils.go
+++ b/lxd/storage_ceph_utils.go
@@ -758,7 +758,7 @@ func (s *storageCeph) copyWithoutSnapshotsFull(target instance.Instance, source
targetContainerName)
if sourceIsSnapshot {
sourceContainerOnlyName, sourceSnapshotOnlyName, _ :=
- shared.ContainerGetParentAndSnapshotName(sourceContainerName)
+ shared.InstanceGetParentAndSnapshotName(sourceContainerName)
oldVolumeName = fmt.Sprintf("%s/container_%s at snapshot_%s",
s.OSDPoolName, sourceContainerOnlyName,
sourceSnapshotOnlyName)
@@ -827,7 +827,7 @@ func (s *storageCeph) copyWithoutSnapshotsSparse(target instance.Instance, sourc
uuid.NewRandom().String())
if sourceIsSnapshot {
sourceContainerOnlyName, sourceSnapshotOnlyName, _ =
- shared.ContainerGetParentAndSnapshotName(sourceContainerName)
+ shared.InstanceGetParentAndSnapshotName(sourceContainerName)
snapshotName = fmt.Sprintf("snapshot_%s", sourceSnapshotOnlyName)
} else {
// create snapshot
@@ -1623,7 +1623,7 @@ func (s *storageCeph) cephRBDVolumeBackupCreate(tmpPath string, backup backup.Ba
// Create a temporary snapshot
snapshotName := fmt.Sprintf("zombie_snapshot_%s", uuid.NewRandom().String())
if sourceIsSnapshot {
- sourceContainerOnlyName, sourceSnapshotOnlyName, _ = shared.ContainerGetParentAndSnapshotName(sourceContainerName)
+ sourceContainerOnlyName, sourceSnapshotOnlyName, _ = shared.InstanceGetParentAndSnapshotName(sourceContainerName)
sourceContainerOnlyName = project.Prefix(source.Project(), sourceContainerOnlyName)
snapshotName = fmt.Sprintf("snapshot_%s", sourceSnapshotOnlyName)
} else {
@@ -1696,7 +1696,7 @@ func (s *storageCeph) cephRBDVolumeBackupCreate(tmpPath string, backup backup.Ba
// Figure out the target name
targetName := sourceContainerName
if sourceIsSnapshot {
- _, targetName, _ = shared.ContainerGetParentAndSnapshotName(sourceContainerName)
+ _, targetName, _ = shared.InstanceGetParentAndSnapshotName(sourceContainerName)
}
// Create the path for the backup.
@@ -1865,7 +1865,7 @@ func (s *storageCeph) doContainerSnapshotCreate(projectName, targetName string,
revert := true
- _, targetSnapshotOnlyName, _ := shared.ContainerGetParentAndSnapshotName(targetName)
+ _, targetSnapshotOnlyName, _ := shared.InstanceGetParentAndSnapshotName(targetName)
targetSnapshotName := fmt.Sprintf("snapshot_%s", targetSnapshotOnlyName)
err := cephRBDSnapshotCreate(s.ClusterName, s.OSDPoolName,
project.Prefix(projectName, sourceName), storagePoolVolumeTypeNameContainer,
@@ -1890,7 +1890,7 @@ func (s *storageCeph) doContainerSnapshotCreate(projectName, targetName string,
}()
targetContainerMntPoint := driver.GetSnapshotMountPoint(projectName, s.pool.Name, targetName)
- sourceOnlyName, _, _ := shared.ContainerGetParentAndSnapshotName(sourceName)
+ sourceOnlyName, _, _ := shared.InstanceGetParentAndSnapshotName(sourceName)
snapshotMntPointSymlinkTarget := shared.VarPath("storage-pools", s.pool.Name, "containers-snapshots", project.Prefix(projectName, sourceOnlyName))
snapshotMntPointSymlink := shared.VarPath("snapshots", project.Prefix(projectName, sourceOnlyName))
err = driver.CreateSnapshotMountpoint(targetContainerMntPoint, snapshotMntPointSymlinkTarget, snapshotMntPointSymlink)
@@ -1950,7 +1950,7 @@ func (s *storageCeph) doCrossPoolVolumeCopy(source *api.StorageVolumeSource) err
if !source.VolumeOnly {
for _, snap := range snapshots {
- _, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name)
+ _, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name)
srcSnapshotMntPoint := driver.GetStoragePoolVolumeSnapshotMountPoint(source.Pool, snap.Name)
_, err = rsync.LocalCopy(srcSnapshotMntPoint, dstVolumeMntPoint, bwlimit, true)
@@ -1989,7 +1989,7 @@ func (s *storageCeph) copyVolumeWithoutSnapshotsFull(source *api.StorageVolumeSo
isSnapshot := shared.IsSnapshot(source.Name)
if isSnapshot {
- _, srcSnapshotOnlyName, _ := shared.ContainerGetParentAndSnapshotName(source.Name)
+ _, srcSnapshotOnlyName, _ := shared.InstanceGetParentAndSnapshotName(source.Name)
oldVolumeName = fmt.Sprintf("%s/snapshot_%s", s.OSDPoolName, srcSnapshotOnlyName)
} else {
oldVolumeName = fmt.Sprintf("%s/custom_%s", s.OSDPoolName, source.Name)
@@ -2021,7 +2021,7 @@ func (s *storageCeph) copyVolumeWithoutSnapshotsFull(source *api.StorageVolumeSo
}
func (s *storageCeph) copyVolumeWithoutSnapshotsSparse(source *api.StorageVolumeSource) error {
- sourceOnlyName, snapshotOnlyName, isSnapshot := shared.ContainerGetParentAndSnapshotName(source.Name)
+ sourceOnlyName, snapshotOnlyName, isSnapshot := shared.InstanceGetParentAndSnapshotName(source.Name)
if isSnapshot {
snapshotOnlyName = fmt.Sprintf("snapshot_%s", snapshotOnlyName)
diff --git a/lxd/storage_cephfs.go b/lxd/storage_cephfs.go
index 61de5d7284..51e694e098 100644
--- a/lxd/storage_cephfs.go
+++ b/lxd/storage_cephfs.go
@@ -806,7 +806,7 @@ func (s *storageCephFs) StoragePoolVolumeCopy(source *api.StorageVolumeSource) e
}
for _, snap := range snapshots {
- _, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name)
+ _, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name)
err = s.copyVolume(source.Pool, snap.Name, fmt.Sprintf("%s/%s", s.volume.Name, snapOnlyName))
if err != nil {
return err
@@ -854,7 +854,7 @@ func (s *storageCephFs) StoragePoolVolumeSnapshotCreate(target *api.StorageVolum
}
// Parse the name
- sourceName, snapName, ok := shared.ContainerGetParentAndSnapshotName(target.Name)
+ sourceName, snapName, ok := shared.InstanceGetParentAndSnapshotName(target.Name)
if !ok {
return fmt.Errorf("Not a snapshot name")
}
@@ -894,7 +894,7 @@ func (s *storageCephFs) StoragePoolVolumeSnapshotDelete() error {
}
// Parse the name
- sourceName, snapName, ok := shared.ContainerGetParentAndSnapshotName(s.volume.Name)
+ sourceName, snapName, ok := shared.InstanceGetParentAndSnapshotName(s.volume.Name)
if !ok {
return fmt.Errorf("Not a snapshot name")
}
@@ -936,7 +936,7 @@ func (s *storageCephFs) StoragePoolVolumeSnapshotRename(newName string) error {
}
// Rename the snapshot entry
- sourceName, oldSnapName, _ := shared.ContainerGetParentAndSnapshotName(s.volume.Name)
+ sourceName, oldSnapName, _ := shared.InstanceGetParentAndSnapshotName(s.volume.Name)
sourcePath := driver.GetStoragePoolVolumeMountPoint(s.pool.Name, sourceName)
oldCephSnapPath := filepath.Join(sourcePath, ".snap", oldSnapName)
newCephSnapPath := filepath.Join(sourcePath, ".snap", newName)
@@ -980,7 +980,7 @@ func (s *storageCephFs) copyVolume(sourcePool string, source string, target stri
}
// Split target name
- targetVolName, targetSnapName, ok := shared.ContainerGetParentAndSnapshotName(target)
+ targetVolName, targetSnapName, ok := shared.InstanceGetParentAndSnapshotName(target)
// Figure out target path
dstMountPoint := driver.GetStoragePoolVolumeMountPoint(s.pool.Name, targetVolName)
diff --git a/lxd/storage_dir.go b/lxd/storage_dir.go
index 91cb164f98..a72fc65b66 100644
--- a/lxd/storage_dir.go
+++ b/lxd/storage_dir.go
@@ -702,7 +702,7 @@ func (s *storageDir) copySnapshot(target instance.Instance, targetPool string, s
sourceContainerMntPoint := driver.GetSnapshotMountPoint(source.Project(), sourcePool, sourceName)
targetContainerMntPoint := driver.GetSnapshotMountPoint(target.Project(), targetPool, targetName)
- targetParentName, _, _ := shared.ContainerGetParentAndSnapshotName(target.Name())
+ targetParentName, _, _ := shared.InstanceGetParentAndSnapshotName(target.Name())
containersPath := driver.GetSnapshotMountPoint(target.Project(), targetPool, targetParentName)
snapshotMntPointSymlinkTarget := shared.VarPath("storage-pools", targetPool, "containers-snapshots", project.Prefix(target.Project(), targetParentName))
snapshotMntPointSymlink := shared.VarPath("snapshots", project.Prefix(target.Project(), targetParentName))
@@ -803,7 +803,7 @@ func (s *storageDir) doContainerCopy(target instance.Instance, source instance.I
return err
}
- _, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name())
+ _, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name())
newSnapName := fmt.Sprintf("%s/%s", target.Name(), snapOnlyName)
targetSnapshot, err := instanceLoadByProjectAndName(s.s, source.Project(), newSnapName)
if err != nil {
@@ -1044,7 +1044,7 @@ func (s *storageDir) ContainerSnapshotCreateEmpty(snapshotContainer instance.Ins
// exists and if not create it.
targetContainerMntPoint = driver.GetSnapshotMountPoint(snapshotContainer.Project(), s.pool.Name,
targetContainerName)
- sourceName, _, _ := shared.ContainerGetParentAndSnapshotName(targetContainerName)
+ sourceName, _, _ := shared.InstanceGetParentAndSnapshotName(targetContainerName)
snapshotMntPointSymlinkTarget := shared.VarPath("storage-pools",
s.pool.Name, "containers-snapshots", project.Prefix(snapshotContainer.Project(), sourceName))
snapshotMntPointSymlink := shared.VarPath("snapshots", project.Prefix(snapshotContainer.Project(), sourceName))
@@ -1069,7 +1069,7 @@ func dirSnapshotDeleteInternal(projectName, poolName string, snapshotName string
}
}
- sourceContainerName, _, _ := shared.ContainerGetParentAndSnapshotName(snapshotName)
+ sourceContainerName, _, _ := shared.InstanceGetParentAndSnapshotName(snapshotName)
snapshotContainerPath := driver.GetSnapshotMountPoint(projectName, poolName, sourceContainerName)
empty, _ := shared.PathIsEmpty(snapshotContainerPath)
if empty == true {
@@ -1174,7 +1174,7 @@ func (s *storageDir) ContainerBackupCreate(path string, backup backup.Backup, so
}
for _, snap := range snapshots {
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name())
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name())
snapshotMntPoint := driver.GetSnapshotMountPoint(snap.Project(), s.pool.Name, snap.Name())
target := fmt.Sprintf("%s/%s", snapshotsPath, snapName)
@@ -1422,7 +1422,7 @@ func (s *storageDir) StoragePoolVolumeCopy(source *api.StorageVolumeSource) erro
}
for _, snap := range snapshots {
- _, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name)
+ _, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name)
err = s.copyVolumeSnapshot(source.Pool, snap.Name, fmt.Sprintf("%s/%s", s.volume.Name, snapOnlyName))
if err != nil {
return err
@@ -1454,7 +1454,7 @@ func (s *storageDir) StoragePoolVolumeSnapshotCreate(target *api.StorageVolumeSn
return fmt.Errorf("no \"source\" property found for the storage pool")
}
- sourceName, _, ok := shared.ContainerGetParentAndSnapshotName(target.Name)
+ sourceName, _, ok := shared.InstanceGetParentAndSnapshotName(target.Name)
if !ok {
return fmt.Errorf("Not a snapshot name")
}
@@ -1490,7 +1490,7 @@ func (s *storageDir) StoragePoolVolumeSnapshotDelete() error {
return err
}
- sourceName, _, _ := shared.ContainerGetParentAndSnapshotName(s.volume.Name)
+ sourceName, _, _ := shared.InstanceGetParentAndSnapshotName(s.volume.Name)
storageVolumeSnapshotPath := driver.GetStoragePoolVolumeSnapshotMountPoint(s.pool.Name, sourceName)
empty, err := shared.PathIsEmpty(storageVolumeSnapshotPath)
if err == nil && empty {
@@ -1512,7 +1512,7 @@ func (s *storageDir) StoragePoolVolumeSnapshotDelete() error {
}
func (s *storageDir) StoragePoolVolumeSnapshotRename(newName string) error {
- sourceName, _, ok := shared.ContainerGetParentAndSnapshotName(s.volume.Name)
+ sourceName, _, ok := shared.InstanceGetParentAndSnapshotName(s.volume.Name)
fullSnapshotName := fmt.Sprintf("%s%s%s", sourceName, shared.SnapshotDelimiter, newName)
logger.Infof("Renaming DIR storage volume on storage pool \"%s\" from \"%s\" to \"%s\"", s.pool.Name, s.volume.Name, fullSnapshotName)
diff --git a/lxd/storage_lvm.go b/lxd/storage_lvm.go
index a49fbac4c4..8fef0f4735 100644
--- a/lxd/storage_lvm.go
+++ b/lxd/storage_lvm.go
@@ -906,7 +906,7 @@ func (s *storageLvm) StoragePoolVolumeRename(newName string) error {
s.volume.Name, newName, err)
}
- sourceName, _, ok := shared.ContainerGetParentAndSnapshotName(s.volume.Name)
+ sourceName, _, ok := shared.InstanceGetParentAndSnapshotName(s.volume.Name)
if !ok {
return fmt.Errorf("Not a snapshot name")
}
@@ -967,7 +967,7 @@ func (s *storageLvm) ContainerCreate(container instance.Instance) error {
if container.IsSnapshot() {
containerMntPoint := driver.GetSnapshotMountPoint(container.Project(), s.pool.Name, containerName)
- sourceName, _, _ := shared.ContainerGetParentAndSnapshotName(containerName)
+ sourceName, _, _ := shared.InstanceGetParentAndSnapshotName(containerName)
snapshotMntPointSymlinkTarget := shared.VarPath("storage-pools", s.pool.Name, "containers-snapshots", project.Prefix(container.Project(), sourceName))
snapshotMntPointSymlink := shared.VarPath("snapshots", project.Prefix(container.Project(), sourceName))
err := os.MkdirAll(containerMntPoint, 0711)
@@ -1098,7 +1098,7 @@ func lvmContainerDeleteInternal(projectName, poolName string, ctName string, isS
var err error
if isSnapshot {
- sourceName, _, _ := shared.ContainerGetParentAndSnapshotName(ctName)
+ sourceName, _, _ := shared.InstanceGetParentAndSnapshotName(ctName)
snapshotMntPointSymlinkTarget := shared.VarPath("storage-pools", poolName, "containers-snapshots", project.Prefix(projectName, sourceName))
snapshotMntPointSymlink := shared.VarPath("snapshots", project.Prefix(projectName, sourceName))
err = deleteSnapshotMountpoint(containerMntPoint, snapshotMntPointSymlinkTarget, snapshotMntPointSymlink)
@@ -1198,7 +1198,7 @@ func (s *storageLvm) doContainerCopy(target instance.Instance, source instance.I
}
for _, snap := range snapshots {
- _, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name())
+ _, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name())
newSnapName := fmt.Sprintf("%s/%s", target.Name(), snapOnlyName)
logger.Debugf("Copying LVM container storage for snapshot %s to %s", snap.Name(), newSnapName)
@@ -1711,7 +1711,7 @@ func (s *storageLvm) ContainerBackupCreate(path string, backup backup.Backup, so
}
for _, snap := range snapshots {
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name())
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name())
snapshotMntPoint := driver.GetSnapshotMountPoint(snap.Project(), s.pool.Name, snap.Name())
target := fmt.Sprintf("%s/%s", snapshotsPath, snapName)
@@ -1842,7 +1842,7 @@ func (s *storageLvm) doContainerBackupLoad(projectName, containerName string, pr
err = lvmCreateLv(projectName, poolName, thinPoolName, containerLvmName, lvFsType, lvSize,
storagePoolVolumeAPIEndpointContainers, s.useThinpool)
} else {
- cname, _, _ := shared.ContainerGetParentAndSnapshotName(containerName)
+ cname, _, _ := shared.InstanceGetParentAndSnapshotName(containerName)
_, err = s.createSnapshotLV(projectName, poolName, cname, storagePoolVolumeAPIEndpointContainers,
containerLvmName, storagePoolVolumeAPIEndpointContainers, false, s.useThinpool)
}
@@ -1869,7 +1869,7 @@ func (s *storageLvm) doContainerBackupLoad(projectName, containerName string, pr
}
if snapshot {
- cname, _, _ := shared.ContainerGetParentAndSnapshotName(containerName)
+ cname, _, _ := shared.InstanceGetParentAndSnapshotName(containerName)
snapshotMntPointSymlink := shared.VarPath("snapshots", project.Prefix(projectName, cname))
snapshotMntPointSymlinkTarget := shared.VarPath("storage-pools", s.pool.Name, "containers-snapshots", project.Prefix(projectName, cname))
err = driver.CreateSnapshotMountpoint(containerMntPoint, snapshotMntPointSymlinkTarget,
@@ -2267,7 +2267,7 @@ func (s *storageLvm) StoragePoolVolumeSnapshotCreate(target *api.StorageVolumeSn
logger.Debugf("Creating LVM storage volume for snapshot \"%s\" on storage pool \"%s\"", s.volume.Name, s.pool.Name)
poolName := s.getOnDiskPoolName()
- sourceOnlyName, _, ok := shared.ContainerGetParentAndSnapshotName(target.Name)
+ sourceOnlyName, _, ok := shared.InstanceGetParentAndSnapshotName(target.Name)
if !ok {
return fmt.Errorf("Not a snapshot")
}
@@ -2318,7 +2318,7 @@ func (s *storageLvm) StoragePoolVolumeSnapshotDelete() error {
return err
}
- sourceName, _, _ := shared.ContainerGetParentAndSnapshotName(s.volume.Name)
+ sourceName, _, _ := shared.InstanceGetParentAndSnapshotName(s.volume.Name)
storageVolumeSnapshotPath = driver.GetStoragePoolVolumeSnapshotMountPoint(s.pool.Name, sourceName)
empty, err := shared.PathIsEmpty(storageVolumeSnapshotPath)
if err == nil && empty {
@@ -2340,7 +2340,7 @@ func (s *storageLvm) StoragePoolVolumeSnapshotDelete() error {
}
func (s *storageLvm) StoragePoolVolumeSnapshotRename(newName string) error {
- sourceName, _, ok := shared.ContainerGetParentAndSnapshotName(s.volume.Name)
+ sourceName, _, ok := shared.InstanceGetParentAndSnapshotName(s.volume.Name)
fullSnapshotName := fmt.Sprintf("%s%s%s", sourceName, shared.SnapshotDelimiter, newName)
logger.Infof("Renaming LVM storage volume on storage pool \"%s\" from \"%s\" to \"%s\"", s.pool.Name, s.volume.Name, fullSnapshotName)
diff --git a/lxd/storage_lvm_utils.go b/lxd/storage_lvm_utils.go
index 4362f09878..c6cdaf0793 100644
--- a/lxd/storage_lvm_utils.go
+++ b/lxd/storage_lvm_utils.go
@@ -287,7 +287,7 @@ func (s *storageLvm) createSnapshotContainer(snapshotContainer instance.Instance
}
if targetIsSnapshot {
targetContainerMntPoint = driver.GetSnapshotMountPoint(sourceContainer.Project(), s.pool.Name, targetContainerName)
- sourceName, _, _ := shared.ContainerGetParentAndSnapshotName(sourceContainerName)
+ sourceName, _, _ := shared.InstanceGetParentAndSnapshotName(sourceContainerName)
snapshotMntPointSymlinkTarget := shared.VarPath("storage-pools", s.pool.Name, "containers-snapshots", project.Prefix(sourceContainer.Project(), sourceName))
snapshotMntPointSymlink := shared.VarPath("snapshots", project.Prefix(sourceContainer.Project(), sourceName))
err = driver.CreateSnapshotMountpoint(targetContainerMntPoint, snapshotMntPointSymlinkTarget, snapshotMntPointSymlink)
@@ -349,7 +349,7 @@ func (s *storageLvm) copySnapshot(target instance.Instance, source instance.Inst
return err
}
- targetParentName, _, _ := shared.ContainerGetParentAndSnapshotName(target.Name())
+ targetParentName, _, _ := shared.InstanceGetParentAndSnapshotName(target.Name())
containersPath := driver.GetSnapshotMountPoint(target.Project(), s.pool.Name, targetParentName)
snapshotMntPointSymlinkTarget := shared.VarPath("storage-pools", s.pool.Name, "containers-snapshots", project.Prefix(target.Project(), targetParentName))
snapshotMntPointSymlink := shared.VarPath("snapshots", project.Prefix(target.Project(), targetParentName))
@@ -973,7 +973,7 @@ func (s *storageLvm) copyVolume(sourcePool string, source string) error {
}
func (s *storageLvm) copyVolumeSnapshot(sourcePool string, source string) error {
- _, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(source)
+ _, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(source)
target := fmt.Sprintf("%s/%s", s.volume.Name, snapOnlyName)
targetMntPoint := driver.GetStoragePoolVolumeSnapshotMountPoint(s.pool.Name, target)
diff --git a/lxd/storage_migration.go b/lxd/storage_migration.go
index d8ef5561d9..c1bcdd2c37 100644
--- a/lxd/storage_migration.go
+++ b/lxd/storage_migration.go
@@ -94,7 +94,7 @@ func (s rsyncStorageSourceDriver) SendStorageVolume(conn *websocket.Conn, op *op
}
func (s rsyncStorageSourceDriver) SendWhileRunning(conn *websocket.Conn, op *operations.Operation, bwlimit string, containerOnly bool) error {
- ctName, _, _ := shared.ContainerGetParentAndSnapshotName(s.container.Name())
+ ctName, _, _ := shared.InstanceGetParentAndSnapshotName(s.container.Name())
if !containerOnly {
for _, send := range s.snapshots {
@@ -133,7 +133,7 @@ func (s rsyncStorageSourceDriver) SendWhileRunning(conn *websocket.Conn, op *ope
}
func (s rsyncStorageSourceDriver) SendAfterCheckpoint(conn *websocket.Conn, bwlimit string) error {
- ctName, _, _ := shared.ContainerGetParentAndSnapshotName(s.container.Name())
+ ctName, _, _ := shared.InstanceGetParentAndSnapshotName(s.container.Name())
// resync anything that changed between our first send and the checkpoint
state := s.container.DaemonState()
return rsync.Send(project.Prefix(s.container.Project(), ctName), shared.AddSlash(s.container.Path()), &shared.WebsocketIO{Conn: conn}, nil, s.rsyncFeatures, bwlimit, state.OS.ExecPath)
@@ -156,7 +156,7 @@ func rsyncRefreshSource(refreshSnapshots []string, args MigrationSourceArgs) (Mi
}
for _, snap := range allSnapshots {
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name())
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name())
if !shared.StringInSlice(snapName, refreshSnapshots) {
continue
}
diff --git a/lxd/storage_migration_btrfs.go b/lxd/storage_migration_btrfs.go
index 3b95273e70..1f52f3076e 100644
--- a/lxd/storage_migration_btrfs.go
+++ b/lxd/storage_migration_btrfs.go
@@ -86,7 +86,7 @@ func (s *btrfsMigrationSourceDriver) SendWhileRunning(conn *websocket.Conn, op *
// Deal with sending a snapshot to create a container on another LXD
// instance.
if s.container.IsSnapshot() {
- sourceName, _, _ := shared.ContainerGetParentAndSnapshotName(containerName)
+ sourceName, _, _ := shared.InstanceGetParentAndSnapshotName(containerName)
snapshotsPath := driver.GetSnapshotMountPoint(s.container.Project(), containerPool, sourceName)
tmpContainerMntPoint, err := ioutil.TempDir(snapshotsPath, sourceName)
if err != nil {
@@ -168,7 +168,7 @@ func (s *btrfsMigrationSourceDriver) SendAfterCheckpoint(conn *websocket.Conn, b
}
s.stoppedSnapName = fmt.Sprintf("%s/.root", tmpPath)
- parentName, _, _ := shared.ContainerGetParentAndSnapshotName(s.container.Name())
+ parentName, _, _ := shared.InstanceGetParentAndSnapshotName(s.container.Name())
containerMntPt := driver.GetContainerMountPoint(s.container.Project(), s.btrfs.pool.Name, parentName)
err = s.btrfs.btrfsPoolVolumesSnapshot(containerMntPt, s.stoppedSnapName, true, true)
if err != nil {
diff --git a/lxd/storage_migration_ceph.go b/lxd/storage_migration_ceph.go
index 851697c3e1..c590569c56 100644
--- a/lxd/storage_migration_ceph.go
+++ b/lxd/storage_migration_ceph.go
@@ -81,7 +81,7 @@ func (s *rbdMigrationSourceDriver) SendWhileRunning(conn *websocket.Conn,
if s.container.IsSnapshot() {
// ContainerSnapshotStart() will create the clone that is
// referenced by sendName here.
- containerOnlyName, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(containerName)
+ containerOnlyName, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(containerName)
sendName := fmt.Sprintf(
"%s/snapshots_%s_%s_start_clone",
s.ceph.OSDPoolName,
diff --git a/lxd/storage_migration_zfs.go b/lxd/storage_migration_zfs.go
index 9568918208..8bbb56a511 100644
--- a/lxd/storage_migration_zfs.go
+++ b/lxd/storage_migration_zfs.go
@@ -28,7 +28,7 @@ type zfsMigrationSourceDriver struct {
}
func (s *zfsMigrationSourceDriver) send(conn *websocket.Conn, zfsName string, zfsParent string, readWrapper func(io.ReadCloser) io.ReadCloser) error {
- sourceParentName, _, _ := shared.ContainerGetParentAndSnapshotName(s.instance.Name())
+ sourceParentName, _, _ := shared.InstanceGetParentAndSnapshotName(s.instance.Name())
poolName := s.zfs.getOnDiskPoolName()
args := []string{"send"}
@@ -83,7 +83,7 @@ func (s *zfsMigrationSourceDriver) send(conn *websocket.Conn, zfsName string, zf
func (s *zfsMigrationSourceDriver) SendWhileRunning(conn *websocket.Conn, op *operations.Operation, bwlimit string, containerOnly bool) error {
if s.instance.IsSnapshot() {
- _, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(s.instance.Name())
+ _, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(s.instance.Name())
snapshotName := fmt.Sprintf("snapshot-%s", snapOnlyName)
wrapper := migration.ProgressReader(op, "fs_progress", s.instance.Name())
return s.send(conn, snapshotName, "", wrapper)
diff --git a/lxd/storage_pools_utils.go b/lxd/storage_pools_utils.go
index 42aa9d24f2..61b57705bc 100644
--- a/lxd/storage_pools_utils.go
+++ b/lxd/storage_pools_utils.go
@@ -111,7 +111,7 @@ func storagePoolUsedByGet(state *state.State, poolID int64, poolName string) ([]
switch apiEndpoint {
case storagePoolVolumeAPIEndpointContainers:
if strings.Index(volumes[i].Name, shared.SnapshotDelimiter) > 0 {
- parentName, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(volumes[i].Name)
+ parentName, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(volumes[i].Name)
poolUsedBy[i] = fmt.Sprintf("/%s/containers/%s/snapshots/%s", version.APIVersion, parentName, snapOnlyName)
} else {
poolUsedBy[i] = fmt.Sprintf("/%s/containers/%s", version.APIVersion, volumes[i].Name)
diff --git a/lxd/storage_volumes.go b/lxd/storage_volumes.go
index 9c8954091d..ef17b367d9 100644
--- a/lxd/storage_volumes.go
+++ b/lxd/storage_volumes.go
@@ -139,7 +139,7 @@ func storagePoolVolumesGet(d *Daemon, r *http.Request) response.Response {
}
if !recursion {
- volName, snapName, ok := shared.ContainerGetParentAndSnapshotName(volume.Name)
+ volName, snapName, ok := shared.InstanceGetParentAndSnapshotName(volume.Name)
if ok {
resultString = append(resultString,
fmt.Sprintf("/%s/storage-pools/%s/volumes/%s/%s/snapshots/%s",
diff --git a/lxd/storage_volumes_snapshot.go b/lxd/storage_volumes_snapshot.go
index 7e21741a34..b0bf02ab76 100644
--- a/lxd/storage_volumes_snapshot.go
+++ b/lxd/storage_volumes_snapshot.go
@@ -216,7 +216,7 @@ func storagePoolVolumeSnapshotsTypeGet(d *Daemon, r *http.Request) response.Resp
resultString := []string{}
resultMap := []*api.StorageVolumeSnapshot{}
for _, volume := range volumes {
- _, snapshotName, _ := shared.ContainerGetParentAndSnapshotName(volume.Name)
+ _, snapshotName, _ := shared.InstanceGetParentAndSnapshotName(volume.Name)
if !recursion {
apiEndpoint, err := storagePoolVolumeTypeToAPIEndpoint(volumeType)
diff --git a/lxd/storage_volumes_utils.go b/lxd/storage_volumes_utils.go
index dd5a672b34..40d8ca789a 100644
--- a/lxd/storage_volumes_utils.go
+++ b/lxd/storage_volumes_utils.go
@@ -411,7 +411,7 @@ func storagePoolVolumeUsedByRunningInstancesWithProfilesGet(s *state.State,
func storagePoolVolumeUsedByGet(s *state.State, project, poolName string, volumeName string, volumeTypeName string) ([]string, error) {
// Handle container volumes
if volumeTypeName == "container" {
- cName, sName, snap := shared.ContainerGetParentAndSnapshotName(volumeName)
+ cName, sName, snap := shared.InstanceGetParentAndSnapshotName(volumeName)
if snap {
return []string{fmt.Sprintf("/%s/containers/%s/snapshots/%s", version.APIVersion, cName, sName)}, nil
@@ -579,7 +579,7 @@ func storagePoolVolumeCreateInternal(state *state.State, poolName string, vol *a
}
for _, snap := range snapshots {
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name)
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name)
_, err := storagePoolVolumeSnapshotCopyInternal(state, poolName, vol, snapName)
if err != nil {
return err
diff --git a/lxd/storage_zfs.go b/lxd/storage_zfs.go
index 53caec7604..f154dcb1fe 100644
--- a/lxd/storage_zfs.go
+++ b/lxd/storage_zfs.go
@@ -942,7 +942,7 @@ func (s *storageZfs) copyWithoutSnapshotsSparse(target instance.Instance, source
sourceZfsDataset := ""
sourceZfsDatasetSnapshot := ""
- sourceName, sourceSnapOnlyName, isSnapshotName := shared.ContainerGetParentAndSnapshotName(sourceContainerName)
+ sourceName, sourceSnapOnlyName, isSnapshotName := shared.InstanceGetParentAndSnapshotName(sourceContainerName)
targetZfsDataset := fmt.Sprintf("containers/%s", project.Prefix(target.Project(), targetContainerName))
@@ -1047,7 +1047,7 @@ func (s *storageZfs) copyWithoutSnapshotFull(target instance.Instance, source in
targetSnapshotDataset := ""
if sourceIsSnapshot {
- sourceParentName, sourceSnapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(source.Name())
+ sourceParentName, sourceSnapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(source.Name())
snapshotSuffix = fmt.Sprintf("snapshot-%s", sourceSnapOnlyName)
sourceDataset = fmt.Sprintf("%s/containers/%s@%s", poolName, project.Prefix(source.Project(), sourceParentName), snapshotSuffix)
targetSnapshotDataset = fmt.Sprintf("%s/containers/%s at snapshot-%s", poolName, project.Prefix(target.Project(), targetName), sourceSnapOnlyName)
@@ -1135,7 +1135,7 @@ func (s *storageZfs) copyWithoutSnapshotFull(target instance.Instance, source in
func (s *storageZfs) copyWithSnapshots(target instance.Instance, source instance.Instance, parentSnapshot string) error {
sourceName := source.Name()
- targetParentName, targetSnapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(target.Name())
+ targetParentName, targetSnapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(target.Name())
containersPath := driver.GetSnapshotMountPoint(target.Project(), s.pool.Name, targetParentName)
snapshotMntPointSymlinkTarget := shared.VarPath("storage-pools", s.pool.Name, "containers-snapshots", project.Prefix(target.Project(), targetParentName))
snapshotMntPointSymlink := shared.VarPath("snapshots", project.Prefix(target.Project(), targetParentName))
@@ -1145,11 +1145,11 @@ func (s *storageZfs) copyWithSnapshots(target instance.Instance, source instance
}
poolName := s.getOnDiskPoolName()
- sourceParentName, sourceSnapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(sourceName)
+ sourceParentName, sourceSnapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(sourceName)
currentSnapshotDataset := fmt.Sprintf("%s/containers/%s at snapshot-%s", poolName, project.Prefix(source.Project(), sourceParentName), sourceSnapOnlyName)
args := []string{"send", currentSnapshotDataset}
if parentSnapshot != "" {
- parentName, parentSnaponlyName, _ := shared.ContainerGetParentAndSnapshotName(parentSnapshot)
+ parentName, parentSnaponlyName, _ := shared.InstanceGetParentAndSnapshotName(parentSnapshot)
parentSnapshotDataset := fmt.Sprintf("%s/containers/%s at snapshot-%s", poolName, project.Prefix(source.Project(), parentName), parentSnaponlyName)
args = append(args, "-i", parentSnapshotDataset)
}
@@ -1240,7 +1240,7 @@ func (s *storageZfs) doCrossPoolContainerCopy(target instance.Instance, source i
}
// create snapshot
- _, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name())
+ _, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name())
err = s.doContainerSnapshotCreate(snap.Project(), fmt.Sprintf("%s/%s", target.Name(), snapOnlyName), target.Name())
if err != nil {
return err
@@ -1324,7 +1324,7 @@ func (s *storageZfs) ContainerCopy(target instance.Instance, source instance.Ins
return err
}
- _, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name())
+ _, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name())
prevSnapOnlyName = snapOnlyName
newSnapName := fmt.Sprintf("%s/%s", target.Name(), snapOnlyName)
targetSnapshot, err := instanceLoadByProjectAndName(s.s, target.Project(), newSnapName)
@@ -1546,7 +1546,7 @@ func (s *storageZfs) ContainerRestore(target instance.Instance, source instance.
}
// Restore the snapshot
- cName, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(source.Name())
+ cName, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(source.Name())
snapName := fmt.Sprintf("snapshot-%s", snapOnlyName)
err = zfsPoolVolumeSnapshotRestore(s.getOnDiskPoolName(), fmt.Sprintf("containers/%s", project.Prefix(source.Project(), cName)), snapName)
@@ -1607,7 +1607,7 @@ func (s *storageZfs) doContainerSnapshotCreate(projectName, targetName string, s
sourceContainerName := sourceName
- cName, snapshotSnapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(snapshotContainerName)
+ cName, snapshotSnapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(snapshotContainerName)
snapName := fmt.Sprintf("snapshot-%s", snapshotSnapOnlyName)
sourceZfsDataset := fmt.Sprintf("containers/%s", project.Prefix(projectName, cName))
@@ -1647,7 +1647,7 @@ func (s *storageZfs) ContainerSnapshotCreate(snapshotContainer instance.Instance
}
func zfsSnapshotDeleteInternal(projectName, poolName string, ctName string, onDiskPoolName string) error {
- sourceContainerName, sourceContainerSnapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(ctName)
+ sourceContainerName, sourceContainerSnapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(ctName)
snapName := fmt.Sprintf("snapshot-%s", sourceContainerSnapOnlyName)
if zfsFilesystemEntityExists(onDiskPoolName,
@@ -1750,10 +1750,10 @@ func (s *storageZfs) ContainerSnapshotRename(snapshotContainer instance.Instance
oldName := snapshotContainer.Name()
- oldcName, oldSnapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(snapshotContainer.Name())
+ oldcName, oldSnapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(snapshotContainer.Name())
oldZfsDatasetName := fmt.Sprintf("snapshot-%s", oldSnapOnlyName)
- _, newSnapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(newName)
+ _, newSnapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(newName)
newZfsDatasetName := fmt.Sprintf("snapshot-%s", newSnapOnlyName)
if oldZfsDatasetName != newZfsDatasetName {
@@ -1813,7 +1813,7 @@ func (s *storageZfs) ContainerSnapshotRename(snapshotContainer instance.Instance
func (s *storageZfs) ContainerSnapshotStart(container instance.Instance) (bool, error) {
logger.Debugf("Initializing ZFS storage volume for snapshot \"%s\" on storage pool \"%s\"", s.volume.Name, s.pool.Name)
- cName, sName, _ := shared.ContainerGetParentAndSnapshotName(container.Name())
+ cName, sName, _ := shared.InstanceGetParentAndSnapshotName(container.Name())
sourceFs := fmt.Sprintf("containers/%s", project.Prefix(container.Project(), cName))
sourceSnap := fmt.Sprintf("snapshot-%s", sName)
destFs := fmt.Sprintf("snapshots/%s/%s", project.Prefix(container.Project(), cName), sName)
@@ -1837,7 +1837,7 @@ func (s *storageZfs) ContainerSnapshotStart(container instance.Instance) (bool,
func (s *storageZfs) ContainerSnapshotStop(container instance.Instance) (bool, error) {
logger.Debugf("Stopping ZFS storage volume for snapshot \"%s\" on storage pool \"%s\"", s.volume.Name, s.pool.Name)
- cName, sName, _ := shared.ContainerGetParentAndSnapshotName(container.Name())
+ cName, sName, _ := shared.InstanceGetParentAndSnapshotName(container.Name())
destFs := fmt.Sprintf("snapshots/%s/%s", project.Prefix(container.Project(), cName), sName)
err := zfsPoolVolumeDestroy(s.getOnDiskPoolName(), destFs)
@@ -1863,7 +1863,7 @@ func (s *storageZfs) doContainerOnlyBackup(tmpPath string, backup backup.Backup,
snapshotSuffix := ""
if sourceIsSnapshot {
- sourceParentName, sourceSnapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(source.Name())
+ sourceParentName, sourceSnapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(source.Name())
snapshotSuffix = fmt.Sprintf("backup-%s", sourceSnapOnlyName)
sourceDataset = fmt.Sprintf("%s/containers/%s@%s", poolName, project.Prefix(source.Project(), sourceParentName), snapshotSuffix)
} else {
@@ -1913,11 +1913,11 @@ func (s *storageZfs) doSnapshotBackup(tmpPath string, backup backup.Backup, sour
}
poolName := s.getOnDiskPoolName()
- sourceParentName, sourceSnapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(sourceName)
+ sourceParentName, sourceSnapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(sourceName)
currentSnapshotDataset := fmt.Sprintf("%s/containers/%s at snapshot-%s", poolName, project.Prefix(source.Project(), sourceParentName), sourceSnapOnlyName)
args := []string{"send", currentSnapshotDataset}
if parentSnapshot != "" {
- parentName, parentSnaponlyName, _ := shared.ContainerGetParentAndSnapshotName(parentSnapshot)
+ parentName, parentSnaponlyName, _ := shared.InstanceGetParentAndSnapshotName(parentSnapshot)
parentSnapshotDataset := fmt.Sprintf("%s/containers/%s at snapshot-%s", poolName, project.Prefix(source.Project(), parentName), parentSnaponlyName)
args = append(args, "-i", parentSnapshotDataset)
}
@@ -1956,7 +1956,7 @@ func (s *storageZfs) doContainerBackupCreateOptimized(tmpPath string, backup bac
return err
}
- _, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name())
+ _, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name())
prevSnapOnlyName = snapOnlyName
err = s.doSnapshotBackup(tmpPath, backup, sourceSnapshot, prev)
if err != nil {
@@ -2036,7 +2036,7 @@ func (s *storageZfs) doContainerBackupCreateVanilla(tmpPath string, backup backu
}
for _, snap := range snapshots {
- _, snapName, _ := shared.ContainerGetParentAndSnapshotName(snap.Name())
+ _, snapName, _ := shared.InstanceGetParentAndSnapshotName(snap.Name())
// Mount the snapshot to a usable path
_, err := s.ContainerSnapshotStart(snap)
@@ -2124,7 +2124,7 @@ func (s *storageZfs) ContainerBackupCreate(path string, backup backup.Backup, so
}
func (s *storageZfs) doContainerBackupLoadOptimized(info backup.Info, data io.ReadSeeker, tarArgs []string) error {
- containerName, _, _ := shared.ContainerGetParentAndSnapshotName(info.Name)
+ containerName, _, _ := shared.InstanceGetParentAndSnapshotName(info.Name)
containerMntPoint := driver.GetContainerMountPoint(info.Project, s.pool.Name, containerName)
err := driver.CreateContainerMountpoint(containerMntPoint, driver.InstancePath(instancetype.Container, info.Project, info.Name, false), info.Privileged)
if err != nil {
@@ -2869,7 +2869,7 @@ func (s *storageZfs) doCrossPoolStorageVolumeCopy(source *api.StorageVolumeSourc
return err
}
- _, snapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(source.Name)
+ _, snapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(source.Name)
s.StoragePoolVolumeSnapshotCreate(&api.StorageVolumeSnapshotsPost{Name: fmt.Sprintf("%s/%s", s.volume.Name, snapOnlyName)})
}
@@ -2905,7 +2905,7 @@ func (s *storageZfs) copyVolumeWithoutSnapshotsFull(source *api.StorageVolumeSou
poolName := s.getOnDiskPoolName()
if sourceIsSnapshot {
- sourceVolumeName, sourceSnapOnlyName, _ := shared.ContainerGetParentAndSnapshotName(source.Name)
+ sourceVolumeName, sourceSnapOnlyName, _ := shared.InstanceGetParentAndSnapshotName(source.Name)
snapshotSuffix = fmt.Sprintf("snapshot-%s", sourceSnapOnlyName)
sourceDataset = fmt.Sprintf("%s/custom/%s@%s", source.Pool, sourceVolumeName, snapshotSuffix)
targetSnapshotDataset = fmt.Sprintf("%s/custom/%s at snapshot-%s", poolName, s.volume.Name, sourceSnapOnlyName)
@@ -2988,7 +2988,7 @@ func (s *storageZfs) copyVolumeWithoutSnapshotsSparse(source *api.StorageVolumeS
sourceZfsDataset := ""
sourceZfsDatasetSnapshot := ""
- sourceName, sourceSnapOnlyName, isSnapshotName := shared.ContainerGetParentAndSnapshotName(sourceVolumeName)
+ sourceName, sourceSnapOnlyName, isSnapshotName := shared.InstanceGetParentAndSnapshotName(sourceVolumeName)
targetZfsDataset := fmt.Sprintf("custom/%s", targetVolumeName)
@@ -3233,7 +3233,7 @@ func (s *storageZfs) StorageMigrationSink(conn *websocket.Conn, op *operations.O
func (s *storageZfs) StoragePoolVolumeSnapshotCreate(target *api.StorageVolumeSnapshotsPost) error {
logger.Infof("Creating ZFS storage volume snapshot \"%s\" on storage pool \"%s\"", s.volume.Name, s.pool.Name)
- sourceOnlyName, snapshotOnlyName, ok := shared.ContainerGetParentAndSnapshotName(target.Name)
+ sourceOnlyName, snapshotOnlyName, ok := shared.InstanceGetParentAndSnapshotName(target.Name)
if !ok {
return fmt.Errorf("Not a snapshot name")
}
@@ -3261,7 +3261,7 @@ func (s *storageZfs) StoragePoolVolumeSnapshotCreate(target *api.StorageVolumeSn
func (s *storageZfs) StoragePoolVolumeSnapshotDelete() error {
logger.Infof("Deleting ZFS storage volume snapshot \"%s\" on storage pool \"%s\"", s.volume.Name, s.pool.Name)
- sourceName, snapshotOnlyName, _ := shared.ContainerGetParentAndSnapshotName(s.volume.Name)
+ sourceName, snapshotOnlyName, _ := shared.InstanceGetParentAndSnapshotName(s.volume.Name)
snapshotName := fmt.Sprintf("snapshot-%s", snapshotOnlyName)
onDiskPoolName := s.getOnDiskPoolName()
@@ -3308,7 +3308,7 @@ func (s *storageZfs) StoragePoolVolumeSnapshotDelete() error {
}
func (s *storageZfs) StoragePoolVolumeSnapshotRename(newName string) error {
- sourceName, snapshotOnlyName, ok := shared.ContainerGetParentAndSnapshotName(s.volume.Name)
+ sourceName, snapshotOnlyName, ok := shared.InstanceGetParentAndSnapshotName(s.volume.Name)
fullSnapshotName := fmt.Sprintf("%s%s%s", sourceName, shared.SnapshotDelimiter, newName)
logger.Infof("Renaming ZFS storage volume snapshot on storage pool \"%s\" from \"%s\" to \"%s\"", s.pool.Name, s.volume.Name, fullSnapshotName)
diff --git a/lxd/vm_qemu.go b/lxd/vm_qemu.go
index 3e6bd600bb..7f62c5d263 100644
--- a/lxd/vm_qemu.go
+++ b/lxd/vm_qemu.go
@@ -1673,7 +1673,7 @@ func (vm *vmQemu) Update(args db.InstanceArgs, userRequested bool) error {
var endpoint string
if vm.IsSnapshot() {
- parentName, snapName, _ := shared.ContainerGetParentAndSnapshotName(vm.name)
+ parentName, snapName, _ := shared.InstanceGetParentAndSnapshotName(vm.name)
endpoint = fmt.Sprintf("/1.0/virtual-machines/%s/snapshots/%s", parentName, snapName)
} else {
endpoint = fmt.Sprintf("/1.0/virtual-machines/%s", vm.name)
More information about the lxc-devel
mailing list