1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-23 22:50:09 +03:00

Merge branch 'feature-1223' of git.opennebula.org:one into feature-1223

This commit is contained in:
Ruben S. Montero 2012-06-15 18:15:09 +02:00
commit 8d79167333
7 changed files with 159 additions and 4 deletions

View File

@ -154,7 +154,7 @@ IM_MAD = [
#IM_MAD = [
# name = "im_vmware",
# executable = "one_im_sh",
# arguments = "-t 15 -r 0 vmware" ]
# arguments = "-c -t 15 -r 0 vmware" ]
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------

View File

@ -516,6 +516,8 @@ class ExecDriver < VirtualMachineDriver
disk_xpath = "VM/TEMPLATE/DISK[DISK_ID='#{disk_id}']/TARGET"
target = ensure_xpath(xml_data, id, action, disk_xpath) || return
target_index = target.downcase[-1..-1].unpack('c').first - 97
action = VmmAction.new(self, id, :attach_disk, drv_message)
steps = [
@ -529,7 +531,12 @@ class ExecDriver < VirtualMachineDriver
{
:driver => :vmm,
:action => :attach_disk,
:parameters => [:deploy_id, :disk_target_path, target]
:parameters => [
:deploy_id,
:disk_target_path,
target,
target_index
]
}
]
@ -549,6 +556,8 @@ class ExecDriver < VirtualMachineDriver
disk_xpath = "VM/TEMPLATE/DISK[DISK_ID='#{disk_id}']/TARGET"
target = ensure_xpath(xml_data, id, action, disk_xpath) || return
target_index = target.downcase[-1..-1].unpack('c').first - 97
action = VmmAction.new(self, id, :detach_disk, drv_message)
steps = [
@ -556,7 +565,12 @@ class ExecDriver < VirtualMachineDriver
{
:driver => :vmm,
:action => :attach_disk,
:parameters => [:deploy_id, target]
:parameters => [
:deploy_id,
:disk_target_path,
target,
target_index
]
},
# Perform an EPILOG on the disk
{

View File

@ -22,6 +22,7 @@ source $(dirname $0)/../../scripts_common.sh
DOMAIN="$1"
SOURCE="$2"
TARGET="$3"
TARGET_INDEX="$4"
ATTACH_PARAMS="--domain $DOMAIN --source $SOURCE --target $TARGET"

View File

@ -20,7 +20,9 @@ source $(dirname $0)/kvmrc
source $(dirname $0)/../../scripts_common.sh
DOMAIN="$1"
TARGET="$2"
SOURCE="$2"
TARGET="$3"
TARGET_INDEX="$4"
DETACH_PARAMS="--domain $DOMAIN --target $TARGET"

View File

@ -0,0 +1,45 @@
#!/bin/sh
# -------------------------------------------------------------------------- #
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
# #
# 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. #
#--------------------------------------------------------------------------- #
source $PWD/scripts_common_sh.sh
DEPLOYID="$1"
SOURCE="$2"
TARGET="$3"
TARGET_NUMBER="$4"
CONTROLLER_NUMBER=0 # Only one controller at the moment (up to 16 devices)
DISK_NAME=`basename $SOURCE`
TEMP_PATH=`dirname $SOURCE`
VM_ID=`basename $TEMP_PATH`
TEMP_PATH=`dirname $TEMP_PATH`
DATASTORE=`basename $TEMP_PATH`
DISK_PATH="/vmfs/volumes/$DATASTORE/$VM_ID/$DISK_NAME/disk.vmdk"
# Get the VMware ID corresponding to the deploy_id
VMWAREID=`vim-cmd vmsvc/getallvms|grep $DEPLOYID|cut -d' ' -f 1`
ATTACH_PARAMS="$VMWAREID $DISK_PATH $CONTROLLER_NUMBER $TARGET_NUMBER $DATASTORE"
exec_and_log "$SUDO vim-cmd vmsvc/device.diskaddexisting $ATTACH_PARAMS" \
"Could not attach $SOURCE ($TARGET) to $DOMAIN"

View File

@ -0,0 +1,34 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
# #
# 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. #
#--------------------------------------------------------------------------- #
source $PWD/scripts_common_sh.sh
DEPLOYID="$1"
IMAGE_PATH="$2"
UNIT="$3"
UNIT_NUMBER="$4"
CONTROLLER_NUMBER=0 # Only one controller at the moment (up to 16 devices)
# Get the VMware ID corresponding to the deploy_id
VMWAREID=`vim-cmd vmsvc/getallvms|grep $DEPLOYID|cut -d' ' -f 1`
DETACH_PARAMS="$VMWAREID $CONTROLLER_NUMBER $UNIT_NUMBER $IMAGE_PATH"
exec_and_log "$SUDO vim-cmd vmsvc/device.diskremove $DETACH_PARAMS" \
"Could not detach $TARGET from $DOMAIN"

View File

@ -0,0 +1,59 @@
# -------------------------------------------------------------------------- #
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
# #
# 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. #
#--------------------------------------------------------------------------- #
error_message()
{
(
echo "ERROR MESSAGE --8<------"
echo "$1"
echo "ERROR MESSAGE ------>8--"
) 1>&2
}
log_function()
{
echo "$1: $SCRIPT_NAME: $2" 1>&2
}
log_error()
{
log_function "ERROR" "$1"
}
exec_and_log()
{
message=$2
EXEC_LOG_ERR=`$1 2>&1 1>/dev/null`
EXEC_LOG_RC=$?
if [ $EXEC_LOG_RC -ne 0 ]; then
log_error "Command \"$1\" failed: $EXEC_LOG_ERR"
if [ -n "$2" ]; then
error_message "$2"
else
error_message "Error executing $1: $EXEC_LOG_ERR"
fi
exit $EXEC_LOG_RC
fi
}
WHICH_SUDO=`which sudo`
if [ ! -z "$WHICH_SUDO" -a -f "$WHICH_SUDO" ]; then
SUDO="sudo "
fi