diff --git a/docs/how-to/import-remote-cluster.rst b/docs/how-to/import-remote-cluster.rst index edeecff0c..76d89c41e 100644 --- a/docs/how-to/import-remote-cluster.rst +++ b/docs/how-to/import-remote-cluster.rst @@ -26,6 +26,11 @@ At the primary cluster, this token can be imported to create the remote record. sudo microceph remote import simple eyJmc2lkIjoiN2FiZmMwYmItNjIwNC00M2FmLTg4NDQtMjg3NDg2OGNiYTc0Iiwia2V5cmluZy5jbGllbnQubWFnaWNhbCI6IkFRQ0hJdmRtNG91SUNoQUFraGsvRldCUFI0WXZCRkpzUC92dDZ3PT0iLCJtb24uaG9zdC5zaW1wbGUtcmVpbmRlZXIiOiIxMC40Mi44OC42OSIsInB1YmxpY19uZXR3b3JrIjoiMTAuNDIuODguNjkvMjQifQ== --local-name magical +.. note:: + + The value of ``--local-name`` must be different from the remote cluster name (``simple`` in this example). + Using the same name for both will result in an error to avoid conflicts during replication. + This will create the required $simple.conf and $simple.keyring files. Note: Importing a remote cluster is a uni-directional operation. For symmetric relations both clusters should be added as remotes at each other. diff --git a/microceph/api/ops_replication.go b/microceph/api/ops_replication.go index 50bc0cd1d..3e9e8a6aa 100644 --- a/microceph/api/ops_replication.go +++ b/microceph/api/ops_replication.go @@ -100,6 +100,10 @@ func cmdOpsReplication(s state.State, r *http.Request, patchRequest types.Replic return response.InternalError(err) } + if data.RemoteName != "" && data.RemoteName == data.LocalAlias { + return response.SmartError(fmt.Errorf("local alias (--local-name) and remote name must be different to avoid site conflicts")) + } + // carry RbdReplicationRequest in interface object. data.SetAPIObjectId(resource) // Patch request type. diff --git a/microceph/api/types/replication_rbd.go b/microceph/api/types/replication_rbd.go index f45a1be2d..0eaa6a121 100644 --- a/microceph/api/types/replication_rbd.go +++ b/microceph/api/types/replication_rbd.go @@ -97,6 +97,7 @@ type RbdReplicationRequest struct { SourcePool string `json:"source_pool" yaml:"source_pool"` SourceImage string `json:"source_image" yaml:"source_image"` RemoteName string `json:"remote" yaml:"remote"` + LocalAlias string `json:"local_alias" yaml:"local_alias"` // snapshot in d,h,m format Schedule string `json:"schedule" yaml:"schedule"` ReplicationType RbdReplicationType `json:"replication_type" yaml:"replication_type"`