diff --git a/src/AzurePowershell.sln b/src/AzurePowershell.sln index c162b0682a80..598c91723ee5 100644 --- a/src/AzurePowershell.sln +++ b/src/AzurePowershell.sln @@ -1,5 +1,5 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 +# Visual Studio Express 2013 for Web VisualStudioVersion = 12.0.31101.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8531411A-0137-4E27-9C5E-49E07C245048}" @@ -210,6 +210,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ApiManagement", "R EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ApiManagement.Test", "ResourceManager\ApiManagement\Commands.ApiManagement.Test\Commands.ApiManagement.Test.csproj", "{BEC9ECE9-A3D6-4B24-A682-1FA890647D9D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.AzureBackup", "ResourceManager\AzureBackup\Commands.AzureBackup\Commands.AzureBackup.csproj", "{6C8D2337-C9D1-4F52-94B3-AB63A19F3453}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -512,6 +514,10 @@ Global {BEC9ECE9-A3D6-4B24-A682-1FA890647D9D}.Debug|Any CPU.Build.0 = Debug|Any CPU {BEC9ECE9-A3D6-4B24-A682-1FA890647D9D}.Release|Any CPU.ActiveCfg = Release|Any CPU {BEC9ECE9-A3D6-4B24-A682-1FA890647D9D}.Release|Any CPU.Build.0 = Release|Any CPU + {6C8D2337-C9D1-4F52-94B3-AB63A19F3453}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6C8D2337-C9D1-4F52-94B3-AB63A19F3453}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6C8D2337-C9D1-4F52-94B3-AB63A19F3453}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6C8D2337-C9D1-4F52-94B3-AB63A19F3453}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/ResourceManager.AzureBackup.sln b/src/ResourceManager.AzureBackup.sln new file mode 100644 index 000000000000..7e69df5fb3c6 --- /dev/null +++ b/src/ResourceManager.AzureBackup.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Express 2013 for Web +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.AzureBackup", "ResourceManager\AzureBackup\Commands.AzureBackup\Commands.AzureBackup.csproj", "{6C8D2337-C9D1-4F52-94B3-AB63A19F3453}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6C8D2337-C9D1-4F52-94B3-AB63A19F3453}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6C8D2337-C9D1-4F52-94B3-AB63A19F3453}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6C8D2337-C9D1-4F52-94B3-AB63A19F3453}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6C8D2337-C9D1-4F52-94B3-AB63A19F3453}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupCmdletBase.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupCmdletBase.cs new file mode 100644 index 000000000000..c0aec687272e --- /dev/null +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupCmdletBase.cs @@ -0,0 +1,174 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Management.Automation; +using System.Collections.Generic; +using System.Xml; +using Microsoft.WindowsAzure.Commands.Utilities.Common; +using Microsoft.Azure.Common.Authentication; +using Microsoft.Azure.Common.Authentication.Models; +using System.Threading; +using Hyak.Common; +using Microsoft.Azure.Commands.AzureBackup.Properties; +using System.Net; +using Microsoft.WindowsAzure.Management.Scheduler; +using Microsoft.Azure.Management.BackupServices; +using Microsoft.Azure.Management.BackupServices.Models; + +namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets +{ + public abstract class AzureBackupCmdletBase : AzurePSCmdlet + { + /// + /// ResourceGroup context for the operation + /// + private string resourceGroupName { get; set; } + + /// + /// Resource context for the operation + /// + private string resourceName { get; set; } + + /// + /// Client request id. + /// + private string clientRequestId; + + /// + /// Azure backup client. + /// + private BackupServicesManagementClient azureBackupClient; + + /// + /// Cancellation Token Source + /// + private CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); + protected CancellationToken CmdletCancellationToken; + + /// + /// Get Azure backup client. + /// + protected BackupServicesManagementClient AzureBackupClient + { + get + { + if (this.azureBackupClient == null) + { + // Temp code to be able to test internal env. + ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; + + var cloudServicesClient = AzureSession.ClientFactory.CreateClient(Profile, Profile.Context.Subscription, AzureEnvironment.Endpoint.ResourceManager); + this.azureBackupClient = AzureSession.ClientFactory.CreateCustomClient(resourceName, resourceGroupName, cloudServicesClient.Credentials, cloudServicesClient.BaseUri); + } + + return this.azureBackupClient; + } + } + + public void InitializeAzureBackupCmdlet(string rgName, string rName) + { + resourceGroupName = rgName; + resourceName = rName; + + clientRequestId = Guid.NewGuid().ToString() + "-" + DateTime.Now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ssZ") + "-PS"; + + WriteDebug(string.Format("Initialized AzureBackup Cmdlet, ClientRequestId: {0}, ResourceGroupName: {1}, ResourceName : {2}", this.clientRequestId, resourceGroupName, resourceName)); + + CmdletCancellationToken = cancellationTokenSource.Token; + } + + protected void ExecutionBlock(Action execAction) + { + try + { + execAction(); + } + catch (Exception exception) + { + WriteDebug(String.Format("Caught exception, type: {0}", exception.GetType())); + HandleException(exception); + } + } + + /// + /// Handles set of exceptions thrown by client + /// + /// + private void HandleException(Exception exception) + { + if (exception is AggregateException && ((AggregateException)exception).InnerExceptions != null + && ((AggregateException)exception).InnerExceptions.Count != 0) + { + WriteDebug("Handling aggregate exception"); + foreach (var innerEx in ((AggregateException)exception).InnerExceptions) + { + HandleException(innerEx); + } + } + else + { + Exception targetEx = exception; + string targetErrorId = String.Empty; + ErrorCategory targetErrorCategory = ErrorCategory.NotSpecified; + + if (exception is CloudException) + { + var cloudEx = exception as CloudException; + if (cloudEx.Response != null && cloudEx.Response.StatusCode == HttpStatusCode.NotFound) + { + WriteDebug(String.Format("Received CloudException, StatusCode: {0}", cloudEx.Response.StatusCode)); + + targetEx = new Exception(Resources.ResourceNotFoundMessage); + targetErrorCategory = ErrorCategory.InvalidArgument; + } + else if (cloudEx.Error != null) + { + WriteDebug(String.Format("Received CloudException, ErrorCode: {0}, Message: {1}", cloudEx.Error.Code, cloudEx.Error.Message)); + + targetErrorId = cloudEx.Error.Code; + targetErrorCategory = ErrorCategory.InvalidOperation; + } + } + else if (exception is WebException) + { + var webEx = exception as WebException; + WriteDebug(string.Format("Received WebException, Response: {0}, Status: {1}", webEx.Response, webEx.Status)); + + targetErrorCategory = ErrorCategory.ConnectionError; + } + else if (exception is ArgumentException || exception is ArgumentNullException) + { + WriteDebug(string.Format("Received ArgumentException")); + targetErrorCategory = ErrorCategory.InvalidArgument; + } + + var errorRecord = new ErrorRecord(targetEx, targetErrorId, targetErrorCategory, null); + WriteError(errorRecord); + } + } + + protected CustomRequestHeaders GetCustomRequestHeaders() + { + var hdrs = new CustomRequestHeaders() + { + // ClientRequestId is a unique ID for every request to backend service. + ClientRequestId = this.clientRequestId, + }; + + return hdrs; + } + } +} + diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupCmdletHelpMessage.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupCmdletHelpMessage.cs new file mode 100644 index 000000000000..ec188f3d5ee5 --- /dev/null +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupCmdletHelpMessage.cs @@ -0,0 +1,25 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets +{ + + internal static class AzureBackupCmdletHelpMessage + { + public const string Vault = "The vault details"; + public const string PolicyName = "The protection policy name."; + public const string ResourceGroupName = "The ResourceGroup name."; + public const string ResourceName = "The Resource name."; + } +} diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupVaultCmdletBase.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupVaultCmdletBase.cs new file mode 100644 index 000000000000..b95e48760f6a --- /dev/null +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupVaultCmdletBase.cs @@ -0,0 +1,50 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Management.Automation; +using System.Collections.Generic; +using System.Xml; +using Microsoft.WindowsAzure.Commands.Utilities.Common; +using Microsoft.Azure.Common.Authentication; +using Microsoft.Azure.Common.Authentication.Models; +using System.Threading; +using Hyak.Common; +using Microsoft.Azure.Commands.AzureBackup.Properties; +using System.Net; + +namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets +{ + public abstract class AzureBackupVaultCmdletBase : AzureBackupCmdletBase + { + [Parameter(Position = 0, Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.ResourceGroupName, ValueFromPipelineByPropertyName = true)] + [ValidateNotNullOrEmpty] + public string ResourceGroupName { get; set; } + + [Parameter(Position = 1, Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.ResourceName, ValueFromPipelineByPropertyName = true)] + [ValidateNotNullOrEmpty] + public string ResourceName { get; set; } + + + public override void ExecuteCmdlet() + { + base.ExecuteCmdlet(); + + WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}", ResourceGroupName, ResourceName)); + + InitializeAzureBackupCmdlet(ResourceGroupName, ResourceName); + } + } +} + diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Jobs/GetAzureBackupJob.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Jobs/GetAzureBackupJob.cs new file mode 100644 index 000000000000..62cb2471c907 --- /dev/null +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Jobs/GetAzureBackupJob.cs @@ -0,0 +1,33 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Management.Automation; +using System.Collections.Generic; +using System.Xml; + +namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets +{ + /// + /// Get list of containers + /// + [Cmdlet(VerbsCommon.Get, "AzureBackupJob"), OutputType(typeof(string))] + public class GetAzureBackupJob : AzureBackupCmdletBase + { + public override void ExecuteCmdlet() + { + } + } +} + diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/ProtectionPolicy/GetAzureBackupProtectionPolicy.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/ProtectionPolicy/GetAzureBackupProtectionPolicy.cs new file mode 100644 index 000000000000..5ab989901c70 --- /dev/null +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/ProtectionPolicy/GetAzureBackupProtectionPolicy.cs @@ -0,0 +1,79 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Management.Automation; +using System.Collections.Generic; +using System.Xml; +using System.Linq; +using Microsoft.Azure.Management.BackupServices.Models; + +namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets +{ + /// + /// Get list of containers + /// + [Cmdlet(VerbsCommon.Get, "AzureBackupProtectionPolicy"), OutputType(typeof(AzureBackupProtectionPolicy), typeof(List))] + public class GetAzureBackupProtectionPolicy : AzureBackupVaultCmdletBase + { + [Parameter(Position = 2, Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.PolicyName)] + [ValidateNotNullOrEmpty] + public string Name { get; set; } + + public override void ExecuteCmdlet() + { + base.ExecuteCmdlet(); + + ExecutionBlock(() => + { + WriteVerbose("Making client call"); + + var policyListResponse = AzureBackupClient.ProtectionPolicy.ListAsync(GetCustomRequestHeaders(), CmdletCancellationToken).Result; + + WriteVerbose("Received policy response"); + WriteVerbose("Received policy response2"); + IEnumerable policyObjects = null; + if (Name != null) + { + policyObjects = policyListResponse.Objects.Where(x => x.Name.Equals(Name, System.StringComparison.InvariantCultureIgnoreCase)); + } + else + { + policyObjects = policyListResponse.Objects; + } + + WriteVerbose("Converting response"); + WriteAzureBackupProtectionPolicy(policyObjects); + }); + } + + public void WriteAzureBackupProtectionPolicy(ProtectionPolicyInfo sourcePolicy) + { + this.WriteObject(new AzureBackupProtectionPolicy(ResourceGroupName, ResourceName, sourcePolicy)); + } + + public void WriteAzureBackupProtectionPolicy(IEnumerable sourcePolicyList) + { + List targetList = new List(); + + foreach (var sourcePolicy in sourcePolicyList) + { + targetList.Add(new AzureBackupProtectionPolicy(ResourceGroupName, ResourceName, sourcePolicy)); + } + + this.WriteObject(targetList, true); + } + } +} + diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj new file mode 100644 index 000000000000..7e47d90c23c7 --- /dev/null +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj @@ -0,0 +1,171 @@ + + + + + Debug + AnyCPU + {6C8D2337-C9D1-4F52-94B3-AB63A19F3453} + Library + Properties + Microsoft.Azure.Commands.AzureBackup + Microsoft.Azure.Commands.AzureBackup + v4.5 + 512 + + ..\..\..\ + true + + + true + full + false + ..\..\..\Package\Debug\ResourceManager\AzureResourceManager\AzureBackup\ + DEBUG;TRACE + prompt + 4 + false + false + true + true + MinimumRecommendedRules.ruleset + + + ..\..\..\Package\Release\ServiceManagement\Azure\StorSimple\ + TRACE;SIGN + true + pdbonly + AnyCPU + prompt + MinimumRecommendedRules.ruleset + true + MSSharedLibKey.snk + true + false + + + + ..\..\..\packages\Hyak.Common.1.0.2\lib\portable-net403+win+wpa81\Hyak.Common.dll + + + ..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll + + + False + ..\..\..\packages\Microsoft.Azure.Common.Authentication.1.0.25-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll + + + ..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll + + + ..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll + + + ..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.14.201151115\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll + + + ..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.14.201151115\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll + + + ..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll + + + ..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll + + + ..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll + + + ..\..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll + + + False + ..\..\..\Microsoft.WindowsAzure.Management.BackupServicesManagment.dll + + + ..\..\..\packages\Microsoft.WindowsAzure.Management.Scheduler.6.0.0\lib\net40\Microsoft.WindowsAzure.Management.Scheduler.dll + + + ..\..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll + + + + + + + + False + ..\..\..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Extensions.dll + + + False + ..\..\..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Primitives.dll + + + + + + + + + + + + + + + + + + + + + True + True + Resources.resx + + + + + + {5ee72c53-1720-4309-b54b-5fb79703195f} + Commands.Common + + + + + Always + Designer + + + Always + + + Designer + + + + + ResXFileCodeGenerator + Designer + Resources.Designer.cs + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + \ No newline at end of file diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Microsoft.Azure.Commands.AzureBackup.format.ps1xml b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Microsoft.Azure.Commands.AzureBackup.format.ps1xml new file mode 100644 index 000000000000..adc17aa5aabe --- /dev/null +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Microsoft.Azure.Commands.AzureBackup.format.ps1xml @@ -0,0 +1,669 @@ + + + + + Microsoft.WindowsAzure.Management.StorSimple.Models.TaskStatusInfo + + Microsoft.WindowsAzure.Management.StorSimple.Models.TaskStatusInfo + + + + + + 36 + + + + 16 + + + + + + + + + + + + + + TaskId + + + AsyncTaskAggregatedResult + + + $_.GetSteps + + + $_.GetErrors + + + + + + + + Microsoft.WindowsAzure.Management.StorSimple.Models.TaskStep + + Microsoft.WindowsAzure.Management.StorSimple.Models.TaskStep + + + + + + + + + + + + Message + + + + + + + + Microsoft.WindowsAzure.Management.StorSimple.Models.ErrorDetails + + Microsoft.WindowsAzure.Management.StorSimple.Models.ErrorDetails + + + + + + + + + + + + + + + Message + + + Code + + + + + + + + Microsoft.WindowsAzure.Management.StorSimple.Models.DeviceJobDetails + + Microsoft.WindowsAzure.Management.StorSimple.Models.DeviceJobDetails + + + + + + 36 + + + + 28 + + + + + + + + + + + + + + + + + + + + InstanceId + + + Type + + + Status + + + $_.Device.Name + + + $_.TimeStats.StartTimestamp + + + Progress + + + + + + + + Microsoft.WindowsAzure.Management.StorSimple.Models.Backup + + Microsoft.WindowsAzure.Management.StorSimple.Models.Backup + + + + + + 36 + + + + + + + 13 + + + + + + + + + + + + + + + + + + + + + + + InstanceId + + + Name + + + Type + + + BackupJobCreationType + + + CreatedOn + + + SizeInBytes + + + Snapshots + + + SSMHostName + + + + + + + + Microsoft.WindowsAzure.Management.StorSimple.Models.BackupPolicy + + Microsoft.WindowsAzure.Management.StorSimple.Models.BackupPolicy + + + + + + 36 + + + + + + + 14 + + + + + + + + + + + + + + + + + + + + + + + InstanceId + + + Name + + + SchedulesCount + + + VolumesCount + + + BackupPolicyCreationType + + + LastBackup + + + NextBackup + + + SSMHostName + + + + + + + + Microsoft.WindowsAzure.Management.StorSimple.Models.BackupPolicyDetails + + Microsoft.WindowsAzure.Management.StorSimple.Models.BackupPolicyDetails + + + + + + + InstanceId + + + Name + + + SchedulesCount + + + BackupSchedules + + + VolumesCount + + + Volumes + + + BackupPolicyCreationType + + + LastBackup + + + NextBackup + + + SSMHostName + + + + + + + + Microsoft.WindowsAzure.Management.StorSimple.Models.VirtualDisk + + Microsoft.WindowsAzure.Management.StorSimple.Models.VirtualDisk + + + + + + + InstanceId + + + Name + + + Online + + + SizeInBytes + + + AccessType + + + AcrList + + + AppType + + + DataContainerId + + + IsBackupEnabled + + + IsDefaultBackupEnabled + + + IsMonitoringEnabled + + + VSN + + + + + + + + Microsoft.WindowsAzure.Management.StorSimple.Models.DataContainer + + Microsoft.WindowsAzure.Management.StorSimple.Models.DataContainer + + + + + + 36 + + + + + + + 20 + + + + 5 + + + + + + + + + + + + + + + + + InstanceId + + + Name + + + IsEncryptionEnabled + + + Owned + + + BandwidthRate + + + $_.PrimaryStorageAccountCredential.Name + + + VolumeCount + + + + + + + + Microsoft.WindowsAzure.Management.StorSimple.Models.DeviceInfo + + Microsoft.WindowsAzure.Management.StorSimple.Models.DeviceInfo + + + + + + + DeviceId + + + + FriendlyName + + + SerialNumber + + + DeviceSoftwareVersion + + + Location + + + ModelDescription + + + Status + + + Type + + + TargetIQN + + + TimeZone + + + ActivationTime + + + AvailableStorageInBytes + + + ProvisionedStorageInBytes + + + TotalStorageInBytes + + + UsingStorageInBytes + + + + + + + + Microsoft.WindowsAzure.Management.StorSimple.Models.AccessControlRecord + + Microsoft.WindowsAzure.Management.StorSimple.Models.AccessControlRecord + + + + + + 36 + + + + + + + + + + + + + + + + InstanceId + + + Name + + + InitiatorName + + + VolumeCount + + + + + + + + Microsoft.WindowsAzure.Commands.StorSimple.ResourceCredentials + + Microsoft.WindowsAzure.Commands.StorSimple.ResourceCredentials + + + + + + + + + 20 + + + + + + + + + + ResourceName + + + ResourceId + + + ResourceState + + + + + + + + Microsoft.WindowsAzure.Commands.StorSimple.StorSimpleResourceContext + + Microsoft.WindowsAzure.Commands.StorSimple.StorSimpleResourceContext + + + + + + 20 + + + + + + + + + + ResourceId + + + ResourceName + + + + + + + + Microsoft.WindowsAzure.Management.StorSimple.Models.StorageAccountCredentialResponse + + Microsoft.WindowsAzure.Management.StorSimple.Models.StorageAccountCredentialResponse + + + + + + 36 + + + + + + + + + + 6 + + + + + + + 12 + + + + + + + + + + InstanceId + + + Login + + + Name + + + UseSSL + + + VolumeCount + + + CloudType + + + Location + + + + + + + + diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Microsoft.Azure.Commands.AzureBackup.types.ps1xml b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Microsoft.Azure.Commands.AzureBackup.types.ps1xml new file mode 100644 index 000000000000..1429986fb1b3 --- /dev/null +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Microsoft.Azure.Commands.AzureBackup.types.ps1xml @@ -0,0 +1,16 @@ + + + + Microsoft.WindowsAzure.Management.StorSimple.Models.TaskStatusInfo + + + GetSteps + if( ($_.TaskSteps | Select Message -ExpandProperty Message) -ne $null ) { [string]::Join(" `n", ($_.TaskSteps | Select -ExpandProperty Message)) } else { "No Steps" } + + + GetErrors + if( ($_.Error | Select Message -ExpandProperty Message) -ne $null ) { [string]::Join(" `n", ($_.Error | Select -ExpandProperty Message)) } else { "No Errors" } + + + + \ No newline at end of file diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Microsoft.WindowsAzure.Commands.StorSimple.dll-help.psd1 b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Microsoft.WindowsAzure.Commands.StorSimple.dll-help.psd1 new file mode 100644 index 000000000000..ead8aec13057 --- /dev/null +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Microsoft.WindowsAzure.Commands.StorSimple.dll-help.psd1 @@ -0,0 +1,88 @@ +# +# Module manifest for module 'Microsoft.WindowsAzure.Commands.StorSimple' +# +# Generated by: Microsoft Corporation +# +# Generated on: 1/18/2015 +# + +@{ + +# Version number of this module. +ModuleVersion = '0.8.13' + +# ID used to uniquely identify this module +GUID = 'd52ed268-64c7-46bd-9cf8-1814d07409f8' + +# Author of this module +Author = 'Microsoft Corporation' + +# Company or vendor of this module +CompanyName = 'Microsoft Corporation' + +# Copyright statement for this module +Copyright = '© Microsoft Corporation. All rights reserved.' + +# Description of the functionality provided by this module +Description = '' + +# Minimum version of the Windows PowerShell engine required by this module +PowerShellVersion = '3.0' + +# Name of the Windows PowerShell host required by this module +PowerShellHostName = '' + +# Minimum version of the Windows PowerShell host required by this module +PowerShellHostVersion = '' + +# Minimum version of the .NET Framework required by this module +DotNetFrameworkVersion = '4.0' + +# Minimum version of the common language runtime (CLR) required by this module +CLRVersion='4.0' + +# Processor architecture (None, X86, Amd64, IA64) required by this module +ProcessorArchitecture = 'None' + +# Modules that must be imported into the global environment prior to importing this module +RequiredModules = @() + +# Assemblies that must be loaded prior to importing this module +RequiredAssemblies = @() + +# Script files (.ps1) that are run in the caller's environment prior to importing this module +ScriptsToProcess = @() + +# Type files (.ps1xml) to be loaded when importing this module +TypesToProcess = @() + +# Format files (.ps1xml) to be loaded when importing this module +FormatsToProcess = @() + +# Modules to import as nested modules of the module specified in ModuleToProcess +NestedModules = @( + '..\..\..\Package\Debug\ServiceManagement\Azure\StorSimple\Microsoft.WindowsAzure.Commands.StorSimple.dll' +) + +# Functions to export from this module +FunctionsToExport = '*' + +# Cmdlets to export from this module +CmdletsToExport = '*' + +# Variables to export from this module +VariablesToExport = '*' + +# Aliases to export from this module +AliasesToExport = @() + +# List of all modules packaged with this module +ModuleList = @() + +# List of all files packaged with this module +FileList = @() + +# Private data to pass to the module specified in ModuleToProcess +PrivateData = '' + +} diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupBaseObjects.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupBaseObjects.cs new file mode 100644 index 000000000000..0d18c1d0987e --- /dev/null +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupBaseObjects.cs @@ -0,0 +1,39 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets +{ + public class AzureBackupVaultContextObject + { + /// + /// ResourceGroupName of the azurebackup object + /// + public string ResourceGroupName { get; set; } + + /// + /// ResourceName of the azurebackup object + /// + public string ResourceName { get; set; } + + public AzureBackupVaultContextObject() + { + } + + public AzureBackupVaultContextObject(string resourceGroupName, string resourceName) + { + ResourceGroupName = resourceGroupName; + ResourceName = resourceName; + } + } +} diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/ProtectionPolicy.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/ProtectionPolicy.cs new file mode 100644 index 000000000000..85ee3774d7dd --- /dev/null +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/ProtectionPolicy.cs @@ -0,0 +1,65 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using Microsoft.Azure.Management.BackupServices.Models; +using System; +using System.Collections.Generic; +namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets +{ + /// + /// Represents ProtectionPolicy object + /// + public class AzureBackupProtectionPolicy : AzureBackupVaultContextObject + { + /// + /// InstanceId of the azurebackup object + /// + public string InstanceId { get; set; } + + /// + /// Name of the azurebackup object + /// + public string Name { get; set; } + + public string WorkloadType { get; set; } + + public string BackupType { get; set; } + + public DateTime ScheduleStartTime { get; set; } + + public IList ScheduleRunTimes { get; set; } + + public string RetentionType { get; set; } + + public int RetentionDuration { get; set; } + + public AzureBackupProtectionPolicy() + { + } + + public AzureBackupProtectionPolicy(string resourceGroupName, string resourceName, ProtectionPolicyInfo sourcePolicy) : base(resourceGroupName, resourceName) + { + InstanceId = sourcePolicy.InstanceId; + Name = sourcePolicy.Name; + WorkloadType = sourcePolicy.WorkloadType; + + BackupType = sourcePolicy.Schedule.BackupType; + ScheduleStartTime = sourcePolicy.Schedule.ScheduleStartTime; + ScheduleRunTimes = sourcePolicy.Schedule.ScheduleRunTimes; + + RetentionType = sourcePolicy.Schedule.RetentionPolicy.RetentionType.ToString(); + RetentionDuration = sourcePolicy.Schedule.RetentionPolicy.RetentionDuration; + } + } +} diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/AssemblyInfo.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..9cea209aa6cd --- /dev/null +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Microsoft Azure Powershell")] +[assembly: AssemblyCompany(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCompany)] +[assembly: AssemblyProduct(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyProduct)] +[assembly: AssemblyCopyright(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyCopyright)] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] +[assembly: CLSCompliant(false)] + +[assembly: AssemblyVersion(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyVersion)] +[assembly: AssemblyFileVersion(Microsoft.WindowsAzure.Commands.Common.AzurePowerShell.AssemblyFileVersion)] \ No newline at end of file diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/Resources.Designer.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/Resources.Designer.cs new file mode 100644 index 000000000000..86135b355019 --- /dev/null +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/Resources.Designer.cs @@ -0,0 +1,72 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.34014 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Microsoft.Azure.Commands.AzureBackup.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Azure.Commands.AzureBackup.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to The specified resource does not exist.. + /// + internal static string ResourceNotFoundMessage { + get { + return ResourceManager.GetString("ResourceNotFoundMessage", resourceCulture); + } + } + } +} diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/Resources.resx b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/Resources.resx new file mode 100644 index 000000000000..11366ab53caa --- /dev/null +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/Resources.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + The specified resource does not exist. + + \ No newline at end of file diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/packages.config b/src/ResourceManager/AzureBackup/Commands.AzureBackup/packages.config new file mode 100644 index 000000000000..88711c491451 --- /dev/null +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/packages.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file