Skip to content

Commit fd402ae

Browse files
committed
Update install script to allow overwriting parameters
The latest version of the plugin introduces support for public cloud setups. This is the behavior by default, this change adds parameters to change the behavior (this needs to be used in the private cloud stack).
1 parent b995add commit fd402ae

File tree

1 file changed

+42
-9
lines changed

1 file changed

+42
-9
lines changed

Containers/InstallPrivateCloudPlugin.ps1

+42-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
# The enable-privilege function was taken from the Windows PowerShell Cookbook and made publically available via this URL: http://www.leeholmes.com/blog/2010/09/24/adjusting-token-privileges-in-powershell/
1+
# This script is for testing purposes; The below registration is being added to the manifest.
22

3-
# Run this script on the Container Host (Tenant) VM
4-
5-
param([switch]$remove)
3+
param(
4+
[switch]$remove, # remove the plugin
5+
[parameter(Mandatory=$false)] [String]$addr,
6+
[parameter(Mandatory=$false)] [int]$port,
7+
[parameter(Mandatory=$false)] [String]$path,
8+
[parameter(Mandatory=$false)] [String]$format
9+
)
610

11+
$agentpath = $path # gets overwritten later, but still keep it user-friendly
712

813
if(!$remove)
914
{
10-
function enable-privilege {
11-
param(
15+
function enable-privilege {
16+
param(
1217
## The privilege to adjust. This set is taken from
1318
## http://msdn.microsoft.com/en-us/library/bb530716(VS.85).aspx
1419
[ValidateSet(
@@ -28,7 +33,7 @@ function enable-privilege {
2833
$ProcessId = $pid,
2934
## Switch to disable the privilege, rather than enable it.
3035
[Switch] $Disable
31-
)
36+
)
3237

3338
## Taken from P/Invoke.NET with minor adjustments.
3439
$definition = @'
@@ -110,8 +115,6 @@ function enable-privilege {
110115
$key.Close()
111116
}
112117

113-
114-
115118
$clsid_plugin = "D5AAF7C4-1B3E-4b49-9CF9-9263FAB9DC6D"
116119
$path = "HKLM:\system\CurrentControlSet\services\hns\Parameters"
117120

@@ -122,6 +125,36 @@ $null = new-itemproperty -path $pluginpath -name "NetworkRequests" -value 31;
122125
$null = new-itemproperty -path $pluginpath -name "EndpointRequests" -value 31;
123126
$null = new-itemproperty -path $pluginpath -name "ServiceRequests" -value 7;
124127

128+
# If the user specified a particular set of configuration parameters, install..
129+
if ($addr -and $port -and $format -and $agentpath)
130+
{
131+
$VALID_FORMATS = "xml","json"
132+
$format = $format.ToLower();
133+
$isValidFormat = $false;
134+
135+
foreach ($fmt in $VALID_FORMATS)
136+
{
137+
if ($format -eq $fmt)
138+
{
139+
$isValidFormat = $true;
140+
break;
141+
}
142+
}
143+
144+
if (!$isValidFormat)
145+
{
146+
Write-Host -ForegroundColor red -NoNewline "Invalid format! ($format) ... "
147+
Write-Host -ForegroundColor red "Must be one of [ ($VALID_FORMATS -join ', ') ]"
148+
}
149+
else
150+
{
151+
echo "Installing configuration: request=${addr}:${port}/${agentpath}, format=${format}"
152+
$null = New-ItemProperty -Path $pluginpath -name "AgentIPAddress" -value $addr
153+
$null = New-ItemProperty -Path $pluginpath -name "AgentFormat" -value $format
154+
$null = New-ItemProperty -Path $pluginpath -name "AgentPort" -value $port
155+
$null = New-ItemProperty -Path $pluginpath -name "AgentPath" -value $agentpath
156+
}
157+
}
125158

126159
$data = @(
127160
[psobject]@{ Path="HKLM:Software\Classes\CLSID\{$clsid_plugin}";

0 commit comments

Comments
 (0)