2018-04-13 12:31:46 +00:00
|
|
|
/*
|
2019-04-03 08:46:15 +00:00
|
|
|
Copyright 2018 The Ceph-CSI Authors.
|
2018-04-13 12:31:46 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package cephfs
|
|
|
|
|
|
|
|
import (
|
2019-08-22 17:19:06 +00:00
|
|
|
"context"
|
|
|
|
|
2020-04-17 09:23:49 +00:00
|
|
|
"github.com/ceph/ceph-csi/internal/util"
|
2018-04-13 12:31:46 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2018-07-28 08:24:07 +00:00
|
|
|
cephUserPrefix = "user-"
|
2018-04-13 12:31:46 +00:00
|
|
|
cephEntityClientPrefix = "client."
|
|
|
|
)
|
|
|
|
|
2019-06-01 21:26:42 +00:00
|
|
|
func genUserIDs(adminCr *util.Credentials, volID volumeID) (adminID, userID string) {
|
|
|
|
return cephEntityClientPrefix + adminCr.ID, cephEntityClientPrefix + getCephUserName(volID)
|
2019-02-14 13:38:53 +00:00
|
|
|
}
|
|
|
|
|
2019-06-20 07:35:53 +00:00
|
|
|
func getCephUserName(volID volumeID) string {
|
|
|
|
return cephUserPrefix + string(volID)
|
2018-04-13 12:31:46 +00:00
|
|
|
}
|
|
|
|
|
2019-08-22 17:19:06 +00:00
|
|
|
func deleteCephUserDeprecated(ctx context.Context, volOptions *volumeOptions, adminCr *util.Credentials, volID volumeID) error {
|
2019-02-14 13:38:53 +00:00
|
|
|
adminID, userID := genUserIDs(adminCr, volID)
|
|
|
|
|
2019-05-28 19:03:18 +00:00
|
|
|
// TODO: Need to return success if userID is not found
|
2019-08-22 17:19:06 +00:00
|
|
|
return execCommandErr(ctx, "ceph",
|
2019-02-13 12:57:16 +00:00
|
|
|
"-m", volOptions.Monitors,
|
2019-02-14 13:38:53 +00:00
|
|
|
"-n", adminID,
|
2019-06-25 19:29:17 +00:00
|
|
|
"--keyfile="+adminCr.KeyFile,
|
2019-04-22 21:35:39 +00:00
|
|
|
"-c", util.CephConfigPath,
|
2019-02-14 13:38:53 +00:00
|
|
|
"auth", "rm", userID,
|
2019-02-14 10:47:16 +00:00
|
|
|
)
|
2018-04-13 12:31:46 +00:00
|
|
|
}
|