From fdcb374dfb5860c917b403e323ccf6072bf810f3 Mon Sep 17 00:00:00 2001 From: Vasiliy Pleshakov Date: Tue, 15 Sep 2015 18:25:44 +0300 Subject: [PATCH] Enable VRDE option for VMs in vbox scripts VRDE option makes VMs accessible via RDP. Fix vboxmanage to run via execute decorator. Closes-Bug: #1498889 Change-Id: I93560126940457518fc4385c0518ab00d4b3d800 --- virtualbox/actions/master-node-create-and-install.sh | 5 +++++ virtualbox/actions/slave-nodes-create-and-boot.sh | 10 ++++++++-- virtualbox/config.sh | 1 + virtualbox/functions/vm.sh | 9 +++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/virtualbox/actions/master-node-create-and-install.sh b/virtualbox/actions/master-node-create-and-install.sh index aae8dca47..78fae1bbf 100755 --- a/virtualbox/actions/master-node-create-and-install.sh +++ b/virtualbox/actions/master-node-create-and-install.sh @@ -43,6 +43,11 @@ add_nat_adapter_to_vm $name 3 $vm_master_nat_network # Mount ISO with installer mount_iso_to_vm $name $iso_path +#add RDP connection +if [ ${headless} -eq 1 ]; then + enable_vrde $name ${RDPport} +fi + # Start virtual machine with the master node echo start_vm $name diff --git a/virtualbox/actions/slave-nodes-create-and-boot.sh b/virtualbox/actions/slave-nodes-create-and-boot.sh index 35e5819ba..de6e3be20 100755 --- a/virtualbox/actions/slave-nodes-create-and-boot.sh +++ b/virtualbox/actions/slave-nodes-create-and-boot.sh @@ -50,8 +50,14 @@ for idx in $(eval echo {1..$cluster_size}); do add_disk_to_vm $name 2 $vm_slave_third_disk_mb #add NIC1 MAC to description - mac=$(vboxmanage showvminfo $name |awk -F ': ' '$1~/NIC 1/ {mac=gensub(/^.+ MAC: ([0-9A-F]{12}).+$/,"\\1","g",$0);print mac}') - vboxmanage modifyvm $name --description $mac + mac=$(execute vboxmanage showvminfo $name |awk -F ': ' '$1~/NIC 1/ {mac=gensub(/^.+ MAC: ([0-9A-F]{12}).+$/,"\\1","g",$0);print mac}') + execute vboxmanage modifyvm $name --description $mac + + #add RDP connection + if [ ${headless} -eq 1 ]; then + enable_vrde $name $((${RDPport} + idx)) + fi + enable_network_boot_for_vm $name # The delay required for downloading tftp boot image diff --git a/virtualbox/config.sh b/virtualbox/config.sh index 8f3afbcbf..8b131cf6a 100755 --- a/virtualbox/config.sh +++ b/virtualbox/config.sh @@ -181,4 +181,5 @@ vm_slave_third_disk_mb=65535 # Set to 1 to run VirtualBox in headless mode headless=0 +RDPport=5000 skipfuelmenu="no" diff --git a/virtualbox/functions/vm.sh b/virtualbox/functions/vm.sh index 643a8367b..56203cb19 100755 --- a/virtualbox/functions/vm.sh +++ b/virtualbox/functions/vm.sh @@ -223,3 +223,12 @@ enable_network_boot_for_vm() { # Set the right boot priority execute VBoxManage modifyvm $name --boot1 net --boot2 disk --boot3 none --boot4 none --nicbootprio1 1 } + +enable_vrde(){ + name=$1 + port=${2:-$RDPport} + + # Enable VRDE, set port and address + execute VBoxManage modifyvm $name --vrde on + execute VBoxManage modifyvm $name --vrdeport $port +}