-
Notifications
You must be signed in to change notification settings - Fork 2
/
create-hpccvm.ps1
75 lines (63 loc) · 2.16 KB
/
create-hpccvm.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<#
.SYNOPSIS
Build HPCCSystems Hyper-V image
.DESCRIPTION
Usage:
.EXAMPLE
.NOTES
.LINK
#>
param(
$version = $(Throw "Missing HPCCSystems version."),
$arch="amd64",
$codename="bionic",
$ubuntu_user="hpccdemo",
$ubuntu_passwd="hpccdemo",
$output_dir="hpcc-vm",
$base_dir="hpcc-base-vm",
$url_prefix = "http://10.224.20.10/builds/",
$download_dir="hpcc-systems/bionic",
$configuration_version="8.0",
$switch="External"
)
$vm_name="hpccvm64-${version}"
$script_directory = split-path $myInvocation.MyCommand.path
@"
Build HPCCSystems Hyper-V Image
-------------------------------
Ubuntu : $codename
Arch : $arch
HPCC Version : $version
"@
#-----------------------------------------------------------
# Download HPCCSystems packages
#-----------------------------------------------------------
Copy-Item $script_directory/hpcc-packages-downloader.ps1
$cmd = "./hpcc-packages-downloader.ps1 -version ${version} -codename ${codename}" +
" -arch ${arch} -download_dir $download_dir -url_prefix ${url_prefix}"
iex "$cmd ; `$err=`$?"
if ( ! ($?) ) { exit 1 }
#-----------------------------------------------------------
# Configure Packer build file from the template
#-----------------------------------------------------------
$directories_to_delete = "packer-cache", $output_dir
Foreach ($dir in $directories_to_delete)
{
If (Test-Path -Path $dir)
{
Remove-Item -Path $dir -Force -Recurse
}
}
(Get-Content $script_directory/hyperv.json.in) | Foreach-Object {
$_ -replace '@SSH_USER@', $ubuntu_user `
-replace '@SSH_PASSWD@', $ubuntu_passwd `
-replace '@VM_NAME@', $vm_name `
-replace '@VM_BASE_DIR@', $base_dir `
-replace '@OUTPUT_DIR@', $output_dir `
-replace '@DOWNLOAD_DIR@', "${download_dir}/" `
-replace '@ARCH@', $arch `
-replace '@CODENAME@', $codename `
-replace '@CONFIGURATION_VERSION@', $configuration_version `
-replace '@SWITCH@', $switch
} | Set-Content hyperv.json
Copy-Item $script_directory/$codename/hpcc-${codename}-${arch}.sh