Skip to content

Commit 4dd5e69

Browse files
committed
Merge pull request #40 from AzCiS/onesdk-p2-sumanths
Added check to ensure volume container creation is allowed only if mandatory config has been done
2 parents b756358 + b39a0da commit 4dd5e69

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/DataContainer/NewAzureStorSimpleDeviceVolumeContainer.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,25 @@ public override void ExecuteCmdlet()
6060
string deviceid = StorSimpleClient.GetDeviceId(DeviceName);
6161
if (deviceid == null)
6262
{
63-
WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
64-
WriteObject(null);
65-
return;
63+
throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
6664
}
6765

68-
if(EncryptionEnabled == true && (string.IsNullOrEmpty(EncryptionKey) || !IsValidAsciiString(EncryptionKey)))
66+
// Get the current device details.
67+
var deviceDetails = StorSimpleClient.GetDeviceDetails(deviceid);
68+
if (deviceDetails == null || deviceDetails.DeviceProperties == null)
69+
{
70+
throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
71+
}
72+
73+
// If the device has not yet been configured with the mandatory params, then don't allow the volume-container creation
74+
// TBD : This check should ideally be in the service code, but is being put here as we want to avoud a major change
75+
// to the service so late in the current release cycle. Once this fix has been migrated to the service, this check can be removed from here
76+
if (!deviceDetails.DeviceProperties.IsConfigUpdated)
77+
{
78+
throw new ArgumentException(Resources.DeviceNotConfiguredMessage);
79+
}
80+
81+
if (EncryptionEnabled == true && (string.IsNullOrEmpty(EncryptionKey) || !IsValidAsciiString(EncryptionKey)))
6982
{
7083
throw new ArgumentException(Resources.EncryptionKeyNotAcceptableMessage);
7184
}

0 commit comments

Comments
 (0)