Skip to content
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

starting changes for ars autoscale #26908

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions src/Network/Network/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,9 @@
<data name="InvalidName" xml:space="preserve">
<value>Field Name {0} contains invalid character.</value>
</data>
<data name="RouteServerToUpdateNotFound" xml:space="preserve">
<value>The Route Server to update could not be found.</value>
</data>
<data name="VirtualHubToUpdateNotFound" xml:space="preserve">
<value>The VirtualHub to update could not be found.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ public partial class NewAzureRmRouteServer : RouteServerBaseCmdlet
[PSDefaultValue(Value=false)]
public SwitchParameter AllowBranchToBranchTraffic { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Autoscale configuration for route server.")]
public PSVirtualRouterAutoScaleConfiguration VirtualRouterAutoScaleConfiguration { get; set; }

public override void Execute()
{
base.Execute();
Expand Down Expand Up @@ -133,7 +138,8 @@ public override void Execute()
{
ResourceGroupName = this.ResourceGroupName,
Name = this.RouteServerName,
Location = this.Location
Location = this.Location,
VirtualRouterAutoScaleConfiguration = this.VirtualRouterAutoScaleConfiguration
};

if (string.IsNullOrWhiteSpace(this.HubRoutingPreference))
Expand Down
32 changes: 21 additions & 11 deletions src/Network/Network/RouteServer/UpdateAzureRMRouteServerCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ public partial class UpdateAzureRmRouteServer : RouteServerBaseCmdlet
IgnoreCase = true)]
public string HubRoutingPreference { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Autoscale configuration for route server.")]
public PSVirtualRouterAutoScaleConfiguration VirtualRouterAutoScaleConfiguration { get; set; }

public override void Execute()
{
base.Execute();
Expand All @@ -94,28 +99,33 @@ public override void Execute()
this.RouteServerName = resourceInfo.ResourceName;
}

var virtualHub = this.NetworkClient.NetworkManagementClient.VirtualHubs.Get(ResourceGroupName, RouteServerName);
var routeServer = this.NetworkClient.NetworkManagementClient.VirtualHubs.Get(ResourceGroupName, RouteServerName);
PSVirtualHub routeServerToUpdate = this.ToPsVirtualHub(routeServer); //?? throw new PSArgumentException(Properties.Resources.RouteServerToUpdateNotFound);

if (this.AllowBranchToBranchTraffic.HasValue)
{
virtualHub.AllowBranchToBranchTraffic = this.AllowBranchToBranchTraffic.Value;
routeServerToUpdate.AllowBranchToBranchTraffic = this.AllowBranchToBranchTraffic.Value;
}

if (!string.IsNullOrWhiteSpace(this.HubRoutingPreference))
{
virtualHub.HubRoutingPreference = this.HubRoutingPreference;
routeServerToUpdate.HubRoutingPreference = this.HubRoutingPreference;
}

if (this.VirtualRouterAutoScaleConfiguration != null)
{
routeServerToUpdate.VirtualRouterAutoScaleConfiguration = this.VirtualRouterAutoScaleConfiguration;
}

this.NetworkClient.NetworkManagementClient.VirtualHubs.CreateOrUpdate(this.ResourceGroupName, this.RouteServerName, virtualHub);
this.NetworkClient.NetworkManagementClient.VirtualHubs.CreateOrUpdate(this.ResourceGroupName, this.RouteServerName, routeServer);

var psVirtualHub = NetworkResourceManagerProfile.Mapper.Map<CNM.PSVirtualHub>(virtualHub);
psVirtualHub.ResourceGroupName = this.ResourceGroupName;
psVirtualHub.Tag = TagsConversionHelper.CreateTagHashtable(virtualHub.Tags);
AddBgpConnectionsToPSVirtualHub(psVirtualHub, ResourceGroupName, RouteServerName);
AddIpConfigurtaionToPSVirtualHub(psVirtualHub, this.ResourceGroupName, RouteServerName);
routeServerToUpdate.ResourceGroupName = this.ResourceGroupName;
routeServerToUpdate.Tag = TagsConversionHelper.CreateTagHashtable(routeServer.Tags);
AddBgpConnectionsToPSVirtualHub(routeServerToUpdate, ResourceGroupName, RouteServerName);
AddIpConfigurtaionToPSVirtualHub(routeServerToUpdate, this.ResourceGroupName, RouteServerName);

var routeServerModel = new PSRouteServer(psVirtualHub);
routeServerModel.Tag = TagsConversionHelper.CreateTagHashtable(virtualHub.Tags);
var routeServerModel = new PSRouteServer(routeServerToUpdate);
routeServerModel.Tag = TagsConversionHelper.CreateTagHashtable(routeServer.Tags);
WriteObject(routeServerModel, true);
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/Network/Network/VirtualRouter/RouteServerBaseCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
using Microsoft.Azure.Management.Network.Models;
using CNM = Microsoft.Azure.Commands.Network.Models;
using System.Collections.Generic;
using Microsoft.Azure.Commands.Network.Models;
using System;
using Microsoft.Azure.Commands.ResourceManager.Common.Tags;

namespace Microsoft.Azure.Commands.Network
{
Expand Down Expand Up @@ -37,5 +40,14 @@ public void AddIpConfigurtaionToPSVirtualHub(CNM.PSVirtualHub virtualHubModel,
virtualHubModel.IpConfigurations = new List<CNM.PSHubIpConfiguration>();
virtualHubModel.IpConfigurations.Add(ipconfig);
}

public PSVirtualHub ToPsVirtualHub(Management.Network.Models.VirtualHub virtualHub)
{
var psVirtualHub = NetworkResourceManagerProfile.Mapper.Map<PSVirtualHub>(virtualHub);

psVirtualHub.Tag = TagsConversionHelper.CreateTagHashtable(virtualHub.Tags);

return psVirtualHub;
}
}
}