ContainerMgt/New-NCHNAVContainer.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
function New-NCHNAVContainer {
    <#
    .SYNOPSIS
    Installs a new container using the navcontainerhelper module (from Freddy) on a docker host.
     
    .DESCRIPTION
    Long description
     
    .PARAMETER ContainerName
    ContainerName
     
    .PARAMETER AdditionalParameters
    Additional Docker parameters
     
    .PARAMETER imageName
    The docker image
 
    .PARAMETER registryUserName
    Login username to login to the private registry that hosts the ContainerDockerImage
     
    .PARAMETER registryPwd
    Password to login to the private registry that hosts the ContainerDockerImage
     
    .PARAMETER LicenseFile
    The NAV License File
     
    .PARAMETER memoryLimit
    The memory the container is limited to use
     
    .PARAMETER Credential
    Credential for the container
     
    .PARAMETER alwaysPull
    Always pull a new version or not (switch)
         
    .PARAMETER DoNotInstallDependentModules
    Switch to avoid installing the Cloud.Ready.Software.* modules on the container
 
    .PARAMETER assignPremiumPlan
    Assigns premium plan in the sandbox
 
    .PARAMETER includeTestToolkit
    include Test Toolkit
 
    .PARAMETER includeTestLibrariesOnly
    include Test Libraries Only
     
    .EXAMPLE
    Simply create a new container:
 
    New-NCHNAVContainer `
        -ContainerDockerImage $ContainerDockerImage `
        -ContainerName $Containername `
        -ContainerLicenseFile $ContainerLicenseFile `
        -ContainerCredential $ContainerCredential `
        -ContainerAlwaysPull `
        -ContainerAdditionalParameters $ContainerAdditionalParameters
    #>

    param(
        [Parameter(Mandatory = $true)]
        [String] $ContainerName,
        [Parameter(Mandatory = $false)]
        [String[]] $AdditionalParameters = @(), 
        [Parameter(Mandatory = $true)]
        [String] $imageName,        
        [Parameter(Mandatory = $false)]
        [String] $registryUserName, 
        [Parameter(Mandatory = $false)]
        [string] $registryPwd,         
        [Parameter(Mandatory = $true)]
        [String] $LicenseFile, 
        [Parameter(Mandatory = $false)]
        [String] $memoryLimit, 
        [Parameter(Mandatory = $true)]
        [System.Management.Automation.PSCredential] $Credential, 
        [Parameter(Mandatory = $false)]
        [Switch] $alwaysPull,
        [Parameter(Mandatory = $false)]
        [Switch] $accept_eula,
        [Parameter(Mandatory = $false)]
        [Switch] $DoNotInstallDependentModules,
        [Parameter(Mandatory = $false)]
        [Switch] $doNotExportObjectsToText,        
        [Parameter(Mandatory = $false)]
        [Switch] $enableSymbolLoading,
        [Parameter(Mandatory = $false)]
        [Switch] $includeTestToolkit,
        [Parameter(Mandatory = $false)]
        [Switch] $includeTestLibrariesOnly,
        [Parameter(Mandatory = $false)]
        [Switch] $assignPremiumPlan

    )

    Write-Host -ForegroundColor Green "$($MyInvocation.MyCommand.Name) on $env:COMPUTERNAME"

    if ($registryUserName) {
        $registry = $imageName.Substring(0, $imageName.IndexOf('/'))
        Write-Host -ForegroundColor Gray "Connecting docker to $registry user: $registryUserName pwd: $registryPwd"
        docker login "$registry" -u "$registryUserName" -p "$registryPwd"
    }

    New-NavContainer `
        -accept_eula:$accept_eula `
        -containerName $ContainerName `
        -imageName $imageName `
        -licenseFile $LicenseFile `
        -memoryLimit $memoryLimit `
        -additionalParameters $AdditionalParameters `
        -alwaysPull:$alwaysPull `
        -Credential $Credential `
        -doNotExportObjectsToText:$doNotExportObjectsToText `
        -updateHosts `
        -auth NavUserPassword `
        -includeCSide `
        -enableSymbolLoading:$enableSymbolLoading `
        -assignPremiumPlan:$assignPremiumPlan `
        -useBestContainerOS `
        -includeTestToolkit:$includeTestToolkit `
        -includeTestLibrariesOnly:$includeTestLibrariesOnly `
        -Verbose

    if (!$DoNotInstallDependentModules) {
        Install-NCHDependentModules `
            -ContainerName $ContainerName `
            -ContainerModulesOnly
    }

    Sync-NCHNAVTenant -containerName $ContainerName
}