Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
82132bf
add BYOIP models
dexiang-ms Jun 18, 2020
a8b5d67
first cherry pick batch
dexiang-ms Jun 19, 2020
f22ad6c
cherrypick second batch
dexiang-ms Jun 28, 2020
b87b907
remove geography tag from MasterCustomIpPrefix
dexiang-ms Jul 19, 2020
c25cdcc
cherrypick 3rd batch
dexiang-ms Jun 26, 2020
cac5f46
updated swagger to allow setting the commissioned state property, cor…
dexiang-ms Jul 27, 2020
df074a2
cherrypick #4
dexiang-ms Jul 28, 2020
b83c2bd
cherrypick #5
dexiang-ms Jul 29, 2020
e988093
update MasterCustomIpPrefix test
dexiang-ms Jul 29, 2020
9d96648
cherrypick #6
dexiang-ms Aug 4, 2020
d4b3994
cherry pick #7
dexiang-ms Aug 13, 2020
fa7906a
fix some text typos and added the help files
dexiang-ms Aug 13, 2020
6d9c536
clean up issues form cherry picking
dexiang-ms Aug 19, 2020
a3c783b
Merge remote-tracking branch 'upstream/network-june' into dexiang/byoip
dexiang-ms Aug 24, 2020
664fd68
update the csproj
dexiang-ms Aug 24, 2020
11f3def
update sdk nuget package
dexiang-ms Aug 24, 2020
37cd92a
add online version url for help files
dexiang-ms Aug 24, 2020
87dd486
update Network.Test.csproj sdk reference
dexiang-ms Aug 24, 2020
f10e551
Merge branch 'network-june' into dexiang/byoip
dexiang-ms Aug 25, 2020
81eb8b3
merge from upstream/network-june branch and resolve merge conflicts
dexiang-ms Aug 27, 2020
ebddff6
pull from origin/dexiang/byoip and fix merge conflict
dexiang-ms Aug 27, 2020
f0d0af4
Merge remote-tracking branch 'upstream/network-june' into dexiang/byoip
dexiang-ms Aug 28, 2020
4a0f72d
skip CustomIpPrefix tests
dexiang-ms Aug 28, 2020
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.Test/NrpTeamAlias.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,8 @@ class NrpTeamAlias

// Azure Network IPAM dev team
public const string ipam = "ipamdev";

// Azure Network Billing and Telemetry team
public const string billingandtelemetry = "azurenetworkbilling";
}
}
37 changes: 37 additions & 0 deletions src/Network/Network.Test/ScenarioTests/CustomIpPrefixTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// ----------------------------------------------------------------------------------
//
// 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 Microsoft.Azure.Commands.Network.Test.ScenarioTests;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

namespace Commands.Network.Test.ScenarioTests
{

public class CustomIpPrefixTests : NetworkTestRunner
{
public CustomIpPrefixTests(Xunit.Abstractions.ITestOutputHelper output)
: base(output)
{
}

[Fact(Skip = "Resource currently in private preview, testing requires very specific conditions, will implement these tests in future.")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.billingandtelemetry)]
public void TestCustomIpPrefixCRUD()
{
TestRunner.RunTestScript("Test-CustomIpPrefixCRUD");
}
}
}
117 changes: 117 additions & 0 deletions src/Network/Network.Test/ScenarioTests/CustomIpPrefixTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------

<#
.SYNOPSIS
Tests CRUD operations on a simple customIpPrefix.

NOTE: This feature is currently in private preview, so updated binaries are on test slice in canary only and is currently un-reacheable via the production manifest.
Testing has been done locally using the brazilus ARM endpoint and a specific subscription that has the necessary flags to run these cmdlets.
#>
function Test-CustomIpPrefixCRUD
{
# Setup
$rgname = "powershell-test-rg"
$rname = "testCustomIpPrefix"
$location = "eastus2euap"
$cidr = "40.40.40.0/24"

try
{
# Create the resource group
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation

# Create customIpPrefix
$job = New-AzCustomIpPrefix -Name $rname -ResourceGroupName $rgname -location $location -Cidr $cidr -AsJob
$job | Wait-Job
$job | Receive-Job

# get by name and resource group
$actual = Get-AzCustomIpPrefix -ResourceGroupName $rgname -name $rname
Assert-AreEqual $actual.ResourceGroupName $rgname
Assert-AreEqual $actual.Name $rname
Assert-AreEqual $actual.Location $location
Assert-AreEqual $actual.Cidr $cidr
Assert-AreEqual $actual.PublicIpPrefixes.Count 0
Assert-NotNull $actual.ResourceGuid
Assert-AreEqual $actual.ProvisioningState "Succeeded"

# get by resource id
$actual = Get-AzCustomIpPrefix -ResourceId $actual.Id
Assert-AreEqual $actual.ResourceGroupName $rgname
Assert-AreEqual $actual.Name $rname
Assert-AreEqual $actual.Location $location
Assert-AreEqual $actual.Cidr $cidr
Assert-AreEqual $actual.PublicIpPrefixes.Count 0
Assert-NotNull $actual.ResourceGuid
Assert-AreEqual $actual.ProvisioningState "Succeeded"

# get by input object
$actual = Get-AzCustomIpPrefix -InputObject $actual
Assert-AreEqual $actual.ResourceGroupName $rgname
Assert-AreEqual $actual.Name $rname
Assert-AreEqual $actual.Location $location
Assert-AreEqual $actual.Cidr $cidr
Assert-AreEqual $actual.PublicIpPrefixes.Count 0
Assert-NotNull $actual.ResourceGuid
Assert-AreEqual $actual.ProvisioningState "Succeeded"

# list
$list = Get-AzCustomIpPrefix -ResourceGroupName $rgname
Assert-AreEqual 1 @($list).Count
Assert-AreEqual $list[0].ResourceGroupName $actual.ResourceGroupName
Assert-AreEqual $list[0].Name $actual.Name
Assert-AreEqual $list[0].Location $actual.Location
Assert-AreEqual $list[0].Cidr $actual.Cidr
Assert-AreEqual $list[0].PublicIpPrefixes.Count 0
Assert-AreEqual $list[0].ProvisioningState "Succeeded"

# delete
$job = Remove-AzCustomIpPrefix -InputObject $actual -PassThru -Force -AsJob
$job | Wait-Job
$delete = $job | Receive-Job
Assert-AreEqual true $delete

$list = Get-AzPublicIpPrefix -ResourceGroupName $rgname
Assert-AreEqual 0 @($list).Count

# Try setting unexisting
Assert-ThrowsLike { Update-AzPublicIpPrefix -PublicIpPrefix $expected } "*not found*"

# Create one more time to test deletion with resource id parameter set
$job = New-AzCustomIpPrefix -Name $rname -ResourceGroupName $rgname -location $location -Cidr $cidr -AsJob
$job | Wait-Job
$expected = $job | Receive-Job

$job = Remove-AzPublicIpPrefix -ResourceId $expected.Id -PassThru -Force -AsJob
$job | Wait-Job
$delete = $job | Receive-Job
Assert-AreEqual true $delete

# Create one more time to test deletion with resource group and name
$job = New-AzCustomIpPrefix -Name $rname -ResourceGroupName $rgname -location $location -Cidr $cidr -AsJob
$job | Wait-Job
$expected = $job | Receive-Job

$job = Remove-AzPublicIpPrefix -Name $rname -ResourceGroupName $rgname
$job | Wait-Job
$delete = $job | Receive-Job
Assert-AreEqual true $delete
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
5 changes: 4 additions & 1 deletion src/Network/Network/Az.Network.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,10 @@ CmdletsToExport = 'Add-AzApplicationGatewayAuthenticationCertificate',
'New-AzVirtualApplianceSite', 'Remove-AzVirtualApplianceSite',
'Update-AzVirtualApplianceSite', 'New-AzOffice365PolicyProperty',
'Get-AzNetworkVirtualApplianceSku',
'New-AzVirtualApplianceSkuProperty'
'New-AzVirtualApplianceSkuProperty',
'New-AzCustomIpPrefix', 'Update-AzCustomIpPrefix',
'Get-AzCustomIpPrefix', 'Remove-AzCustomIpPrefix'


# Variables to export from this module
# VariablesToExport = @()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// ----------------------------------------------------------------------------------
//
// 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 Microsoft.Azure.Commands.Network.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.Tags;
using Microsoft.Azure.Management.Network;
using Microsoft.Azure.Management.Network.Models;
using System.Net;

public abstract class CustomIpPrefixBaseCmdlet : NetworkBaseCmdlet
{
public ICustomIPPrefixesOperations CustomIpPrefixClient
{
get
{
return NetworkClient.NetworkManagementClient.CustomIPPrefixes;
}
}

public PSCustomIpPrefix GetCustomIpPrefix(string resourceGroupName, string name, string expandResource = null)
{
var sdkModel = this.CustomIpPrefixClient.Get(resourceGroupName, name, expandResource);

var psModel = ToPsCustomIpPrefix(sdkModel);
psModel.ResourceGroupName = resourceGroupName;

return psModel;
}

public PSCustomIpPrefix ToPsCustomIpPrefix(CustomIpPrefix customIpPrefix)
{
var psModel = NetworkResourceManagerProfile.Mapper.Map<PSCustomIpPrefix>(customIpPrefix);

psModel.Tag = TagsConversionHelper.CreateTagHashtable(customIpPrefix.Tags);

return psModel;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
// ----------------------------------------------------------------------------------
//
// 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 Microsoft.Azure.Commands.Network.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.Tags;
using Microsoft.Azure.Management.Network;
using System.Collections.Generic;
using System.Management.Automation;
using Microsoft.Azure.Management.Network.Models;
using Microsoft.Rest.Azure;
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;

[Cmdlet(VerbsCommon.Get, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "CustomIpPrefix", DefaultParameterSetName = GetByNameParameterSet), OutputType(typeof(PSCustomIpPrefix))]
public class GetAzureCustomIpPrefixCommand : CustomIpPrefixBaseCmdlet
{
private const string GetByNameParameterSet = "GetByNameParameterSet";
private const string GetByResourceIdParameterSet = "GetByResourceIdParameterSet";

[Alias("ResourceName")]
[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The resource name.",
ParameterSetName = GetByNameParameterSet)]
[ResourceNameCompleter("Microsoft.Network/customIpPrefix", "ResourceGroupName")]
[ValidateNotNullOrEmpty]
[SupportsWildcards]
public virtual string Name { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The resource group name.",
ParameterSetName = GetByNameParameterSet)]
[ResourceGroupCompleter]
[ValidateNotNullOrEmpty]
[SupportsWildcards]
public virtual string ResourceGroupName { get; set; }

[Parameter(
Mandatory = true,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The resource id.",
ParameterSetName = GetByResourceIdParameterSet)]
[ValidateNotNullOrEmpty]
public virtual string ResourceId { get; set; }

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

if (this.IsParameterBound(c => c.ResourceId))
{
var resourceIdentifier = new ResourceIdentifier(this.ResourceId);
this.ResourceGroupName = resourceIdentifier.ResourceGroupName;
this.Name = resourceIdentifier.ResourceName;
}

if (ShouldGetByName(this.ResourceGroupName, this.Name))
{
PSCustomIpPrefix psModel;

psModel = this.GetCustomIpPrefix(this.ResourceGroupName, this.Name);

WriteObject(psModel);
}
else
{
IPage<CustomIpPrefix> page;
if (ShouldListByResourceGroup(this.ResourceGroupName, this.Name))
{
page = this.CustomIpPrefixClient.List(this.ResourceGroupName);
}
else
{
page = this.CustomIpPrefixClient.ListAll();
}

// Get all resources by polling on next page link
List<CustomIpPrefix> sdkModelList;

sdkModelList = ListNextLink<CustomIpPrefix>.GetAllResourcesByPollingNextLink(page, this.CustomIpPrefixClient.ListNext);

var psModelList = new List<PSCustomIpPrefix>();

// populate the publicIpPrefixes with the ResourceGroupName
foreach (var sdkModel in sdkModelList)
{
var psModel = this.ToPsCustomIpPrefix(sdkModel);
psModel.ResourceGroupName = NetworkBaseCmdlet.GetResourceGroup(psModel.Id);
psModelList.Add(psModel);
}

WriteObject(TopLevelWildcardFilter(this.ResourceGroupName, this.Name, psModelList), true);
}
}
}
}
Loading