Skip to content

Networking Hybrid team minor but important PS changes #1230

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 4 commits into from
Nov 3, 2015
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
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.13-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.15-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function Test-ExpressRouteCircuitCRUD
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation

# Create the ExpressRouteCircuit
$circuit = New-AzureRmExpressRouteCircuit -Name $circuitName -Location $location -ResourceGroupName $rgname -SkuTier Standard -SkuFamily MeteredData -ServiceProviderName "equinix" -PeeringLocation "Silicon Valley" -BandwidthInMbps 1000;
$circuit = New-AzureRmExpressRouteCircuit -Name $circuitName -Location $location -ResourceGroupName $rgname -SkuTier Standard -SkuFamily MeteredData -BillingType MeteredData -ServiceProviderName "equinix" -PeeringLocation "Silicon Valley" -BandwidthInMbps 1000;

# get Circuit
$getCircuit = Get-AzureRmExpressRouteCircuit -Name $circuitName -ResourceGroupName $rgname
Expand Down Expand Up @@ -61,7 +61,7 @@ function Test-ExpressRouteCircuitCRUD
# set
$getCircuit.ServiceProviderProperties.BandwidthInMbps = 500

$getCircuit = $getCircuit | Set-AzureRmExpressRouteCircuit
$getCircuit = Set-AzureRmExpressRouteCircuit -ExpressRouteCircuit $getCircuit -BillingType UnlimitedData
Assert-AreEqual $rgName $getCircuit.ResourceGroupName
Assert-AreEqual $circuitName $getCircuit.Name
Assert-NotNull $getCircuit.Location
Expand Down Expand Up @@ -108,7 +108,7 @@ function Test-ExpressRouteCircuitPeeringCRUD

# Create the ExpressRouteCircuit with peering
$peering = New-AzureRmExpressRouteCircuitPeeringConfig -Name AzurePrivatePeering -PeeringType AzurePrivatePeering -PeerASN 100 -PrimaryPeerAddressPrefix "192.168.1.0/30" -SecondaryPeerAddressPrefix "192.168.2.0/30" -VlanId 200
$circuit = New-AzureRmExpressRouteCircuit -Name $circuitName -Location $location -ResourceGroupName $rgname -SkuTier Standard -SkuFamily MeteredData -ServiceProviderName "equinix" -PeeringLocation "Silicon Valley" -BandwidthInMbps 1000 -Peering $peering
$circuit = New-AzureRmExpressRouteCircuit -Name $circuitName -Location $location -ResourceGroupName $rgname -SkuTier Standard -SkuFamily MeteredData -BillingType UnlimitedData -ServiceProviderName "equinix" -PeeringLocation "Silicon Valley" -BandwidthInMbps 1000 -Peering $peering

#verification
Assert-AreEqual $rgName $circuit.ResourceGroupName
Expand Down Expand Up @@ -146,7 +146,7 @@ function Test-ExpressRouteCircuitPeeringCRUD
Assert-AreEqual 1 @($listPeering).Count

# add a new Peering
$circuit = Get-AzureRmExpressRouteCircuit -Name $circuitName -ResourceGroupName $rgname | Add-AzureRmExpressRouteCircuitPeeringConfig -Name MicrosoftPeering -PeeringType MicrosoftPeering -PeerASN 99 -PrimaryPeerAddressPrefix "192.168.1.0/30" -SecondaryPeerAddressPrefix "192.168.2.0/30" -VlanId 200 -MircosoftConfigAdvertisedPublicPrefixes @("11.2.3.4/30", "12.2.3.4/30") -MircosoftConfigCustomerAsn 1000 -MircosoftConfigRoutingRegistryName AFRINIC | Set-AzureRmExpressRouteCircuit
$circuit = Get-AzureRmExpressRouteCircuit -Name $circuitName -ResourceGroupName $rgname | Add-AzureRmExpressRouteCircuitPeeringConfig -Name MicrosoftPeering -PeeringType MicrosoftPeering -PeerASN 99 -PrimaryPeerAddressPrefix "192.168.1.0/30" -SecondaryPeerAddressPrefix "192.168.2.0/30" -VlanId 200 -MircosoftConfigAdvertisedPublicPrefixes @("11.2.3.4/30", "12.2.3.4/30") -MircosoftConfigCustomerAsn 1000 -MircosoftConfigRoutingRegistryName AFRINIC | Set-AzureRmExpressRouteCircuit -BillingType UnlimitedData

$p = $circuit | Get-AzureRmExpressRouteCircuitPeeringConfig -Name MicrosoftPeering
Assert-AreEqual "MicrosoftPeering" $p.Name
Expand All @@ -165,7 +165,7 @@ function Test-ExpressRouteCircuitPeeringCRUD
Assert-AreEqual 2 @($listPeering).Count

# Set a new peering
$circuit = Get-AzureRmExpressRouteCircuit -Name $circuitName -ResourceGroupName $rgname | Set-AzureRmExpressRouteCircuitPeeringConfig -Name MicrosoftPeering -PeeringType MicrosoftPeering -PeerASN 100 -PrimaryPeerAddressPrefix "192.168.1.0/30" -SecondaryPeerAddressPrefix "192.168.2.0/30" -VlanId 200 -MircosoftConfigAdvertisedPublicPrefixes @("11.2.3.4/30", "12.2.3.4/30") -MircosoftConfigCustomerAsn 1000 -MircosoftConfigRoutingRegistryName AFRINIC | Set-AzureRmExpressRouteCircuit
$circuit = Get-AzureRmExpressRouteCircuit -Name $circuitName -ResourceGroupName $rgname | Set-AzureRmExpressRouteCircuitPeeringConfig -Name MicrosoftPeering -PeeringType MicrosoftPeering -PeerASN 100 -PrimaryPeerAddressPrefix "192.168.1.0/30" -SecondaryPeerAddressPrefix "192.168.2.0/30" -VlanId 200 -MircosoftConfigAdvertisedPublicPrefixes @("11.2.3.4/30", "12.2.3.4/30") -MircosoftConfigCustomerAsn 1000 -MircosoftConfigRoutingRegistryName AFRINIC | Set-AzureRmExpressRouteCircuit -BillingType UnlimitedData
$p = $circuit | Get-AzureRmExpressRouteCircuitPeeringConfig -Name MicrosoftPeering
Assert-AreEqual "MicrosoftPeering" $p.Name
Assert-AreEqual "MicrosoftPeering" $p.PeeringType
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Graph.RBAC" version="1.7.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Authorization" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Network" version="2.0.13-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Network" version="2.0.15-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.18.7-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Test.Framework" version="1.0.5774.40163-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.0.5774.40163-prerelease" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.1.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.13-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.2.0.15-preview\lib\net40\Microsoft.Azure.Management.Network.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -296,6 +296,8 @@
<Compile Include="VirtualNetworkGateway\NewAzureVirtualNetworkGatewayIpConfigCommand.cs" />
<Compile Include="VirtualNetworkGateway\RemoveAzureVirtualNetworkGatewayCommand.cs" />
<Compile Include="VirtualNetworkGateway\ResetAzureVirtualNetworkGatewayCommand.cs" />
<Compile Include="VirtualNetworkGateway\SetAzureVirtualNetworkGatewayDefaultSiteCommand.cs" />
<Compile Include="VirtualNetworkGateway\RemoveAzureVirtualNetworkGatewayDefaultSiteCommand.cs" />
<Compile Include="LocalNetworkGateway\LocalNetworkGatewayBaseCmdlet.cs" />
<Compile Include="LocalNetworkGateway\RemoveAzureLocalNetworkGatewayCommand.cs" />
<Compile Include="LocalNetworkGateway\GetAzureLocalNetworkGatewayCommand.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,20 @@ public class NewAzureExpressRouteCircuitCommand : ExpressRouteCircuitBaseCmdlet
public int BandwidthInMbps { get; set; }

[Parameter(
Mandatory = false,
Mandatory = false,
ValueFromPipelineByPropertyName = true)]
[ValidateNotNullOrEmpty]
public List<PSPeering> Peering { get; set; }

[Parameter(
Mandatory = true,
ValueFromPipelineByPropertyName = true)]
[ValidateSet(
MNM.ExpressRouteCircuitBillingType.MeteredData,
MNM.ExpressRouteCircuitBillingType.UnlimitedData,
IgnoreCase = true)]
public string BillingType { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
Expand Down Expand Up @@ -129,7 +138,7 @@ private PSExpressRouteCircuit CreateExpressRouteCircuit()
circuit.Name = this.Name;
circuit.ResourceGroupName = this.ResourceGroupName;
circuit.Location = this.Location;

// Construct sku
if (!string.IsNullOrEmpty(this.SkuTier))
{
Expand All @@ -150,6 +159,7 @@ private PSExpressRouteCircuit CreateExpressRouteCircuit()

circuit.Peerings = new List<PSPeering>();
circuit.Peerings = this.Peering;
circuit.BillingType = this.BillingType;

// Map to the sdk object
var circuitModel = Mapper.Map<MNM.ExpressRouteCircuit>(circuit);
Expand All @@ -160,7 +170,7 @@ private PSExpressRouteCircuit CreateExpressRouteCircuit()
this.ExpressRouteCircuitClient.CreateOrUpdate(this.ResourceGroupName, this.Name, circuitModel);

var getExpressRouteCircuit = this.GetExpressRouteCircuit(this.ResourceGroupName, this.Name);

getExpressRouteCircuit.BillingType = this.BillingType;
return getExpressRouteCircuit;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ public class SetAzureExpressRouteCircuitCommand : ExpressRouteCircuitBaseCmdlet
HelpMessage = "The ExpressRouteCircuit")]
public PSExpressRouteCircuit ExpressRouteCircuit { get; set; }

[Parameter(
Mandatory = true,
ValueFromPipelineByPropertyName = true)]
[ValidateSet(
MNM.ExpressRouteCircuitBillingType.MeteredData,
MNM.ExpressRouteCircuitBillingType.UnlimitedData,
IgnoreCase = true)]
public string BillingType { get; set; }

protected override void ProcessRecord()
{
base.ProcessRecord();
Expand All @@ -39,7 +48,8 @@ protected override void ProcessRecord()
{
throw new ArgumentException(Microsoft.Azure.Commands.Network.Properties.Resources.ResourceNotFound);
}

ExpressRouteCircuit.BillingType = BillingType;

// Map to the sdk object
var circuitModel = Mapper.Map<MNM.ExpressRouteCircuit>(this.ExpressRouteCircuit);
circuitModel.Type = Microsoft.Azure.Commands.Network.Properties.Resources.ExpressRouteCircuitType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class PSExpressRouteCircuit : PSTopLevelResource

public PSExpressRouteCircuitSku Sku { get; set; }

public string BillingType { get; set; }

public string ProvisioningState { get; set; }

[JsonIgnore]
Expand All @@ -47,7 +49,7 @@ public string ServiceProviderPropertiesText
{
get { return JsonConvert.SerializeObject(ServiceProviderProperties, Formatting.Indented); }
}

[JsonIgnore]
public string PeeringsText
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,21 @@ public class PSVirtualNetworkGateway : PSTopLevelResource
public string VpnType { get; set; }

public bool EnableBgp { get; set; }


public PSResourceId GatewayDefaultSite { get; set; }

public string ProvisioningState { get; set; }

[JsonIgnore]
public string IpConfigurationsText
{
get { return JsonConvert.SerializeObject(IpConfigurations, Formatting.Indented); }
}

[JsonIgnore]
public string GatewayDefaultSiteText
{
get { return JsonConvert.SerializeObject(GatewayDefaultSite, Formatting.Indented); }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public class PSVirtualNetworkGatewayConnection : PSTopLevelResource

public string SharedKey { get; set; }

public string ConnectionStatus { get; set; }

public ulong EgressBytesTransferred { get; set; }

public ulong IngressBytesTransferred { get; set; }

[JsonIgnore]
public string VirtualNetworkGateway1Text
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ public class NewAzureVirtualNetworkGatewayCommand : VirtualNetworkGatewayBaseCmd
HelpMessage = "EnableBgp Flag")]
public bool EnableBgp { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
ParameterSetName = "SetByResource",
HelpMessage = "GatewayDefaultSite")]
public PSLocalNetworkGateway GatewayDefaultSite { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
Expand Down Expand Up @@ -132,6 +139,16 @@ private PSVirtualNetworkGateway CreateVirtualNetworkGateway()
vnetGateway.VpnType = this.VpnType;
vnetGateway.EnableBgp = this.EnableBgp;

if (this.GatewayDefaultSite != null)
{
vnetGateway.GatewayDefaultSite = new PSResourceId();
vnetGateway.GatewayDefaultSite.Id = this.GatewayDefaultSite.Id;
}
else
{
vnetGateway.GatewayDefaultSite = null;
}

// Map to the sdk object
var vnetGatewayModel = Mapper.Map<MNM.VirtualNetworkGateway>(vnetGateway);
vnetGatewayModel.Type = Microsoft.Azure.Commands.Network.Properties.Resources.VirtualNetworkGatewayType;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// ----------------------------------------------------------------------------------
//
// 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 System.Management.Automation;
using AutoMapper;
using Microsoft.Azure.Management.Network;
using Microsoft.Azure.Commands.Network.Models;
using Microsoft.Azure.Commands.Resources.Models;
using MNM = Microsoft.Azure.Management.Network.Models;
using System.Collections;
using Microsoft.Azure.Commands.Tags.Model;
using System.Collections.Generic;

namespace Microsoft.Azure.Commands.Network
{
[Cmdlet(VerbsCommon.Remove, "AzureVirtualNetworkGatewayDefaultSite"), OutputType(typeof(PSVirtualNetworkGateway))]
public class RemoveAzureVirtualNetworkGatewayDefaultSiteCommand : VirtualNetworkGatewayBaseCmdlet
{
[Parameter(
Mandatory = true,
ValueFromPipeline = true,
HelpMessage = "The VirtualNetworkGateway")]
public PSVirtualNetworkGateway VirtualNetworkGateway { get; set; }

protected override void ProcessRecord()
{
base.ProcessRecord();

if (!this.IsVirtualNetworkGatewayPresent(this.VirtualNetworkGateway.ResourceGroupName, this.VirtualNetworkGateway.Name))
{
throw new ArgumentException(Microsoft.Azure.Commands.Network.Properties.Resources.ResourceNotFound);
}

//this.VirtualNetworkGateway.GatewayDefaultSite = new PSResourceId();
//this.VirtualNetworkGateway.GatewayDefaultSite.Id = string.Empty;
this.VirtualNetworkGateway.GatewayDefaultSite = null;

// Map to the sdk object
var virtualnetGatewayModel = Mapper.Map<MNM.VirtualNetworkGateway>(this.VirtualNetworkGateway);
virtualnetGatewayModel.Type = Microsoft.Azure.Commands.Network.Properties.Resources.VirtualNetworkGatewayType;
virtualnetGatewayModel.Tags = TagsConversionHelper.CreateTagDictionary(this.VirtualNetworkGateway.Tag, validate: true);

this.VirtualNetworkGatewayClient.CreateOrUpdate(this.VirtualNetworkGateway.ResourceGroupName, this.VirtualNetworkGateway.Name, virtualnetGatewayModel);

var getvirtualnetGateway = this.GetVirtualNetworkGateway(this.VirtualNetworkGateway.ResourceGroupName, this.VirtualNetworkGateway.Name);

WriteObject(getvirtualnetGateway);
}
}
}

Loading