Skip to content

Commit 766658a

Browse files
committed
Merge pull request #11 from AzCiS/device-config
remove primaryDnsServer from params for Set-DeviceConfig
2 parents 2bb7860 + 741630d commit 766658a

File tree

4 files changed

+12
-40
lines changed

4 files changed

+12
-40
lines changed

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/DeviceDetails/SetAzureStorSimpleDevice.cs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,28 +61,20 @@ public class SetAzureStorSimpleDevice : StorSimpleCmdletBase
6161
[ValidateNotNullOrEmpty]
6262
public TimeZoneInfo TimeZone { get; set; }
6363

64-
/// <summary>
65-
/// Primary DNS server for the device.
66-
/// </summary>
67-
[Parameter(Mandatory = false, Position = 3, HelpMessage = StorSimpleCmdletHelpMessage.PrimaryDnsServer)]
68-
[ValidateNotNullOrEmpty]
69-
public string PrimaryDnsServer { get; set; }
70-
7164
/// <summary>
7265
/// Secondary DNS server for the device.
7366
/// </summary>
74-
[Parameter(Mandatory = false, Position = 4, HelpMessage = StorSimpleCmdletHelpMessage.SecondaryDnsServer)]
67+
[Parameter(Mandatory = false, Position = 3, HelpMessage = StorSimpleCmdletHelpMessage.SecondaryDnsServer)]
7568
[ValidateNotNullOrEmpty]
7669
public string SecondaryDnsServer { get; set; }
7770

7871
/// <summary>
7972
/// A collection of network configs for interfaces on the device.
8073
/// </summary>
81-
[Parameter(Mandatory = false, Position = 5, HelpMessage = StorSimpleCmdletHelpMessage.StorSimpleNetworkConfig)]
74+
[Parameter(Mandatory = false, Position = 4, HelpMessage = StorSimpleCmdletHelpMessage.StorSimpleNetworkConfig)]
8275
[ValidateNotNullOrEmpty]
8376
public NetworkConfig[] StorSimpleNetworkConfig { get; set; }
8477

85-
private IPAddress primaryDnsServer;
8678
private IPAddress secondaryDnsServer;
8779

8880
public override void ExecuteCmdlet()
@@ -107,7 +99,7 @@ public override void ExecuteCmdlet()
10799

108100
// If the device is being configured for the first time, validate that mandatory params
109101
// for first setup have been provided
110-
if (!this.IsDeviceConfigurationCompleteForDevice(deviceDetails) && !ValidParamsForFirstDeviceConfiguration(StorSimpleNetworkConfig, TimeZone,PrimaryDnsServer))
102+
if (!deviceDetails.DeviceProperties.IsConfigUpdated && !ValidParamsForFirstDeviceConfiguration(StorSimpleNetworkConfig, TimeZone, SecondaryDnsServer))
111103
{
112104
WriteVerbose(Resources.MandatoryParamsMissingForInitialDeviceConfiguration);
113105
WriteObject(null);
@@ -124,7 +116,7 @@ public override void ExecuteCmdlet()
124116

125117
// Update device details objects with the details provided to the cmdlet
126118
// and make request with updated data
127-
var taskStatusInfo = StorSimpleClient.UpdateDeviceDetails(deviceDetails, this.NewName, this.TimeZone, this.primaryDnsServer, this.secondaryDnsServer, this.StorSimpleNetworkConfig);
119+
var taskStatusInfo = StorSimpleClient.UpdateDeviceDetails(deviceDetails, this.NewName, this.TimeZone, this.secondaryDnsServer, this.StorSimpleNetworkConfig);
128120

129121
HandleSyncTaskResponse(taskStatusInfo, "Setup");
130122
if (taskStatusInfo.AsyncTaskAggregatedResult == AsyncTaskAggregatedResult.Succeeded)
@@ -155,10 +147,6 @@ private bool ProcessParameters()
155147
}
156148
DeviceId = deviceId;
157149
}
158-
if (!TrySetIPAddress(PrimaryDnsServer, out primaryDnsServer, "PrimaryDnsServer"))
159-
{
160-
return false;
161-
}
162150
if (!TrySetIPAddress(SecondaryDnsServer, out secondaryDnsServer, "SecondaryDnsServer"))
163151
{
164152
return false;

src/ServiceManagement/StorSimple/Commands.StorSimple/ServiceClients/StorSimpleDevicesClient.cs

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,13 @@ public DeviceDetails GetDeviceDetails(string deviceId)
4646
/// <param name="deviceDetails">Current device details for the device.</param>
4747
/// <param name="newName">New friendly name for the device. Null if its not to be changed</param>
4848
/// <param name="timeZone">New timeZone value for the device. Null if its not to be changed</param>
49-
/// <param name="primaryDnsServer">New primary DNS server address for the device. Null if its not to be changed</param>
5049
/// <param name="secondaryDnsServer">New Secondary DNS Server address for the device. Null if its not to be changed</param>
5150
/// <param name="networkConfigs">An array or NetworkConfig objects for different interfaces. Null if its not to be changed</param>
5251
/// <returns></returns>
53-
public TaskStatusInfo UpdateDeviceDetails(DeviceDetails deviceDetails, string newName, TimeZoneInfo timeZone, IPAddress primaryDnsServer,
54-
IPAddress secondaryDnsServer, NetworkConfig[] networkConfigs)
52+
public TaskStatusInfo UpdateDeviceDetails(DeviceDetails deviceDetails, string newName, TimeZoneInfo timeZone, IPAddress secondaryDnsServer, NetworkConfig[] networkConfigs)
5553
{
5654
// Update the object
57-
this.UpdateDeviceDetailsObject(deviceDetails, newName, timeZone, primaryDnsServer, secondaryDnsServer, networkConfigs);
55+
this.UpdateDeviceDetailsObject(deviceDetails, newName, timeZone, secondaryDnsServer, networkConfigs);
5856
// Copy stuff over from the DeviceDetails object into a new DeviceDetailsRequest object.
5957
var request = new DeviceDetailsRequest();
6058
MiscUtils.CopyProperties(deviceDetails, request);
@@ -153,8 +151,7 @@ private void UpdateDeviceDetailsWithNetworkConfig(DeviceDetails details, Network
153151
/// Modify the provided DeviceDetails object with the data provided
154152
/// </summary>
155153
/// <param name="details"></param>
156-
private void UpdateDeviceDetailsObject(DeviceDetails deviceDetails, string newName, TimeZoneInfo timeZone, IPAddress primaryDnsServer,
157-
IPAddress secondaryDnsServer, NetworkConfig[] networkConfigs)
154+
private void UpdateDeviceDetailsObject(DeviceDetails deviceDetails, string newName, TimeZoneInfo timeZone, IPAddress secondaryDnsServer, NetworkConfig[] networkConfigs)
158155
{
159156
// modify details for non-null data provided to cmdlet
160157

@@ -167,19 +164,7 @@ private void UpdateDeviceDetailsObject(DeviceDetails deviceDetails, string newNa
167164
{
168165
deviceDetails.TimeServer.TimeZone = timeZone.StandardName;
169166
}
170-
if (primaryDnsServer != null)
171-
{
172-
var primaryDnsString = primaryDnsServer.ToString();
173-
var primaryDnsType = primaryDnsServer.AddressFamily;
174-
if (primaryDnsType == AddressFamily.InterNetwork) // IPv4
175-
{
176-
deviceDetails.DnsServer.PrimaryIPv4 = primaryDnsString;
177-
}
178-
else if (primaryDnsType == AddressFamily.InterNetworkV6)
179-
{
180-
deviceDetails.DnsServer.PrimaryIPv6 = primaryDnsString;
181-
}
182-
}
167+
183168
if (secondaryDnsServer != null)
184169
{
185170
var secondaryDnsString = secondaryDnsServer.ToString();

src/ServiceManagement/StorSimple/Commands.StorSimple/StorSimpleCmdletBase.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -460,20 +460,20 @@ internal bool TrySetIPAddress(string data, out IPAddress ipAddress, string param
460460
/// Validate that all mandatory data for the first Device Configuration has been provided.
461461
/// </summary>
462462
/// <returns>bool indicating whether all mandatory data is there or not.</returns>
463-
internal bool ValidParamsForFirstDeviceConfiguration(NetworkConfig[] netConfigs, TimeZoneInfo timeZone, string primaryDnsServer)
463+
internal bool ValidParamsForFirstDeviceConfiguration(NetworkConfig[] netConfigs, TimeZoneInfo timeZone, string secondaryDnsServer)
464464
{
465465
if (netConfigs == null)
466466
{
467467
return false;
468468
}
469469
// Make sure network config for Data0 has been provided with atleast Controller0 IP Address
470470
var data0 = netConfigs.FirstOrDefault(x => x.InterfaceAlias == NetInterfaceId.Data0);
471-
if (data0 == null || data0.Controller0IPv4Address == null)
471+
if (data0 == null || data0.Controller0IPv4Address == null || data0.Controller1IPv4Address == null)
472472
{
473473
return false;
474474
}
475-
// Timezone and Primary Dns Server are also mandatory
476-
if (timeZone == null || string.IsNullOrEmpty(primaryDnsServer))
475+
// Timezone and Secondary Dns Server are also mandatory
476+
if (timeZone == null || string.IsNullOrEmpty(secondaryDnsServer))
477477
{
478478
return false;
479479
}

src/ServiceManagement/StorSimple/Commands.StorSimple/StorSimpleCmdletHelpMessage.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ internal static class StorSimpleCmdletHelpMessage
106106
public const string IPv6Prefix = "IPv6 Prefix for the net interface";
107107
public const string IsCloudEnabled = "Whether the net interface is cloud enabled/disabled";
108108
public const string IsIscsiEnabled = "Whether the net interface is iscsi enabled/disabled";
109-
public const string PrimaryDnsServer = "Primary DNS server for the device.";
110109
public const string SecondaryDnsServer = "Secondary DNS server for the device.";
111110
public const string StorSimpleNetworkConfig = "A collection of network configs for interfaces on the device.";
112111
public const string TimeZone = "TimeZone for the device.";

0 commit comments

Comments
 (0)