Skip to content
Merged
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
10 changes: 10 additions & 0 deletions src/Network/Network/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@

## Version 4.16.1
* Fixed `ArgumentNullException` in `Add-AzureRmRouteConfig` when `RouteTable.Routes` is null.
* Added new cmdlets for RoutingIntent child resource of VirtualHub.
-`Add-AzRoutingPolicy`
-`Get-AzRoutingPolicy`
-`New-AzRoutingPolicy`
-`Remove-AzRoutingPolicy`
-`Set-AzRoutingPolicy`
-`Get-AzRoutingIntent`
-`New-AzRoutingIntent`
-`Remove-AzRoutingIntent`
-`Set-AzRoutingIntent`

## Version 4.16.0
* Added support for retrieving the state of packet capture even when the provisioning state of the packet capture was failure
Expand Down
9 changes: 9 additions & 0 deletions src/Network/Network/Common/NetworkResourceManagerProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,15 @@ private static void Initialize()
cfg.CreateMap<MNM.PropagatedRouteTable, CNM.PSPropagatedRouteTable>();
cfg.CreateMap<MNM.StaticRoute, CNM.PSStaticRoute>();

//// Virtual Hub Routing Intent
// CNM to MNM
cfg.CreateMap<CNM.PSRoutingIntent, MNM.RoutingIntent>();
cfg.CreateMap<CNM.PSRoutingPolicy, MNM.RoutingPolicy>();

// MNM to CNM
cfg.CreateMap<MNM.RoutingIntent, CNM.PSRoutingIntent>();
cfg.CreateMap<MNM.RoutingPolicy, CNM.PSRoutingPolicy>();

// Virtual wan Point to site
// MNM to CNM
cfg.CreateMap<MNM.P2SVpnGateway, CNM.PSP2SVpnGateway>();
Expand Down
6 changes: 5 additions & 1 deletion src/Network/Network/Cortex/CortexParameterSetNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,9 @@ internal static class CortexParameterSetNames
internal const string ByHubBgpConnectionObject = "ByHubBgpConnectionObject";
internal const string ByHubBgpConnectionResourceId = "ByHubBgpConnectionResourceId";

}
internal const string ByRoutingIntentName = "ByRoutingInctentName";
internal const string ByRoutingIntentResourceId = "ByRoutingInctentResourceId";
internal const string ByRoutingIntentObject = "ByRoutingInctentObject";

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@

// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

namespace Microsoft.Azure.Commands.Network
{
using System;
using System.Management.Automation;
using Microsoft.Azure.Commands.Network.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;

[Cmdlet(VerbsCommon.Get,
ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RoutingIntent",
DefaultParameterSetName = CortexParameterSetNames.ByVirtualHubName),
OutputType(typeof(PSRoutingIntent))]
public class GetAzureRmRoutingIntentCommand : RoutingIntentBaseCmdlet
{
[Parameter(
Mandatory = true,
ParameterSetName = CortexParameterSetNames.ByVirtualHubName,
HelpMessage = "The resource group name.")]
[ResourceGroupCompleter]
[ValidateNotNullOrEmpty]
public string ResourceGroupName { get; set; }

[Alias("VirtualHubName", "ParentVirtualHubName", "ParentResourceName")]
[Parameter(
Mandatory = true,
ParameterSetName = CortexParameterSetNames.ByVirtualHubName,
HelpMessage = "The parent resource name.")]
[ResourceNameCompleter("Microsoft.Network/virtualHubs", "ResourceGroupName")]
public string HubName { get; set; }

[Alias("ParentObject", "ParentVirtualHub")]
[Parameter(
Mandatory = true,
ValueFromPipeline = true,
ParameterSetName = CortexParameterSetNames.ByVirtualHubObject,
HelpMessage = "The parent resource.")]
public PSVirtualHub VirtualHub { get; set; }

[Alias("VirtualHubId", "ParentVirtualHubId")]
[Parameter(
Mandatory = true,
ValueFromPipelineByPropertyName = true,
ParameterSetName = CortexParameterSetNames.ByVirtualHubResourceId,
HelpMessage = "The parent resource id.")]
[ResourceIdCompleter("Microsoft.Network/virtualHubs")]
public string ParentResourceId { get; set; }

[Alias("ResourceName", "RoutingIntentName")]
[Parameter(
Mandatory = false,
HelpMessage = "The resource name.")]
[ResourceNameCompleter("Microsoft.Network/virtualHubs/routingIntent", "ResourceGroupName", "ParentResourceName")]
[ValidateNotNullOrEmpty]
[SupportsWildcards]
public string Name { get; set; }

public override void Execute()
{
base.Execute();

if (ParameterSetName.Equals(CortexParameterSetNames.ByVirtualHubObject, StringComparison.OrdinalIgnoreCase))
{
this.HubName = this.VirtualHub.Name;
this.ResourceGroupName = this.VirtualHub.ResourceGroupName;
}
else if (ParameterSetName.Equals(CortexParameterSetNames.ByVirtualHubResourceId, StringComparison.OrdinalIgnoreCase))
{
var parsedResourceId = new ResourceIdentifier(this.ParentResourceId);
this.HubName = parsedResourceId.ResourceName;
ResourceGroupName = parsedResourceId.ResourceGroupName;
}

if (ShouldGetByName(ResourceGroupName, Name))
{
WriteObject(GetRoutingIntent(this.ResourceGroupName, this.HubName, this.Name));
}
else
{
WriteObject(SubResourceWildcardFilter(Name, this.ListRoutingIntents(this.ResourceGroupName, this.HubName)), true);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

namespace Microsoft.Azure.Commands.Network
{
using System;
using System.Linq;
using System.Management.Automation;
using Microsoft.Azure.Commands.Network.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;

[Cmdlet(VerbsCommon.New,
ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RoutingIntent",
DefaultParameterSetName = CortexParameterSetNames.ByVirtualHubName,
SupportsShouldProcess = true),
OutputType(typeof(PSRoutingIntent))]
public class NewAzureRmRoutingIntentCommand : RoutingIntentBaseCmdlet
{
[Parameter(
Mandatory = true,
ParameterSetName = CortexParameterSetNames.ByVirtualHubName,
HelpMessage = "The resource group name.")]
[ResourceGroupCompleter]
[ValidateNotNullOrEmpty]
public string ResourceGroupName { get; set; }

[Alias("VirtualHubName", "ParentVirtualHubName")]
[Parameter(
Mandatory = true,
ParameterSetName = CortexParameterSetNames.ByVirtualHubName,
HelpMessage = "The resource group name.")]
public string ParentResourceName { get; set; }

[Alias("VirtualHub", "ParentVirtualHub")]
[Parameter(
Mandatory = true,
ValueFromPipeline = true,
ParameterSetName = CortexParameterSetNames.ByVirtualHubObject,
HelpMessage = "The parent resource.")]
public PSVirtualHub ParentObject { get; set; }

[Alias("VirtualHubId", "ParentVirtualHubId")]
[Parameter(
Mandatory = true,
ValueFromPipelineByPropertyName = true,
ParameterSetName = CortexParameterSetNames.ByVirtualHubResourceId,
HelpMessage = "The parent resource.")]
[ResourceIdCompleter("Microsoft.Network/virtualHubs")]
public string ParentResourceId { get; set; }

[Alias("ResourceName", "RoutingIntentName", "RoutingIntentName")]
[Parameter(
Mandatory = true,
HelpMessage = "Name of the routing intent resource.")]
public string Name { get; set; }

[Parameter(
Mandatory = true,
HelpMessage = "The list of policies for this routing intent resource.")]
public PSRoutingPolicy[] RoutingPolicy { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Run cmdlet in the background")]
public SwitchParameter AsJob { get; set; }

public override void Execute()
{
base.Execute();

if (ParameterSetName.Equals(CortexParameterSetNames.ByVirtualHubObject, StringComparison.OrdinalIgnoreCase))
{
this.ResourceGroupName = this.ParentObject.ResourceGroupName;
this.ParentResourceName = this.ParentObject.Name;
}
else if (ParameterSetName.Contains(CortexParameterSetNames.ByVirtualHubResourceId))
{
var parsedResourceId = new ResourceIdentifier(this.ParentResourceId);
this.ResourceGroupName = parsedResourceId.ResourceGroupName;
this.ParentResourceName = parsedResourceId.ResourceName;
}

if (this.IsRoutingIntentPresent(this.ResourceGroupName, this.ParentResourceName, this.Name))
{
throw new PSArgumentException(string.Format(Properties.Resources.ChildResourceAlreadyPresentInResourceGroup, this.Name, this.ResourceGroupName, this.ParentResourceName));
}

// this will thorw if hub does not exist.
IsParentVirtualHubPresent(this.ResourceGroupName, this.ParentResourceName);

PSRoutingIntent routingIntent = new PSRoutingIntent
{
Name = this.Name,
RoutingPolicies = this.RoutingPolicy.ToList()
};

ConfirmAction(
Properties.Resources.CreatingResourceMessage,
this.Name,
() =>
{
WriteVerbose(String.Format(Properties.Resources.CreatingLongRunningOperationMessage, this.ResourceGroupName, this.Name));
WriteObject(this.CreateOrUpdateRoutingIntent(this.ResourceGroupName, this.ParentResourceName, this.Name, routingIntent));
});
}
}
}
Loading