Skip to content

Commit d1a1de3

Browse files
author
v-yuchenli
committed
replace models
1 parent 32c85b8 commit d1a1de3

29 files changed

+332
-221
lines changed

src/HDInsight/HDInsight/HDInsight.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14+
<PackageReference Include="Azure.Identity" Version="1.9.0" />
1415
<PackageReference Include="Azure.ResourceManager.HDInsight" Version="1.2.0-beta.1" />
1516
<PackageReference Include="Microsoft.Azure.Management.HDInsight" Version="8.0.0" />
1617
<PackageReference Include="Microsoft.Azure.Management.HDInsight.Job" Version="2.0.7" />

src/HDInsight/HDInsight/Models/Management/AzureHDInsightAutoscale.cs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.Management.HDInsight.Models;
15+
using Azure.ResourceManager.HDInsight.Models;
1616
using System;
1717
using System.Collections.Generic;
1818
using System.Linq;
@@ -21,7 +21,7 @@ namespace Microsoft.Azure.Commands.HDInsight.Models
2121
{
2222
public class AzureHDInsightAutoscale
2323
{
24-
public AzureHDInsightAutoscale(Autoscale autoscale)
24+
public AzureHDInsightAutoscale(HDInsightAutoScaleConfiguration autoscale)
2525
{
2626
Capacity = autoscale?.Capacity != null ? new AzureHDInsightAutoscaleCapacity(autoscale.Capacity) : null;
2727
Recurrence = autoscale?.Recurrence != null ? new AzureHDInsightAutoscaleRecurrence(autoscale.Recurrence) : null;
@@ -37,17 +37,29 @@ public AzureHDInsightAutoscale(AzureHDInsightAutoscaleCapacity capacity = null,
3737
/// Convert AzureHDInsightAutoscaleConfiguration to Autoscale
3838
/// </summary>
3939
/// <returns></returns>
40-
public Autoscale ToAutoscale()
40+
public HDInsightAutoScaleConfiguration ToAutoscale()
4141
{
42-
Autoscale autoscale = new Autoscale();
42+
HDInsightAutoScaleConfiguration autoscale = new HDInsightAutoScaleConfiguration();
4343
if (Capacity != null)
4444
{
45-
autoscale.Capacity = new AutoscaleCapacity(Capacity.MinInstanceCount, Capacity.MaxInstanceCount);
45+
autoscale.Capacity = new HDInsightAutoScaleCapacity()
46+
{
47+
MaxInstanceCount = Capacity.MaxInstanceCount,
48+
MinInstanceCount = Capacity.MinInstanceCount,
49+
};
4650
}
4751

4852
if (Recurrence != null)
4953
{
50-
autoscale.Recurrence = new AutoscaleRecurrence(Recurrence.TimeZone, Recurrence.Condition?.Select(condition => condition.ToAutoscaleSchedule()).ToList());
54+
//Recurrence.TimeZone, Recurrence.Condition?.Select(condition => condition.ToAutoscaleSchedule()).ToList()
55+
autoscale.Recurrence = new HDInsightAutoScaleRecurrence();
56+
autoscale.Recurrence.TimeZone = Recurrence.TimeZone;
57+
58+
foreach (var item in Recurrence.Condition)
59+
{
60+
autoscale.Recurrence.Schedule.Add(item.ToAutoscaleSchedule());
61+
}
62+
5163
}
5264
return autoscale;
5365
}

src/HDInsight/HDInsight/Models/Management/AzureHDInsightAutoscaleCapacity.cs

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

15-
using Microsoft.Azure.Management.HDInsight.Models;
15+
using Azure.ResourceManager.HDInsight.Models;
1616
using System;
1717
using System.Collections.Generic;
1818
using System.Linq;
@@ -21,7 +21,7 @@ namespace Microsoft.Azure.Commands.HDInsight.Models
2121
{
2222
public class AzureHDInsightAutoscaleCapacity
2323
{
24-
public AzureHDInsightAutoscaleCapacity(AutoscaleCapacity capacity)
24+
public AzureHDInsightAutoscaleCapacity(HDInsightAutoScaleCapacity capacity)
2525
{
2626

2727
MinInstanceCount = capacity?.MinInstanceCount;

src/HDInsight/HDInsight/Models/Management/AzureHDInsightAutoscaleCondition.cs

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

15-
using Microsoft.Azure.Management.HDInsight.Models;
15+
using Azure.ResourceManager.HDInsight.Models;
1616
using System;
1717
using System.Collections.Generic;
1818
using System.Linq;
@@ -21,7 +21,7 @@ namespace Microsoft.Azure.Commands.HDInsight.Models
2121
{
2222
public class AzureHDInsightAutoscaleCondition
2323
{
24-
public AzureHDInsightAutoscaleCondition(AutoscaleSchedule autoscaleSchedule)
24+
public AzureHDInsightAutoscaleCondition(HDInsightAutoScaleSchedule autoscaleSchedule)
2525
{
2626
Time = autoscaleSchedule?.TimeAndCapacity?.Time;
2727
WorkerNodeCount = autoscaleSchedule?.TimeAndCapacity?.MinInstanceCount;
@@ -33,18 +33,22 @@ public AzureHDInsightAutoscaleCondition()
3333
Days = new List<AzureHDInsightDaysOfWeek>();
3434
}
3535

36-
public AutoscaleSchedule ToAutoscaleSchedule()
36+
public HDInsightAutoScaleSchedule ToAutoscaleSchedule()
3737
{
38-
return new AutoscaleSchedule()
38+
HDInsightAutoScaleSchedule autoScaleSchedule = new HDInsightAutoScaleSchedule()
3939
{
40-
TimeAndCapacity = new AutoscaleTimeAndCapacity()
40+
TimeAndCapacity = new HDInsightAutoScaleTimeAndCapacity()
4141
{
4242
Time = Time,
4343
MinInstanceCount = WorkerNodeCount,
4444
MaxInstanceCount = WorkerNodeCount
45-
},
46-
Days = Days.Select(day => day.ToString()).ToList()
45+
}
4746
};
47+
foreach (var day in Days)
48+
{
49+
autoScaleSchedule.Days.Add(new HDInsightDayOfWeek(day.ToString()));
50+
}
51+
return autoScaleSchedule;
4852
}
4953

5054
/// <summary>

src/HDInsight/HDInsight/Models/Management/AzureHDInsightAutoscaleRecurrence.cs

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

15-
using Microsoft.Azure.Management.HDInsight.Models;
15+
using Azure.ResourceManager.HDInsight.Models;
1616
using System;
1717
using System.Collections.Generic;
1818
using System.Linq;
@@ -21,7 +21,7 @@ namespace Microsoft.Azure.Commands.HDInsight.Models
2121
{
2222
public class AzureHDInsightAutoscaleRecurrence
2323
{
24-
public AzureHDInsightAutoscaleRecurrence(AutoscaleRecurrence autoscaleRecurrence)
24+
public AzureHDInsightAutoscaleRecurrence(HDInsightAutoScaleRecurrence autoscaleRecurrence)
2525
{
2626
TimeZone = autoscaleRecurrence?.TimeZone;
2727
Condition = autoscaleRecurrence?.Schedule?.Select(item => new AzureHDInsightAutoscaleCondition(item)).ToList();

src/HDInsight/HDInsight/Models/Management/AzureHDInsightClientGroupInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.Management.HDInsight.Models;
15+
using Azure.ResourceManager.HDInsight.Models;
1616
using System;
1717
using System.Collections.Generic;
1818
using System.Text;

src/HDInsight/HDInsight/Models/Management/AzureHDInsightCluster.cs

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

15-
using Microsoft.Azure.Management.HDInsight.Models;
1615
using System;
1716
using System.Collections.Generic;
1817
using System.Linq;
1918
using System.Management.Automation;
2019
using Microsoft.WindowsAzure.Commands.Common;
20+
using Azure.ResourceManager.HDInsight;
21+
using Azure.ResourceManager.HDInsight.Models;
2122

2223
namespace Microsoft.Azure.Commands.HDInsight.Models
2324
{
2425
public class AzureHDInsightCluster
2526
{
26-
public AzureHDInsightCluster(Cluster cluster)
27+
public AzureHDInsightCluster(HDInsightClusterData cluster)
2728
{
2829
Id = cluster.Id;
2930
Name = cluster.Name;
3031
Location = cluster.Location;
3132
ClusterId = cluster.Properties.ClusterId;
3233
ClusterVersion = cluster.Properties.ClusterVersion;
33-
OperatingSystemType = cluster.Properties.OsType;
34-
ClusterTier = cluster.Properties.Tier;
34+
OperatingSystemType = cluster.Properties.OSType.ToString();
35+
ClusterTier = cluster.Properties.Tier.ToString();
3536
ClusterState = cluster.Properties.ClusterState;
3637
ClusterType = cluster.Properties.ClusterDefinition.Kind;
37-
CoresUsed = cluster.Properties.QuotaInfo.CoresUsed ?? 0;
38+
CoresUsed = cluster.Properties.QuotaInfoCoresUsed ?? 0;
3839
var httpEndpoint =
3940
cluster.Properties.ConnectivityEndpoints?.FirstOrDefault(c => c.Name.Equals("HTTPS", StringComparison.OrdinalIgnoreCase));
40-
HttpEndpoint = httpEndpoint != null ? httpEndpoint.Location : null;
41+
HttpEndpoint = httpEndpoint != null ? httpEndpoint.EndpointLocation : null;
4142
ConnectivityEndpoints = cluster?.Properties?.ConnectivityEndpoints?.Select(endpoint => new AzureHDInsightConnectivityEndpoint(endpoint)).ToList();
4243
Error = cluster.Properties.Errors?.Select(s => s.Message).FirstOrDefault();
4344
ResourceGroup = ClusterConfigurationUtils.GetResourceGroupFromClusterId(cluster.Id);
@@ -49,10 +50,10 @@ public AzureHDInsightCluster(Cluster cluster)
4950
ComponentVersion.Add(componentVersion.ToString());
5051
}
5152
}
52-
WorkerNodeDataDisksGroups = new List<DataDisksGroups>();
53-
if (cluster.Properties.ComputeProfile != null && cluster.Properties.ComputeProfile.Roles.Any())
53+
WorkerNodeDataDisksGroups = new List<HDInsightClusterDataDiskGroup>();
54+
if (cluster.Properties.ComputeRoles != null && cluster.Properties.ComputeRoles.Any())
5455
{
55-
var rolesWithDataDisksGroups = cluster.Properties.ComputeProfile.Roles.Where(x => x.DataDisksGroups != null);
56+
var rolesWithDataDisksGroups = cluster.Properties.ComputeRoles.Where(x => x.DataDisksGroups != null);
5657
foreach (var role in rolesWithDataDisksGroups)
5758
{
5859
WorkerNodeDataDisksGroups.AddRange(role.DataDisksGroups);
@@ -65,27 +66,27 @@ public AzureHDInsightCluster(Cluster cluster)
6566
//We should not be returning the actual password to the user
6667
DomainUserCredential = new PSCredential(clusterSecurityProfile.DomainUsername, "***".ConvertToSecureString()),
6768
OrganizationalUnitDN = clusterSecurityProfile.OrganizationalUnitDN,
68-
LdapsUrls = clusterSecurityProfile.LdapsUrls != null ? clusterSecurityProfile.LdapsUrls.ToArray() : null,
69+
LdapsUrls = clusterSecurityProfile.LdapUris != null ? clusterSecurityProfile.LdapUris.Select(uri => uri.ToString()).ToArray() : null,
6970
ClusterUsersGroupDNs = clusterSecurityProfile.ClusterUsersGroupDNs != null ? clusterSecurityProfile.ClusterUsersGroupDNs.ToArray() : null,
7071
} : null;
7172

7273
MinSupportedTlsVersion = cluster.Properties.MinSupportedTlsVersion;
7374
DiskEncryption = cluster.Properties.DiskEncryptionProperties;
7475
AssignedIdentity = new AzureHDInsightClusterIdentity(cluster.Identity);
75-
EncryptionInTransit =cluster.Properties?.EncryptionInTransitProperties?.IsEncryptionInTransitEnabled;
76-
PrivateEndpoint = cluster.Properties?.ConnectivityEndpoints?.FirstOrDefault(endpoint => endpoint.Name.Equals("HTTPS-INTERNAL"))?.Location;
77-
var vnet = Utils.ExtractRole(AzureHDInsightClusterNodeType.WorkerNode.ToString(),cluster.Properties.ComputeProfile)?.VirtualNetworkProfile;
76+
EncryptionInTransit = cluster.Properties?.IsEncryptionInTransitEnabled;
77+
PrivateEndpoint = cluster.Properties?.ConnectivityEndpoints?.FirstOrDefault(endpoint => endpoint.Name.Equals("HTTPS-INTERNAL"))?.EndpointLocation;
78+
var vnet = Utils.ExtractRole(AzureHDInsightClusterNodeType.WorkerNode.ToString(),cluster.Properties.ComputeRoles)?.VirtualNetworkProfile;
7879
VirtualNetworkId = vnet?.Id;
7980
SubnetName = Utils.GetResourceNameFromResourceId(vnet?.Subnet);
80-
ComputeProfile = cluster.Properties?.ComputeProfile != null ? new AzureHDInsightComputeProfile(cluster.Properties.ComputeProfile) : null;
81+
ComputeProfile = cluster.Properties.ComputeRoles != null ? new AzureHDInsightComputeProfile(cluster.Properties.ComputeRoles) : null;
8182
KafkaRestProperties = cluster?.Properties?.KafkaRestProperties != null ? new AzureHDInsightKafkaRestProperties(cluster.Properties.KafkaRestProperties) : null;
8283
NetworkProperties = cluster?.Properties?.NetworkProperties != null ? new AzureHDInsightNetworkProperties(cluster.Properties.NetworkProperties) : null;
8384
ComputeIsolationProperties = cluster?.Properties?.ComputeIsolationProperties != null ? new AzureHDInsightComputeIsolationProperties(cluster.Properties.ComputeIsolationProperties) : null;
8485
PrivateLinkConfigurations = cluster?.Properties?.PrivateLinkConfigurations?.Select(config => new AzureHDInsightPrivateLinkConfiguration(config)).ToList();
8586
PrivateEndpointConnections = cluster?.Properties?.PrivateEndpointConnections?.Select(connection => new AzureHDInsightPrivateEndpointConnection(connection)).ToList();
8687
}
8788

88-
public AzureHDInsightCluster(Cluster cluster, IDictionary<string, string> clusterConfiguration, IDictionary<string, string> clusterIdentity)
89+
public AzureHDInsightCluster(HDInsightClusterData cluster, IReadOnlyDictionary<string, string> clusterConfiguration, IReadOnlyDictionary<string, string> clusterIdentity)
8990
: this(cluster)
9091
{
9192
if (clusterConfiguration != null)
@@ -220,7 +221,7 @@ public AzureHDInsightCluster(Cluster cluster, IDictionary<string, string> cluste
220221
/// <summary>
221222
/// Data Disks Group Properties for the Worker Role.
222223
/// </summary>
223-
public List<DataDisksGroups> WorkerNodeDataDisksGroups { get; set; }
224+
public List<HDInsightClusterDataDiskGroup> WorkerNodeDataDisksGroups { get; set; }
224225

225226
/// <summary>
226227
/// Gets or sets the security profile.
@@ -238,7 +239,7 @@ public AzureHDInsightCluster(Cluster cluster, IDictionary<string, string> cluste
238239
/// <summary>
239240
/// Gets or sets the disk encryption properties.
240241
/// </summary>
241-
public DiskEncryptionProperties DiskEncryption { get; set; }
242+
public HDInsightDiskEncryptionProperties DiskEncryption { get; set; }
242243

243244
/// <summary>
244245
/// Gets or sets the assigned identity.

src/HDInsight/HDInsight/Models/Management/AzureHDInsightClusterIdentity.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Microsoft.Azure.Management.HDInsight.Models;
1+
using Azure.Core;
2+
using Azure.ResourceManager.Models;
23
using System;
34
using System.Collections.Generic;
45
using System.Text;
@@ -20,17 +21,17 @@ public AzureHDInsightClusterIdentity(string principalId = null, string tenantId
2021
UserAssignedIdentities = userAssignedIdentities;
2122
}
2223

23-
public AzureHDInsightClusterIdentity(ClusterIdentity clusterIdentity)
24+
public AzureHDInsightClusterIdentity(ManagedServiceIdentity clusterIdentity)
2425
{
25-
PrincipalId = clusterIdentity?.PrincipalId;
26-
TenantId = clusterIdentity?.TenantId;
27-
Type = clusterIdentity?.Type;
26+
PrincipalId = clusterIdentity?.PrincipalId.ToString();
27+
TenantId = clusterIdentity?.TenantId.ToString();
28+
Type = clusterIdentity.ManagedServiceIdentityType.ToString();
2829
UserAssignedIdentities =clusterIdentity?.UserAssignedIdentities != null ? new Dictionary<string, AzureHDInsightUserAssignedIdentity>() : null;
2930
if (UserAssignedIdentities != null)
3031
{
3132
foreach( var entry in clusterIdentity.UserAssignedIdentities)
3233
{
33-
UserAssignedIdentities.Add(entry.Key, new AzureHDInsightUserAssignedIdentity(entry.Value));
34+
UserAssignedIdentities.Add(entry.Key.ToString(), new AzureHDInsightUserAssignedIdentity(entry.Value));
3435
}
3536
}
3637
}

src/HDInsight/HDInsight/Models/Management/AzureHDInsightComputeIsolationProperties.cs

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

15-
using Microsoft.Azure.Management.HDInsight.Models;
15+
using Azure.ResourceManager.HDInsight.Models;
1616
using System;
1717
using System.Collections.Generic;
1818
using System.Text;
@@ -29,7 +29,7 @@ public AzureHDInsightComputeIsolationProperties(bool? enableComputeIsolation = n
2929
HostSku = hostSku;
3030
}
3131

32-
public AzureHDInsightComputeIsolationProperties(ComputeIsolationProperties computeIsolationProperties = null)
32+
public AzureHDInsightComputeIsolationProperties(HDInsightComputeIsolationProperties computeIsolationProperties = null)
3333
{
3434
EnableComputeIsolation = computeIsolationProperties?.EnableComputeIsolation;
3535
HostSku = computeIsolationProperties?.HostSku;

src/HDInsight/HDInsight/Models/Management/AzureHDInsightComputeProfile.cs

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

15-
using Microsoft.Azure.Management.HDInsight.Models;
1615
using System;
1716
using System.Collections.Generic;
1817
using System.Linq;
1918
using System.Management.Automation;
19+
using Azure.ResourceManager.HDInsight.Models;
2020
using Microsoft.WindowsAzure.Commands.Common;
2121

2222
namespace Microsoft.Azure.Commands.HDInsight.Models
@@ -30,9 +30,9 @@ public AzureHDInsightComputeProfile(IList<AzureHDInsightRole> roles = null)
3030
Roles = roles;
3131
}
3232

33-
public AzureHDInsightComputeProfile(ComputeProfile computeProfile)
33+
public AzureHDInsightComputeProfile(IList<HDInsightClusterRole> roles)
3434
{
35-
Roles = computeProfile.Roles?.Select(role => new AzureHDInsightRole(role)).ToList();
35+
Roles = roles?.Select(role => new AzureHDInsightRole(role)).ToList();
3636
}
3737

3838
public IList<AzureHDInsightRole> Roles { get; set; }

0 commit comments

Comments
 (0)