Victor Morales | 5d5c5da | 2017-08-15 16:24:05 -0500 | [diff] [blame] | 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 | |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 23 | .PARAMETER g |
| 24 | Skips creation or retrieve image process. |
| 25 | |
| 26 | .PARAMETER i |
| 27 | Skips installation service process. |
| 28 | |
Victor Morales | 5d5c5da | 2017-08-15 16:24:05 -0500 | [diff] [blame] | 29 | .LINK |
| 30 | https://wiki.onap.org/display/DW/ONAP+on+Vagrant |
| 31 | #> |
| 32 | |
| 33 | Param( |
Victor Morales | 9d205bc | 2017-12-01 17:52:07 -0800 | [diff] [blame] | 34 | [ValidateSet("all_in_one","dns", "mr", "sdc", "aai", "mso", "robot", "vid", "sdnc", "portal", "dcae", "policy", "appc", "vfc", "multicloud", "ccsdk", "vnfsdk", "vvp", "openstack", "msb", "testing")] |
Victor Morales | 4ab71c1 | 2017-11-08 07:28:28 -0800 | [diff] [blame] | 35 | |
Victor Morales | 5d5c5da | 2017-08-15 16:24:05 -0500 | [diff] [blame] | 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] |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 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 |
Victor Morales | 5d5c5da | 2017-08-15 16:24:05 -0500 | [diff] [blame] | 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 | |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 83 | $env:SKIP_GET_IMAGES=$skip_get_images |
| 84 | $env:SKIP_INSTALL=$skip_install |
| 85 | |
Victor Morales | 5d5c5da | 2017-08-15 16:24:05 -0500 | [diff] [blame] | 86 | switch ($Command) |
Victor Morales | 134f97a | 2017-08-08 16:08:19 -0500 | [diff] [blame] | 87 | { |
| 88 | "all_in_one" { $env:DEPLOY_MODE="all-in-one" } |
Victor Morales | 9d205bc | 2017-12-01 17:52:07 -0800 | [diff] [blame] | 89 | { @("dns", "mr", "sdc", "aai", "mso", "robot", "vid", "sdnc", "portal", "dcae", "policy", "appc", "vfc", "multicloud", "ccsdk", "vnfsdk", "vvp", "openstack", "msb") -contains $_ } { $env:DEPLOY_MODE="individual" } |
Victor Morales | 134f97a | 2017-08-08 16:08:19 -0500 | [diff] [blame] | 90 | "testing" |
| 91 | { |
| 92 | $env:DEPLOY_MODE="testing" |
Victor Morales | 5d5c5da | 2017-08-15 16:24:05 -0500 | [diff] [blame] | 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 |
Victor Morales | 134f97a | 2017-08-08 16:08:19 -0500 | [diff] [blame] | 108 | |
Victor Morales | 5d5c5da | 2017-08-15 16:24:05 -0500 | [diff] [blame] | 109 | &cmd.exe /c rd /s /q .\opt\ |
| 110 | &cmd.exe /c rd /s /q $HOME\.m2\ |
Victor Morales | 2016306 | 2017-08-09 10:50:44 -0500 | [diff] [blame] | 111 | } |
| 112 | default |
| 113 | { |
Victor Morales | d3cbcf2 | 2017-10-25 16:01:58 -0700 | [diff] [blame] | 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}" |
Victor Morales | 2016306 | 2017-08-09 10:50:44 -0500 | [diff] [blame] | 115 | exit 1 |
Victor Morales | 134f97a | 2017-08-08 16:08:19 -0500 | [diff] [blame] | 116 | } |
| 117 | } |
| 118 | |
Victor Morales | 5d5c5da | 2017-08-15 16:24:05 -0500 | [diff] [blame] | 119 | vagrant destroy -f $Command |
| 120 | vagrant up $Command |