From 445c8029b3bf1951279272768e2dab67ecfcfd1d Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Mon, 5 Dec 2011 18:23:24 +0100 Subject: [PATCH] feature-#1020: Add ssh support --- install.sh | 9 +++- src/tm_mad/vmware-ssh/tm_clone.sh | 53 ++++++++++++++++++++++++ src/tm_mad/vmware-ssh/tm_ln.sh | 32 ++++++++++++++ src/tm_mad/vmware-ssh/tm_vmware_ssh.conf | 24 +++++++++++ 4 files changed, 117 insertions(+), 1 deletion(-) create mode 100755 src/tm_mad/vmware-ssh/tm_clone.sh create mode 100755 src/tm_mad/vmware-ssh/tm_ln.sh create mode 100644 src/tm_mad/vmware-ssh/tm_vmware_ssh.conf diff --git a/install.sh b/install.sh index a8ded00a12..f1f6115192 100755 --- a/install.sh +++ b/install.sh @@ -210,6 +210,7 @@ LIB_DIRS="$LIB_LOCATION/ruby \ $LIB_LOCATION/tm_commands/dummy \ $LIB_LOCATION/tm_commands/lvm \ $LIB_LOCATION/tm_commands/vmware \ + $LIB_LOCATION/tm_commands/vmware-ssh \ $LIB_LOCATION/mads \ $LIB_LOCATION/sh \ $LIB_LOCATION/ruby/cli \ @@ -348,6 +349,7 @@ INSTALL_FILES=( SHARED_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/shared SSH_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/ssh VMWARE_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/vmware + VMWARE_TM_SSH_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/vmware-ssh DUMMY_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/dummy LVM_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/lvm IMAGE_DRIVER_FS_SCRIPTS:$VAR_LOCATION/remotes/image/fs @@ -683,6 +685,10 @@ VMWARE_TM_COMMANDS_LIB_FILES="src/tm_mad/vmware/tm_clone.sh \ src/tm_mad/vmware/tm_ln.sh \ src/tm_mad/vmware/tm_mv.sh" +VMWARE_TM_SSH_COMMANDS_LIB_FILES="src/tm_mad/vmware-ssh/tm_clone.sh \ + src/tm_mad/vmware-ssh/tm_ln.sh" + + #------------------------------------------------------------------------------- # Image Repository drivers, to be installed under $REMOTES_LOCATION/image # - FS based Image Repository, $REMOTES_LOCATION/image/fs @@ -757,7 +763,8 @@ TM_DUMMY_ETC_FILES="src/tm_mad/dummy/tm_dummy.conf \ TM_LVM_ETC_FILES="src/tm_mad/lvm/tm_lvm.conf \ src/tm_mad/lvm/tm_lvmrc" -TM_VMWARE_ETC_FILES="src/tm_mad/vmware/tm_vmware.conf" +TM_VMWARE_ETC_FILES="src/tm_mad/vmware/tm_vmware.conf \ + src/tm_mad/vmware/tm_vmware_ssh.conf" #------------------------------------------------------------------------------- # Hook Manager driver config. files, to be installed under $ETC_LOCATION/hm diff --git a/src/tm_mad/vmware-ssh/tm_clone.sh b/src/tm_mad/vmware-ssh/tm_clone.sh new file mode 100755 index 0000000000..29b0e8295c --- /dev/null +++ b/src/tm_mad/vmware-ssh/tm_clone.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# ---------------------------------------------------------------------------- # +# Copyright 2010-2011, C12G Labs S.L # +# # +# 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. # +# ---------------------------------------------------------------------------- # + +SRC=$1 +DST=$2 + +if [ -z "${ONE_LOCATION}" ]; then + TMCOMMON=/usr/lib/one/mads/tm_common.sh +else + TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh +fi + +. $TMCOMMON + +DST_PATH=`arg_path $DST` +DST_HOST=`arg_host $DST` + +log "$1 $2" +log "DST_HOST: $DST_HOST" +log "DST_PATH: $DST_PATH" + +log "Creating directory $DST_PATH" +exec_and_log "$SSH $DST_HOST mkdir -p $DST_PATH" + +case $SRC in +http://*) + log "Downloading $SRC" + exec_and_log "$SSH $DST_HOST $WGET -O $DST_PATH $SRC" + ;; + +*) + log "Cloning $SRC" + exec_and_log "$SCP -r $SRC/* $DST" + ;; +esac + +exec_and_log "$SSH $DST_HOST chmod a+rwx $DST_PATH" + diff --git a/src/tm_mad/vmware-ssh/tm_ln.sh b/src/tm_mad/vmware-ssh/tm_ln.sh new file mode 100755 index 0000000000..8b1d41f77f --- /dev/null +++ b/src/tm_mad/vmware-ssh/tm_ln.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# ---------------------------------------------------------------------------- # +# Copyright 2010-2011, C12G Labs S.L # +# # +# 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. # +# ---------------------------------------------------------------------------- # + +SRC=$1 +DST=$2 + +if [ -z "${ONE_LOCATION}" ]; then + TMCOMMON=/usr/lib/one/mads/tm_common.sh + TM_COMMANDS_LOCATION=/usr/lib/one/tm_commands/ +else + TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh + TM_COMMANDS_LOCATION=$ONE_LOCATION/lib/tm_commands/ +fi + +. $TMCOMMON + +exec $TM_COMMANDS_LOCATION/vmware-ssh/tm_clone.sh $SRC $DST diff --git a/src/tm_mad/vmware-ssh/tm_vmware_ssh.conf b/src/tm_mad/vmware-ssh/tm_vmware_ssh.conf new file mode 100644 index 0000000000..8b2bca4d20 --- /dev/null +++ b/src/tm_mad/vmware-ssh/tm_vmware_ssh.conf @@ -0,0 +1,24 @@ +# ---------------------------------------------------------------------------- # +# Copyright 2010-2011, C12G Labs S.L # +# # +# 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. # +# ---------------------------------------------------------------------------- # + +CLONE = vmware-ssh/tm_clone.sh +LN = vmware-ssh/tm_ln.sh +MKSWAP = ssh/tm_mkswap.sh +MKIMAGE = ssh/tm_mkimage.sh +DELETE = ssh/tm_delete.sh +MV = ssh/tm_mv.sh +CONTEXT = ssh/tm_context.sh +