1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-24 02:03:52 +03:00

feature #4215: context cd change in KVM VMM driver

This commit is contained in:
Javi Fontan 2016-01-29 15:51:07 +01:00
parent 7410c78981
commit 5f1bacf81b
4 changed files with 83 additions and 1 deletions

View File

@ -686,7 +686,9 @@ VMM_EXEC_KVM_SCRIPTS="src/vmm_mad/remotes/kvm/cancel \
src/vmm_mad/remotes/kvm/snapshot_create \
src/vmm_mad/remotes/kvm/snapshot_revert \
src/vmm_mad/remotes/kvm/snapshot_delete \
src/vmm_mad/remotes/kvm/shutdown"
src/vmm_mad/remotes/kvm/shutdown \
src/vmm_mad/remotes/kvm/cdrom_exec \
src/vmm_mad/remotes/kvm/cdrom_change"
#-------------------------------------------------------------------------------
# VMM SH Driver Xen scripts, to be installed under $REMOTES_LOCATION/vmm/xen

View File

@ -793,8 +793,15 @@ class ExecDriver < VirtualMachineDriver
# ATTACHNIC action to attach a new nic interface
#
def attach_nic(id, drv_message)
action = ACTION[:attach_nic]
xml_data = decode(drv_message)
tm_command = ensure_xpath(xml_data, id, action, 'TM_COMMAND') || return
target_path = ensure_xpath(xml_data, id, action,
'DISK_TARGET_PATH') || return
target_device = ensure_xpath(xml_data, id, action,
'VM/TEMPLATE/CONTEXT/TARGET') || return
begin
source = xml_data.elements["VM/TEMPLATE/NIC[ATTACH='YES']/BRIDGE"]
source_ovs =
@ -851,6 +858,21 @@ class ExecDriver < VirtualMachineDriver
:parameters => [:deploy_id, mac]
}
]
},
{
:driver => :vmm,
:action => :cdrom_eject,
:parameters => [:deploy_id, target_device]
},
{
:driver => :tm,
:action => :tm_context,
:parameters => tm_command.split
},
{
:driver => :vmm,
:action => :cdrom_change,
:parameters => [:deploy_id, target_device, target_path]
}
]

View File

@ -0,0 +1,30 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2016, OpenNebula Project, OpenNebula Systems #
# #
# 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 $(dirname $0)/kvmrc
source $(dirname $0)/../../scripts_common.sh
DOMAIN=$1
TARGET_DEVICE=$2
ISO_PATH=$3
CMD="virsh --connect $LIBVIRT_URI \
change-media $DOMAIN $TARGET_DEVICE $ISO_PATH --insert"
exec_and_log "$CMD" "Could not insert CDROM $ISO_PATH to $TARGET_DEVICE"

View File

@ -0,0 +1,28 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2016, OpenNebula Project, OpenNebula Systems #
# #
# 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 $(dirname $0)/kvmrc
source $(dirname $0)/../../scripts_common.sh
DOMAIN=$1
TARGET_DEVICE=$2
CMD="virsh --connect $LIBVIRT_URI change-media $DOMAIN $TARGET_DEVICE --eject"
exec_and_log "$CMD" "Could not eject CDROM $TARGET_DEVICE"