rbd: Add rados namespace support for rbd

Make sure to operate within the namespace if any given
when dealing with rbd images and snapshots and their journals.

Signed-off-by: Mehdy Khoshnoody <mehdy.khoshnoody@gmail.com>
This commit is contained in:
Mehdy Khoshnoody
2020-06-01 18:27:51 +04:30
committed by Humble Devassy Chirammal
parent b5320d9273
commit fc5eadf106
12 changed files with 125 additions and 58 deletions

View File

@ -37,6 +37,8 @@ const (
type ClusterInfo struct {
// ClusterID is used for unique identification
ClusterID string `json:"clusterID"`
// Namespace is the namespace in the pool
RadosNamespace string `json:"radosNamespace"`
// Monitors is monitor list for corresponding cluster ID
Monitors []string `json:"monitors"`
// CephFS contains CephFS specific options
@ -50,6 +52,7 @@ type ClusterInfo struct {
// [
// {
// "clusterID": "<cluster-id>",
// "namespace": "<namespace>",
// "monitors":
// [
// "<monitor-value>",
@ -100,6 +103,15 @@ func Mons(pathToConfig, clusterID string) (string, error) {
return strings.Join(cluster.Monitors, ","), nil
}
// RadosNamespace returns the namespace for the given clusterID.
func RadosNamespace(pathToConfig, clusterID string) (string, error) {
cluster, err := readClusterInfo(pathToConfig, clusterID)
if err != nil {
return "", err
}
return cluster.RadosNamespace, nil
}
// CephFSSubvolumeGroup returns the subvolumeGroup for CephFS volumes. If not set, it returns the default value "csi".
func CephFSSubvolumeGroup(pathToConfig, clusterID string) (string, error) {
cluster, err := readClusterInfo(pathToConfig, clusterID)