Skip to content

Commit 383ffb9

Browse files
committed
upstream merge
2 parents a74fa44 + 0bfed89 commit 383ffb9

File tree

9 files changed

+1545
-10
lines changed

9 files changed

+1545
-10
lines changed

src/ResourceManager/Network/Commands.Network.Test/Commands.Network.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@
230230
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.NetworkInterfaceTests\TestNetworkInterfaceCRUDUsingId.json">
231231
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
232232
</None>
233+
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.NetworkInterfaceTests\TestNetworkInterfaceIDns.json">
234+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
235+
</None>
233236
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.NetworkInterfaceTests\TestNetworkInterfaceSet.json">
234237
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
235238
</None>

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/NetworkInterfaceTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,12 @@ public void TestNetworkInterfaceSet()
5353
{
5454
NetworkResourcesController.NewInstance.RunPsTest("Test-NetworkInterfaceSet");
5555
}
56+
57+
[Fact]
58+
[Trait(Category.AcceptanceType, Category.CheckIn)]
59+
public void TestNetworkInterfaceIDns()
60+
{
61+
NetworkResourcesController.NewInstance.RunPsTest("Test-NetworkInterfaceIDns");
62+
}
5663
}
5764
}

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/NetworkInterfaceTests.ps1

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,4 +375,64 @@ function Test-NetworkInterfaceSet
375375
# Cleanup
376376
Clean-ResourceGroup $rgname
377377
}
378+
}
379+
380+
<#
381+
.SYNOPSIS
382+
Tests creating new simple public networkinterface with Idns.
383+
#>
384+
function Test-NetworkInterfaceIDns
385+
{
386+
# Setup
387+
$rgname = Get-ResourceGroupName
388+
$vnetName = Get-ResourceName
389+
$subnetName = Get-ResourceName
390+
$publicIpName = Get-ResourceName
391+
$nicName = Get-ResourceName
392+
$domainNameLabel = Get-ResourceName
393+
$rglocation = Get-ProviderLocation ResourceManagement
394+
$resourceTypeParent = "Microsoft.Network/networkInterfaces"
395+
<#
396+
uncomment after IDNS is enabled in all locations
397+
$location = Get-ProviderLocation $resourceTypeParent
398+
#>
399+
$location = "centralus"
400+
401+
try
402+
{
403+
# Create the resource group
404+
$resourceGroup = New-AzureResourceGroup -Name $rgname -Location $rglocation -Tags @{Name = "testtag"; Value = "testval"}
405+
406+
# Create the Virtual Network
407+
$subnet = New-AzureVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.1.0/24
408+
$vnet = New-AzurevirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
409+
410+
# Create NetworkInterface
411+
$actualNic = New-AzureNetworkInterface -Name $nicName -ResourceGroupName $rgname -Location $location -Subnet $vnet.Subnets[0] -InternalDnsNameLabel "idnstest"
412+
$expectedNic = Get-AzureNetworkInterface -Name $nicName -ResourceGroupName $rgname
413+
414+
Assert-AreEqual $expectedNic.ResourceGroupName $actualNic.ResourceGroupName
415+
Assert-AreEqual $expectedNic.Name $actualNic.Name
416+
Assert-AreEqual $expectedNic.Location $actualNic.Location
417+
Assert-AreEqual "Succeeded" $expectedNic.ProvisioningState
418+
Assert-AreEqual $expectedNic.IpConfigurations[0].Name $actualNic.IpConfigurations[0].Name
419+
Assert-AreEqual $expectedNic.IpConfigurations[0].PublicIpAddress.Id $actualNic.IpConfigurations[0].PublicIpAddress.Id
420+
Assert-AreEqual $expectedNic.IpConfigurations[0].Subnet.Id $actualNic.IpConfigurations[0].Subnet.Id
421+
Assert-NotNull $expectedNic.IpConfigurations[0].PrivateIpAddress
422+
Assert-AreEqual "Dynamic" $expectedNic.IpConfigurations[0].PrivateIpAllocationMethod
423+
Assert-AreEqual "idnstest" $expectedNic.DnsSettings.InternalDnsNameLabel
424+
Assert-Null $expectedNic.DnsSettings.InternalFqdn
425+
426+
# Delete NetworkInterface
427+
$delete = Remove-AzureNetworkInterface -ResourceGroupName $rgname -name $nicName -PassThru -Force
428+
Assert-AreEqual true $delete
429+
430+
$list = Get-AzureNetworkInterface -ResourceGroupName $rgname
431+
Assert-AreEqual 0 @($list).Count
432+
}
433+
finally
434+
{
435+
# Cleanup
436+
Clean-ResourceGroup $rgname
437+
}
378438
}

src/ResourceManager/Network/Commands.Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.NetworkInterfaceTests/TestNetworkInterfaceIDns.json

Lines changed: 1448 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/Network/Commands.Network/Commands.Network.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@
281281
<Compile Include="Models\PSProbeProtocol.cs" />
282282
<Compile Include="Models\PSAddressSpace.cs" />
283283
<Compile Include="Models\PSDhcpOptions.cs" />
284-
<Compile Include="Models\PSDnsSettings.cs" />
284+
<Compile Include="Models\PSNetworkInterfaceDnsSettings.cs" />
285285
<Compile Include="Models\PSNetworkInterface.cs" />
286286
<Compile Include="Models\PSNetworkInterfaceIpConfiguration.cs" />
287287
<Compile Include="Models\PSProvisioningState.cs" />

src/ResourceManager/Network/Commands.Network/Common/NetworkResourceManagerProfile.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,12 @@ protected override void Configure()
100100

101101
// NetworkInterface
102102
// CNM to MNM
103-
Mapper.CreateMap<CNM.PSNetworkInterface, MNM.NetworkInterface>();
104-
Mapper.CreateMap<CNM.PSDnsSettings, MNM.NetworkInterfaceDnsSettings>();
103+
Mapper.CreateMap<CNM.PSNetworkInterfaceDnsSettings, MNM.NetworkInterfaceDnsSettings>();
105104
Mapper.CreateMap<CNM.PSNetworkInterfaceIpConfiguration, MNM.NetworkInterfaceIpConfiguration>();
106105

107106
// MNM to CNM
108107
Mapper.CreateMap<MNM.NetworkInterface, CNM.PSNetworkInterface>();
109-
Mapper.CreateMap<MNM.NetworkInterfaceDnsSettings, CNM.PSDnsSettings>();
108+
Mapper.CreateMap<MNM.NetworkInterfaceDnsSettings, CNM.PSNetworkInterfaceDnsSettings>();
110109
Mapper.CreateMap<MNM.NetworkInterfaceIpConfiguration, CNM.PSNetworkInterfaceIpConfiguration>();
111110

112111
// LoadBalancer

src/ResourceManager/Network/Commands.Network/Models/PSNetworkInterface.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class PSNetworkInterface : PSTopLevelResource
2424

2525
public List<PSNetworkInterfaceIpConfiguration> IpConfigurations { get; set; }
2626

27-
public PSDnsSettings DnsSettings { get; set; }
27+
public PSNetworkInterfaceDnsSettings DnsSettings { get; set; }
2828

2929
public string MacAddress { get; set; }
3030

@@ -49,7 +49,7 @@ public string IpConfigurationsText
4949
[JsonIgnore]
5050
public string DnsSettingsText
5151
{
52-
get { return JsonConvert.SerializeObject(DnsSettings, Formatting.Indented); }
52+
get { return JsonConvert.SerializeObject(this.DnsSettings, Formatting.Indented); }
5353
}
5454

5555
[JsonIgnore]

src/ResourceManager/Network/Commands.Network/Models/PSDnsSettings.cs renamed to src/ResourceManager/Network/Commands.Network/Models/PSNetworkInterfaceDnsSettings.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@
1616

1717
namespace Microsoft.Azure.Commands.Network.Models
1818
{
19-
public class PSDnsSettings
19+
public class PSNetworkInterfaceDnsSettings
2020
{
2121
public List<string> DnsServers { get; set; }
2222

2323
public List<string> AppliedDnsServers { get; set; }
24+
25+
public string InternalDnsNameLabel { get; set; }
26+
27+
public string InternalFqdn { get; set; }
2428
}
2529
}

src/ResourceManager/Network/Commands.Network/NetworkInterface/NewAzureNetworkInterfaceCommand.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ public class NewAzureNetworkInterfaceCommand : NetworkInterfaceBaseCmdlet
143143
HelpMessage = "The list of Dns Servers")]
144144
public List<string> DnsServer { get; set; }
145145

146+
[Parameter(
147+
Mandatory = false,
148+
ValueFromPipelineByPropertyName = true,
149+
HelpMessage = "The Internal Dns name")]
150+
public string InternalDnsNameLabel { get; set; }
151+
146152
[Parameter(
147153
Mandatory = false,
148154
ValueFromPipelineByPropertyName = true,
@@ -261,10 +267,18 @@ private PSNetworkInterface CreateNetworkInterface()
261267
}
262268
}
263269

264-
if (this.DnsServer != null)
270+
if (this.DnsServer != null || this.InternalDnsNameLabel != null)
265271
{
266-
networkInterface.DnsSettings = new PSDnsSettings();
267-
networkInterface.DnsSettings.DnsServers = this.DnsServer;
272+
networkInterface.DnsSettings = new PSNetworkInterfaceDnsSettings();
273+
if (this.DnsServer != null)
274+
{
275+
networkInterface.DnsSettings.DnsServers = this.DnsServer;
276+
}
277+
if (this.InternalDnsNameLabel != null)
278+
{
279+
networkInterface.DnsSettings.InternalDnsNameLabel = this.InternalDnsNameLabel;
280+
}
281+
268282
}
269283

270284
networkInterface.IpConfigurations.Add(nicIpConfiguration);

0 commit comments

Comments
 (0)