Skip to content

Clu #289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 1, 2016
Merged

Clu #289

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/CLU/CLUCoreCLR.sln
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,15 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Sync", "Sync\Sync.xproj", "
{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9} = {094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Azure.Commands.Network", "Microsoft.Azure.Commands.Network\Microsoft.Azure.Commands.Network.xproj", "{C4DCF4EA-62E7-431E-ADB5-16FD6CFEA5D6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5F567ACA-595E-436D-83DB-A21E08F82DF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5F567ACA-595E-436D-83DB-A21E08F82DF6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5F567ACA-595E-436D-83DB-A21E08F82DF6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F567ACA-595E-436D-83DB-A21E08F82DF6}.Release|Any CPU.Build.0 = Release|Any CPU
{4CE82310-D016-497D-93A0-0323A3E62064}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -153,7 +154,6 @@ Global
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Release|Any CPU.Build.0 = Release|Any CPU
{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -162,6 +162,10 @@ Global
{6EDCB32A-8420-48FC-99CE-94BEA12D2FD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6EDCB32A-8420-48FC-99CE-94BEA12D2FD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6EDCB32A-8420-48FC-99CE-94BEA12D2FD2}.Release|Any CPU.Build.0 = Release|Any CPU
{C4DCF4EA-62E7-431E-ADB5-16FD6CFEA5D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C4DCF4EA-62E7-431E-ADB5-16FD6CFEA5D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C4DCF4EA-62E7-431E-ADB5-16FD6CFEA5D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C4DCF4EA-62E7-431E-ADB5-16FD6CFEA5D6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@

// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System.Net;
using AutoMapper;
using Microsoft.Azure.Commands.Network.Models;
using Microsoft.Azure.Commands.Tags.Model;
using Microsoft.Azure.Management.Network;
using Microsoft.Azure.Management.Network.Models;


namespace Microsoft.Azure.Commands.Network
{
public abstract class ApplicationGatewayBaseCmdlet : NetworkBaseCmdlet
{
public IApplicationGatewaysOperations ApplicationGatewayClient
{
get
{
return NetworkClient.NetworkManagementClient.ApplicationGateways;
}
}

public bool IsApplicationGatewayPresent(string resourceGroupName, string name)
{
try
{
GetApplicationGateway(resourceGroupName, name);
}
catch (Microsoft.Rest.Azure.CloudException exception)
{
if (exception.Response.StatusCode == HttpStatusCode.NotFound)
{
// Resource is not present
return false;
}

throw;
}

return true;
}

public PSApplicationGateway GetApplicationGateway(string resourceGroupName, string name)
{
var appGateway = this.ApplicationGatewayClient.Get(resourceGroupName, name);

var psApplicationGateway = Mapper.Map<PSApplicationGateway>(appGateway);
psApplicationGateway.ResourceGroupName = resourceGroupName;
psApplicationGateway.Tag =
TagsConversionHelper.CreateTagHashtable(appGateway.Tags);

return psApplicationGateway;
}

public PSApplicationGateway ToPsApplicationGateway(ApplicationGateway appGw)
{
var psAppGw = Mapper.Map<PSApplicationGateway>(appGw);

psAppGw.Tag = TagsConversionHelper.CreateTagHashtable(appGw.Tags);

return psAppGw;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using Microsoft.Azure.Commands.Network.Models;
using MNM = Microsoft.Azure.Management.Network.Models;

namespace Microsoft.Azure.Commands.Network
{
public static class ApplicationGatewayChildResourceHelper
{
public static string GetResourceId(
string subscriptionId,
string resourceGroupName,
string applicationGatewayName,
string resource,
string resourceName)
{
return string.Format(
Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewayChildResourceId,
subscriptionId,
resourceGroupName,
applicationGatewayName,
resource,
resourceName);
}

public static string GetResourceNotSetId(string subscriptionId, string resource, string resourceName)
{
return string.Format(
Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewayChildResourceId,
subscriptionId,
Microsoft.Azure.Commands.Network.Properties.Resources.ResourceGroupNotSet,
Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewayNameNotSet,
resource,
resourceName);
}

private static string NormalizeApplicationGatewayNameChildResourceIds(string id, string resourceGroupName, string applicationGatewayName)
{
id = NormalizeId(id, "resourceGroups", resourceGroupName);
id = NormalizeId(id, "applicationGateways", applicationGatewayName);

return id;
}

private static string NormalizeId(string id, string resourceName, string resourceValue)
{
int startIndex = id.IndexOf(resourceName, StringComparison.OrdinalIgnoreCase) + resourceName.Length + 1;
int endIndex = id.IndexOf("/", startIndex, StringComparison.OrdinalIgnoreCase);

// Replace the following string '/{value}/'
startIndex--;
string orignalString = id.Substring(startIndex, endIndex - startIndex + 1);

return id.Replace(orignalString, string.Format("/{0}/", resourceValue));
}

public static void NormalizeChildResourcesId(PSApplicationGateway applicationGateway)
{
// Normalize GatewayIpConfiguration
if (applicationGateway.GatewayIPConfigurations != null)
{
foreach (var gatewayIpConfig in applicationGateway.GatewayIPConfigurations)
{
gatewayIpConfig.Id = string.Empty;
}
}

// Normalize SslCertificates
if (applicationGateway.SslCertificates != null)
{
foreach (var sslCertificate in applicationGateway.SslCertificates)
{
sslCertificate.Id = string.Empty;
}
}

// Normalize FrontendIpConfiguration
if (applicationGateway.FrontendIPConfigurations != null)
{
foreach (var frontendIpConfiguration in applicationGateway.FrontendIPConfigurations)
{
frontendIpConfiguration.Id = string.Empty;
}
}

// Normalize FrontendPort
if (applicationGateway.FrontendPorts != null)
{
foreach (var frontendPort in applicationGateway.FrontendPorts)
{
frontendPort.Id = string.Empty;
}
}

// Normalize BackendAddressPool
if (applicationGateway.BackendAddressPools != null)
{
foreach (var backendAddressPool in applicationGateway.BackendAddressPools)
{
backendAddressPool.Id = string.Empty;
}
}

// Normalize Probe
if (applicationGateway.Probes != null)
{
foreach (var probe in applicationGateway.Probes)
{
probe.Id = string.Empty;
}
}

// Normalize BackendHttpSettings
if (applicationGateway.BackendHttpSettingsCollection != null)
{
foreach (var backendHttpSettings in applicationGateway.BackendHttpSettingsCollection)
{
backendHttpSettings.Id = string.Empty;

if (null != backendHttpSettings.Probe)
{
backendHttpSettings.Probe.Id = NormalizeApplicationGatewayNameChildResourceIds(
backendHttpSettings.Probe.Id,
applicationGateway.ResourceGroupName,
applicationGateway.Name);
}
}
}

// Normalize HttpListener
if (applicationGateway.HttpListeners != null)
{
foreach (var httpListener in applicationGateway.HttpListeners)
{
httpListener.Id = string.Empty;

httpListener.FrontendPort.Id = NormalizeApplicationGatewayNameChildResourceIds(
httpListener.FrontendPort.Id,
applicationGateway.ResourceGroupName,
applicationGateway.Name);

if (null != httpListener.FrontendIpConfiguration)
{
httpListener.FrontendIpConfiguration.Id = NormalizeApplicationGatewayNameChildResourceIds(
httpListener.FrontendIpConfiguration.Id,
applicationGateway.ResourceGroupName,
applicationGateway.Name);
}

if (null != httpListener.SslCertificate)
{
httpListener.SslCertificate.Id = NormalizeApplicationGatewayNameChildResourceIds(
httpListener.SslCertificate.Id,
applicationGateway.ResourceGroupName,
applicationGateway.Name);
}
}
}

// Normalize UrlPathMap
if (applicationGateway.UrlPathMaps != null)
{
foreach (var urlPathMap in applicationGateway.UrlPathMaps)
{
urlPathMap.Id = string.Empty;

urlPathMap.DefaultBackendAddressPool.Id = NormalizeApplicationGatewayNameChildResourceIds(
urlPathMap.DefaultBackendAddressPool.Id,
applicationGateway.ResourceGroupName,
applicationGateway.Name);

urlPathMap.DefaultBackendHttpSettings.Id = NormalizeApplicationGatewayNameChildResourceIds(
urlPathMap.DefaultBackendHttpSettings.Id,
applicationGateway.ResourceGroupName,
applicationGateway.Name);

foreach (var pathRule in urlPathMap.PathRules)
{
pathRule.BackendAddressPool.Id = NormalizeApplicationGatewayNameChildResourceIds(
pathRule.BackendAddressPool.Id,
applicationGateway.ResourceGroupName,
applicationGateway.Name);

pathRule.BackendHttpSettings.Id = NormalizeApplicationGatewayNameChildResourceIds(
pathRule.BackendHttpSettings.Id,
applicationGateway.ResourceGroupName,
applicationGateway.Name);
}
}
}

// Normalize RequestRoutingRule
if (applicationGateway.RequestRoutingRules != null)
{
foreach (var requestRoutingRule in applicationGateway.RequestRoutingRules)
{
requestRoutingRule.Id = string.Empty;

requestRoutingRule.HttpListener.Id = NormalizeApplicationGatewayNameChildResourceIds(
requestRoutingRule.HttpListener.Id,
applicationGateway.ResourceGroupName,
applicationGateway.Name);

if (null != requestRoutingRule.BackendAddressPool)
{
requestRoutingRule.BackendAddressPool.Id = NormalizeApplicationGatewayNameChildResourceIds(
requestRoutingRule.BackendAddressPool.Id,
applicationGateway.ResourceGroupName,
applicationGateway.Name);
}

if (null != requestRoutingRule.BackendHttpSettings)
{
requestRoutingRule.BackendHttpSettings.Id = NormalizeApplicationGatewayNameChildResourceIds(
requestRoutingRule.BackendHttpSettings.Id,
applicationGateway.ResourceGroupName,
applicationGateway.Name);
}

if (null != requestRoutingRule.UrlPathMap)
{
requestRoutingRule.UrlPathMap.Id = NormalizeApplicationGatewayNameChildResourceIds(
requestRoutingRule.UrlPathMap.Id,
applicationGateway.ResourceGroupName,
applicationGateway.Name);
}
}
}
}
}
}
Loading