Skip to content

Commit 99623cf

Browse files
committed
Merge pull request #289 from Azure/clu
Clu
2 parents 50ed951 + 0157049 commit 99623cf

File tree

292 files changed

+50048
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

292 files changed

+50048
-3
lines changed

src/CLU/CLUCoreCLR.sln

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,15 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Sync", "Sync\Sync.xproj", "
6464
{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9} = {094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}
6565
EndProjectSection
6666
EndProject
67+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Azure.Commands.Network", "Microsoft.Azure.Commands.Network\Microsoft.Azure.Commands.Network.xproj", "{C4DCF4EA-62E7-431E-ADB5-16FD6CFEA5D6}"
68+
EndProject
6769
Global
6870
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6971
Debug|Any CPU = Debug|Any CPU
7072
Release|Any CPU = Release|Any CPU
7173
EndGlobalSection
7274
GlobalSection(ProjectConfigurationPlatforms) = postSolution
7375
{5F567ACA-595E-436D-83DB-A21E08F82DF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
74-
{5F567ACA-595E-436D-83DB-A21E08F82DF6}.Debug|Any CPU.Build.0 = Debug|Any CPU
7576
{5F567ACA-595E-436D-83DB-A21E08F82DF6}.Release|Any CPU.ActiveCfg = Release|Any CPU
7677
{5F567ACA-595E-436D-83DB-A21E08F82DF6}.Release|Any CPU.Build.0 = Release|Any CPU
7778
{4CE82310-D016-497D-93A0-0323A3E62064}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
@@ -153,7 +154,6 @@ Global
153154
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
154155
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
155156
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
156-
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Release|Any CPU.Build.0 = Release|Any CPU
157157
{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
158158
{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
159159
{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -162,6 +162,10 @@ Global
162162
{6EDCB32A-8420-48FC-99CE-94BEA12D2FD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
163163
{6EDCB32A-8420-48FC-99CE-94BEA12D2FD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
164164
{6EDCB32A-8420-48FC-99CE-94BEA12D2FD2}.Release|Any CPU.Build.0 = Release|Any CPU
165+
{C4DCF4EA-62E7-431E-ADB5-16FD6CFEA5D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
166+
{C4DCF4EA-62E7-431E-ADB5-16FD6CFEA5D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
167+
{C4DCF4EA-62E7-431E-ADB5-16FD6CFEA5D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
168+
{C4DCF4EA-62E7-431E-ADB5-16FD6CFEA5D6}.Release|Any CPU.Build.0 = Release|Any CPU
165169
EndGlobalSection
166170
GlobalSection(SolutionProperties) = preSolution
167171
HideSolutionNode = FALSE
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+

2+
// ----------------------------------------------------------------------------------
3+
//
4+
// Copyright Microsoft Corporation
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
// ----------------------------------------------------------------------------------
15+
16+
using System.Net;
17+
using AutoMapper;
18+
using Microsoft.Azure.Commands.Network.Models;
19+
using Microsoft.Azure.Commands.Tags.Model;
20+
using Microsoft.Azure.Management.Network;
21+
using Microsoft.Azure.Management.Network.Models;
22+
23+
24+
namespace Microsoft.Azure.Commands.Network
25+
{
26+
public abstract class ApplicationGatewayBaseCmdlet : NetworkBaseCmdlet
27+
{
28+
public IApplicationGatewaysOperations ApplicationGatewayClient
29+
{
30+
get
31+
{
32+
return NetworkClient.NetworkManagementClient.ApplicationGateways;
33+
}
34+
}
35+
36+
public bool IsApplicationGatewayPresent(string resourceGroupName, string name)
37+
{
38+
try
39+
{
40+
GetApplicationGateway(resourceGroupName, name);
41+
}
42+
catch (Microsoft.Rest.Azure.CloudException exception)
43+
{
44+
if (exception.Response.StatusCode == HttpStatusCode.NotFound)
45+
{
46+
// Resource is not present
47+
return false;
48+
}
49+
50+
throw;
51+
}
52+
53+
return true;
54+
}
55+
56+
public PSApplicationGateway GetApplicationGateway(string resourceGroupName, string name)
57+
{
58+
var appGateway = this.ApplicationGatewayClient.Get(resourceGroupName, name);
59+
60+
var psApplicationGateway = Mapper.Map<PSApplicationGateway>(appGateway);
61+
psApplicationGateway.ResourceGroupName = resourceGroupName;
62+
psApplicationGateway.Tag =
63+
TagsConversionHelper.CreateTagHashtable(appGateway.Tags);
64+
65+
return psApplicationGateway;
66+
}
67+
68+
public PSApplicationGateway ToPsApplicationGateway(ApplicationGateway appGw)
69+
{
70+
var psAppGw = Mapper.Map<PSApplicationGateway>(appGw);
71+
72+
psAppGw.Tag = TagsConversionHelper.CreateTagHashtable(appGw.Tags);
73+
74+
return psAppGw;
75+
}
76+
}
77+
}
Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using Microsoft.Azure.Commands.Network.Models;
17+
using MNM = Microsoft.Azure.Management.Network.Models;
18+
19+
namespace Microsoft.Azure.Commands.Network
20+
{
21+
public static class ApplicationGatewayChildResourceHelper
22+
{
23+
public static string GetResourceId(
24+
string subscriptionId,
25+
string resourceGroupName,
26+
string applicationGatewayName,
27+
string resource,
28+
string resourceName)
29+
{
30+
return string.Format(
31+
Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewayChildResourceId,
32+
subscriptionId,
33+
resourceGroupName,
34+
applicationGatewayName,
35+
resource,
36+
resourceName);
37+
}
38+
39+
public static string GetResourceNotSetId(string subscriptionId, string resource, string resourceName)
40+
{
41+
return string.Format(
42+
Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewayChildResourceId,
43+
subscriptionId,
44+
Microsoft.Azure.Commands.Network.Properties.Resources.ResourceGroupNotSet,
45+
Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewayNameNotSet,
46+
resource,
47+
resourceName);
48+
}
49+
50+
private static string NormalizeApplicationGatewayNameChildResourceIds(string id, string resourceGroupName, string applicationGatewayName)
51+
{
52+
id = NormalizeId(id, "resourceGroups", resourceGroupName);
53+
id = NormalizeId(id, "applicationGateways", applicationGatewayName);
54+
55+
return id;
56+
}
57+
58+
private static string NormalizeId(string id, string resourceName, string resourceValue)
59+
{
60+
int startIndex = id.IndexOf(resourceName, StringComparison.OrdinalIgnoreCase) + resourceName.Length + 1;
61+
int endIndex = id.IndexOf("/", startIndex, StringComparison.OrdinalIgnoreCase);
62+
63+
// Replace the following string '/{value}/'
64+
startIndex--;
65+
string orignalString = id.Substring(startIndex, endIndex - startIndex + 1);
66+
67+
return id.Replace(orignalString, string.Format("/{0}/", resourceValue));
68+
}
69+
70+
public static void NormalizeChildResourcesId(PSApplicationGateway applicationGateway)
71+
{
72+
// Normalize GatewayIpConfiguration
73+
if (applicationGateway.GatewayIPConfigurations != null)
74+
{
75+
foreach (var gatewayIpConfig in applicationGateway.GatewayIPConfigurations)
76+
{
77+
gatewayIpConfig.Id = string.Empty;
78+
}
79+
}
80+
81+
// Normalize SslCertificates
82+
if (applicationGateway.SslCertificates != null)
83+
{
84+
foreach (var sslCertificate in applicationGateway.SslCertificates)
85+
{
86+
sslCertificate.Id = string.Empty;
87+
}
88+
}
89+
90+
// Normalize FrontendIpConfiguration
91+
if (applicationGateway.FrontendIPConfigurations != null)
92+
{
93+
foreach (var frontendIpConfiguration in applicationGateway.FrontendIPConfigurations)
94+
{
95+
frontendIpConfiguration.Id = string.Empty;
96+
}
97+
}
98+
99+
// Normalize FrontendPort
100+
if (applicationGateway.FrontendPorts != null)
101+
{
102+
foreach (var frontendPort in applicationGateway.FrontendPorts)
103+
{
104+
frontendPort.Id = string.Empty;
105+
}
106+
}
107+
108+
// Normalize BackendAddressPool
109+
if (applicationGateway.BackendAddressPools != null)
110+
{
111+
foreach (var backendAddressPool in applicationGateway.BackendAddressPools)
112+
{
113+
backendAddressPool.Id = string.Empty;
114+
}
115+
}
116+
117+
// Normalize Probe
118+
if (applicationGateway.Probes != null)
119+
{
120+
foreach (var probe in applicationGateway.Probes)
121+
{
122+
probe.Id = string.Empty;
123+
}
124+
}
125+
126+
// Normalize BackendHttpSettings
127+
if (applicationGateway.BackendHttpSettingsCollection != null)
128+
{
129+
foreach (var backendHttpSettings in applicationGateway.BackendHttpSettingsCollection)
130+
{
131+
backendHttpSettings.Id = string.Empty;
132+
133+
if (null != backendHttpSettings.Probe)
134+
{
135+
backendHttpSettings.Probe.Id = NormalizeApplicationGatewayNameChildResourceIds(
136+
backendHttpSettings.Probe.Id,
137+
applicationGateway.ResourceGroupName,
138+
applicationGateway.Name);
139+
}
140+
}
141+
}
142+
143+
// Normalize HttpListener
144+
if (applicationGateway.HttpListeners != null)
145+
{
146+
foreach (var httpListener in applicationGateway.HttpListeners)
147+
{
148+
httpListener.Id = string.Empty;
149+
150+
httpListener.FrontendPort.Id = NormalizeApplicationGatewayNameChildResourceIds(
151+
httpListener.FrontendPort.Id,
152+
applicationGateway.ResourceGroupName,
153+
applicationGateway.Name);
154+
155+
if (null != httpListener.FrontendIpConfiguration)
156+
{
157+
httpListener.FrontendIpConfiguration.Id = NormalizeApplicationGatewayNameChildResourceIds(
158+
httpListener.FrontendIpConfiguration.Id,
159+
applicationGateway.ResourceGroupName,
160+
applicationGateway.Name);
161+
}
162+
163+
if (null != httpListener.SslCertificate)
164+
{
165+
httpListener.SslCertificate.Id = NormalizeApplicationGatewayNameChildResourceIds(
166+
httpListener.SslCertificate.Id,
167+
applicationGateway.ResourceGroupName,
168+
applicationGateway.Name);
169+
}
170+
}
171+
}
172+
173+
// Normalize UrlPathMap
174+
if (applicationGateway.UrlPathMaps != null)
175+
{
176+
foreach (var urlPathMap in applicationGateway.UrlPathMaps)
177+
{
178+
urlPathMap.Id = string.Empty;
179+
180+
urlPathMap.DefaultBackendAddressPool.Id = NormalizeApplicationGatewayNameChildResourceIds(
181+
urlPathMap.DefaultBackendAddressPool.Id,
182+
applicationGateway.ResourceGroupName,
183+
applicationGateway.Name);
184+
185+
urlPathMap.DefaultBackendHttpSettings.Id = NormalizeApplicationGatewayNameChildResourceIds(
186+
urlPathMap.DefaultBackendHttpSettings.Id,
187+
applicationGateway.ResourceGroupName,
188+
applicationGateway.Name);
189+
190+
foreach (var pathRule in urlPathMap.PathRules)
191+
{
192+
pathRule.BackendAddressPool.Id = NormalizeApplicationGatewayNameChildResourceIds(
193+
pathRule.BackendAddressPool.Id,
194+
applicationGateway.ResourceGroupName,
195+
applicationGateway.Name);
196+
197+
pathRule.BackendHttpSettings.Id = NormalizeApplicationGatewayNameChildResourceIds(
198+
pathRule.BackendHttpSettings.Id,
199+
applicationGateway.ResourceGroupName,
200+
applicationGateway.Name);
201+
}
202+
}
203+
}
204+
205+
// Normalize RequestRoutingRule
206+
if (applicationGateway.RequestRoutingRules != null)
207+
{
208+
foreach (var requestRoutingRule in applicationGateway.RequestRoutingRules)
209+
{
210+
requestRoutingRule.Id = string.Empty;
211+
212+
requestRoutingRule.HttpListener.Id = NormalizeApplicationGatewayNameChildResourceIds(
213+
requestRoutingRule.HttpListener.Id,
214+
applicationGateway.ResourceGroupName,
215+
applicationGateway.Name);
216+
217+
if (null != requestRoutingRule.BackendAddressPool)
218+
{
219+
requestRoutingRule.BackendAddressPool.Id = NormalizeApplicationGatewayNameChildResourceIds(
220+
requestRoutingRule.BackendAddressPool.Id,
221+
applicationGateway.ResourceGroupName,
222+
applicationGateway.Name);
223+
}
224+
225+
if (null != requestRoutingRule.BackendHttpSettings)
226+
{
227+
requestRoutingRule.BackendHttpSettings.Id = NormalizeApplicationGatewayNameChildResourceIds(
228+
requestRoutingRule.BackendHttpSettings.Id,
229+
applicationGateway.ResourceGroupName,
230+
applicationGateway.Name);
231+
}
232+
233+
if (null != requestRoutingRule.UrlPathMap)
234+
{
235+
requestRoutingRule.UrlPathMap.Id = NormalizeApplicationGatewayNameChildResourceIds(
236+
requestRoutingRule.UrlPathMap.Id,
237+
applicationGateway.ResourceGroupName,
238+
applicationGateway.Name);
239+
}
240+
}
241+
}
242+
}
243+
}
244+
}

0 commit comments

Comments
 (0)