script mkvm mise a jour

This commit is contained in:
Alhassane Kone 2024-02-02 15:00:22 +01:00
parent 35e816c2eb
commit 80295cba99
2 changed files with 34 additions and 4 deletions

View File

@ -17,6 +17,11 @@ vmMem[s-nas]=512
vmMem[s-infra]=768
vmMem[s-backup]=768
vmMem[s-elk]=3072
vmMem[s-awx]=4096
declare -A vmCpus
vmCpus[s-peertube]=2
vmCpus[s-awx]=2
usage () {
echo "$0 - version ${mkvmrelease} - Ova version ${ovarelease}"
@ -40,12 +45,15 @@ create_vm () {
if [[ "${deletemode}" = 1 ]] ; then
VBoxManage unregistervm --delete "${nom}"
fi
vboxmanage import "${nomova}" --vsys 0 --vmname "${nom}"
mem=1024
cpus=1
if [[ -v vmMem[${nom}] ]]; then
mem=${vmMem[${nom}]}
echo "machine ${nom}: ${mem} ..."
VBoxManage modifyvm "${nom}" --memory "${mem}"
fi
if [[ -v vmCpus[${nom}] ]]; then
cpus=${vmCpus[${nom}]}
fi
vboxmanage import "${nomova}" --vsys 0 --vmname "${nom}" --memory "${mem}" --cpus "${cpus}"
}
setif () {
@ -145,6 +153,8 @@ elif [[ "${vm}" == "r-vp2" ]] ; then
./addint.r-vp2
elif [[ "${vm}" == "s-agence" ]] ; then
create_if "${vm}" "n-adm" "n-agence"
elif [[ "${vm}" == "s-awx" ]] ; then
create_if "${vm}" "n-adm" "n-infra"
else
echo "$0 : vm ${vm} non prevue "
exit 2

View File

@ -20,12 +20,16 @@ $vmMem = @{
"s-elk" = "3072"
}
$vmCpus = @{
"s-awx" = "4096"
"s-peertube" = "4096"
}
#FONCTIONS
function create_vm{ param([string]$nomvm)
if ($vmMem.ContainsKey($nomvm)) {
& "$vboxmanage" import "$ovafile" --vsys 0 --vmname "$nomvm" --memory $vmMem[$nomvm]
& "$vboxmanage" import "$ovafile" --vsys 0 --vmname "$nomvm" --memory $vmMem[$nomvm] --cpus $vmCpus[$nomvm}
Write-Host "Machine $nomvm importée"
} else {
#Importation depuis l'ova
@ -133,6 +137,22 @@ elseif ($args[0] -eq "s-kea2") {
create_if $args[0] "int" 3 "n-user"
}
elseif ($args[0] -eq "s-awx") {
create_vm $args[0]
create_if $args[0] "int" 1 "n-adm"
create_if $args[0] "int" 2 "n-infra"
}
elseif ($args[0] -eq "s-peertube") {
create_vm $args[0]
create_if $args[0] "int" 1 "n-adm"
create_if $args[0] "int" 2 "n-infra"
}
elseif ($args[0] -eq "s-agence") {
create_vm $args[0]