Skip to content

Commit 04e2aa8

Browse files
committed
Merge pull request #20 from AzCiS/fix-set-vd
Fix set vd
2 parents 37ec0eb + e4f8985 commit 04e2aa8

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,18 @@ public class SetAzureStorSimpleVirtualDevice : StorSimpleCmdletBase
3838
[Parameter(Mandatory = true, Position = 0, HelpMessage = StorSimpleCmdletHelpMessage.DeviceName)]
3939
[ValidateNotNullOrEmpty]
4040
public string DeviceName { get; set; }
41-
42-
/// <summary>
43-
/// New friendly name for the device.
44-
/// </summary>
45-
[Parameter(Mandatory=false, Position = 1, HelpMessage = StorSimpleCmdletHelpMessage.NewDeviceName)]
46-
[ValidateNotNullOrEmpty]
47-
public string NewName { get; set; }
4841

4942
/// <summary>
5043
/// TimeZone for the device.
5144
/// </summary>
52-
[Parameter(Mandatory = false, Position = 2, HelpMessage = StorSimpleCmdletHelpMessage.TimeZone, ValueFromPipeline=true)]
45+
[Parameter(Mandatory = false, Position = 1, HelpMessage = StorSimpleCmdletHelpMessage.TimeZone, ValueFromPipeline=true)]
5346
[ValidateNotNullOrEmpty]
5447
public TimeZoneInfo TimeZone { get; set; }
5548

5649
/// <summary>
5750
/// Service Encryption Key for the resource.
5851
/// </summary>
59-
[Parameter(Mandatory=true, Position = 3, HelpMessage = StorSimpleCmdletHelpMessage.SEK)]
52+
[Parameter(Mandatory=true, Position = 2, HelpMessage = StorSimpleCmdletHelpMessage.SEK)]
6053
[ValidateNotNullOrEmpty]
6154
public string SecretKey { get; set; }
6255

@@ -76,8 +69,11 @@ public override void ExecuteCmdlet()
7669
// Get the current device details. ( If we found id from the name, this call is bound to succeed)
7770
var deviceDetails = StorSimpleClient.GetDeviceDetails(deviceId);
7871

72+
// The cik also needs to be sent to the service.
73+
string cik = EncryptionCmdLetHelper.RetrieveCIK(this, StorSimpleContext.ResourceId);
74+
7975
// Update device details.
80-
StorSimpleClient.UpdateVirtualDeviceDetails(deviceDetails, NewName, TimeZone, SecretKey);
76+
StorSimpleClient.UpdateVirtualDeviceDetails(deviceDetails, TimeZone, SecretKey, cik);
8177

8278
// Make request with updated data
8379
WriteVerbose(string.Format(Resources.BeginningDeviceConfiguration, deviceDetails.DeviceProperties.FriendlyName));

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets.Library;
2121
using System.Net;
2222
using System.Net.Sockets;
23+
using Microsoft.WindowsAzure.Commands.StorSimple.Encryption;
2324

2425
namespace Microsoft.WindowsAzure.Commands.StorSimple
2526
{
@@ -201,12 +202,8 @@ private void UpdateDeviceDetailsObject(DeviceDetails deviceDetails, string newNa
201202
deviceDetails.WebProxy = null;
202203
}
203204

204-
public void UpdateVirtualDeviceDetails(DeviceDetails details, string newName, TimeZoneInfo timeZone, string sek)
205+
public void UpdateVirtualDeviceDetails(DeviceDetails details, TimeZoneInfo timeZone, string sek, string cik)
205206
{
206-
if (newName != null)
207-
{
208-
details.DeviceProperties.FriendlyName = newName;
209-
}
210207
if (timeZone != null)
211208
{
212209
details.TimeServer.TimeZone = timeZone.StandardName;
@@ -216,8 +213,16 @@ public void UpdateVirtualDeviceDetails(DeviceDetails details, string newName, Ti
216213

217214
details.VirtualApplianceProperties.EncodedServiceEncryptionKey = encryptedSecretKey;
218215

216+
// Also set the CIK before making the request - service needs it.
217+
var encryptedCik = this.EncryptWithDevicePublicKey(details.DeviceProperties.DeviceId, cik);
218+
219+
details.VirtualApplianceProperties.EncodedChannelIntegrityKey = encryptedCik;
220+
221+
details.VirtualApplianceProperties.IsServiceEncryptionKeySet = true;
222+
219223
// mark everything that we dont intend to modify as null - indicating
220224
// to the service that there has been no change
225+
details.DeviceProperties = null;
221226
details.AlertNotification = null;
222227
details.Chap = null;
223228
details.DnsServer = null;

0 commit comments

Comments
 (0)