Skip to content

Commit b25e639

Browse files
committed
Merge pull request #7 from AzCiS/parvezah
Virtual Device Related Changes
2 parents e4dd767 + d0608f9 commit b25e639

File tree

8 files changed

+118
-11
lines changed

8 files changed

+118
-11
lines changed

src/ServiceManagement.StorSimple.sln

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 2013
4-
VisualStudioVersion = 12.0.21005.1
4+
VisualStudioVersion = 12.0.31101.0
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.StorSimple.Library", "Commands.StorSimple.Library\Commands.StorSimple.Library.csproj", "{B0E9C13F-4E03-4DF0-91FA-9A8C76E7422D}"
7-
EndProject
86
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.StorSimple", "ServiceManagement\StorSimple\Commands.StorSimple\Commands.StorSimple.csproj", "{11524D98-6C40-4091-A8E1-86463FEE607C}"
97
EndProject
108
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.StorSimple.Test", "ServiceManagement\StorSimple\Commands.StorSimple.Test\Commands.StorSimple.Test.csproj", "{0FA676D5-1349-4086-B33F-65EC2CB7DA41}"
@@ -15,10 +13,6 @@ Global
1513
Release|Any CPU = Release|Any CPU
1614
EndGlobalSection
1715
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18-
{B0E9C13F-4E03-4DF0-91FA-9A8C76E7422D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19-
{B0E9C13F-4E03-4DF0-91FA-9A8C76E7422D}.Debug|Any CPU.Build.0 = Debug|Any CPU
20-
{B0E9C13F-4E03-4DF0-91FA-9A8C76E7422D}.Release|Any CPU.ActiveCfg = Release|Any CPU
21-
{B0E9C13F-4E03-4DF0-91FA-9A8C76E7422D}.Release|Any CPU.Build.0 = Release|Any CPU
2216
{11524D98-6C40-4091-A8E1-86463FEE607C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2317
{11524D98-6C40-4091-A8E1-86463FEE607C}.Debug|Any CPU.Build.0 = Debug|Any CPU
2418
{11524D98-6C40-4091-A8E1-86463FEE607C}.Release|Any CPU.ActiveCfg = Release|Any CPU
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Management.Automation;
17+
using Microsoft.WindowsAzure.Management.StorSimple.Models;
18+
19+
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets.VirtualDevice
20+
{
21+
[Cmdlet(VerbsCommon.New, "AzureStorSimpleVirtualDevice"), OutputType(typeof(string))]
22+
public class NewAzureStorSimpleVirtualDeviceCommand : StorSimpleCmdletBase
23+
{
24+
[Parameter(Position = 0, Mandatory = true, HelpMessage = StorSimpleCmdletHelpMessage.VirtualDeviceName)]
25+
[Alias("Name")]
26+
[ValidateNotNullOrEmpty]
27+
public string VirtualDeviceName { get; set; }
28+
29+
[Parameter(Position = 1, Mandatory = true, HelpMessage = StorSimpleCmdletHelpMessage.VirtualNetworkName)]
30+
[Alias("VNetName")]
31+
[ValidateNotNullOrEmpty]
32+
public string VirtualNetworkName { get; set; }
33+
34+
[Parameter(Position = 2, Mandatory = true, HelpMessage = StorSimpleCmdletHelpMessage.SubNetName)]
35+
[ValidateNotNullOrEmpty]
36+
public string SubNetName { get; set; }
37+
38+
[Parameter(Position = 3, Mandatory = false, HelpMessage = StorSimpleCmdletHelpMessage.StorageAccountNameForVirtualDevice)]
39+
public string StorageAccountName { get; set; }
40+
41+
[Parameter(Position = 4, Mandatory = false, HelpMessage = StorSimpleCmdletHelpMessage.CreateNewStorageAccount)]
42+
public SwitchParameter CreateNewStorageAccount { get; set; }
43+
44+
public override void ExecuteCmdlet()
45+
{
46+
try
47+
{
48+
var applianceProvisiongInfo = new VirtualDeviceProvisioningInfo()
49+
{
50+
SubscriptionId = CurrentContext.Subscription.Id.ToString(),
51+
DeviceName = VirtualDeviceName,
52+
ReturnWorkflowId = true,
53+
VirtualNetworkName = VirtualNetworkName,
54+
SubNetName = SubNetName,
55+
CreateNewStorageAccount = CreateNewStorageAccount.IsPresent,
56+
StorageAccountName = StorageAccountName
57+
};
58+
59+
var deviceJobResponse = StorSimpleClient.CreateVirtualDevice(applianceProvisiongInfo);
60+
61+
HandleDeviceJobResponse(deviceJobResponse, "create");
62+
}
63+
catch (Exception exception)
64+
{
65+
this.HandleException(exception);
66+
}
67+
}
68+
}
69+
70+
}

src/ServiceManagement/StorSimple/Commands.StorSimple/Commands.StorSimple.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
<Compile Include="Cmdlets\ServiceConfig\RemoveAzureStorSimpleStorageAccountCredential.cs" />
144144
<Compile Include="Cmdlets\ServiceConfig\SetAzureStorSimpleAccessControlRecord.cs" />
145145
<Compile Include="Cmdlets\ServiceConfig\SetAzureStorSimpleStorageAccountCredential.cs" />
146+
<Compile Include="Cmdlets\VirtualDevice\NewAzureStorSimpleVirtualDeviceCommand.cs" />
146147
<Compile Include="Cmdlets\Volume\GetAzureStorSimpleDeviceVolume .cs" />
147148
<Compile Include="Cmdlets\Volume\NewAzureStorSimpleDeviceVolume.cs" />
148149
<Compile Include="Cmdlets\Volume\RemoveAzureStorSimpleDeviceVolume .cs" />
@@ -169,6 +170,7 @@
169170
<Compile Include="ServiceClients\StorSimpleDeviceFailoverClient.cs" />
170171
<Compile Include="ServiceClients\StorSimpleDevicesClient.cs" />
171172
<Compile Include="ServiceClients\StorSimpleServiceConfigClient.cs" />
173+
<Compile Include="ServiceClients\StorSimpleVirtualDeviceClient.cs" />
172174
<Compile Include="ServiceClients\StorSimpleVolumeClient.cs" />
173175
<Compile Include="StorSimpleCmdletBase.cs" />
174176
<Compile Include="StorSimpleCmdletHelpMessage.cs" />

src/ServiceManagement/StorSimple/Commands.StorSimple/Properties/Resources.Designer.cs

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ private StorSimpleManagementClient GetStorSimpleClient()
6161
AzureSession.ClientFactory.CreateCustomClient<StorSimpleManagementClient>(
6262
StorSimpleContext.CloudServiceName,
6363
StorSimpleContext.ResourceName, StorSimpleContext.ResourceId,
64-
StorSimpleContext.ResourceProviderNameSpace, StorSimpleContext.StampId,
65-
this.cloudServicesClient.Credentials,
64+
StorSimpleContext.ResourceProviderNameSpace, this.cloudServicesClient.Credentials,
6665
AzureSession.CurrentContext.Environment.GetEndpointAsUri(AzureEnvironment.Endpoint.ServiceManagement));
6766

6867
if (storSimpleClient == null)
@@ -101,7 +100,7 @@ public void ThrowCloudExceptionDetails(CloudException cloudException)
101100
throw new InvalidOperationException(
102101
string.Format(error.Message,"\n",error.HttpCode,"\n",error.ExtendedCode));
103102
}
104-
103+
105104
private CustomRequestHeaders GetCustomRequestHeaders()
106105
{
107106
var hdrs = new CustomRequestHeaders()
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.WindowsAzure.Management.StorSimple;
16+
using Microsoft.WindowsAzure.Management.StorSimple.Models;
17+
18+
namespace Microsoft.WindowsAzure.Commands.StorSimple
19+
{
20+
public partial class StorSimpleClient
21+
{
22+
public JobResponse CreateVirtualDevice(VirtualDeviceProvisioningInfo virtualApplianceProvisioningInfo)
23+
{
24+
return this.GetStorSimpleClient().VirtualDevice.Create(virtualApplianceProvisioningInfo, this.GetCustomRequestHeaders());
25+
}
26+
}
27+
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ internal static class StorSimpleCmdletHelpMessage
7979
public const string HelpMessageBackupScheduleBaseObjsToDelete = "List of Instance Id of BackupSchedule objects to be deleted";
8080
public const string HelpMessageVolumeObjsToUpdate = "List of VolumeIds to be updated";
8181
public const string HelpMessageResourceName = "Name of the resource which needs to be retrieved";
82+
83+
public const string VirtualDeviceName = "Name of the Virtual Device to be created.";
84+
public const string VirtualNetworkName = "Name of the Virtual Network to be used by the Virtual Device.";
85+
public const string SubNetName = "Name of the Subnet in the Virtual Network which should be used by the Virtual Device.";
86+
public const string StorageAccountNameForVirtualDevice = "Name of the Storage Account to be used to create the Virtual Device.";
87+
public const string CreateNewStorageAccount = "Switch which decides whether to create a new storage account.";
8288
public const string HelpMessageVolumeContainerGroups = "List of Volme Container Groups to be failed over";
8389
public const string HelpMessageFailoverTargetDeviceName = "Name of the StorSimple failover target device";
8490
public const string HelpMessageFailoverTargetDeviceId = "The device identifier of the StorSimple failover target device";

0 commit comments

Comments
 (0)