diff --git a/labs/lib/wbatch/template-begin_base_bat b/labs/lib/wbatch/template-begin_base_bat new file mode 100644 index 00000000..fda2d0b5 --- /dev/null +++ b/labs/lib/wbatch/template-begin_base_bat @@ -0,0 +1,24 @@ +ECHO %time% Cleaning up autostart and log directories +DEL /S /Q %AUTODIR% +DEL /S /Q %LOGDIR% + +ECHO %time% Looking for %IMGDIR%\%INSTALLFILE% +IF EXIST %IMGDIR%\%INSTALLFILE% goto got_install_iso +ECHO. +ECHO %INSTALLFILE% not found in %IMGDIR%. +ECHO. +ECHO To proceed, I need the install ISO from +ECHO %ISOURL% +ECHO. +goto :terminate + +:got_install_iso +ECHO. +ECHO %time% Found %IMGDIR%\%INSTALLFILE% +ECHO. +ECHO %time% Initialization done. Hit any key to continue. +ECHO. +PAUSE + +REM vim: set ai ts=4 sw=4 et ft=dosbatch: + diff --git a/labs/lib/wbatch/template-begin_node_bat b/labs/lib/wbatch/template-begin_node_bat new file mode 100644 index 00000000..530b71c7 --- /dev/null +++ b/labs/lib/wbatch/template-begin_node_bat @@ -0,0 +1,23 @@ +ECHO %time% Cleaning up autostart and log directories +DEL /S /Q %AUTODIR% +DEL /S /Q %LOGDIR% + +ECHO %time% Looking for %IMGDIR%\%BASEDISK% +IF EXIST %IMGDIR%\%BASEDISK% goto got_base_disk +ECHO. +ECHO %BASEDISK% not found in %IMGDIR%. +ECHO. +ECHO You need to build a base disk before you can create node VMs. +ECHO. +goto :terminate + +:got_base_disk +ECHO. +ECHO %time% Found %IMGDIR%\%BASEDISK% +ECHO. +ECHO %time% Initialization done. Hit any key to continue. +ECHO. +PAUSE + +REM vim: set ai ts=4 sw=4 et ft=dosbatch: + diff --git a/labs/lib/wbatch/template-create_hostnet_bat b/labs/lib/wbatch/template-create_hostnet_bat new file mode 100644 index 00000000..867ba0b0 --- /dev/null +++ b/labs/lib/wbatch/template-create_hostnet_bat @@ -0,0 +1,31 @@ +ECHO. +ECHO %time% Initialization done. Hit any key to continue. +ECHO. +PAUSE + +ECHO VBoxManage hostonlyif create +VBoxManage hostonlyif create +IF %errorlevel% NEQ 0 GOTO :vbm_error + +ECHO VBoxManage hostonlyif ipconfig "VirtualBox Host-Only Ethernet Adapter" --ip %MGMTNET% --netmask 255.255.255.0 +VBoxManage hostonlyif ipconfig "VirtualBox Host-Only Ethernet Adapter" --ip %MGMTNET% --netmask 255.255.255.0 +IF %errorlevel% NEQ 0 GOTO :vbm_error + +ECHO VBoxManage hostonlyif create +VBoxManage hostonlyif create +IF %errorlevel% NEQ 0 GOTO :vbm_error + +ECHO VBoxManage hostonlyif ipconfig "VirtualBox Host-Only Ethernet Adapter #2" --ip %DATANET% --netmask 255.255.255.0 +VBoxManage hostonlyif ipconfig "VirtualBox Host-Only Ethernet Adapter #2" --ip %DATANET% --netmask 255.255.255.0 +IF %errorlevel% NEQ 0 GOTO :vbm_error + +ECHO VBoxManage hostonlyif create +VBoxManage hostonlyif create +IF %errorlevel% NEQ 0 GOTO :vbm_error + +ECHO VBoxManage hostonlyif ipconfig "VirtualBox Host-Only Ethernet Adapter #3" --ip %APINET% --netmask 255.255.255.0 +VBoxManage hostonlyif ipconfig "VirtualBox Host-Only Ethernet Adapter #3" --ip %APINET% --netmask 255.255.255.0 +IF %errorlevel% NEQ 0 GOTO :vbm_error + +REM vim: set ai ts=4 sw=4 et ft=dosbatch: + diff --git a/labs/lib/wbatch/template-end_file_bat b/labs/lib/wbatch/template-end_file_bat new file mode 100644 index 00000000..b81a84ee --- /dev/null +++ b/labs/lib/wbatch/template-end_file_bat @@ -0,0 +1,47 @@ +ECHO. +ECHO %time% Batch script seems to have succeeded. +ECHO. + +GOTO :terminate + +REM Note: vbm_error falls through to terminate +:vbm_error +ECHO. +ECHO %time% VBoxManage returned with an error. Aborting. +ECHO. + +:terminate +ENDLOCAL +PAUSE +GOTO :eof + +REM ============================================================================ +REM +REM End of program, function definitions follow +REM +REM ============================================================================ +:wait_auto +IF EXIST %STATUSDIR%\done ( + DEL %STATUSDIR%\done + GOTO :eof +) +TIMEOUT /T 5 /NOBREAK +GOTO :wait_auto +REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +:wait_poweroff +VBoxManage showvminfo %~1 --machinereadable|findstr poweroff +IF %errorlevel% EQU 0 GOTO :eof +TIMEOUT /T 2 /NOBREAK +GOTO :wait_poweroff +REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +:vm_exists +VBoxManage list vms|findstr %~1 +IF %errorlevel% NEQ 0 GOTO :eof +ECHO. +ECHO %time% VM %~1 already exists. Aborting. +ECHO. +GOTO :terminate +REM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +REM vim: set ai ts=4 sw=4 et ft=dosbatch: + diff --git a/labs/lib/wbatch/template-file_header_bat b/labs/lib/wbatch/template-file_header_bat new file mode 100644 index 00000000..ce5c771d --- /dev/null +++ b/labs/lib/wbatch/template-file_header_bat @@ -0,0 +1,16 @@ +@ECHO OFF + +REM This is an automatically generated Windows batch file. It creates the +REM %PRODUCT% for an OpenStack training-labs setup. + +SETLOCAL ENABLEDELAYEDEXPANSION + +ECHO. +ECHO OpenStack labs for VirtualBox on Windows +ECHO Generated by osbash (%USER%@%HOSTNAME%, %DATE%) +ECHO. +ECHO Create %PRODUCT% +ECHO. + +REM vim: set ai ts=4 sw=4 et ft=dosbatch: + diff --git a/labs/lib/wbatch/template-find_vbm_bat b/labs/lib/wbatch/template-find_vbm_bat new file mode 100644 index 00000000..8a66ea53 --- /dev/null +++ b/labs/lib/wbatch/template-find_vbm_bat @@ -0,0 +1,30 @@ +REM VBoxManage is not in PATH, but this is a good guess +IF EXIST %ProgramFiles%\Oracle\VirtualBox\VBoxManage.exe ( + SET PATH=%PATH%;%ProgramFiles%\Oracle\VirtualBox + ECHO. + ECHO %time% Found %ProgramFiles%\Oracle\VirtualBox\VBoxManage.exe + ECHO. + GOTO :vbm_found +) + +ECHO. +ECHO %time% Searching %SystemDrive% for VBoxManage, this may take a while +ECHO. +FOR /r %SystemDrive% %%a IN (*) DO ( + IF "%%~nxa"=="VBoxManage.exe" ( + SET PATH=%PATH%;%%~dpa + ECHO %time% Found %%~dpnxa + GOTO :vbm_found + ) +) + +ECHO. +ECHO %time% Cannot find VBoxManage.exe (part of VirtualBox) on %SystemDrive%. +ECHO %time% Program stops. +ECHO. +GOTO :terminate + +:vbm_found + +REM vim: set ai ts=4 sw=4 et ft=dosbatch: + diff --git a/labs/lib/wbatch/template-mkdirs_bat b/labs/lib/wbatch/template-mkdirs_bat new file mode 100644 index 00000000..cf18e1e5 --- /dev/null +++ b/labs/lib/wbatch/template-mkdirs_bat @@ -0,0 +1,19 @@ +SET BATDIR=%~dp0 +PUSHD %BATDIR%.. +SET TOPDIR=%cd% +POPD + +SET AUTODIR=%TOPDIR%\%P_AUTODIR% +SET IMGDIR=%TOPDIR%\%P_IMGDIR% +SET LOGDIR=%TOPDIR%\%P_LOGDIR% +SET STATUSDIR=%TOPDIR%\%P_STATUSDIR% +SET SHAREDIR=%TOPDIR% + +ECHO %time% Creating directories (if needed) +IF NOT EXIST %AUTODIR% mkdir %AUTODIR% +IF NOT EXIST %IMGDIR% mkdir %IMGDIR% +IF NOT EXIST %LOGDIR% mkdir %LOGDIR% +IF NOT EXIST %SHAREDIR% mkdir %SHAREDIR% + +REM vim: set ai ts=4 sw=4 et ft=dosbatch: +