Merge "Change from using chef to local config files"
[integration.git] / bootstrap / vagrant-onap / tools / Run.ps1
1 <#
2 .SYNOPSIS
3 This script helps to configure its environment variables based on the component selected.
4
5 .EXAMPLE
6 .\tools\Run.ps1 testing -s functions -c install_maven -y
7
8 .EXAMPLE
9 .\tools\Run.ps1 all_in_one
10
11 .EXAMPLE
12 .\tools\Run.ps1 aai
13
14 .PARAMETER s
15 Test suite to use in testing mode.
16
17 .PARAMETER c
18 Test case to use in testing mode.
19
20 .PARAMETER y
21 Skips warning prompt.
22
23 .PARAMETER g
24 Skips creation or retrieve image process.
25
26 .PARAMETER i
27 Skips installation service process.
28
29 .LINK
30 https://wiki.onap.org/display/DW/ONAP+on+Vagrant
31 #>
32
33 Param(
34     [ValidateSet("all_in_one","dns", "mr", "sdc", "aai", "mso", "robot", "vid", "sdnc", "portal", "dcae", "policy", "appc", "vfc", "multicloud", "ccsdk", "vnfsdk", "vvp", "openstack", "msb", "oom", "testing")]
35
36     [Parameter(Mandatory=$True,Position=0)]
37     [ValidateNotNullOrEmpty()]
38     [String]
39     $Command
40 ,
41     [Parameter(Mandatory=$False,HelpMessage="Test suite to use in testing mode.")]
42     [Alias("suite")]
43     [String]
44     $s = "*"
45 ,
46     [Parameter(Mandatory=$False,HelpMessage="Test case to sue in testing mode.")]
47     [Alias("case")]
48     [String]
49     $c = "*"
50 ,
51     [Parameter(Mandatory=$False,HelpMessage="Skips warning prompt.")]
52     [AllowNull()]
53     [Switch]
54     $y = $True
55 ,
56     [Parameter(Mandatory=$False,HelpMessage="Skips creation or retrieve image process.")]
57     [AllowNull()]
58     [Switch]
59     $skip_get_images = $True
60 ,
61     [Parameter(Mandatory=$False,HelpMessage="Skips warning prompt.")]
62     [AllowNull()]
63     [Switch]
64     $skip_install = $True
65 )
66
67 if ( -Not "testing".Equals($Command) )
68     {
69         if($PsBoundParameters.ContainsKey('s'))
70             {
71                 Write-Host "Test suite should only be specified in testing mode."
72                 Write-Host ".\tools\Run.ps1 -?"
73                 exit 1
74             }
75         if($PsBoundParameters.ContainsKey('c'))
76             {
77                 Write-Host "Test case should only be specified in testing mode."
78                 Write-Host ".\tools\Run.ps1 -?"
79                 exit 1
80             }
81     }
82
83 $env:SKIP_GET_IMAGES=$skip_get_images
84 $env:SKIP_INSTALL=$skip_install
85
86 switch ($Command)
87     {
88         "all_in_one" { $env:DEPLOY_MODE="all-in-one" }
89         { @("dns", "mr", "sdc", "aai", "mso", "robot", "vid", "sdnc", "portal", "dcae", "policy", "appc", "vfc", "multicloud", "ccsdk", "vnfsdk", "vvp", "openstack", "msb", "oom") -contains $_ } { $env:DEPLOY_MODE="individual" }
90         "testing"
91             {
92                 $env:DEPLOY_MODE="testing"
93                 If(-Not $y)
94                     {
95                         Write-Host "Warning: This test script will delete the contents of ../opt/ and ~/.m2."
96                         $yn = Read-Host "Would you like to continue? [y]es/[n]o: "
97                         switch ($yn)
98                             {
99                                 { @("n", "N") -contains $_ }
100                                     {
101                                         Write-Host "Exiting."
102                                         exit 0
103                                     }
104                             }
105                     }
106                 $env:TEST_SUITE=$s
107                 $env:TEST_CASE=$c
108
109                 &cmd.exe /c rd /s /q .\opt\
110                 &cmd.exe /c rd /s /q $HOME\.m2\
111              }
112          default
113              {
114                 Write-Output $"Usage: $0 {all_in_one|dns|mr|sdc|aai|mso|robot|vid|sdnc|portal|dcae|policy|appc|vfc|multicloud|ccsdk|vnfsdk|vvp|testing}"
115                 exit 1
116              }
117     }
118
119 vagrant destroy -f $Command
120 vagrant up $Command