From cc88d2fa09190c8f7598bf73452a806a84537d31 Mon Sep 17 00:00:00 2001 From: gman Date: Tue, 12 Jun 2018 17:02:14 +0200 Subject: [PATCH] cephfs: cephconf: include volume UUID in keyrings/secrets --- pkg/cephfs/cephconf.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pkg/cephfs/cephconf.go b/pkg/cephfs/cephconf.go index 58ac292e6..8c74b4fdd 100644 --- a/pkg/cephfs/cephconf.go +++ b/pkg/cephfs/cephconf.go @@ -52,8 +52,8 @@ const cephSecret = `{{.Key}}` const ( cephConfigRoot = "/etc/ceph" cephConfigFileNameFmt = "ceph.share.%s.conf" - cephKeyringFileNameFmt = "ceph.client.%s.keyring" - cephSecretFileNameFmt = "ceph.client.%s.secret" + cephKeyringFileNameFmt = "ceph.share.%s.client.%s.keyring" + cephSecretFileNameFmt = "ceph.share.%s.client.%s.secret" ) var ( @@ -115,34 +115,37 @@ type cephKeyringData struct { UserId, Key string RootPath string Pool, Namespace string + VolumeUuid string } func (d *cephKeyringData) writeToFile() error { - return writeCephTemplate(fmt.Sprintf(cephKeyringFileNameFmt, d.UserId), 0600, cephKeyringTempl, d) + return writeCephTemplate(fmt.Sprintf(cephKeyringFileNameFmt, d.VolumeUuid, d.UserId), 0600, cephKeyringTempl, d) } type cephFullCapsKeyringData struct { UserId, Key string + VolumeUuid string } func (d *cephFullCapsKeyringData) writeToFile() error { - return writeCephTemplate(fmt.Sprintf(cephKeyringFileNameFmt, d.UserId), 0600, cephFullCapsKeyringTempl, d) + return writeCephTemplate(fmt.Sprintf(cephKeyringFileNameFmt, d.VolumeUuid, d.UserId), 0600, cephFullCapsKeyringTempl, d) } type cephSecretData struct { UserId, Key string + VolumeUuid string } func (d *cephSecretData) writeToFile() error { - return writeCephTemplate(fmt.Sprintf(cephSecretFileNameFmt, d.UserId), 0600, cephSecretTempl, d) + return writeCephTemplate(fmt.Sprintf(cephSecretFileNameFmt, d.VolumeUuid, d.UserId), 0600, cephSecretTempl, d) } -func getCephSecretPath(userId string) string { - return path.Join(cephConfigRoot, fmt.Sprintf(cephSecretFileNameFmt, userId)) +func getCephSecretPath(volUuid, userId string) string { + return path.Join(cephConfigRoot, fmt.Sprintf(cephSecretFileNameFmt, volUuid, userId)) } -func getCephKeyringPath(userId string) string { - return path.Join(cephConfigRoot, fmt.Sprintf(cephKeyringFileNameFmt, userId)) +func getCephKeyringPath(volUuid, userId string) string { + return path.Join(cephConfigRoot, fmt.Sprintf(cephKeyringFileNameFmt, volUuid, userId)) } func getCephConfPath(volUuid string) string {