From 0921cfd3436017ae0110546ea394bec75020e263 Mon Sep 17 00:00:00 2001 From: lsimngar Date: Mon, 11 Aug 2014 14:54:35 +0200 Subject: [PATCH 1/2] 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 1fc1b318306..8ce58e6828a 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 a7c8865c1fa..27c38e96569 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 < Date: Thu, 14 Aug 2014 11:34:32 +0200 Subject: [PATCH 2/2] Included CEPH_USER variable if set is used by ceph tm and datastore scripts --- src/datastore_mad/remotes/ceph/clone | 8 ++++---- src/datastore_mad/remotes/ceph/cp | 10 ++++------ src/datastore_mad/remotes/ceph/mkfs | 11 +++++------ src/datastore_mad/remotes/ceph/monitor | 7 +++---- src/datastore_mad/remotes/ceph/rm | 7 +++---- src/tm_mad/ceph/clone | 22 +++++++++++++++++++++- src/tm_mad/ceph/cpds | 9 ++++++++- src/tm_mad/ceph/delete | 10 ++++++++-- src/tm_mad/ceph/mvds | 10 ++++++++-- 9 files changed, 64 insertions(+), 30 deletions(-) diff --git a/src/datastore_mad/remotes/ceph/clone b/src/datastore_mad/remotes/ceph/clone index 8ce58e6828a..9402cdc878a 100755 --- a/src/datastore_mad/remotes/ceph/clone +++ b/src/datastore_mad/remotes/ceph/clone @@ -67,9 +67,8 @@ if [ -z "$DST_HOST" ]; then exit -1 fi -if [ -z "$CEPH_USER" ]; then - error_message "Datastore template missing 'CEPH_USER' attribute." - exit -1 +if [ -n "$CEPH_USER" ]; then + RBD="$RBD --id ${CEPH_USER}" fi SAFE_DIRS="" @@ -77,7 +76,8 @@ SAFE_DIRS="" IMAGE_NAME="one-${ID}" RBD_DST="${POOL_NAME}/${IMAGE_NAME}" -ssh_exec_and_log "$DST_HOST" "$RBD copy $SRC $RBD_DST --id ${CEPH_USER}" \ +ssh_exec_and_log "$DST_HOST" "$RBD copy $SRC $RBD_DST" \ "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 27c38e96569..3603a9ebca1 100755 --- a/src/datastore_mad/remotes/ceph/cp +++ b/src/datastore_mad/remotes/ceph/cp @@ -87,12 +87,10 @@ if [ -z "$DST_HOST" ]; then exit -1 fi -if [ -z "$CEPH_USER" ]; then - error_message "Datastore template missing 'CEPH_USER' attribute." - exit -1 +if [ -n "$CEPH_USER" ]; then + RBD="$RBD --id ${CEPH_USER}" fi - set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" IMAGE_HASH=`generate_image_hash` @@ -142,7 +140,7 @@ REGISTER_CMD=$(cat </one---" RBD_SRC="${SRC}-${VM_ID}-${DISK_ID}" RBD_SNAP="${VM_ID}-${DISK_ID}" @@ -93,7 +99,7 @@ log "Deleting $DST_PATH" DELETE_CMD=$(cat </one---" RBD_DST="${RBD_SRC}-${VM_ID}-${DISK_ID}" RBD_SNAP="${VM_ID}-${DISK_ID}" @@ -82,7 +88,7 @@ log "Dumping $RBD_DST to $DST" DUMP_CMD=$(cat <