From 0921cfd3436017ae0110546ea394bec75020e263 Mon Sep 17 00:00:00 2001 From: lsimngar Date: Mon, 11 Aug 2014 14:54:35 +0200 Subject: [PATCH] Modified 2 lines and rados command to take into account the POOL_NAME and CEPH_USER from the datastore template. At this moment all Ceph remotes are using Ceph admin privileges. This could be a sec. issue, CEPH_USER should be a mandatory param into Ceph datastores and it should be used by Ceph remotes by default. --- src/datastore_mad/remotes/ceph/clone | 11 +++++++++-- src/datastore_mad/remotes/ceph/cp | 14 +++++++++++--- src/datastore_mad/remotes/ceph/mkfs | 15 +++++++++++---- src/datastore_mad/remotes/ceph/monitor | 11 +++++++++-- src/datastore_mad/remotes/ceph/rm | 12 ++++++++++-- 5 files changed, 50 insertions(+), 13 deletions(-) diff --git a/src/datastore_mad/remotes/ceph/clone b/src/datastore_mad/remotes/ceph/clone index 1fc1b31830..8ce58e6828 100755 --- a/src/datastore_mad/remotes/ceph/clone +++ b/src/datastore_mad/remotes/ceph/clone @@ -48,7 +48,8 @@ done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \ /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BRIDGE_LIST \ /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/POOL_NAME \ /DS_DRIVER_ACTION_DATA/IMAGE/PATH \ - /DS_DRIVER_ACTION_DATA/IMAGE/SIZE) + /DS_DRIVER_ACTION_DATA/IMAGE/SIZE \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/CEPH_USER) unset i @@ -57,6 +58,7 @@ BRIDGE_LIST="${XPATH_ELEMENTS[i++]}" POOL_NAME="${XPATH_ELEMENTS[i++]:-$POOL_NAME}" SRC="${XPATH_ELEMENTS[i++]}" SIZE="${XPATH_ELEMENTS[i++]}" +CEPH_USER="${XPATH_ELEMENTS[i++]}" DST_HOST=`get_destination_host $ID` @@ -65,12 +67,17 @@ if [ -z "$DST_HOST" ]; then exit -1 fi +if [ -z "$CEPH_USER" ]; then + error_message "Datastore template missing 'CEPH_USER' attribute." + exit -1 +fi + SAFE_DIRS="" IMAGE_NAME="one-${ID}" RBD_DST="${POOL_NAME}/${IMAGE_NAME}" -ssh_exec_and_log "$DST_HOST" "$RBD copy $SRC $RBD_DST" \ +ssh_exec_and_log "$DST_HOST" "$RBD copy $SRC $RBD_DST --id ${CEPH_USER}" \ "Error cloning $SRC to $RBD_DST in $DST_HOST" echo "$RBD_DST" diff --git a/src/datastore_mad/remotes/ceph/cp b/src/datastore_mad/remotes/ceph/cp index a7c8865c1f..27c38e9656 100755 --- a/src/datastore_mad/remotes/ceph/cp +++ b/src/datastore_mad/remotes/ceph/cp @@ -60,7 +60,8 @@ done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \ /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/MD5 \ /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1 \ /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/NO_DECOMPRESS \ - /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/LIMIT_TRANSFER_BW) + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/LIMIT_TRANSFER_BW \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/CEPH_USER) unset i @@ -77,6 +78,7 @@ MD5="${XPATH_ELEMENTS[i++]}" SHA1="${XPATH_ELEMENTS[i++]}" NO_DECOMPRESS="${XPATH_ELEMENTS[i++]}" LIMIT_TRANSFER_BW="${XPATH_ELEMENTS[i++]}" +CEPH_USER="${XPATH_ELEMENTS[i++]}" DST_HOST=`get_destination_host $ID` @@ -85,6 +87,12 @@ if [ -z "$DST_HOST" ]; then exit -1 fi +if [ -z "$CEPH_USER" ]; then + error_message "Datastore template missing 'CEPH_USER' attribute." + exit -1 +fi + + set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" IMAGE_HASH=`generate_image_hash` @@ -134,7 +142,7 @@ REGISTER_CMD=$(cat <