Skip to content

Commit 605f1ea

Browse files
committed
Address CR comments (Ip -> IP, parameter set for Test cmdlet that takes vnet name + resource group name, format.xml changes, move network SDK to 6.1.1)
1 parent 615d558 commit 605f1ea

File tree

9 files changed

+230
-118
lines changed

9 files changed

+230
-118
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6565
</Reference>
6666
<Reference Include="Microsoft.Azure.Management.Network">
67-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.6.1.0-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
67+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.6.1.1-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
6868
<Private>True</Private>
6969
</Reference>
7070
<Reference Include="Microsoft.Azure.Insights">

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

Lines changed: 113 additions & 104 deletions
Large diffs are not rendered by default.

src/ResourceManager/Network/Commands.Network.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
77
<package id="Microsoft.Azure.Graph.RBAC" version="3.2.0-preview" targetFramework="net45" />
88
<package id="Microsoft.Azure.Management.Authorization" version="1.0.0" targetFramework="net45" />
9-
<package id="Microsoft.Azure.Management.Network" version="6.1.0-preview" targetFramework="net45" />
9+
<package id="Microsoft.Azure.Management.Network" version="6.1.1-preview" targetFramework="net45" />
1010
<package id="Microsoft.Azure.Insights" version="0.13.1-preview" targetFramework="net45" />
1111
<package id="Microsoft.Azure.Management.Redis" version="3.1.1-preview" targetFramework="net45" />
1212
<package id="Microsoft.Azure.Management.Resources" version="2.20.0-preview" targetFramework="net45" />

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
7474
</Reference>
7575
<Reference Include="Microsoft.Azure.Management.Network">
76-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.6.1.0-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
76+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.6.1.1-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
7777
<Private>True</Private>
7878
</Reference>
7979
<Reference Include="Microsoft.Data.Edm">
@@ -275,7 +275,7 @@
275275
<Compile Include="ExpressRouteCircuit\RemoveAzureExpressRouteCircuitCommand.cs" />
276276
<Compile Include="ExpressRouteCircuit\SetAzureExpressRouteCircuitCommand.cs" />
277277
<Compile Include="ExpressRouteCircuit\ExpressRouteCircuitBaseCmdlet.cs" />
278-
<Compile Include="Models\PSPrivateIpAddressAvailabilityResponse.cs" />
278+
<Compile Include="Models\PSIPAddressAvailabilityResult.cs" />
279279
<Compile Include="Models\PSApplicationGatewayAuthenticationCertificate.cs" />
280280
<Compile Include="Models\PSApplicationGatewaySslPolicy.cs" />
281281
<Compile Include="Models\PSBgpSettings.cs" />
@@ -326,7 +326,7 @@
326326
<Compile Include="NetworkInterface\IpConfiguration\RemoveAzureNetworkInterfaceIpConfigCommand.cs" />
327327
<Compile Include="NetworkInterface\IpConfiguration\SetAzureNetworkInterfaceIpConfigCommand.cs" />
328328
<Compile Include="ProviderWideCmdlets\GetAzureExpressRouteServiceProviderCommand.cs" />
329-
<Compile Include="VirtualNetwork\TestAzurePrivateIpAddressAvailabilityCmdlet.cs" />
329+
<Compile Include="VirtualNetwork\TestAzurePrivateIPAddressAvailabilityCmdlet.cs" />
330330
<Compile Include="PublicIpAddress\GetAzurePublicIpAddressCommand.cs" />
331331
<Compile Include="PublicIpAddress\NewAzurePublicIpAddressCommand.cs" />
332332
<Compile Include="PublicIpAddress\PublicIpAddressBaseCmdlet.cs" />

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ protected override void Configure()
8484
Mapper.CreateMap<MNM.IPConfiguration, CNM.PSIPConfiguration>();
8585
Mapper.CreateMap<MNM.ResourceNavigationLink, CNM.PSResourceNavigationLink>();
8686

87+
// TestPrivateIpAddressAvailability
88+
// CNM to MNM
89+
Mapper.CreateMap<CNM.PSIPAddressAvailabilityResult, MNM.IPAddressAvailabilityResult>();
90+
91+
// MNM to CNM
92+
Mapper.CreateMap<MNM.IPAddressAvailabilityResult, CNM.PSIPAddressAvailabilityResult>();
93+
8794
// VirtualNetwork Peering
8895
Mapper.CreateMap<CNM.PSVirtualNetworkPeering, MNM.VirtualNetworkPeering>();
8996

src/ResourceManager/Network/Commands.Network/Microsoft.Azure.Commands.Network.format.ps1xml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@
9696
<Label>IpConfigurations</Label>
9797
<PropertyName>IpConfigurationsText</PropertyName>
9898
</ListItem>
99+
<ListItem>
100+
<Label>ResourceNavigationLinks</Label>
101+
<PropertyName>ResourceNavigationLinksText</PropertyName>
102+
</ListItem>
99103
<ListItem>
100104
<Label>NetworkSecurityGroup</Label>
101105
<PropertyName>NetworkSecurityGroupText</PropertyName>
@@ -1307,5 +1311,53 @@
13071311
</ListEntries>
13081312
</ListControl>
13091313
</View>
1314+
<View>
1315+
<Name>Microsoft.Azure.Commands.Network.Models.PSResourceNavigationLink</Name>
1316+
<ViewSelectedBy>
1317+
<TypeName>Microsoft.Azure.Commands.Network.Models.PSResourceNavigationLink</TypeName>
1318+
</ViewSelectedBy>
1319+
<ListControl>
1320+
<ListEntries>
1321+
<ListEntry>
1322+
<ListItems>
1323+
<ListItem>
1324+
<Label>LinkedResourceType</Label>
1325+
<PropertyName>LinkedResourceType</PropertyName>
1326+
</ListItem>
1327+
<ListItem>
1328+
<Label>Link</Label>
1329+
<PropertyName>Link</PropertyName>
1330+
</ListItem>
1331+
<ListItem>
1332+
<Label>ProvisioningState</Label>
1333+
<PropertyName>ProvisioningState</PropertyName>
1334+
</ListItem>
1335+
</ListItems>
1336+
</ListEntry>
1337+
</ListEntries>
1338+
</ListControl>
1339+
</View>
1340+
<View>
1341+
<Name>Microsoft.Azure.Commands.Network.Models.PSIPAddressAvailabilityResult</Name>
1342+
<ViewSelectedBy>
1343+
<TypeName>Microsoft.Azure.Commands.Network.Models.PSIPAddressAvailabilityResult</TypeName>
1344+
</ViewSelectedBy>
1345+
<ListControl>
1346+
<ListEntries>
1347+
<ListEntry>
1348+
<ListItems>
1349+
<ListItem>
1350+
<Label>Available</Label>
1351+
<PropertyName>Available</PropertyName>
1352+
</ListItem>
1353+
<ListItem>
1354+
<Label>AvailableIPAddresses</Label>
1355+
<PropertyName>AvailableIPAddressesText</PropertyName>
1356+
</ListItem>
1357+
</ListItems>
1358+
</ListEntry>
1359+
</ListEntries>
1360+
</ListControl>
1361+
</View>
13101362
</ViewDefinitions>
13111363
</Configuration>
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,21 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System.Collections.Generic;
16-
1715
namespace Microsoft.Azure.Commands.Network.Models
1816
{
19-
public class PSPrivateIpAddressAvailabilityResponse
17+
using Newtonsoft.Json;
18+
using System.Collections.Generic;
19+
20+
public class PSIPAddressAvailabilityResult
2021
{
2122
public bool Available { get; set; }
2223

23-
public List<string> AvailableIpAddresses { get; set; }
24+
public List<string> AvailableIPAddresses { get; set; }
25+
26+
[JsonIgnore]
27+
public string AvailableIPAddressesText
28+
{
29+
get { return JsonConvert.SerializeObject(AvailableIPAddresses, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
30+
}
2431
}
2532
}

src/ResourceManager/Network/Commands.Network/VirtualNetwork/TestAzurePrivateIpAddressAvailabilityCmdlet.cs

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,69 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using AutoMapper;
1516
using System.Management.Automation;
1617
using Microsoft.Azure.Commands.Network.Models;
1718
using Microsoft.Azure.Management.Network;
1819

1920
namespace Microsoft.Azure.Commands.Network
2021
{
21-
[Cmdlet(VerbsDiagnostic.Test, "AzureRmPrivateIpAddressAvailability"), OutputType(typeof(PSPrivateIpAddressAvailabilityResponse))]
22-
public class TestAzurePrivateIpAddressAvailabilityCmdlet : VirtualNetworkBaseCmdlet
22+
[Cmdlet(VerbsDiagnostic.Test, "AzureRmPrivateIPAddressAvailability"), OutputType(typeof(PSIPAddressAvailabilityResult))]
23+
public class TestAzurePrivateIPAddressAvailabilityCmdlet : VirtualNetworkBaseCmdlet
2324
{
2425
[Parameter(
2526
Mandatory = true,
2627
ValueFromPipeline = true,
28+
ParameterSetName = "TestByResource",
2729
HelpMessage = "The virtualNetwork")]
2830
public PSVirtualNetwork VirtualNetwork { get; set; }
2931

32+
[Parameter(
33+
Mandatory = true,
34+
ValueFromPipeline = false,
35+
ParameterSetName = "TestByResourceId",
36+
HelpMessage = "The resource group name")]
37+
[ValidateNotNullOrEmpty]
38+
public string ResourceGroupName { get; set; }
39+
40+
[Parameter(
41+
Mandatory = true,
42+
ValueFromPipeline = false,
43+
ParameterSetName = "TestByResourceId",
44+
HelpMessage = "The virtualNetwork name")]
45+
[ValidateNotNullOrEmpty]
46+
public string VirtualNetworkName { get; set; }
47+
3048
[Parameter(
3149
Mandatory = true,
3250
HelpMessage = "The Private Ip Address")]
3351
[ValidateNotNullOrEmpty]
34-
public string IpAddress { get; set; }
52+
public string IPAddress { get; set; }
3553

3654
public override void Execute()
3755
{
3856
base.Execute();
39-
var result = this.NetworkClient.NetworkManagementClient.VirtualNetworks.CheckIPAddressAvailability(this.VirtualNetwork.ResourceGroupName, this.VirtualNetwork.Name, this.IpAddress);
57+
58+
PSIPAddressAvailabilityResult result;
59+
60+
if (string.Equals(ParameterSetName, "TestByResource"))
61+
{
62+
result = this.TestIpAddressAvailability(this.VirtualNetwork.ResourceGroupName, this.VirtualNetwork.Name, this.IPAddress);
63+
}
64+
else
65+
{
66+
result = this.TestIpAddressAvailability(this.ResourceGroupName, this.VirtualNetworkName, this.IPAddress);
67+
}
68+
4069
WriteObject(result);
4170
}
71+
72+
public PSIPAddressAvailabilityResult TestIpAddressAvailability(string resourceGroupName, string vnetName, string ipAddress)
73+
{
74+
var result = this.NetworkClient.NetworkManagementClient.VirtualNetworks.CheckIPAddressAvailability(resourceGroupName, vnetName, ipAddress);
75+
var psResult = Mapper.Map<PSIPAddressAvailabilityResult>(result);
76+
77+
return psResult;
78+
}
4279
}
4380
}

src/ResourceManager/Network/Commands.Network/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<package id="Microsoft.Azure.Graph.RBAC" version="3.2.0-preview" targetFramework="net45" />
99
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net45" />
1010
<package id="Microsoft.Azure.Management.Authorization" version="1.0.0" targetFramework="net45" />
11-
<package id="Microsoft.Azure.Management.Network" version="6.1.0-preview" targetFramework="net45" />
11+
<package id="Microsoft.Azure.Management.Network" version="6.1.1-preview" targetFramework="net45" />
1212
<package id="Microsoft.Azure.Management.Resources" version="2.20.0-preview" targetFramework="net45" />
1313
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
1414
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />

0 commit comments

Comments
 (0)