Skip to content

Commit

Permalink
Merge pull request #49 from AzCiS/onesdk-phase2
Browse files Browse the repository at this point in the history
Onesdk phase2
  • Loading branch information
parvezah committed Apr 13, 2015
2 parents 8e8c4f8 + 68c9386 commit 30d9907
Show file tree
Hide file tree
Showing 15 changed files with 1,032 additions and 227 deletions.
49 changes: 46 additions & 3 deletions src/ServiceManagement/Services/Commands.Utilities/Azure.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ ScriptsToProcess = @()
TypesToProcess = @(
'.\Services\Microsoft.WindowsAzure.Commands.Websites.Types.ps1xml',
'.\Sql\Microsoft.WindowsAzure.Commands.SqlDatabase.Types.ps1xml'
'.\Storage\Microsoft.WindowsAzure.Commands.Storage.Types.ps1xml'
'.\Storage\Microsoft.WindowsAzure.Commands.Storage.Types.ps1xml',
'.\StorSimple\Microsoft.WindowsAzure.Commands.StorSimple.Types.ps1xml'
)

# Format files (.ps1xml) to be loaded when importing this module
Expand All @@ -70,7 +71,8 @@ FormatsToProcess = @(
'.\Services\Microsoft.WindowsAzure.Commands.Scheduler.format.ps1xml',
'.\Compute\Microsoft.WindowsAzure.Commands.ServiceManagement.format.ps1xml',
'.\Services\Microsoft.WindowsAzure.Commands.Profile.format.ps1xml',
'.\Network\Microsoft.Azure.Commands.Network.format.ps1xml'
'.\Network\Microsoft.Azure.Commands.Network.format.ps1xml',
'.\StorSimple\Microsoft.WindowsAzure.Commands.StorSimple.format.ps1xml'
)

# Modules to import as nested modules of the module specified in ModuleToProcess
Expand Down Expand Up @@ -154,7 +156,48 @@ AliasesToExport = @(
'Wait-AzureHDInsightJob',
'Get-AzureStorageContainerAcl',
'Start-CopyAzureStorageBlob',
'Stop-CopyAzureStorageBlob'
'Stop-CopyAzureStorageBlob',
'Get-SSAccessControlRecord',
'Get-SSDevice',
'Get-SSDeviceBackup',
'Get-SSDeviceBackupPolicy',
'Get-SSDeviceConnectedInitiator',
'Get-SSDeviceVolume',
'Get-SSDeviceVolumeContainer',
'Get-SSFailoverVolumeContainers',
'Get-SSJob',
'Get-SSResource',
'Get-SSResourceContext',
'Get-SSStorageAccountCredential',
'Get-SSTask',
'New-SSAccessControlRecord',
'New-SSDeviceBackupPolicy',
'New-SSDeviceBackupScheduleAddConfig',
'New-SSDeviceBackupScheduleUpdateConfig',
'New-SSDeviceVolume',
'New-SSDeviceVolumeContainer',
'New-SSInlineStorageAccountCredential',
'New-SSNetworkConfig',
'New-SSStorageAccountCredential',
'New-SSVirtualDevice',
'Remove-SSAccessControlRecord',
'Remove-SSDeviceBackup',
'Remove-SSDeviceBackupPolicy',
'Remove-SSDeviceVolume',
'Remove-SSDeviceVolumeContainer',
'Remove-SSStorageAccountCredential',
'Select-SSResource',
'Set-SSAccessControlRecord',
'Set-SSDevice',
'Set-SSDeviceBackupPolicy',
'Set-SSDeviceVolume',
'Set-SSStorageAccountCredential',
'Set-SSVirtualDevice',
'Start-SSBackupCloneJob',
'Start-SSDeviceBackupJob',
'Start-SSDeviceBackupRestoreJob',
'Start-SSDeviceFailoverJob',
'Stop-SSJob'
)

# List of all modules packaged with this module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,50 @@ $aliases = @{

# HDInsight aliases
"Invoke-Hive" = "Invoke-AzureHDInsightHiveJob";
"hive" = "Invoke-AzureHDInsightHiveJob"
"hive" = "Invoke-AzureHDInsightHiveJob";

#StorSimple aliases
"Get-SSAccessControlRecord" = "Get-AzureStorSimpleAccessControlRecord" ;
"Get-SSDevice"= "Get-AzureStorSimpleDevice" ;
"Get-SSDeviceBackup" = "Get-AzureStorSimpleDeviceBackup" ;
"Get-SSDeviceBackupPolicy" = "Get-AzureStorSimpleDeviceBackupPolicy" ;
"Get-SSDeviceConnectedInitiator" = "Get-AzureStorSimpleDeviceConnectedInitiator" ;
"Get-SSDeviceVolume" = "Get-AzureStorSimpleDeviceVolume" ;
"Get-SSDeviceVolumeContainer" = "Get-AzureStorSimpleDeviceVolumeContainer" ;
"Get-SSFailoverVolumeContainers" = "Get-AzureStorSimpleFailoverVolumeContainers" ;
"Get-SSJob" = "Get-AzureStorSimpleJob" ;
"Get-SSResource" = "Get-AzureStorSimpleResource" ;
"Get-SSResourceContext" = "Get-AzureStorSimpleResourceContext" ;
"Get-SSStorageAccountCredential" = "Get-AzureStorSimpleStorageAccountCredential" ;
"Get-SSTask" = "Get-AzureStorSimpleTask" ;
"New-SSAccessControlRecord" = "New-AzureStorSimpleAccessControlRecord" ;
"New-SSDeviceBackupPolicy" = "New-AzureStorSimpleDeviceBackupPolicy" ;
"New-SSDeviceBackupScheduleAddConfig" = "New-AzureStorSimpleDeviceBackupScheduleAddConfig" ;
"New-SSDeviceBackupScheduleUpdateConfig" = "New-AzureStorSimpleDeviceBackupScheduleUpdateConfig" ;
"New-SSDeviceVolume" = "New-AzureStorSimpleDeviceVolume";
"New-SSDeviceVolumeContainer" = "New-AzureStorSimpleDeviceVolumeContainer" ;
"New-SSInlineStorageAccountCredential" = "New-AzureStorSimpleInlineStorageAccountCredential" ;
"New-SSNetworkConfig" = "New-AzureStorSimpleNetworkConfig";
"New-SSStorageAccountCredential" = "New-AzureStorSimpleStorageAccountCredential";
"New-SSVirtualDevice" = "New-AzureStorSimpleVirtualDevice";
"Remove-SSAccessControlRecord" = "Remove-AzureStorSimpleAccessControlRecord";
"Remove-SSDeviceBackup" = "Remove-AzureStorSimpleDeviceBackup";
"Remove-SSDeviceBackupPolicy" = "Remove-AzureStorSimpleDeviceBackupPolicy";
"Remove-SSDeviceVolume" = "Remove-AzureStorSimpleDeviceVolume";
"Remove-SSDeviceVolumeContainer" = "Remove-AzureStorSimpleDeviceVolumeContainer";
"Remove-SSStorageAccountCredential" = "Remove-AzureStorSimpleStorageAccountCredential";
"Select-SSResource" = "Select-AzureStorSimpleResource";
"Set-SSAccessControlRecord" = "Set-AzureStorSimpleAccessControlRecord";
"Set-SSDevice" = "Set-AzureStorSimpleDevice";
"Set-SSDeviceBackupPolicy" = "Set-AzureStorSimpleDeviceBackupPolicy";
"Set-SSDeviceVolume" = "Set-AzureStorSimpleDeviceVolume";
"Set-SSStorageAccountCredential" = "Set-AzureStorSimpleStorageAccountCredential";
"Set-SSVirtualDevice" = "Set-AzureStorSimpleVirtualDevice";
"Start-SSBackupCloneJob" = "Start-AzureStorSimpleBackupCloneJob";
"Start-SSDeviceBackupJob" = "Start-AzureStorSimpleDeviceBackupJob";
"Start-SSDeviceBackupRestoreJob" = "Start-AzureStorSimpleDeviceBackupRestoreJob";
"Start-SSDeviceFailoverJob" = "Start-AzureStorSimpleDeviceFailoverJob";
"Stop-SSJob" = "Stop-AzureStorSimpleJob";
}

$aliases.GetEnumerator() | Select @{Name='Name'; Expression={$_.Key}}, @{Name='Value'; Expression={$_.Value}} | New-Alias -Description "AzureAlias"
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
{
[Cmdlet(VerbsCommon.Get, "AzureStorSimpleDeviceBackup", DefaultParameterSetName = StorSimpleCmdletParameterSet.Empty),OutputType(typeof(GetBackupResponse))]
[Cmdlet(VerbsCommon.Get, "AzureStorSimpleDeviceBackup", DefaultParameterSetName = StorSimpleCmdletParameterSet.Empty),OutputType(typeof(IList<Backup>))]
public class GetAzureStorSimpleDeviceBackup: StorSimpleCmdletBase
{
[Parameter(Position = 0, Mandatory = true, HelpMessage = StorSimpleCmdletHelpMessage.DeviceName, ParameterSetName = StorSimpleCmdletParameterSet.Empty)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public override void ExecuteCmdlet()

if(EncryptionEnabled == true && (string.IsNullOrEmpty(EncryptionKey) || !IsValidAsciiString(EncryptionKey)))
{
throw new ArgumentNullException("EncryptionKey");
throw new ArgumentException(Resources.EncryptionKeyNotAcceptableMessage);
}

string encryptedKey = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,67 +28,61 @@ namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
/// <summary>
/// Stop the specified device job if its in progress and is cancellable.
/// </summary>
[Cmdlet(VerbsCommon.Get, "AzureStorSimpleJob", DefaultParameterSetName=StorSimpleCmdletParameterSet.IdentifyByDeviceName),
OutputType(typeof(IList<DeviceJobDetails>), typeof(DeviceJobDetails))]
[Cmdlet(VerbsCommon.Get, "AzureStorSimpleJob"), OutputType(typeof(IList<DeviceJobDetails>), typeof(DeviceJobDetails))]
public class GetAzureStorSimpleJob : StorSimpleCmdletBase
{
#region params
/// <summary>
/// Name of StorSimple device for which to fetch jobs
/// </summary>
[Parameter(Mandatory = true, Position = 0, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyByDeviceName,
HelpMessage=StorSimpleCmdletHelpMessage.DeviceName)]
[Parameter(Mandatory = false, Position = 0, HelpMessage=StorSimpleCmdletHelpMessage.DeviceName)]
[ValidateNotNullOrEmpty]
public string DeviceName { get; set; }


/// <summary>
/// InstanceId/JobId of the job to retrieve
/// </summary>
[Parameter(Mandatory=true, Position = 0, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyById,
HelpMessage = StorSimpleCmdletHelpMessage.DeviceJobId)]
[Parameter(Mandatory = false, Position = 1, HelpMessage = StorSimpleCmdletHelpMessage.DeviceJobId)]
[ValidateNotNullOrEmpty]
public string InstanceId { get; set; }

/// <summary>
/// Filter jobs by their status.
/// </summary>
[Parameter(Mandatory = true, Position = 0, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyByStatus,
HelpMessage=StorSimpleCmdletHelpMessage.DeviceJobStatus)]
[Parameter(Mandatory = false, Position = 2, HelpMessage=StorSimpleCmdletHelpMessage.DeviceJobStatus)]
[ValidateSetAttribute(new string[] { "Running", "Completed", "Cancelled", "Failed", "Cancelling", "CompletedWithErrors" })]
public string Status { get; set; }

/// <summary>
/// Filter jobs by their status.
/// </summary>
[Parameter(Mandatory = true, Position = 0, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyByType,
HelpMessage=StorSimpleCmdletHelpMessage.DeviceJobType)]
[Parameter(Mandatory = false, Position = 3, HelpMessage=StorSimpleCmdletHelpMessage.DeviceJobType)]
[ValidateSetAttribute(new string[] { "Backup", "ManualBackup", "Restore", "CloneWorkflow", "DeviceRestore", "Update", "SupportPackage", "VirtualApplianceProvisioning" })]
public string Type { get; set; }

/// <summary>
/// Filter jobs that were created after specified time
/// </summary>
[Parameter(Position = 1, Mandatory=false, HelpMessage = StorSimpleCmdletHelpMessage.FromTime)]
[Parameter(Mandatory = false, Position = 4, HelpMessage = StorSimpleCmdletHelpMessage.FromTime)]
public DateTime? From { get; set; }

/// <summary>
/// Filter jobs that were created till specified time
/// </summary
[Parameter(Position = 2, Mandatory=false, HelpMessage = StorSimpleCmdletHelpMessage.ToTime)]
[Parameter(Mandatory = false, Position = 5, HelpMessage = StorSimpleCmdletHelpMessage.ToTime)]
public DateTime? To { get; set; }

/// <summary>
/// Number of results to skip
/// </summary>
[Parameter(Position = 3, Mandatory=false, HelpMessage = StorSimpleCmdletHelpMessage.SkipDesc)]
[Parameter(Mandatory = false, Position = 6, HelpMessage = StorSimpleCmdletHelpMessage.SkipDesc)]
[ValidateRange(0, Int32.MaxValue)]
public int? Skip { get; set; }

/// <summary>
/// Number of results to include.
/// </summary>
[Parameter(Position = 4, Mandatory=false, HelpMessage = StorSimpleCmdletHelpMessage.FirstDesc)]
[Parameter(Mandatory = false, Position = 7, HelpMessage = StorSimpleCmdletHelpMessage.FirstDesc)]
[ValidateRange(0, Int32.MaxValue)]
public int? First { get; set; }
#endregion params
Expand All @@ -108,41 +102,29 @@ public override void ExecuteCmdlet()
// Make call to get device jobs.
var response = StorSimpleClient.GetDeviceJobs(deviceId, Type, Status, InstanceId, fromDateTimeIsoString, toDateTimeIsoString, (int)Skip, (int)First);

if (ParameterSetName == StorSimpleCmdletParameterSet.IdentifyById)
WriteObject(response.DeviceJobList, true);
WriteVerbose(string.Format(Resources.DeviceJobsReturnedCount, response.DeviceJobList.Count,
response.DeviceJobList.Count > 1 ? "s" : string.Empty));
if (response.NextPageUri != null
&& response.NextPageStartIdentifier != "-1")
{
if (response == null || response.DeviceJobList.Count < 1)
if (First != null)
{
throw new ArgumentException(string.Format(Resources.NoDeviceJobFoundWithGivenIdMessage, InstanceId));
}
WriteObject(response.DeviceJobList.First());
return;
}
else
{
WriteObject(response.DeviceJobList, true);
WriteVerbose(string.Format(Resources.DeviceJobsReturnedCount, response.DeviceJobList.Count,
response.DeviceJobList.Count > 1 ? "s" : string.Empty));
if (response.NextPageUri != null
&& response.NextPageStartIdentifier != "-1")
{
if (First != null)
{
//user has provided First(Top) parameter while calling the commandlet
//so we need to provide it to him for calling the next page
WriteVerbose(string.Format(Resources.DeviceJobsNextPageFormatMessage, First, response.NextPageStartIdentifier));
}
else
{
//user has NOT provided First(Top) parameter while calling the commandlet
//so we DONT need to provide it to him for calling the next page
WriteVerbose(string.Format(Resources.DeviceJobsNextPagewithNoFirstMessage, response.NextPageStartIdentifier));
}
//user has provided First(Top) parameter while calling the commandlet
//so we need to provide it to him for calling the next page
WriteVerbose(string.Format(Resources.DeviceJobsNextPageFormatMessage, First, response.NextPageStartIdentifier));
}
else
{
WriteVerbose(Resources.DeviceJobsNoMorePagesMessage);
//user has NOT provided First(Top) parameter while calling the commandlet
//so we DONT need to provide it to him for calling the next page
WriteVerbose(string.Format(Resources.DeviceJobsNextPagewithNoFirstMessage, response.NextPageStartIdentifier));
}
}
else
{
WriteVerbose(Resources.DeviceJobsNoMorePagesMessage);
}
}
catch (Exception exception)
{
Expand All @@ -164,7 +146,7 @@ private void ProcessParameters()

deviceId = null;

if (ParameterSetName == StorSimpleCmdletParameterSet.IdentifyByDeviceName)
if (DeviceName != null)
{
deviceId = StorSimpleClient.GetDeviceId(DeviceName);
if (deviceId == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
using System.Management.Automation;
using Microsoft.WindowsAzure.Management.StorSimple.Models;

namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets.VirtualDevice
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
{
[Cmdlet(VerbsCommon.New, "AzureStorSimpleVirtualDevice"), OutputType(typeof(string))]
public class NewAzureStorSimpleVirtualDeviceCommand : StorSimpleCmdletBase
Expand All @@ -41,6 +41,9 @@ public class NewAzureStorSimpleVirtualDeviceCommand : StorSimpleCmdletBase

[Parameter(Position = 3, Mandatory = true, HelpMessage = StorSimpleCmdletHelpMessage.CreateNewStorageAccount, ParameterSetName = StorSimpleCmdletParameterSet.CreateNewStorageAccount)]
public SwitchParameter CreateNewStorageAccount { get; set; }

[Parameter(DontShow = true, Mandatory = false, HelpMessage = StorSimpleCmdletHelpMessage.PersistAzureVMOnFailrue)]
public SwitchParameter PersistAzureVMOnFailrue { get; set; }

public override void ExecuteCmdlet()
{
Expand All @@ -57,6 +60,11 @@ public override void ExecuteCmdlet()
StorageAccountName = StorageAccountName
};

if (PersistAzureVMOnFailrue.IsPresent)
{
applianceProvisiongInfo.DeleteAzureCisVMOnFailure = false;
}

var deviceJobResponse = StorSimpleClient.CreateVirtualDevice(applianceProvisiongInfo);

HandleDeviceJobResponse(deviceJobResponse, "create");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@
<Reference Include="Microsoft.WindowsAzure.Management.Scheduler">
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Scheduler.6.0.0\lib\net40\Microsoft.WindowsAzure.Management.Scheduler.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.StorSimple">
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.StorSimple.1.0.0-preview\lib\net40\Microsoft.WindowsAzure.Management.StorSimple.dll</HintPath>
<Reference Include="Microsoft.WindowsAzure.Management.StorSimple, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.StorSimple.1.0.1-preview\lib\net40\Microsoft.WindowsAzure.Management.StorSimple.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand Down Expand Up @@ -193,6 +194,12 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Microsoft.WindowsAzure.Commands.StorSimple.format.ps1xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Microsoft.WindowsAzure.Commands.StorSimple.types.ps1xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="MSSharedLibKey.snk" />
<None Include="packages.config">
<SubType>Designer</SubType>
Expand Down
Loading

0 comments on commit 30d9907

Please sign in to comment.