1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
package migration
// BTRFSFeatureMigrationHeader indicates a migration header will be sent/recv in data channel after index header.
const BTRFSFeatureMigrationHeader = "migration_header"
// BTRFSFeatureSubvolumes indicates migration can send/recv subvolumes.
const BTRFSFeatureSubvolumes = "header_subvolumes"
// BTRFSFeatureSubvolumeUUIDs indicates that the header will include subvolume UUIDs.
const BTRFSFeatureSubvolumeUUIDs = "header_subvolume_uuids"
// ZFSFeatureMigrationHeader indicates a migration header will be sent/recv in data channel after index header.
const ZFSFeatureMigrationHeader = "migration_header"
// ZFSFeatureZvolFilesystems indicates migration can send/recv zvols.
const ZFSFeatureZvolFilesystems = "header_zvol_filesystems"
// GetRsyncFeaturesSlice returns a slice of strings representing the supported RSYNC features.
func (m *MigrationHeader) GetRsyncFeaturesSlice() []string {
features := []string{}
if m == nil {
return features
}
if m.RsyncFeatures != nil {
if m.RsyncFeatures.Xattrs != nil && *m.RsyncFeatures.Xattrs {
features = append(features, "xattrs")
}
if m.RsyncFeatures.Delete != nil && *m.RsyncFeatures.Delete {
features = append(features, "delete")
}
if m.RsyncFeatures.Compress != nil && *m.RsyncFeatures.Compress {
features = append(features, "compress")
}
if m.RsyncFeatures.Bidirectional != nil && *m.RsyncFeatures.Bidirectional {
features = append(features, "bidirectional")
}
}
return features
}
// GetZfsFeaturesSlice returns a slice of strings representing the supported ZFS features.
func (m *MigrationHeader) GetZfsFeaturesSlice() []string {
features := []string{}
if m == nil {
return features
}
if m.ZfsFeatures != nil {
if m.ZfsFeatures.Compress != nil && *m.ZfsFeatures.Compress {
features = append(features, "compress")
}
if m.ZfsFeatures.MigrationHeader != nil && *m.ZfsFeatures.MigrationHeader {
features = append(features, ZFSFeatureMigrationHeader)
}
if m.ZfsFeatures.HeaderZvols != nil && *m.ZfsFeatures.HeaderZvols {
features = append(features, ZFSFeatureZvolFilesystems)
}
}
return features
}
// GetBtrfsFeaturesSlice returns a slice of strings representing the supported BTRFS features.
func (m *MigrationHeader) GetBtrfsFeaturesSlice() []string {
features := []string{}
if m == nil {
return features
}
if m.BtrfsFeatures != nil {
if m.BtrfsFeatures.MigrationHeader != nil && *m.BtrfsFeatures.MigrationHeader {
features = append(features, BTRFSFeatureMigrationHeader)
}
if m.BtrfsFeatures.HeaderSubvolumes != nil && *m.BtrfsFeatures.HeaderSubvolumes {
features = append(features, BTRFSFeatureSubvolumes)
}
if m.BtrfsFeatures.HeaderSubvolumeUuids != nil && *m.BtrfsFeatures.HeaderSubvolumeUuids {
features = append(features, BTRFSFeatureSubvolumeUUIDs)
}
}
return features
}
// GetSnapshotConfigValue retrieves the value associated with the given key from the snapshot LocalConfig.
func GetSnapshotConfigValue(snapshot *Snapshot, key string) string {
var value string
for _, c := range snapshot.LocalConfig {
if c.GetKey() != key {
continue
}
value = c.GetValue()
}
return value
}
// SetSnapshotConfigValue stores the given value for the specified key in the snapshot LocalConfig.
func SetSnapshotConfigValue(snapshot *Snapshot, key string, value string) {
for _, c := range snapshot.LocalConfig {
if c.GetKey() != key {
continue
}
c.Value = &value
return
}
config := Config{Key: &key, Value: &value}
snapshot.LocalConfig = append(snapshot.LocalConfig, &config)
}
|