Add Windows batch templates used by wbatch/osbash

The files added in this changeset are used by osbash as templates when
the user requests the creation of Windows batch files.

The names of the templates end on _bat rather than .bat because some
mail providers refuse to deliver .bat files even within archives.

The generated Windows batch files will have the proper extension (.bat).

Change-Id: I5dbed4bc6a4e30b50693208812d3dbfebecb2f19
Partial-Bug: 1312764
Implements: blueprint openstack-training-labs
This commit is contained in:
Roger Luethi 2014-06-16 13:20:29 +02:00
parent aefe47bb64
commit 271448cee6
7 changed files with 190 additions and 0 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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:

View File

@ -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: