Skip to content

Commit b189adf

Browse files
committed
Merge pull request #32 from AzCiS/onesdk-p2-sumanths
Onesdk p2 sumanths
2 parents 79ca0ee + 85993fa commit b189adf

File tree

4 files changed

+45
-7
lines changed

4 files changed

+45
-7
lines changed

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/Failover/GetAzureStorSimpleFailoverVolumeContainers.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
2222
{
2323

2424

25-
[Cmdlet(VerbsCommon.Get, "AzureStorSimpleFailoverVolumeContainers", DefaultParameterSetName = StorSimpleCmdletParameterSet.Empty),
26-
OutputType(typeof(IList<DataContainerGroup>))]
25+
[Cmdlet(VerbsCommon.Get, "AzureStorSimpleFailoverVolumeContainers"), OutputType(typeof(IList<DataContainerGroup>))]
2726
public class GetAzureStorSimpleFailoverVolumeContainers : StorSimpleCmdletBase
2827
{
2928
[Parameter(Position = 0, Mandatory = true, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyById, HelpMessage = StorSimpleCmdletHelpMessage.DeviceId)]
@@ -43,7 +42,14 @@ public override void ExecuteCmdlet()
4342
switch(ParameterSetName)
4443
{
4544
case StorSimpleCmdletParameterSet.IdentifyById:
46-
deviceid = DeviceId;
45+
if (StorSimpleClient.IsValidDeviceId(DeviceId))
46+
{
47+
deviceid = DeviceId;
48+
}
49+
else
50+
{
51+
WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenIdInResourceMessage, StorSimpleContext.ResourceName, DeviceId));
52+
}
4753
break;
4854
case StorSimpleCmdletParameterSet.IdentifyByName:
4955
deviceid = StorSimpleClient.GetDeviceId(DeviceName);

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/Volume/RemoveAzureStorSimpleDeviceVolume .cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class RemoveAzureStorSimpleDeviceVolume : StorSimpleCmdletBase
3131
[ValidateNotNullOrEmpty]
3232
public string VolumeName { get; set; }
3333

34-
[Parameter(Position = 1, Mandatory = true, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyByObject, ValueFromPipeline = true, HelpMessage = StorSimpleCmdletHelpMessage.VolumeId)]
34+
[Parameter(Position = 1, Mandatory = true, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyByObject, ValueFromPipeline = true, HelpMessage = StorSimpleCmdletHelpMessage.VolumeObject)]
3535
[ValidateNotNullOrEmpty]
3636
public VirtualDisk Volume { get; set; }
3737

@@ -68,7 +68,7 @@ public override void ExecuteCmdlet()
6868
break;
6969
case StorSimpleCmdletParameterSet.IdentifyByName:
7070
var volumeInfo = StorSimpleClient.GetVolumeByName(deviceid, VolumeName);
71-
if (volumeInfo == null)
71+
if (volumeInfo == null || volumeInfo.VirtualDiskInfo == null || volumeInfo.VirtualDiskInfo.InstanceId == null)
7272
{
7373
WriteVerbose(Resources.NotFoundMessageVirtualDisk);
7474
return;

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/Volume/SetAzureStorSimpleDeviceVolume.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@ public class SetAzureStorSimpleDeviceVolume : StorSimpleCmdletBase
2828
public string DeviceName { get; set; }
2929

3030
[Alias("Name")]
31-
[Parameter(Position = 1, Mandatory = true, HelpMessage = StorSimpleCmdletHelpMessage.VolumeName)]
31+
[Parameter(Position = 1, Mandatory = true, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyByName, HelpMessage = StorSimpleCmdletHelpMessage.VolumeName)]
3232
[ValidateNotNullOrEmpty]
3333
public string VolumeName { get; set; }
3434

35+
[Parameter(Position = 1, Mandatory = true, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyByObject, ValueFromPipeline = true, HelpMessage = StorSimpleCmdletHelpMessage.VolumeObject)]
36+
[ValidateNotNullOrEmpty]
37+
public VirtualDisk Volume { get; set; }
38+
3539
[Parameter(Position = 2, Mandatory = false, HelpMessage = StorSimpleCmdletHelpMessage.VolumeOnline)]
3640
[ValidateNotNullOrEmpty]
3741
public bool? Online { get; set; }
@@ -70,7 +74,20 @@ public override void ExecuteCmdlet()
7074
return;
7175
}
7276

73-
VirtualDisk diskDetails = StorSimpleClient.GetVolumeByName(deviceId, VolumeName).VirtualDiskInfo;
77+
VirtualDisk diskDetails = null;
78+
79+
switch (ParameterSetName)
80+
{
81+
case StorSimpleCmdletParameterSet.IdentifyByObject:
82+
diskDetails = Volume;
83+
break;
84+
case StorSimpleCmdletParameterSet.IdentifyByName:
85+
diskDetails = StorSimpleClient.GetVolumeByName(deviceId, VolumeName).VirtualDiskInfo;
86+
break;
87+
default:
88+
break;
89+
}
90+
7491
if (diskDetails == null)
7592
{
7693
WriteVerbose(Resources.NotFoundMessageVirtualDisk);

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,21 @@ public TaskStatusInfo UpdateDeviceDetails(DeviceDetails updatedDetails)
7474
return taskStatusInfo;
7575
}
7676

77+
public bool IsValidDeviceId(string deviceId)
78+
{
79+
if (string.IsNullOrWhiteSpace(deviceId)) throw new ArgumentNullException("deviceId");
80+
var deviceInfos = GetAllDevices();
81+
foreach (var deviceInfo in deviceInfos)
82+
{
83+
if (deviceInfo.DeviceId.Equals(deviceId, StringComparison.InvariantCultureIgnoreCase))
84+
{
85+
return true;
86+
}
87+
}
88+
89+
return false;
90+
}
91+
7792
public string GetDeviceId(string deviceToUse)
7893
{
7994
if (deviceToUse == null) throw new ArgumentNullException("deviceToUse");

0 commit comments

Comments
 (0)