From 3f2cb13d5d4ef1854758c777acf682086c5da8b1 Mon Sep 17 00:00:00 2001 From: pragrawa Date: Wed, 26 Aug 2015 16:14:24 +0530 Subject: [PATCH 01/24] Policy Fix for Monthly Retention --- .../Commands.AzureBackup/Helpers/ProtectionPolicyHelpers.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Helpers/ProtectionPolicyHelpers.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Helpers/ProtectionPolicyHelpers.cs index 97044655a262..41a26ccef932 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Helpers/ProtectionPolicyHelpers.cs +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Helpers/ProtectionPolicyHelpers.cs @@ -763,7 +763,7 @@ private static IList ConvertToCSMDayList(List DaysOfMonth) foreach (string DayOfMonth in DaysOfMonth) { Day day = new Day(); - if (string.Compare(DayOfMonth,"IsLast", true) == 0) + if (string.Compare(DayOfMonth,"Last", true) == 0) { day.IsLast = true; } From b151fa3e9ca585c0d296b36825c205a5b9a11910 Mon Sep 17 00:00:00 2001 From: swatimadhukar Date: Tue, 8 Sep 2015 06:28:54 -0700 Subject: [PATCH 02/24] Scenario Tests improvement --- .../ScenarioTests/AzureBackupScenarioTests.cs | 4 +- .../AzureBackupScenarioTests.ps1 | 251 +++++++++++++++++- 2 files changed, 247 insertions(+), 8 deletions(-) diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.cs index b5578d5037d8..8ee22afe6c4b 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.cs +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.cs @@ -20,10 +20,10 @@ namespace Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests public class AzureBackupScenarioTests : AzureBackupTestsBase { [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + //[Trait(Category.AcceptanceType, Category.CheckIn)] public void AzureBackupEndToEndTests() { - //this.RunPowerShellTest("Test-AzureBackupEndToEnd"); + this.RunPowerShellTest("Test-AzureBackupEndToEnd"); } } } diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.ps1 b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.ps1 index a807675645ce..97d0fd915675 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.ps1 +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.ps1 @@ -12,22 +12,87 @@ # limitations under the License. # ---------------------------------------------------------------------------------- -$ResourceGroupName = "backuprg" -$ResourceName = "backuprn" +$ResourceGroupName = "scenariorg" +$ResourceName = "scenariorn" $Location = "southeastasia" -$VirtualMachineName = "hydrarecordvm" -$ProtectionPolicyName = "e2epolicy1" +$VirtualMachineName = "e2epowershell2" +$ProtectionPolicyName = "e2epolicy2" $RestoreStorageAccount = "e2estore" +$ResultTxtFile = "EndToEndScenarioTest.txt" +$ResultCsvFile = "EndToEndScenarioTest.csv" + function Test-AzureBackupEndToEnd { + $FailFlag = 0; + $FailedAt = ""; + + Try + { + $startTime = Get-Date -format G; + New-AzureResourceGroup -Name $ResourceGroupName -Location $Location -Force; + $endTime = Get-Date -format G; + "New-AzureResourceGroup", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; + } + Catch + { + $endTime = Get-Date -format G; + "New-AzureResourceGroup", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; + $FailFlag = 1; + $FailedAt = $FailedAt + ("New-AzureResourceGroup : " + $_); + } + + Try + { + $startTime = Get-Date -format G; New-AzureRMBackupVault -ResourceGroupName $ResourceGroupName -Name $ResourceName -Region $Location; + $endTime = Get-Date -format G; + "New-AzureRMBackupVault", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; + } + Catch + { + $endTime = Get-Date -format G; + "New-AzureRMBackupVault", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; + $FailFlag = 1; + $FailedAt = $FailedAt + ("New-AzureRMBackupVault : " + $_); + } + + Try + { + $startTime = Get-Date -format G; $vault = Get-AzureRMBackupVault -Name $ResourceName; + $endTime = Get-Date -format G; + "Get-AzureRMBackupVault", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; + } + Catch + { + $endTime = Get-Date -format G; + "Get-AzureRMBackupVault", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; + $FailFlag = 1; + $FailedAt = $FailedAt + ("Get-AzureRMBackupVault : " + $_); + } + + Try + { + $startTime = Get-Date -format G; $Job = Register-AzureRMBackupContainer -Vault $vault -Name $VirtualMachineName -ServiceName $VirtualMachineName; Wait-AzureRMBackupJob -Job $Job; $JobDetails = Get-AzureRMBackupJobDetails -Vault $vault -JobId $Job.InstanceId; Assert-AreEqual $JobDetails.Status "Completed"; + $endTime = Get-Date -format G; + "Register-AzureRMBackupContainer", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; + } + Catch + { + $endTime = Get-Date -format G; + "Register-AzureRMBackupContainer", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; + $FailFlag = 1; + $FailedAt = $FailedAt + ("Register-AzureRMBackupContainer : " + $_); + } + Try + { + $startTime = Get-Date -format G; $r1 = New-AzureRMBackupRetentionPolicyObject -DailyRetention -Retention 20; $r2 = New-AzureRMBackupRetentionPolicyObject -WeeklyRetention -DaysOfWeek "Monday" -Retention 10; $r3 = New-AzureRMBackupRetentionPolicyObject -MonthlyRetentionInDailyFormat -DaysOfMonth "10" -Retention 10; @@ -42,7 +107,20 @@ function Test-AzureBackupEndToEnd Assert-AreEqual $protectionpolicy.ResourceGroupName $ResourceGroupName; Assert-AreEqual $protectionpolicy.ResourceName $ResourceName; Assert-AreEqual $protectionpolicy.Location $Location; - + $endTime = Get-Date -format G; + "New-AzureRMBackupProtectionPolicy", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; + } + Catch + { + $endTime = Get-Date -format G; + "New-AzureRMBackupProtectionPolicy", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; + $FailFlag = 1; + $FailedAt = $FailedAt + ("New-AzureRMBackupProtectionPolicy : " + $_); + } + + Try + { + $startTime = Get-Date -format G; $container = Get-AzureRMBackupContainer -Vault $vault -Name $VirtualMachineName -Type "AzureVM"; Assert-AreEqual $container.ContainerType "AzureVM"; Assert-AreEqual $container.ContainerUniqueName.Contains("iaasvmcontainer") "True"; @@ -51,7 +129,20 @@ function Test-AzureBackupEndToEnd Assert-AreEqual $container.ResourceGroupName $ResourceGroupName; Assert-AreEqual $container.ResourceName $ResourceName; Assert-AreEqual $container.Location $Location; + $endTime = Get-Date -format G; + "Get-AzureRMBackupContainer", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; + } + Catch + { + $endTime = Get-Date -format G; + "Get-AzureRMBackupContainer", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; + $FailFlag = 1; + $FailedAt = $FailedAt + ("Get-AzureRMBackupContainer : " + $_); + } + Try + { + $startTime = Get-Date -format G; $Job = Enable-AzureRMBackupProtection -Item $container[0] -Policy $protectionpolicy[0]; Wait-AzureRMBackupJob -Job $Job; $JobDetails = Get-AzureRMBackupJobDetails -Vault $vault -JobID $Job.InstanceId; @@ -63,7 +154,20 @@ function Test-AzureBackupEndToEnd Assert-AreEqual $JobDetails.ResourceGroupName $ResourceGroupName; Assert-AreEqual $JobDetails.ResourceName $ResourceName; Assert-AreEqual $JobDetails.Location $Location; + $endTime = Get-Date -format G; + "Enable-AzureRMBackupProtection", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; + } + Catch + { + $endTime = Get-Date -format G; + "Enable-AzureRMBackupProtection", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; + $FailFlag = 1; + $FailedAt = $FailedAt + ("Enable-AzureRMBackupProtection : " + $_); + } + Try + { + $startTime = Get-Date -format G; $item = Get-AzureRMBackupItem -Container $container[0]; Assert-AreEqual $item.ProtectionStatus "Protected"; Assert-AreEqual $item.DataSourceStatus "IRPending"; @@ -75,7 +179,20 @@ function Test-AzureBackupEndToEnd Assert-AreEqual $item.ResourceGroupName $ResourceGroupName; Assert-AreEqual $item.ResourceName $ResourceName; Assert-AreEqual $item.Location $Location; + $endTime = Get-Date -format G; + "Get-AzureRMBackupItem", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; + } + Catch + { + $endTime = Get-Date -format G; + "Get-AzureRMBackupItem", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; + $FailFlag = 1; + $FailedAt = $FailedAt + ("Get-AzureRMBackupItem : " + $_); + } + Try + { + $startTime = Get-Date -format G; $Job = Backup-AzureRMBackupItem -Item $item[0]; Wait-AzureRMBackupJob -Job $Job; $JobDetails = Get-AzureRMBackupJobDetails -Vault $vault -JobID $Job.InstanceId; @@ -87,7 +204,20 @@ function Test-AzureBackupEndToEnd Assert-AreEqual $JobDetails.ResourceGroupName $ResourceGroupName; Assert-AreEqual $JobDetails.ResourceName $ResourceName; Assert-AreEqual $JobDetails.Location $Location; + $endTime = Get-Date -format G; + "Backup-AzureRMBackupItem", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; + } + Catch + { + $endTime = Get-Date -format G; + "Backup-AzureRMBackupItem", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; + $FailFlag = 1; + $FailedAt = $FailedAt + ("Backup-AzureRMBackupItem : " + $_); + } + Try + { + $startTime = Get-Date -format G; $item = Get-AzureRMBackupItem -Container $container[0]; Assert-AreEqual $item.ProtectionStatus "Protected"; Assert-AreEqual $item.DataSourceStatus "Protected"; @@ -96,7 +226,20 @@ function Test-AzureBackupEndToEnd Assert-AreEqual $item.ResourceGroupName $ResourceGroupName; Assert-AreEqual $item.ResourceName $ResourceName; Assert-AreEqual $item.Location $Location; + $endTime = Get-Date -format G; + "Get-AzureRMBackupItemPostBackup", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; + } + Catch + { + $endTime = Get-Date -format G; + "Get-AzureRMBackupItemPostBackup", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; + $FailFlag = 1; + $FailedAt = $FailedAt + ("Get-AzureRMBackupItemPostBackup : " + $_); + } + Try + { + $startTime = Get-Date -format G; $recoveryPoints = Get-AzureRMBackupRecoveryPoint -Item $item[0]; Assert-NotNull $recoveryPoints.RecoveryPointTime; Assert-NotNull $recoveryPoints.RecoveryPointName; @@ -104,7 +247,20 @@ function Test-AzureBackupEndToEnd Assert-AreEqual $recoveryPoints.ContainerType "AzureVM"; Assert-AreEqual $recoveryPoints.ItemName.Contains($VirtualMachineName) "True"; Assert-AreEqual $recoveryPoints.ItemName.Contains("iaasvmcontainer") "True"; + $endTime = Get-Date -format G; + "Get-AzureRMBackupRecoveryPoint", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; + } + Catch + { + $endTime = Get-Date -format G; + "Get-AzureRMBackupRecoveryPoint", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; + $FailFlag = 1; + $FailedAt = $FailedAt + ("Get-AzureRMBackupRecoveryPoint : " + $_); + } + Try + { + $startTime = Get-Date -format G; $Job = Restore-AzureRMBackupItem -RecoveryPoint $recoveryPoints -StorageAccountName $RestoreStorageAccount; Wait-AzureRMBackupJob -Job $Job; $JobDetails = Get-AzureRMBackupJobDetails -Vault $vault -JobID $Job.InstanceId; @@ -117,7 +273,20 @@ function Test-AzureBackupEndToEnd Assert-AreEqual $JobDetails.ResourceGroupName $ResourceGroupName; Assert-AreEqual $JobDetails.ResourceName $ResourceName; Assert-AreEqual $JobDetails.Location $Location; + $endTime = Get-Date -format G; + "Restore-AzureRMBackupItem", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; + } + Catch + { + $endTime = Get-Date -format G; + "Restore-AzureRMBackupItem", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; + $FailFlag = 1; + $FailedAt = $FailedAt + ("Restore-AzureRMBackupItem : " + $_); + } + Try + { + $startTime = Get-Date -format G; $Job = Disable-AzureRMBackupProtection -RemoveRecoveryPoints -Item $item[0]; Wait-AzureRMBackupJob -Job $Job; $JobDetails = Get-AzureRMBackupJobDetails -Vault $vault -JobID $Job.InstanceId; @@ -129,18 +298,88 @@ function Test-AzureBackupEndToEnd Assert-AreEqual $JobDetails.ResourceGroupName $ResourceGroupName; Assert-AreEqual $JobDetails.ResourceName $ResourceName; Assert-AreEqual $JobDetails.Location $Location; + $endTime = Get-Date -format G; + "Disable-AzureRMBackupProtection", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; + } + Catch + { + $endTime = Get-Date -format G; + "Disable-AzureRMBackupProtection", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; + $FailFlag = 1; + $FailedAt = $FailedAt + ("Disable-AzureRMBackupProtection : " + $_); + } + Try + { + $startTime = Get-Date -format G; $Job = Unregister-AzureRMBackupContainer -Container $container[0]; Wait-AzureRMBackupJob -Job $Job; $JobDetails = Get-AzureRMBackupJobDetails -Vault $vault -JobId $Job.InstanceId; Assert-AreEqual $JobDetails.Operation "UnRegister"; Assert-AreEqual $JobDetails.Status "Completed"; Assert-AreEqual $JobDetails.WorkloadName $VirtualMachineName; + $endTime = Get-Date -format G; + "Unregister-AzureRMBackupContaine", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; + } + Catch + { + $endTime = Get-Date -format G; + "Unregister-AzureRMBackupContaine", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; + $FailFlag = 1; + $FailedAt = $FailedAt + ("Unregister-AzureRMBackupContaine : " + $_); + } + Try + { + $startTime = Get-Date -format G; Remove-AzureRMBackupProtectionPolicy -ProtectionPolicy $protectionpolicy; + $endTime = Get-Date -format G; + "Remove-AzureRMBackupProtectionPolicy", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; + } + Catch + { + $endTime = Get-Date -format G; + "Remove-AzureRMBackupProtectionPolicy", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; + $FailFlag = 1; + $FailedAt = $FailedAt + ("Remove-AzureRMBackupProtectionPolicy : " + $_); + } + Try + { + $startTime = Get-Date -format G; Remove-AzureRMBackupVault -Vault $vault; - $deletedVault = Get-AzureRMBackupVault -Name $ResourceName; Assert-Null $deletedVault; + $endTime = Get-Date -format G; + "Remove-AzureRMBackupVault", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; + } + Catch + { + $endTime = Get-Date -format G; + "Remove-AzureRMBackupVault", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; + $FailFlag = 1; + $FailedAt = $FailedAt + ("Remove-AzureRMBackupVault : " + $_); + } + + Try + { + $startTime = Get-Date -format G; + Remove-AzureResourceGroup -Name $ResourceGroupName -Force; + $endTime = Get-Date -format G; + "Remove-AzureResourceGroup", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; + } + Catch + { + $endTime = Get-Date -format G; + "Remove-AzureResourceGroup", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; + $FailFlag = 1; + $FailedAt = $FailedAt + ("Remove-AzureResourceGroup : " + $_); + } + + import-csv $ResultTxtFile -delimiter "," | export-csv $ResultCsvFile -NoTypeInformation; + + if ($FailFlag -eq 1) + { + throw $FailedAt; + } } \ No newline at end of file From add2821afae3428e883a21a2b8831abd35fc04bd Mon Sep 17 00:00:00 2001 From: nityasharma Date: Tue, 8 Sep 2015 16:53:20 -0700 Subject: [PATCH 03/24] First commit --- .../Commands.HDInsight.Test.csproj | 28 +++++-- .../Commands.HDInsight.Test/packages.config | 8 +- .../ClusterConfigurationUtils.cs | 77 +++++++++++++++++++ .../Commands.HDInsight.csproj | 16 ++-- .../HDInsight/Commands.HDInsight/Constants.cs | 7 ++ .../GetAzureHDInsightClusterCommand.cs | 9 ++- .../Management/AzureHDInsightCluster.cs | 40 ++++++++++ .../AzureHDInsightDefaultStorageAccount.cs | 24 ++++++ .../AzureHdInsightManagementClient.cs | 16 ++++ .../Commands.HDInsight/packages.config | 4 +- 10 files changed, 210 insertions(+), 19 deletions(-) create mode 100644 src/ResourceManager/HDInsight/Commands.HDInsight/ClusterConfigurationUtils.cs create mode 100644 src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightDefaultStorageAccount.cs diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight.Test/Commands.HDInsight.Test.csproj b/src/ResourceManager/HDInsight/Commands.HDInsight.Test/Commands.HDInsight.Test.csproj index 6eb3f88dfe98..522085b2d03d 100644 --- a/src/ResourceManager/HDInsight/Commands.HDInsight.Test/Commands.HDInsight.Test.csproj +++ b/src/ResourceManager/HDInsight/Commands.HDInsight.Test/Commands.HDInsight.Test.csproj @@ -38,8 +38,9 @@ ..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll - - ..\..\..\packages\Microsoft.Azure.Common.Authentication.1.0.26-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll + + ..\..\..\packages\Microsoft.Azure.Common.Authentication.1.1.5-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll + True ..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll @@ -62,17 +63,28 @@ ..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll - - ..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.5571.32271-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll + + ..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.5687.28567-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll + True ..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.0.5513.27084-prerelease\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll - - ..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.14.201151115\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll + + ..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.18.206251556\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll + True - - ..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.14.201151115\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll + + ..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.18.206251556\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll + True + + + ..\..\..\packages\Microsoft.Rest.ClientRuntime.1.2.0\lib\net45\Microsoft.Rest.ClientRuntime.dll + True + + + ..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.0.9.3\lib\net45\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll + True ..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight.Test/packages.config b/src/ResourceManager/HDInsight/Commands.HDInsight.Test/packages.config index 72b5f01f87f2..5db534fdbdba 100644 --- a/src/ResourceManager/HDInsight/Commands.HDInsight.Test/packages.config +++ b/src/ResourceManager/HDInsight/Commands.HDInsight.Test/packages.config @@ -2,7 +2,7 @@ - + @@ -10,13 +10,15 @@ - + - + + + diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight/ClusterConfigurationUtils.cs b/src/ResourceManager/HDInsight/Commands.HDInsight/ClusterConfigurationUtils.cs new file mode 100644 index 000000000000..7298c7f6615d --- /dev/null +++ b/src/ResourceManager/HDInsight/Commands.HDInsight/ClusterConfigurationUtils.cs @@ -0,0 +1,77 @@ +// +// 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.Collections.Generic; +using System.Linq; + +namespace Microsoft.Azure.Commands.HDInsight.Models +{ + internal class ClusterConfigurationUtils + { + public static string GetResourceGroupFromClusterId(string clusterId) + { + string clusterGroup = null; + int index = clusterId.IndexOf("resourceGroups", StringComparison.OrdinalIgnoreCase); + + if (index >= 0) + { + index += "resourceGroups".Length; + string[] parts = clusterId.Substring(index).Split(new [] { '/' }, StringSplitOptions.RemoveEmptyEntries); + + if (parts.Length > 0) + { + clusterGroup = parts[0]; + } + } + + return clusterGroup; + } + + public static AzureHDInsightDefaultStorageAccount GetDefaultStorageAccountDetails( + IDictionary configuration, + string version) + { + string key = Constants.ClusterConfiguration.DefaultStorageAccountNameKey; + + if (version.Equals("2.1")) + { + key = Constants.ClusterConfiguration.DefaultStorageAccountNameKeyOld; + } + + string accountAndContainerStr; + + if (configuration.TryGetValue(key, out accountAndContainerStr)) + { + string[] accountAndContainer = accountAndContainerStr.Substring("wasb://".Length).Split('@'); + + return new AzureHDInsightDefaultStorageAccount + { + StorageContainerName = accountAndContainer[0], + StorageAccountName = accountAndContainer[1], + StorageAccountKey = configuration[Constants.ClusterConfiguration.StorageAccountKeyPrefix + accountAndContainer[1]] + }; + } + + return null; + } + + public static List GetAdditionStorageAccounts(IDictionary configuration, string defaultAccount) + { + return (from key in configuration.Keys + where key.StartsWith(Constants.ClusterConfiguration.StorageAccountKeyPrefix) && + !key.EndsWith(defaultAccount) + select key.Remove(0, Constants.ClusterConfiguration.StorageAccountKeyPrefix.Length)).ToList(); + } + } +} diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight/Commands.HDInsight.csproj b/src/ResourceManager/HDInsight/Commands.HDInsight/Commands.HDInsight.csproj index 7efebfe59878..2029cc496bbb 100644 --- a/src/ResourceManager/HDInsight/Commands.HDInsight/Commands.HDInsight.csproj +++ b/src/ResourceManager/HDInsight/Commands.HDInsight/Commands.HDInsight.csproj @@ -75,10 +75,12 @@ + + @@ -86,7 +88,9 @@ Always - + + Designer + @@ -101,11 +105,13 @@ ..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll - - ..\..\..\packages\Microsoft.Azure.Management.HDInsight.1.0.1-preview\lib\net40\Microsoft.Azure.Management.HDInsight.dll + + ..\..\..\packages\Microsoft.Azure.Management.HDInsight.1.0.5-preview\lib\net40\Microsoft.Azure.Management.HDInsight.dll + True - - ..\..\..\packages\Microsoft.Azure.Management.HDInsight.Job.1.0.1-preview\lib\net40\Microsoft.Azure.Management.HDInsight.Job.dll + + ..\..\..\packages\Microsoft.Azure.Management.HDInsight.Job.1.0.5-preview\lib\net40\Microsoft.Azure.Management.HDInsight.Job.dll + True False diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight/Constants.cs b/src/ResourceManager/HDInsight/Commands.HDInsight/Constants.cs index 7a203f4fb828..c3ca5a74ed21 100644 --- a/src/ResourceManager/HDInsight/Commands.HDInsight/Constants.cs +++ b/src/ResourceManager/HDInsight/Commands.HDInsight/Constants.cs @@ -40,5 +40,12 @@ public static class JobDefinitions public const string AzureHDInsightMapReduceJobDefinition = "AzureHDInsightMapReduceJobDefinition"; public const string AzureHDInsightStreamingMapReduceJobDefinition = "AzureHDInsightStreamingMapReduceJobDefinition"; } + + public static class ClusterConfiguration + { + public const string DefaultStorageAccountNameKey = "fs.defaultFS"; + public const string DefaultStorageAccountNameKeyOld = "fs.default.name"; + public const string StorageAccountKeyPrefix = "fs.azure.account.key."; + } } } diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight/ManagementCommands/GetAzureHDInsightClusterCommand.cs b/src/ResourceManager/HDInsight/Commands.HDInsight/ManagementCommands/GetAzureHDInsightClusterCommand.cs index 0c96dbf50985..80a1f4538101 100644 --- a/src/ResourceManager/HDInsight/Commands.HDInsight/ManagementCommands/GetAzureHDInsightClusterCommand.cs +++ b/src/ResourceManager/HDInsight/Commands.HDInsight/ManagementCommands/GetAzureHDInsightClusterCommand.cs @@ -12,6 +12,7 @@ // limitations under the License. // ---------------------------------------------------------------------------------- +using System; using System.Collections.Generic; using System.Linq; using System.Management.Automation; @@ -44,7 +45,13 @@ public class GetAzureHDInsightCommand : HDInsightCmdletBase public override void ExecuteCmdlet() { var result = HDInsightManagementClient.GetCluster(ResourceGroupName, ClusterName); - var output = result.Select(cluster => new AzureHDInsightCluster(cluster)).ToList(); + + var output = result.Select(entry => + { + var configuration = HDInsightManagementClient.GetClusterConfigurations(entry, "core-site"); + return new AzureHDInsightCluster(entry, configuration); + }).ToList(); + WriteObject(output, true); } } diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightCluster.cs b/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightCluster.cs index 8a03fd720ee0..5ff9e6dd6b45 100644 --- a/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightCluster.cs +++ b/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightCluster.cs @@ -13,6 +13,7 @@ // ---------------------------------------------------------------------------------- using System; +using System.Collections.Generic; using System.Linq; using Microsoft.Azure.Management.HDInsight.Models; @@ -34,6 +35,25 @@ public AzureHDInsightCluster(Cluster cluster) cluster.Properties.ConnectivityEndpoints.FirstOrDefault(c => c.Name.Equals("HTTPS", StringComparison.OrdinalIgnoreCase)); HttpEndpoint = httpEndpoint != null ? httpEndpoint.Location : null; + ResourceGroup = ClusterConfigurationUtils.GetResourceGroupFromClusterId(cluster.Id); + + } + + public AzureHDInsightCluster(Cluster cluster, IDictionary clusterConfiguration) + : this(cluster) + { + if (clusterConfiguration != null) + { + var defaultAccount = ClusterConfigurationUtils.GetDefaultStorageAccountDetails( + clusterConfiguration, + cluster.Properties.ClusterVersion); + + DefaultStorageAccount = defaultAccount.StorageAccountName; + DefaultStorageContainer = defaultAccount.StorageContainerName; + + AdditionalStorageAccounts = ClusterConfigurationUtils.GetAdditionStorageAccounts(clusterConfiguration, DefaultStorageAccount); + } + } /// @@ -80,5 +100,25 @@ public AzureHDInsightCluster(Cluster cluster) /// The endpoint with which to connect to the cluster. /// public string HttpEndpoint { get; set; } + + /// + /// Default storage account for this cluster. + /// + public string DefaultStorageAccount { get; set; } + + /// + /// Default storage container for this cluster. + /// + public string DefaultStorageContainer { get; set; } + + /// + /// Default storage container for this cluster. + /// + public string ResourceGroup { get; set; } + + /// + /// Additional storage accounts for this cluster + /// + public List AdditionalStorageAccounts { get; set; } } } diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightDefaultStorageAccount.cs b/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightDefaultStorageAccount.cs new file mode 100644 index 000000000000..9a6dca3733b2 --- /dev/null +++ b/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightDefaultStorageAccount.cs @@ -0,0 +1,24 @@ +// +// 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.HDInsight.Models +{ + public class AzureHDInsightDefaultStorageAccount + { + public string StorageAccountName { get; set; } + + public string StorageAccountKey { get; set; } + + public string StorageContainerName { get; set; } + } +} diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHdInsightManagementClient.cs b/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHdInsightManagementClient.cs index abacaac0d61c..5ffb92a8db77 100644 --- a/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHdInsightManagementClient.cs +++ b/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHdInsightManagementClient.cs @@ -109,5 +109,21 @@ public virtual CapabilitiesResponse GetCapabilities(string location) { return HdInsightManagementClient.Clusters.GetCapabilities(location); } + + public virtual IDictionary GetClusterConfigurations(Cluster cluster, string configurationName) + { + Dictionary properties = new Dictionary(); + + if(string.IsNullOrWhiteSpace(configurationName)) + { + return properties; + } + + string resourceGroupName = ClusterConfigurationUtils.GetResourceGroupFromClusterId(cluster.Id); + return HdInsightManagementClient.Clusters.GetClusterConfigurations( + resourceGroupName, + cluster.Name, + configurationName).Configuration; + } } } diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight/packages.config b/src/ResourceManager/HDInsight/Commands.HDInsight/packages.config index ca7b4a5aadcd..b886773a7ee5 100644 --- a/src/ResourceManager/HDInsight/Commands.HDInsight/packages.config +++ b/src/ResourceManager/HDInsight/Commands.HDInsight/packages.config @@ -4,8 +4,8 @@ - - + + From b2a06019d3cb0892f7c4d81cdde1eb2b05b79b1d Mon Sep 17 00:00:00 2001 From: nityasharma Date: Fri, 18 Sep 2015 12:35:30 -0700 Subject: [PATCH 04/24] Merged changes --- .../ClusterConfigurationUtils.cs | 35 ++++++++++--------- .../GetAzureHDInsightClusterCommand.cs | 7 ++-- .../Management/AzureHDInsightCluster.cs | 10 +++--- .../AzureHdInsightManagementClient.cs | 17 ++++----- 4 files changed, 35 insertions(+), 34 deletions(-) diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight/ClusterConfigurationUtils.cs b/src/ResourceManager/HDInsight/Commands.HDInsight/ClusterConfigurationUtils.cs index 7298c7f6615d..4c9216626e28 100644 --- a/src/ResourceManager/HDInsight/Commands.HDInsight/ClusterConfigurationUtils.cs +++ b/src/ResourceManager/HDInsight/Commands.HDInsight/ClusterConfigurationUtils.cs @@ -20,34 +20,34 @@ namespace Microsoft.Azure.Commands.HDInsight.Models internal class ClusterConfigurationUtils { public static string GetResourceGroupFromClusterId(string clusterId) - { - string clusterGroup = null; + { + // Parse resource group from cluster Id + // The code expects Id to be of the format \ + // /subscriptions//resourceGroups//providers/Microsoft.HDInsight/clusters/ + + string resourceGroup = null; int index = clusterId.IndexOf("resourceGroups", StringComparison.OrdinalIgnoreCase); if (index >= 0) { index += "resourceGroups".Length; - string[] parts = clusterId.Substring(index).Split(new [] { '/' }, StringSplitOptions.RemoveEmptyEntries); + string[] parts = clusterId.Substring(index).Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length > 0) { - clusterGroup = parts[0]; + resourceGroup = parts[0]; } - } + } - return clusterGroup; + return resourceGroup; } public static AzureHDInsightDefaultStorageAccount GetDefaultStorageAccountDetails( - IDictionary configuration, + IDictionary configuration, string version) - { - string key = Constants.ClusterConfiguration.DefaultStorageAccountNameKey; - - if (version.Equals("2.1")) - { - key = Constants.ClusterConfiguration.DefaultStorageAccountNameKeyOld; - } + { + string key = version.Equals("2.1") ? Constants.ClusterConfiguration.DefaultStorageAccountNameKeyOld + : Constants.ClusterConfiguration.DefaultStorageAccountNameKey; string accountAndContainerStr; @@ -68,9 +68,10 @@ public static AzureHDInsightDefaultStorageAccount GetDefaultStorageAccountDetail public static List GetAdditionStorageAccounts(IDictionary configuration, string defaultAccount) { - return (from key in configuration.Keys - where key.StartsWith(Constants.ClusterConfiguration.StorageAccountKeyPrefix) && - !key.EndsWith(defaultAccount) + // Parse the storage account names from the key and exclude the default one + return (from key in configuration.Keys + where key.StartsWith(Constants.ClusterConfiguration.StorageAccountKeyPrefix, StringComparison.OrdinalIgnoreCase) && + !key.EndsWith(defaultAccount, StringComparison.OrdinalIgnoreCase) select key.Remove(0, Constants.ClusterConfiguration.StorageAccountKeyPrefix.Length)).ToList(); } } diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight/ManagementCommands/GetAzureHDInsightClusterCommand.cs b/src/ResourceManager/HDInsight/Commands.HDInsight/ManagementCommands/GetAzureHDInsightClusterCommand.cs index cf761f4d4a15..dfab29435d2f 100644 --- a/src/ResourceManager/HDInsight/Commands.HDInsight/ManagementCommands/GetAzureHDInsightClusterCommand.cs +++ b/src/ResourceManager/HDInsight/Commands.HDInsight/ManagementCommands/GetAzureHDInsightClusterCommand.cs @@ -45,11 +45,12 @@ public class GetAzureHDInsightCommand : HDInsightCmdletBase protected override void ProcessRecord() { var result = HDInsightManagementClient.GetCluster(ResourceGroupName, ClusterName); - + var output = result.Select(entry => { - var configuration = HDInsightManagementClient.GetClusterConfigurations(entry, "core-site"); - return new AzureHDInsightCluster(entry, configuration); + string resourceGroupName = ClusterConfigurationUtils.GetResourceGroupFromClusterId(entry.Id); + var configuration = HDInsightManagementClient.GetClusterConfigurations(resourceGroupName, entry.Name, "core-site"); + return new AzureHDInsightCluster(entry, configuration); }).ToList(); WriteObject(output, true); diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightCluster.cs b/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightCluster.cs index 5ff9e6dd6b45..5b1584ea6a72 100644 --- a/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightCluster.cs +++ b/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightCluster.cs @@ -36,10 +36,9 @@ public AzureHDInsightCluster(Cluster cluster) HttpEndpoint = httpEndpoint != null ? httpEndpoint.Location : null; ResourceGroup = ClusterConfigurationUtils.GetResourceGroupFromClusterId(cluster.Id); - } - public AzureHDInsightCluster(Cluster cluster, IDictionary clusterConfiguration) + public AzureHDInsightCluster(Cluster cluster, IDictionary clusterConfiguration) : this(cluster) { if (clusterConfiguration != null) @@ -53,19 +52,18 @@ public AzureHDInsightCluster(Cluster cluster, IDictionary cluste AdditionalStorageAccounts = ClusterConfigurationUtils.GetAdditionStorageAccounts(clusterConfiguration, DefaultStorageAccount); } - } /// /// The name of the resource. /// public string Name { get; set; } - + /// /// The ID of the resource. /// public string Id { get; set; } - + /// /// The location of the resource. /// @@ -100,7 +98,7 @@ public AzureHDInsightCluster(Cluster cluster, IDictionary cluste /// The endpoint with which to connect to the cluster. /// public string HttpEndpoint { get; set; } - + /// /// Default storage account for this cluster. /// diff --git a/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHdInsightManagementClient.cs b/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHdInsightManagementClient.cs index 5ffb92a8db77..b1a8582480e2 100644 --- a/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHdInsightManagementClient.cs +++ b/src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHdInsightManagementClient.cs @@ -59,7 +59,7 @@ public virtual List GetCluster(string resourceGroupName, string cluster var getresponse = Get(resourceGroupName, clusterName); if (getresponse != null) { - result.Add(getresponse.Cluster); + result.Add(getresponse.Cluster); } } return result; @@ -72,7 +72,7 @@ public virtual ClusterListResponse ListClusters() public virtual ClusterListResponse ListClusters(string resourceGroupName) { - return HdInsightManagementClient.Clusters.ListByResourceGroup(resourceGroupName); + return HdInsightManagementClient.Clusters.ListByResourceGroup(resourceGroupName); } public virtual ClusterGetResponse Get(string resourceGroupName, string clusterName) @@ -110,19 +110,20 @@ public virtual CapabilitiesResponse GetCapabilities(string location) return HdInsightManagementClient.Clusters.GetCapabilities(location); } - public virtual IDictionary GetClusterConfigurations(Cluster cluster, string configurationName) + public virtual IDictionary GetClusterConfigurations(string resourceGroupName, string clusterName, string configurationName) { Dictionary properties = new Dictionary(); - - if(string.IsNullOrWhiteSpace(configurationName)) + + if (string.IsNullOrWhiteSpace(resourceGroupName) || + string.IsNullOrWhiteSpace(clusterName) || + string.IsNullOrWhiteSpace(configurationName)) { return properties; } - string resourceGroupName = ClusterConfigurationUtils.GetResourceGroupFromClusterId(cluster.Id); return HdInsightManagementClient.Clusters.GetClusterConfigurations( - resourceGroupName, - cluster.Name, + resourceGroupName, + clusterName, configurationName).Configuration; } } From 01271f67f2f726bed79df3c49b2ecf893a123fc1 Mon Sep 17 00:00:00 2001 From: mkherani Date: Tue, 22 Sep 2015 19:10:29 +0530 Subject: [PATCH 05/24] Bug #4674630: Register-AzureRMBackupContainer failing with mixed case names --- .../Cmdlets/Container/RegisterAzureRMBackupContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Container/RegisterAzureRMBackupContainer.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Container/RegisterAzureRMBackupContainer.cs index 60b2bba83617..2cbf0c61b33b 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Container/RegisterAzureRMBackupContainer.cs +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Container/RegisterAzureRMBackupContainer.cs @@ -176,7 +176,7 @@ private bool IsDiscoveryNeeded(string vmName, string rgName, out CSMContainerRes else { //We can have multiple container with same friendly name. - container = containers.Where(c => ContainerHelpers.GetRGNameFromId(c.Properties.ParentContainerId).Equals(rgName.ToLower())).FirstOrDefault(); //TODO need to change. + container = containers.Where(c => ContainerHelpers.GetRGNameFromId(c.Properties.ParentContainerId).Equals(rgName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); if (container == null) { //Container is not in list of registered container From 045092b1e4b079f92f7dc919e8b393e6439f7e2d Mon Sep 17 00:00:00 2001 From: AditTulasi Date: Tue, 22 Sep 2015 19:19:46 +0530 Subject: [PATCH 06/24] fixing datetime tostring locale issue --- .../Cmdlets/Jobs/GetAzureRMBackupJob.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Jobs/GetAzureRMBackupJob.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Jobs/GetAzureRMBackupJob.cs index 2e3f297ac8e7..0be5932dba45 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Jobs/GetAzureRMBackupJob.cs +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Jobs/GetAzureRMBackupJob.cs @@ -13,6 +13,7 @@ // ---------------------------------------------------------------------------------- using System; +using System.Globalization; using System.Management.Automation; using System.Collections.Generic; using System.Xml; @@ -139,10 +140,12 @@ protected override void ProcessRecord() WriteDebug(String.Format(Resources.TypeFilter, Type)); WriteDebug(String.Format(Resources.JobIdFilter, JobId)); + DateTimeFormatInfo format = new CultureInfo("en-US").DateTimeFormat; Mgmt.CSMJobQueryObject queryParams = new Mgmt.CSMJobQueryObject() { - StartTime = From.Value.ToString("yyyy-MM-dd hh:mm:ss tt"), - EndTime = To.Value.ToString("yyyy-MM-dd hh:mm:ss tt"), + + StartTime = From.Value.ToString("yyyy-MM-dd hh:mm:ss tt", format), + EndTime = To.Value.ToString("yyyy-MM-dd hh:mm:ss tt", format), Operation = Operation, Status = Status, WorkloadType = Type, From 378af92445e18964693f1147f8e112accea6806a Mon Sep 17 00:00:00 2001 From: AditTulasi Date: Wed, 23 Sep 2015 11:28:35 +0530 Subject: [PATCH 07/24] incorporating comments from CR --- .../Cmdlets/Jobs/GetAzureRMBackupJob.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Jobs/GetAzureRMBackupJob.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Jobs/GetAzureRMBackupJob.cs index 0be5932dba45..de54121fc7be 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Jobs/GetAzureRMBackupJob.cs +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Jobs/GetAzureRMBackupJob.cs @@ -133,14 +133,14 @@ protected override void ProcessRecord() To = DateTime.UtcNow; } - WriteDebug(String.Format(Resources.StartTimeFilter, System.Uri.EscapeDataString(From.Value.ToString("yyyy-MM-dd hh:mm:ss tt")))); - WriteDebug(String.Format(Resources.EndTimeFilter, System.Uri.EscapeDataString(To.Value.ToString("yyyy-MM-dd hh:mm:ss tt")))); + DateTimeFormatInfo format = new CultureInfo("en-US").DateTimeFormat; + WriteDebug(String.Format(Resources.StartTimeFilter, System.Uri.EscapeDataString(From.Value.ToString("yyyy-MM-dd hh:mm:ss tt", format)))); + WriteDebug(String.Format(Resources.EndTimeFilter, System.Uri.EscapeDataString(To.Value.ToString("yyyy-MM-dd hh:mm:ss tt", format)))); WriteDebug(String.Format(Resources.OperationFilter, Operation)); WriteDebug(String.Format(Resources.StatusFilter, Status)); WriteDebug(String.Format(Resources.TypeFilter, Type)); WriteDebug(String.Format(Resources.JobIdFilter, JobId)); - DateTimeFormatInfo format = new CultureInfo("en-US").DateTimeFormat; Mgmt.CSMJobQueryObject queryParams = new Mgmt.CSMJobQueryObject() { From d3576533474638971087e011e31b97f9104d3cd9 Mon Sep 17 00:00:00 2001 From: AditTulasi Date: Wed, 23 Sep 2015 19:08:42 +0530 Subject: [PATCH 08/24] Commenting out a test case which is not relevant --- .../ScenarioTests/AzureBackupScenarioTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.cs index 8ee22afe6c4b..c1a2a78c6876 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.cs +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.cs @@ -23,7 +23,7 @@ public class AzureBackupScenarioTests : AzureBackupTestsBase //[Trait(Category.AcceptanceType, Category.CheckIn)] public void AzureBackupEndToEndTests() { - this.RunPowerShellTest("Test-AzureBackupEndToEnd"); + //this.RunPowerShellTest("Test-AzureBackupEndToEnd"); } } } From 6f62d3a2351395d1f81e67f7ab2739adbcac413f Mon Sep 17 00:00:00 2001 From: pragrawa Date: Wed, 23 Sep 2015 20:43:24 +0530 Subject: [PATCH 09/24] Adding Force Option for Remove Commandlets --- .../AzureBackupItemTestCases.ps1 | 2 +- .../ScenarioTests/AzureBackupPolicyTests.ps1 | 2 +- .../RemoveAzureRMBackupProtectionPolicy.cs | 43 ++++--- .../Properties/Resources.Designer.cs | 106 ++++++++++++------ .../Properties/Resources.resx | 12 ++ 5 files changed, 114 insertions(+), 51 deletions(-) diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupItemTestCases.ps1 b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupItemTestCases.ps1 index b2c9869ebc92..54a4144e943f 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupItemTestCases.ps1 +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupItemTestCases.ps1 @@ -80,5 +80,5 @@ function Test-DisableAzureBackupProtection $azureBackUpItem.Type = $DataSourceType $azureBackUpItem.ItemName = $itemName $azureBackUpItem.Name = $POName - $jobId1 = Disable-AzureRMBackupProtection -Item $azureBackUpItem + $jobId1 = Disable-AzureRMBackupProtection -Item $azureBackUpItem -Force } diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 index 824ae6637d0f..2920f63c8f99 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 @@ -92,7 +92,7 @@ function Test-SetAzureBackupProtectionPolicyTests function Test-RemoveAzureBackupProtectionPolicyTests { - $vault = Get-AzureRMBackupVault -Name $ResourceName; + $vault = Get-AzureRMBackupVault -Name $ResourceName -Force; $protectionPolicy = Get-AzureRMBackupProtectionPolicy -vault $vault -Name $PolicyName Remove-AzureRMBackupProtectionPolicy -ProtectionPolicy $protectionPolicy diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/ProtectionPolicy/RemoveAzureRMBackupProtectionPolicy.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/ProtectionPolicy/RemoveAzureRMBackupProtectionPolicy.cs index a1e0712d986c..c36308698317 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/ProtectionPolicy/RemoveAzureRMBackupProtectionPolicy.cs +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/ProtectionPolicy/RemoveAzureRMBackupProtectionPolicy.cs @@ -29,26 +29,37 @@ namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets [Cmdlet(VerbsCommon.Remove, "AzureRMBackupProtectionPolicy")] public class RemoveAzureRMBackupProtectionPolicy : AzureBackupPolicyCmdletBase { + [Parameter(Mandatory = false, HelpMessage = "Don't ask for confirmation.")] + public SwitchParameter Force { get; set; } + protected override void ProcessRecord() { - ExecutionBlock(() => - { - base.ProcessRecord(); + ConfirmAction( + Force.IsPresent, + string.Format(Resources.RemoveProtectionPolicyWarning, ProtectionPolicy.Name), + Resources.RemoveProtectionPolicyMessage, + ProtectionPolicy.Name, () => + { + ExecutionBlock(() => + { + base.ProcessRecord(); + + WriteDebug(Resources.MakingClientCall); - WriteDebug(Resources.MakingClientCall); + var policyInfo = AzureBackupClient.GetProtectionPolicyByName(ProtectionPolicy.ResourceGroupName, ProtectionPolicy.ResourceName, ProtectionPolicy.Name); + if (policyInfo != null) + { + AzureBackupClient.DeleteProtectionPolicy(ProtectionPolicy.ResourceGroupName, ProtectionPolicy.ResourceName, policyInfo.Name); + WriteDebug(Resources.ProtectionPolicyDeleted); + } + else + { + var exception = new ArgumentException(string.Format(Resources.PolicyNotFound, ProtectionPolicy.Name)); + throw exception; + } + }); - var policyInfo = AzureBackupClient.GetProtectionPolicyByName(ProtectionPolicy.ResourceGroupName, ProtectionPolicy.ResourceName, ProtectionPolicy.Name); - if (policyInfo != null) - { - AzureBackupClient.DeleteProtectionPolicy(ProtectionPolicy.ResourceGroupName, ProtectionPolicy.ResourceName, policyInfo.Name); - WriteDebug(Resources.ProtectionPolicyDeleted); - } - else - { - var exception = new ArgumentException(string.Format(Resources.PolicyNotFound, ProtectionPolicy.Name)); - throw exception; - } - }); + }); } } } diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/Resources.Designer.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/Resources.Designer.cs index 5f78194dd775..a26fb69fc7f8 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/Resources.Designer.cs +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18449 +// Runtime Version:4.0.30319.34209 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -139,7 +139,7 @@ internal static string BackupItemCmdletCalled { } /// - /// Looks up a localized string similar to For daily backup schedule, protection policy cannot have DaysOfWeek param in backup schedule. + /// Looks up a localized string similar to For a daily backup schedule, using the DaysOfWeek parameter is not allowed. /// internal static string BackupScheduleDailyParamException { get { @@ -148,7 +148,7 @@ internal static string BackupScheduleDailyParamException { } /// - /// Looks up a localized string similar to For weekly backup schedule, DaysOfWeek in backup schedule is mandatory and cannot be empty. + /// Looks up a localized string similar to For a weekly backup schedule, using the DaysOfWeek parameter is mandatory. /// internal static string BackupScheduleWeeklyParamException { get { @@ -265,7 +265,7 @@ internal static string CreatingBackupVault { } /// - /// Looks up a localized string similar to Only one AzureBackupDailyRetentionPolicy in RetentionPolicies is allowed. + /// Looks up a localized string similar to Only one daily retention policy is allowed for a Protection Policy. /// internal static string DailyRetentionPolicyException { get { @@ -274,7 +274,7 @@ internal static string DailyRetentionPolicyException { } /// - /// Looks up a localized string similar to For AzureBackupDailyRetentionPolicy , valid values of retention are {0} to {1}. + /// Looks up a localized string similar to The daily retention value should be between {0} and {1}. /// internal static string DailyRetentionPolicyValueException { get { @@ -283,7 +283,7 @@ internal static string DailyRetentionPolicyValueException { } /// - /// Looks up a localized string similar to For Daily Schedule, AzureBackupDailyRetentionPolicy in RetentionPolicies param is mandatory. + /// Looks up a localized string similar to For a daily backup schedule, setting a daily retention policy is mandatory. /// internal static string DailyScheduleException { get { @@ -292,7 +292,7 @@ internal static string DailyScheduleException { } /// - /// Looks up a localized string similar to Days of the month in Monthly/Yearly retention is not allowed for weekly backup Schedules. + /// Looks up a localized string similar to Using the DaysOfMonth parameter in retention policies is not allowed when weekly backup schedules are used. /// internal static string DaysOfMonthsNotAllowedinMonthlyYearlyFormat { get { @@ -301,7 +301,7 @@ internal static string DaysOfMonthsNotAllowedinMonthlyYearlyFormat { } /// - /// Looks up a localized string similar to DaysofTheWeek list in Weekly retention schedule must be same of backup schedule DaysOfTheWeek. + /// Looks up a localized string similar to The DaysOfWeek specified in a weekly retention schedule should be same as of DaysOfWeek value specified in the backup schedule. /// internal static string DaysofTheWeekInWeeklyRetentionException { get { @@ -310,7 +310,7 @@ internal static string DaysofTheWeekInWeeklyRetentionException { } /// - /// Looks up a localized string similar to DaysOfTheWeek of retention schedule must be same of backup schedule DaysOfTheWeek. + /// Looks up a localized string similar to The DaysOfWeek specified in a weekly retention schedule should be same as of DaysOfWeek value specified in the backup schedule. /// internal static string DaysOfTheWeekOfRetentionScheduleException { get { @@ -463,7 +463,7 @@ internal static string MakingClientCall { } /// - /// Looks up a localized string similar to For AzureBackupMonthlyRetentionPolicy and RetentionFormat in Days, DaysOfMonth param is mandatory and can not be empty. + /// Looks up a localized string similar to For a monthly retention policy specified in days, using the DaysOfMonth parameter is mandatory. /// internal static string MonthlyRetentionPolicyDaysOfMonthParamException { get { @@ -472,7 +472,7 @@ internal static string MonthlyRetentionPolicyDaysOfMonthParamException { } /// - /// Looks up a localized string similar to For AzureBackupMonthlyRetentionPolicy and RetentionFormat in Weeks, DaysOfMonth param is not allowed.. + /// Looks up a localized string similar to For a monthly retention policy specified in weeks, using the DaysOfMonth parameter is not allowed. /// internal static string MonthlyRetentionPolicyDaysOfMonthsException { get { @@ -481,7 +481,7 @@ internal static string MonthlyRetentionPolicyDaysOfMonthsException { } /// - /// Looks up a localized string similar to For AzureBackupMonthlyRetentionPolicy and RetentionFormat in Weeks, DaysOfWeek param is mandatory and can not be empty. + /// Looks up a localized string similar to For a monthly retention policy specified in weeks, using the DaysOfWeek parameter is mandatory. /// internal static string MonthlyRetentionPolicyDaysOfWeekException { get { @@ -490,7 +490,7 @@ internal static string MonthlyRetentionPolicyDaysOfWeekException { } /// - /// Looks up a localized string similar to For AzureBackupMonthlyRetentionPolicy and RetentionFormat in Days, DaysOfWeek or WeekNumber params are not allowed. + /// Looks up a localized string similar to For a monthly retention policy specified in days, using the DaysOfWeek and WeekNumber parameters is not allowed. /// internal static string MonthlyRetentionPolicyDaysOfWeekParamException { get { @@ -499,7 +499,7 @@ internal static string MonthlyRetentionPolicyDaysOfWeekParamException { } /// - /// Looks up a localized string similar to Only one AzureBackupMonthlyRetentionPolicy in RetentionPolicies is allowed. + /// Looks up a localized string similar to Only one monthly retention policy is allowed for a Protection Policy. /// internal static string MonthlyRetentionPolicyException { get { @@ -508,7 +508,7 @@ internal static string MonthlyRetentionPolicyException { } /// - /// Looks up a localized string similar to For AzureBackupMonthlyRetentionPolicy , valid values of retention are {0} to {1}. + /// Looks up a localized string similar to The monthly retention value should be between {0} and {1}. /// internal static string MonthlyRetentionPolicyValueException { get { @@ -517,7 +517,7 @@ internal static string MonthlyRetentionPolicyValueException { } /// - /// Looks up a localized string similar to For AzureBackupMonthlyRetentionPolicy and RetentionFormat in Weeks, WeekNumber param is mandatory and can not be empty. + /// Looks up a localized string similar to For a monthly retention policy specified in weeks, using the WeekNumber parameter is mandatory. /// internal static string MonthlyRetentionPolicyWeekNumException { get { @@ -526,7 +526,7 @@ internal static string MonthlyRetentionPolicyWeekNumException { } /// - /// Looks up a localized string similar to Days of the week list in Monthly/Yearly retention schedule should be subset of Day of week list in Backup Schedule. + /// Looks up a localized string similar to The DaysOfWeek specified for monthly and yearly retention policies should be a subset of the DaysOfWeek value specified in the backup schedule. /// internal static string MonthlyYearlyRetentionArgumentException { get { @@ -580,7 +580,7 @@ internal static string OperationStatus { } /// - /// Looks up a localized string similar to A protection policy with the specified name already exists.. + /// Looks up a localized string similar to A protection policy with the specified name already exists. /// internal static string PolicyAlreadyExist { get { @@ -589,7 +589,7 @@ internal static string PolicyAlreadyExist { } /// - /// Looks up a localized string similar to For DaysOfWeek, weekly switch param is required. + /// Looks up a localized string similar to The DaysOfWeek parameter should be used in conjunction with the –Weekly switch parameter. /// internal static string PolicyArgumentException { get { @@ -723,6 +723,46 @@ internal static string RegisteringVM { } } + /// + /// Looks up a localized string similar to Remove Protection Policy Message. + /// + internal static string RemoveProtectionPolicyMessage { + get { + return ResourceManager.GetString("RemoveProtectionPolicyMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Remove Protection Policy Warning;. + /// + internal static string RemoveProtectionPolicyWarning { + get { + return ResourceManager.GetString("RemoveProtectionPolicyWarning", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Disable Protection Message. + /// + internal static string DisableProtectionMessage + { + get + { + return ResourceManager.GetString("DisableProtectionMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Disable Protection Warning;. + /// + internal static string DisableProtectionWarning + { + get + { + return ResourceManager.GetString("DisableProtectionWarning", resourceCulture); + } + } + /// /// Looks up a localized string similar to Going to retry Discovery if retry count is not exceeded. /// @@ -949,7 +989,7 @@ internal static string WebException { } /// - /// Looks up a localized string similar to For AzureBackupWeeklyRetentionPolicy , DaysOfWeek param is mandatory and can not be empty. + /// Looks up a localized string similar to For a weekly retention policy, using the DaysOfWeek parameter is mandatory. /// internal static string WeeklyRetentionPolicyDaysOfWeekException { get { @@ -958,7 +998,7 @@ internal static string WeeklyRetentionPolicyDaysOfWeekException { } /// - /// Looks up a localized string similar to Only one AzureBackupWeeklyRetentionPolicy in RetentionPolicies is allowed. + /// Looks up a localized string similar to Only one weekly retention policy is allowed for a Protection Policy. /// internal static string WeeklyRetentionPolicyException { get { @@ -967,7 +1007,7 @@ internal static string WeeklyRetentionPolicyException { } /// - /// Looks up a localized string similar to For AzureBackupWeeklyRetentionPolicy , valid values of retention are {0} to {1}. + /// Looks up a localized string similar to The weekly retention value should be between {0} and {1}. /// internal static string WeeklyRetentionPolicyValueException { get { @@ -976,7 +1016,7 @@ internal static string WeeklyRetentionPolicyValueException { } /// - /// Looks up a localized string similar to For Weekly Schedule, AzureBackupWeeklyRetentionPolicy in RetentionPolicies param is mandatory. + /// Looks up a localized string similar to For a weekly backup schedule, setting a weekly retention policy is mandatory. /// internal static string WeeklyScheduleException { get { @@ -985,7 +1025,7 @@ internal static string WeeklyScheduleException { } /// - /// Looks up a localized string similar to For weekly scheduletype , ScheduleRunDays param is mandatory and can not be empty.. + /// Looks up a localized string similar to For a weekly backup schedule, using the DaysOfWeek parameter is mandatory. /// internal static string WeeklyScheduleRunDaysException { get { @@ -994,7 +1034,7 @@ internal static string WeeklyScheduleRunDaysException { } /// - /// Looks up a localized string similar to For Weekly Schedule, AzureBackupDailyRetentionPolicy in RetentionPolicies param is not allowed. + /// Looks up a localized string similar to For a weekly backup schedule, setting a daily retention policy is not allowed. /// internal static string WeeklyScheduleWithDailyException { get { @@ -1003,7 +1043,7 @@ internal static string WeeklyScheduleWithDailyException { } /// - /// Looks up a localized string similar to For AzureBackupYearlyRetentionPolicy and RetentionFormat in Weeks, DaysOfMonth param is not allowed. + /// Looks up a localized string similar to For a yearly retention policy specified in days, using the MonthsOfYear and DaysOfMonth parameters is not allowed. /// internal static string YearlyRetentionPolicyDaysOfMonthInWeekFormatException { get { @@ -1012,7 +1052,7 @@ internal static string YearlyRetentionPolicyDaysOfMonthInWeekFormatException { } /// - /// Looks up a localized string similar to For AzureBackupYearlyRetentionPolicy and RetentionFormat in Days, DaysOfMonth param is mandatory and can not be empty. + /// Looks up a localized string similar to For a yearly retention policy specified in days, using the MonthsOfYear and DaysOfMonth parameters is mandatory. /// internal static string YearlyRetentionPolicyDaysOfMonthParamException { get { @@ -1021,7 +1061,7 @@ internal static string YearlyRetentionPolicyDaysOfMonthParamException { } /// - /// Looks up a localized string similar to For AzureBackupYearlyRetentionPolicy and RetentionFormat in Weeks, DaysOfWeek param is mandatory and can not be empty. + /// Looks up a localized string similar to For a yearly retention policy specified in weeks, using the DaysOfWeek and WeekNumber parameters is mandatory. /// internal static string YearlyRetentionPolicyDaysOfWeekInWeeksFormatParamException { get { @@ -1030,7 +1070,7 @@ internal static string YearlyRetentionPolicyDaysOfWeekInWeeksFormatParamExceptio } /// - /// Looks up a localized string similar to For AzureBackupYearlyRetentionPolicy and RetentionFormat in Days, DaysOfWeek or WeekNumber params are not allowed. + /// Looks up a localized string similar to For a yearly retention policy specified in days, using the DaysOfWeek and WeekNumber parameters is not allowed. /// internal static string YearlyRetentionPolicyDaysOfWeekParamException { get { @@ -1039,7 +1079,7 @@ internal static string YearlyRetentionPolicyDaysOfWeekParamException { } /// - /// Looks up a localized string similar to Only one AzureBackupYearlyRetentionPolicy in RetentionPolicies is allowed. + /// Looks up a localized string similar to Only one yearly retention policy is allowed for a Protection Policy. /// internal static string YearlyRetentionPolicyException { get { @@ -1048,7 +1088,7 @@ internal static string YearlyRetentionPolicyException { } /// - /// Looks up a localized string similar to For AzureBackupYearlyRetentionPolicy and RetentionFormat in days, MonthsOfYear param is mandatory and can not be empty. + /// Looks up a localized string similar to For a yearly retention policy specified in days, using the MonthsOfYear and DaysOfMonth parameters is mandatory. /// internal static string YearlyRetentionPolicyMonthOfYearParamException { get { @@ -1057,7 +1097,7 @@ internal static string YearlyRetentionPolicyMonthOfYearParamException { } /// - /// Looks up a localized string similar to For AzureBackupYearlyRetentionPolicy , valid values of retention are {0} to {1}. + /// Looks up a localized string similar to Yearly retention value should be between {0} and {1}. /// internal static string YearlyRetentionPolicyValueException { get { @@ -1066,7 +1106,7 @@ internal static string YearlyRetentionPolicyValueException { } /// - /// Looks up a localized string similar to For AzureBackupYearlyRetentionPolicy and RetentionFormat in Weeks, WeekNumber param is mandatory and can not be empty. + /// Looks up a localized string similar to For a yearly retention policy specified in weeks, using the DaysOfWeek and WeekNumber parameters is mandatory. /// internal static string YearlyRetentionPolicyWeekNumParamException { get { diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/Resources.resx b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/Resources.resx index b6bca7072396..e300ab5acf9b 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/Resources.resx +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/Resources.resx @@ -493,4 +493,16 @@ Please contact Microsoft for further assistant. For a yearly retention policy specified in weeks, using the DaysOfWeek and WeekNumber parameters is mandatory Scrubbed + + Disabling protection for item + + + Are you sure you want to disable protection for item '{0}' + + + Removing protection policy + + + Are you sure you want to remove protection policy '{0}' + \ No newline at end of file From a3fbfe58f62ab10575807b75e36888466a603a7d Mon Sep 17 00:00:00 2001 From: pragrawa Date: Wed, 23 Sep 2015 20:48:47 +0530 Subject: [PATCH 10/24] Adding Force Option for Remove Commandlets --- .../Item/Disable-AzureRMBackupProtection .cs | 61 +++++++++++-------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Item/Disable-AzureRMBackupProtection .cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Item/Disable-AzureRMBackupProtection .cs index 750de6953a4d..21adff32d317 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Item/Disable-AzureRMBackupProtection .cs +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Item/Disable-AzureRMBackupProtection .cs @@ -38,41 +38,52 @@ public SwitchParameter RemoveRecoveryPoints get { return DeleteBackupData; } set { DeleteBackupData = value; } } + + [Parameter(Mandatory = false, HelpMessage = "Don't ask for confirmation.")] + public SwitchParameter Force { get; set; } + private bool DeleteBackupData; protected override void ProcessRecord() { - ExecutionBlock(() => - { - base.ProcessRecord(); - Guid operationId = Guid.Empty; - WriteDebug(Resources.MakingClientCall); - - if (!this.DeleteBackupData) + ConfirmAction( + Force.IsPresent, + string.Format(Resources.DisableProtectionWarning, Item.Name), + Resources.DisableProtectionMessage, + Item.Name, () => { - //Calling update protection with policy Id as empty. - CSMUpdateProtectionRequest input = new CSMUpdateProtectionRequest() + ExecutionBlock(() => { - Properties = new CSMUpdateProtectionRequestProperties(string.Empty) - }; + base.ProcessRecord(); + Guid operationId = Guid.Empty; + WriteDebug(Resources.MakingClientCall); - operationId = AzureBackupClient.UpdateProtection(Item.ResourceGroupName, Item.ResourceName, Item.ContainerUniqueName, Item.ItemName, input); - } + if (!this.DeleteBackupData) + { + //Calling update protection with policy Id as empty. + CSMUpdateProtectionRequest input = new CSMUpdateProtectionRequest() + { + Properties = new CSMUpdateProtectionRequestProperties(string.Empty) + }; - else - { - //Calling disable protection - operationId = AzureBackupClient.DisableProtection(Item.ResourceGroupName, Item.ResourceName, Item.ContainerUniqueName, Item.ItemName); - } + operationId = AzureBackupClient.UpdateProtection(Item.ResourceGroupName, Item.ResourceName, Item.ContainerUniqueName, Item.ItemName, input); + } + + else + { + //Calling disable protection + operationId = AzureBackupClient.DisableProtection(Item.ResourceGroupName, Item.ResourceName, Item.ContainerUniqueName, Item.ItemName); + } - WriteDebug(Resources.DisableAzureBackupProtection); - var operationStatus = TrackOperation(Item.ResourceGroupName, Item.ResourceName, operationId); - this.WriteObject(GetCreatedJobs(Item.ResourceGroupName, - Item.ResourceName, - new Models.AzureRMBackupVault(Item.ResourceGroupName, Item.ResourceName, Item.Location), - operationStatus.JobList).FirstOrDefault()); - }); + WriteDebug(Resources.DisableAzureBackupProtection); + var operationStatus = TrackOperation(Item.ResourceGroupName, Item.ResourceName, operationId); + this.WriteObject(GetCreatedJobs(Item.ResourceGroupName, + Item.ResourceName, + new Models.AzureRMBackupVault(Item.ResourceGroupName, Item.ResourceName, Item.Location), + operationStatus.JobList).FirstOrDefault()); + }); + }); } } } \ No newline at end of file From ad719bea947734fd2ab467436f87cd8ee5959681 Mon Sep 17 00:00:00 2001 From: pragrawa Date: Wed, 23 Sep 2015 21:56:59 +0530 Subject: [PATCH 11/24] Merge Conflict --- .../ScenarioTests/AzureBackupItemTestCases.ps1 | 4 ---- .../ScenarioTests/AzureBackupPolicyTests.ps1 | 8 ++------ 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupItemTestCases.ps1 b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupItemTestCases.ps1 index d5d7a0af3afb..79f7e505f86f 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupItemTestCases.ps1 +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupItemTestCases.ps1 @@ -80,9 +80,5 @@ function Test-DisableAzureBackupProtection $azureBackUpItem.Type = $DataSourceType $azureBackUpItem.ItemName = $itemName $azureBackUpItem.Name = $POName -<<<<<<< HEAD $jobId1 = Disable-AzureRMBackupProtection -Item $azureBackUpItem -Force -======= - $jobId1 = Disable-AzureRmBackupProtection -Item $azureBackUpItem ->>>>>>> 06dd1ed62c72c0cf77f77233dda1c5c619cbe1eb } diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 index 4816570b5e30..a6e172604406 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 @@ -95,10 +95,6 @@ function Test-RemoveAzureBackupProtectionPolicyTests <<<<<<< HEAD $vault = Get-AzureRMBackupVault -Name $ResourceName -Force; $protectionPolicy = Get-AzureRMBackupProtectionPolicy -vault $vault -Name $PolicyName -======= - $vault = Get-AzureRmBackupVault -Name $ResourceName; - $protectionPolicy = Get-AzureRmBackupProtectionPolicy -vault $vault -Name $PolicyName ->>>>>>> 06dd1ed62c72c0cf77f77233dda1c5c619cbe1eb - - Remove-AzureRmBackupProtectionPolicy -ProtectionPolicy $protectionPolicy + + Remove-AzureRmBackupProtectionPolicy -ProtectionPolicy $protectionPolicy -Force } From ca64e18d74bb839fa22447f251d8ea8459f70aec Mon Sep 17 00:00:00 2001 From: pragrawa Date: Wed, 23 Sep 2015 21:59:01 +0530 Subject: [PATCH 12/24] Merge Conflict --- .../ScenarioTests/AzureBackupPolicyTests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 index a6e172604406..8bfec5a3f1f4 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 @@ -92,7 +92,7 @@ function Test-SetAzureBackupProtectionPolicyTests function Test-RemoveAzureBackupProtectionPolicyTests { -<<<<<<< HEAD + $vault = Get-AzureRMBackupVault -Name $ResourceName -Force; $protectionPolicy = Get-AzureRMBackupProtectionPolicy -vault $vault -Name $PolicyName From 58dfc04df2bb2f0ba5804ae8a9268be7bcbaab45 Mon Sep 17 00:00:00 2001 From: pragrawa Date: Wed, 23 Sep 2015 22:00:12 +0530 Subject: [PATCH 13/24] Merge Conflict --- .../ScenarioTests/AzureBackupPolicyTests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 index 8bfec5a3f1f4..c6000d4eb642 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 @@ -93,7 +93,7 @@ function Test-SetAzureBackupProtectionPolicyTests function Test-RemoveAzureBackupProtectionPolicyTests { - $vault = Get-AzureRMBackupVault -Name $ResourceName -Force; + $vault = Get-AzureRMBackupVault -Name $ResourceName; $protectionPolicy = Get-AzureRMBackupProtectionPolicy -vault $vault -Name $PolicyName Remove-AzureRmBackupProtectionPolicy -ProtectionPolicy $protectionPolicy -Force From 2444a52b0229f0b60466aca167cdfc7999573c7d Mon Sep 17 00:00:00 2001 From: stankovski Date: Wed, 23 Sep 2015 14:36:19 -0700 Subject: [PATCH 14/24] Updated parallel scripts --- setup-powershellget/Setup/ShortcutStartup.ps1 | 19 ++++- tools/AzureRM/AzureRM.psm1 | 85 ++++++++++++------- 2 files changed, 71 insertions(+), 33 deletions(-) diff --git a/setup-powershellget/Setup/ShortcutStartup.ps1 b/setup-powershellget/Setup/ShortcutStartup.ps1 index fed332e89acc..fc17b7356151 100644 --- a/setup-powershellget/Setup/ShortcutStartup.ps1 +++ b/setup-powershellget/Setup/ShortcutStartup.ps1 @@ -26,14 +26,25 @@ Finalizing installation of Azure PowerShell. Installing Azure Modules from PowerShell Gallery. This may take some time... "@ - Import-Module PackageManagement - Get-PackageProvider -Name NuGet -ForceBootstrap + Import-Module "$env:programfiles\WindowsPowerShell\Modules\PackageManagement\1.0.0.0\PackageManagement.psd1" + + $result = Get-PackageProvider -Name NuGet -ForceBootstrap + + Import-Module "$env:programfiles\WindowsPowerShell\Modules\PowerShellGet\PowerShellGet.psd1" $NuGetPublishingSource = $env:NuGetPublishingSource if ([string]::IsNullOrWhiteSpace($NuGetPublishingSource)) { - Install-Module AzureRM -Repository $NuGetPublishingSource - } else { + Install-Module Azure + Write-Output "Azure $((Get-InstalledModule -Name Azure)[0].Version) installed..." Install-Module AzureRM + Write-Output "AzureRM $((Get-InstalledModule -Name AzureRM)[0].Version) installed..." + Update-AzureRM + } else { + Install-Module Azure -Repository $NuGetPublishingSource + Write-Output "Azure $((Get-InstalledModule -Name Azure)[0].Version) installed..." + Install-Module AzureRM -Repository $NuGetPublishingSource + Write-Output "AzureRM $((Get-InstalledModule -Name AzureRM)[0].Version) installed..." + Update-AzureRM -Repository $NuGetPublishingSource } } else { cd c:\ diff --git a/tools/AzureRM/AzureRM.psm1 b/tools/AzureRM/AzureRM.psm1 index dbcfdd49a92b..9b3e46003bad 100644 --- a/tools/AzureRM/AzureRM.psm1 +++ b/tools/AzureRM/AzureRM.psm1 @@ -1,3 +1,30 @@ +$AzureRMModules = ( + "Azure.Storage", + "AzureRM.ApiManagement", + "AzureRM.Automation", + "AzureRM.Backup", + "AzureRM.Batch", + "AzureRM.Compute", + "AzureRM.DataFactories", + "AzureRM.Dns", + "AzureRM.HDInsight", + "AzureRM.Insights", + "AzureRM.KeyVault", + "AzureRM.Network", + "AzureRM.OperationalInsights", + "AzureRM.Profile", + "AzureRM.RedisCache", + "AzureRM.Resources", + "AzureRM.SiteRecovery", + "AzureRM.Sql", + "AzureRM.Storage", + "AzureRM.StreamAnalytics", + "AzureRM.Tags", + "AzureRM.TrafficManager", + "AzureRM.UsageAggregates", + "AzureRM.Websites" +) + <# .Synopsis Install Azure Resource Manager cmdlet modules @@ -13,36 +40,36 @@ #> function Update-AzureRM { - param( - [Parameter(Position=0, Mandatory = $false)] - [string] - $Repository, - - [Parameter(Position=1, Mandatory = $false)] - [ValidateSet("CurrentUser","AllUsers")] - [string] - $Scope) + param( + [Parameter(Position=0, Mandatory = $false)] + [string] + $Repository, - if ([string]::IsNullOrWhiteSpace($Scope)) - { - $Scope = "AllUsers" - } + [Parameter(Position=1, Mandatory = $false)] + [ValidateSet("CurrentUser","AllUsers")] + [string] + $Scope) - Install-Module AzureRM.Profile -Repository $Repository - if ([string]::IsNullOrWhiteSpace($Repository)) - { - $modules = Find-Module -Name AzureRM.* | Where-Object {$_.Name -ne "AzureRM" -and $_.Name -ne "AzureRM.Profile"} - } else { - $modules = Find-Module -Repository $Repository | Where-Object {$_.Name -like "AzureRM.*" -and $_.Name -ne "AzureRM" -and $_.Name -ne "AzureRM.Profile"} - } + if ([string]::IsNullOrWhiteSpace($Scope)) + { + $Scope = "AllUsers" + } - Write-Output "Installing $($modules.Length) AzureRM modules. This may take a few minutes." + Write-Output "Installing AzureRM modules." - $result = $modules | ForEach { - Start-Job -Name $_.Name -ScriptBlock { - Install-Module -Name $args[0] -Repository $args[1] -Scope $args[2] - Write-Output "$($args[0]) installed..." - } -ArgumentList $_.Name, $Repository, $Scope } - - $modules | ForEach {Get-Job -Name $_.Name | Wait-Job | Receive-Job } -} \ No newline at end of file + $result = $AzureRMModules | ForEach { + Start-Job -Name $_ -ScriptBlock { + if ([string]::IsNullOrWhiteSpace($args[1])) + { + Install-Module -Name $args[0] -Scope $args[2] + } else { + Install-Module -Name $args[0] -Repository $args[1] -Scope $args[2] + } + $v = (Get-InstalledModule -Name $args[0])[0].Version.ToString() + Write-Output "$($args[0]) $v installed..." + } -ArgumentList $_, $Repository, $Scope } + + $AzureRMModules | ForEach {Get-Job -Name $_ | Wait-Job | Receive-Job } +} +New-Alias -Name Install-AzureRM -Value Update-AzureRM +Export-ModuleMember -function * -Alias * \ No newline at end of file From b5af0ccd2adb8c4890cf2e5f026d215afbb889e0 Mon Sep 17 00:00:00 2001 From: stankovski Date: Wed, 23 Sep 2015 16:43:54 -0700 Subject: [PATCH 15/24] Work in progress --- build.proj | 2 +- setup-powershellget/Setup/ShortcutStartup.ps1 | 4 +-- tools/PublishModules.ps1 | 31 +++++++++++++------ 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/build.proj b/build.proj index b49b13d339c6..abe9a6ee424d 100644 --- a/build.proj +++ b/build.proj @@ -289,7 +289,7 @@ - + diff --git a/setup-powershellget/Setup/ShortcutStartup.ps1 b/setup-powershellget/Setup/ShortcutStartup.ps1 index fc17b7356151..9ff5d31478bc 100644 --- a/setup-powershellget/Setup/ShortcutStartup.ps1 +++ b/setup-powershellget/Setup/ShortcutStartup.ps1 @@ -26,11 +26,11 @@ Finalizing installation of Azure PowerShell. Installing Azure Modules from PowerShell Gallery. This may take some time... "@ - Import-Module "$env:programfiles\WindowsPowerShell\Modules\PackageManagement\1.0.0.0\PackageManagement.psd1" + Import-Module PackageManagement $result = Get-PackageProvider -Name NuGet -ForceBootstrap - Import-Module "$env:programfiles\WindowsPowerShell\Modules\PowerShellGet\PowerShellGet.psd1" + Import-Module PowerShellGet $NuGetPublishingSource = $env:NuGetPublishingSource if ([string]::IsNullOrWhiteSpace($NuGetPublishingSource)) { diff --git a/tools/PublishModules.ps1 b/tools/PublishModules.ps1 index e8535c77ebc7..ef28708f0d1c 100644 --- a/tools/PublishModules.ps1 +++ b/tools/PublishModules.ps1 @@ -18,7 +18,7 @@ param( [Parameter(Mandatory = $false, Position = 1)] [string] $apiKey, [Parameter(Mandatory = $false, Position = 2)] - [string] $repositoryLocation + [string] $repository ) if ([string]::IsNullOrEmpty($buildConfig)) @@ -29,18 +29,32 @@ if ([string]::IsNullOrEmpty($buildConfig)) if ([string]::IsNullOrEmpty($repositoryLocation)) { - Write-Verbose "Setting repository location to 'http://psget/PSGallery/api/v2/'" - $repositoryLocation = 'http://psget/PSGallery/api/v2/' + Write-Verbose "Setting repository location to 'https://dtlgalleryint.cloudapp.net/api/v2'" + + $repository = 'https://dtlgalleryint.cloudapp.net' } +$repositoryLocation = '$repository/api/v2/' +$repositoryPackageLocation = '$repository/api/v2/package' + + $packageFolder = "$PSScriptRoot\..\src\Package" -$repoName = $(New-Guid).ToString() -Register-PSRepository -Name $repoName -SourceLocation $repositoryLocation -PublishLocation $repositoryLocation -InstallationPolicy Trusted +$repo = Get-PSRepository | where { $_.SourceLocation -eq $repositoryLocation } +if ($repo -ne $null) { + $repoName = $repo.Name +} else { + $repoName = $(New-Guid).ToString() + Register-PSRepository -Name $repoName -SourceLocation $repositoryLocation -PublishLocation $repositoryPackageLocation -InstallationPolicy Trusted +} $modulePath = "$packageFolder\$buildConfig\ServiceManagement\Azure" # Publish Azure module Write-Host "Publishing Azure module from $modulePath" -Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName +Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName -Tags ("Azure", "AzureRM") +# Publish AzureRM module +$modulePath = "$PSScriptRoot\AzureRM" +Write-Host "Publishing AzureRM module from $modulePath" +Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName -Tags ("Azure", "AzureRM") Write-Host "Published Azure module" # Publish AzureRM.Profile module Write-Host "Publishing AzureRM.Profile module from $modulePath" @@ -53,8 +67,7 @@ foreach ($module in $resourceManagerModules) { if ($module -ne "AzureRM.Profile") { $modulePath = $module.FullName Write-Host "Publishing $module module from $modulePath" - Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName + Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName -Tags ("Azure", "AzureRM") Write-Host "Published $module module" } -} -Unregister-PSRepository -Name $repoName \ No newline at end of file +} \ No newline at end of file From 8da70da8f02681cd5a8cf565822f3e8d5f29110d Mon Sep 17 00:00:00 2001 From: pragrawa Date: Thu, 24 Sep 2015 12:39:34 +0530 Subject: [PATCH 16/24] Merge Conflict --- .../ScenarioTests/AzureBackupItemTestCases.ps1 | 2 +- .../ScenarioTests/AzureBackupPolicyTests.ps1 | 4 ++-- .../ScenarioTests/AzureBackupScenarioTests.ps1 | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupItemTestCases.ps1 b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupItemTestCases.ps1 index 79f7e505f86f..7d798efdee15 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupItemTestCases.ps1 +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupItemTestCases.ps1 @@ -80,5 +80,5 @@ function Test-DisableAzureBackupProtection $azureBackUpItem.Type = $DataSourceType $azureBackUpItem.ItemName = $itemName $azureBackUpItem.Name = $POName - $jobId1 = Disable-AzureRMBackupProtection -Item $azureBackUpItem -Force + $jobId1 = Disable-AzureRmBackupProtection -Item $azureBackUpItem -Force } diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 index c6000d4eb642..dd6ab6348991 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 @@ -93,8 +93,8 @@ function Test-SetAzureBackupProtectionPolicyTests function Test-RemoveAzureBackupProtectionPolicyTests { - $vault = Get-AzureRMBackupVault -Name $ResourceName; - $protectionPolicy = Get-AzureRMBackupProtectionPolicy -vault $vault -Name $PolicyName + $vault = Get-AzureRmBackupVault -Name $ResourceName; + $protectionPolicy = Get-AzureRmBackupProtectionPolicy -vault $vault -Name $PolicyName Remove-AzureRmBackupProtectionPolicy -ProtectionPolicy $protectionPolicy -Force } diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.ps1 b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.ps1 index 1fc676f33a9d..3c50b376f733 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.ps1 +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.ps1 @@ -287,7 +287,7 @@ function Test-AzureBackupEndToEnd Try { $startTime = Get-Date -format G; - $Job = Disable-AzureRmBackupProtection -RemoveRecoveryPoints -Item $item[0]; + $Job = Disable-AzureRmBackupProtection -RemoveRecoveryPoints -Item $item[0] -Force; Wait-AzureRmBackupJob -Job $Job; $JobDetails = Get-AzureRmBackupJobDetails -Vault $vault -JobID $Job.InstanceId; Assert-AreEqual $JobDetails.Operation "Unprotect"; @@ -332,7 +332,7 @@ function Test-AzureBackupEndToEnd Try { $startTime = Get-Date -format G; - Remove-AzureRmBackupProtectionPolicy -ProtectionPolicy $protectionpolicy; + Remove-AzureRmBackupProtectionPolicy -ProtectionPolicy $protectionpolicy -Force; $endTime = Get-Date -format G; "Remove-AzureRmBackupProtectionPolicy", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; } From 2eec8839de05fe26848e592263298e262e4b65e2 Mon Sep 17 00:00:00 2001 From: pragrawa Date: Thu, 24 Sep 2015 12:59:07 +0530 Subject: [PATCH 17/24] Merge Conflict --- .../ScenarioTests/AzureBackupPolicyTests.ps1 | 2 +- .../Commands.AzureBackup/Helpers/ProtectionPolicyHelpers.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 index dd6ab6348991..ab3e4a480995 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 @@ -95,6 +95,6 @@ function Test-RemoveAzureBackupProtectionPolicyTests $vault = Get-AzureRmBackupVault -Name $ResourceName; $protectionPolicy = Get-AzureRmBackupProtectionPolicy -vault $vault -Name $PolicyName - + Remove-AzureRmBackupProtectionPolicy -ProtectionPolicy $protectionPolicy -Force } diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Helpers/ProtectionPolicyHelpers.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Helpers/ProtectionPolicyHelpers.cs index 41a26ccef932..9980dfcdf7a5 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Helpers/ProtectionPolicyHelpers.cs +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Helpers/ProtectionPolicyHelpers.cs @@ -763,7 +763,7 @@ private static IList ConvertToCSMDayList(List DaysOfMonth) foreach (string DayOfMonth in DaysOfMonth) { Day day = new Day(); - if (string.Compare(DayOfMonth,"Last", true) == 0) + if (string.Compare(DayOfMonth, LastDayOfTheMonth, true) == 0) { day.IsLast = true; } From 323db1bbff1e134f815e80aba31fd1da923d791c Mon Sep 17 00:00:00 2001 From: pragrawa Date: Thu, 24 Sep 2015 14:23:34 +0530 Subject: [PATCH 18/24] Scrub strings --- .../Commands.AzureBackup/Properties/Resources.resx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/Resources.resx b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/Resources.resx index e300ab5acf9b..2cd8f7ffdf93 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/Resources.resx +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup/Properties/Resources.resx @@ -494,15 +494,15 @@ Please contact Microsoft for further assistant. Scrubbed - Disabling protection for item + Disabling protection for the item - Are you sure you want to disable protection for item '{0}' + Are you sure you want to disable protection for the item '{0}' - Removing protection policy + Removing the protection policy - Are you sure you want to remove protection policy '{0}' + Are you sure you want to remove the protection policy '{0}' \ No newline at end of file From cfacd2b9e61b07aa67d6b6d23cbf9ab85f843ec2 Mon Sep 17 00:00:00 2001 From: pragrawa Date: Thu, 24 Sep 2015 18:46:08 +0530 Subject: [PATCH 19/24] TestCases --- .../AzureBackupItemTestCases.ps1 | 12 +- .../ScenarioTests/AzureBackupPolicyTests.ps1 | 4 +- .../ScenarioTests/AzureBackupScenarioTests.cs | 29 -- .../AzureBackupScenarioTests.ps1 | 385 ------------------ 4 files changed, 8 insertions(+), 422 deletions(-) delete mode 100644 src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.cs delete mode 100644 src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.ps1 diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupItemTestCases.ps1 b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupItemTestCases.ps1 index 7d798efdee15..3a7a0aa0ad49 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupItemTestCases.ps1 +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupItemTestCases.ps1 @@ -13,16 +13,16 @@ # ---------------------------------------------------------------------------------- $ResourceGroupName = "backuprg" -$ResourceName = "backuprn" -$ContainerName = "iaasvmcontainer;hydrarecordvm;hydrarecordvm" +$ResourceName = "backuprn2" +$ContainerName = "iaasvmcontainer;powershellbvt1;powershellbvt1" $ContainerType = "IaasVMContainer" $DataSourceType = "IaasVM" $DataSourceId = "17593283453810" -$Location = "SouthEast Asia" +$Location = "westus" $PolicyName = "ProtPolicy01"; -$PolicyId = "/subscriptions/f5303a0b-fae4-4cdb-b44d-0e4c032dde26/resourceGroups/backuprg/providers/Microsoft.Backup/BackupVault/backuprn/protectionPolicies/DefaultPolicy"; -$POName = "hydrarecordvm" -$itemName = "iaasvmcontainer;hydrarecordvm;hydrarecordvm" +$PolicyId = "/subscriptions/f5303a0b-fae4-4cdb-b44d-0e4c032dde26/resourceGroups/backuprg/providers/Microsoft.Backup/BackupVault/backuprn2/protectionPolicies/DefaultPolicy"; +$POName = "powershellbvt1" +$itemName = "iaasvmcontainer;powershellbvt1;powershellbvt1" function Test-GetAzureBackupItemTests diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 index ab3e4a480995..55be49cf5939 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupPolicyTests.ps1 @@ -13,9 +13,9 @@ # ---------------------------------------------------------------------------------- $ResourceGroupName = "backuprg" -$ResourceName = "backuprn" +$ResourceName = "backuprn2" $DataSourceType = "VM" -$Location = "SouthEast Asia" +$Location = "westus" $PolicyName = "Policy10"; $PolicyId = "c87bbada-6e1b-4db2-b76c-9062d28959a4"; $POName = "iaasvmcontainer;hydrarecordvm;hydrarecordvm" diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.cs b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.cs deleted file mode 100644 index 8ee22afe6c4b..000000000000 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.cs +++ /dev/null @@ -1,29 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// 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.WindowsAzure.Commands.ScenarioTest; -using Xunit; - -namespace Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests -{ - public class AzureBackupScenarioTests : AzureBackupTestsBase - { - [Fact] - //[Trait(Category.AcceptanceType, Category.CheckIn)] - public void AzureBackupEndToEndTests() - { - this.RunPowerShellTest("Test-AzureBackupEndToEnd"); - } - } -} diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.ps1 b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.ps1 deleted file mode 100644 index 3c50b376f733..000000000000 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupScenarioTests.ps1 +++ /dev/null @@ -1,385 +0,0 @@ -# ---------------------------------------------------------------------------------- -# -# 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. -# ---------------------------------------------------------------------------------- - -$ResourceGroupName = "scenariorg" -$ResourceName = "scenariorn" -$Location = "southeastasia" -$VirtualMachineName = "e2epowershell2" -$ProtectionPolicyName = "e2epolicy2" -$RestoreStorageAccount = "e2estore" -$ResultTxtFile = "EndToEndScenarioTest.txt" -$ResultCsvFile = "EndToEndScenarioTest.csv" - - -function Test-AzureBackupEndToEnd -{ - $FailFlag = 0; - $FailedAt = ""; - - Try - { - $startTime = Get-Date -format G; - New-AzureResourceGroup -Name $ResourceGroupName -Location $Location -Force; - $endTime = Get-Date -format G; - "New-AzureResourceGroup", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; - } - Catch - { - $endTime = Get-Date -format G; - "New-AzureResourceGroup", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; - $FailFlag = 1; - $FailedAt = $FailedAt + ("New-AzureResourceGroup : " + $_); - } - - Try - { - $startTime = Get-Date -format G; - New-AzureRmBackupVault -ResourceGroupName $ResourceGroupName -Name $ResourceName -Region $Location; - $endTime = Get-Date -format G; - "New-AzureRmBackupVault", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; - } - Catch - { - $endTime = Get-Date -format G; - "New-AzureRmBackupVault", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; - $FailFlag = 1; - $FailedAt = $FailedAt + ("New-AzureRmBackupVault : " + $_); - } - - Try - { - $startTime = Get-Date -format G; - $vault = Get-AzureRmBackupVault -Name $ResourceName; - $endTime = Get-Date -format G; - "Get-AzureRmBackupVault", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; - } - Catch - { - $endTime = Get-Date -format G; - "Get-AzureRmBackupVault", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; - $FailFlag = 1; - $FailedAt = $FailedAt + ("Get-AzureRmBackupVault : " + $_); - } - - Try - { - $startTime = Get-Date -format G; - $Job = Register-AzureRmBackupContainer -Vault $vault -Name $VirtualMachineName -ServiceName $VirtualMachineName; - Wait-AzureRmBackupJob -Job $Job; - $JobDetails = Get-AzureRmBackupJobDetails -Vault $vault -JobId $Job.InstanceId; - Assert-AreEqual $JobDetails.Status "Completed"; - $endTime = Get-Date -format G; - "Register-AzureRmBackupContainer", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; - } - Catch - { - $endTime = Get-Date -format G; - "Register-AzureRmBackupContainer", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; - $FailFlag = 1; - $FailedAt = $FailedAt + ("Register-AzureRmBackupContainer : " + $_); - } - - Try - { - $startTime = Get-Date -format G; - $r1 = New-AzureRmBackupRetentionPolicyObject -DailyRetention -Retention 20; - $r2 = New-AzureRmBackupRetentionPolicyObject -WeeklyRetention -DaysOfWeek "Monday" -Retention 10; - $r3 = New-AzureRmBackupRetentionPolicyObject -MonthlyRetentionInDailyFormat -DaysOfMonth "10" -Retention 10; - $r = ($r1, $r2, $r3); - $backupTime = (Get-Date("17 August 2015 15:30:00")).ToUniversalTime(); - $protectionpolicy = New-AzureRmBackupProtectionPolicy -Vault $vault -Name $ProtectionPolicyName -Type "AzureVM" -Daily -BackupTime $backupTime -RetentionPolicy $r; - - Assert-AreEqual $protectionpolicy.Name $ProtectionPolicyName; - Assert-AreEqual $protectionpolicy.Type "AzureVM"; - Assert-AreEqual $protectionpolicy.ScheduleType "Daily"; - Assert-AreEqual $protectionpolicy.RetentionPolicy.Count 3; - Assert-AreEqual $protectionpolicy.ResourceGroupName $ResourceGroupName; - Assert-AreEqual $protectionpolicy.ResourceName $ResourceName; - Assert-AreEqual $protectionpolicy.Location $Location; - $endTime = Get-Date -format G; - "New-AzureRmBackupProtectionPolicy", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; - } - Catch - { - $endTime = Get-Date -format G; - "New-AzureRmBackupProtectionPolicy", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; - $FailFlag = 1; - $FailedAt = $FailedAt + ("New-AzureRmBackupProtectionPolicy : " + $_); - } - - Try - { - $startTime = Get-Date -format G; - $container = Get-AzureRmBackupContainer -Vault $vault -Name $VirtualMachineName -Type "AzureVM"; - Assert-AreEqual $container.ContainerType "AzureVM"; - Assert-AreEqual $container.ContainerUniqueName.Contains("iaasvmcontainer") "True"; - Assert-AreEqual $container.ContainerUniqueName.Contains($VirtualMachineName) "True"; - Assert-AreEqual $container.Status "Registered"; - Assert-AreEqual $container.ResourceGroupName $ResourceGroupName; - Assert-AreEqual $container.ResourceName $ResourceName; - Assert-AreEqual $container.Location $Location; - $endTime = Get-Date -format G; - "Get-AzureRmBackupContainer", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; - } - Catch - { - $endTime = Get-Date -format G; - "Get-AzureRmBackupContainer", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; - $FailFlag = 1; - $FailedAt = $FailedAt + ("Get-AzureRmBackupContainer : " + $_); - } - - Try - { - $startTime = Get-Date -format G; - $Job = Enable-AzureRmBackupProtection -Item $container[0] -Policy $protectionpolicy[0]; - Wait-AzureRmBackupJob -Job $Job; - $JobDetails = Get-AzureRmBackupJobDetails -Vault $vault -JobID $Job.InstanceId; - Assert-AreEqual $JobDetails.Operation "ConfigureBackup"; - Assert-AreEqual $JobDetails.Status "Completed"; - Assert-AreEqual $JobDetails.WorkloadName $VirtualMachineName; - Assert-AreEqual $JobDetails.Properties.Values.Contains($VirtualMachineName) "True"; - Assert-AreEqual $JobDetails.Properties.Values.Contains($ProtectionPolicyName) "True"; - Assert-AreEqual $JobDetails.ResourceGroupName $ResourceGroupName; - Assert-AreEqual $JobDetails.ResourceName $ResourceName; - Assert-AreEqual $JobDetails.Location $Location; - $endTime = Get-Date -format G; - "Enable-AzureRmBackupProtection", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; - } - Catch - { - $endTime = Get-Date -format G; - "Enable-AzureRmBackupProtection", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; - $FailFlag = 1; - $FailedAt = $FailedAt + ("Enable-AzureRmBackupProtection : " + $_); - } - - Try - { - $startTime = Get-Date -format G; - $item = Get-AzureRmBackupItem -Container $container[0]; - Assert-AreEqual $item.ProtectionStatus "Protected"; - Assert-AreEqual $item.DataSourceStatus "IRPending"; - Assert-AreEqual $item.ProtectionPolicyName $ProtectionPolicyName; - Assert-AreEqual $item.ContainerType "AzureVM"; - Assert-NotNull $item.Type; - Assert-AreEqual $item.ItemName.Contains("iaasvmcontainer") "True"; - Assert-AreEqual $item.ItemName.Contains($VirtualMachineName) "True"; - Assert-AreEqual $item.ResourceGroupName $ResourceGroupName; - Assert-AreEqual $item.ResourceName $ResourceName; - Assert-AreEqual $item.Location $Location; - $endTime = Get-Date -format G; - "Get-AzureRmBackupItem", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; - } - Catch - { - $endTime = Get-Date -format G; - "Get-AzureRmBackupItem", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; - $FailFlag = 1; - $FailedAt = $FailedAt + ("Get-AzureRmBackupItem : " + $_); - } - - Try - { - $startTime = Get-Date -format G; - $Job = Backup-AzureRmBackupItem -Item $item[0]; - Wait-AzureRmBackupJob -Job $Job; - $JobDetails = Get-AzureRmBackupJobDetails -Vault $vault -JobID $Job.InstanceId; - Assert-AreEqual $JobDetails.Operation "Backup"; - Assert-AreEqual $JobDetails.Status "Completed"; - Assert-NotNull $JobDetails.WorkloadType; - Assert-AreEqual $JobDetails.WorkloadName $VirtualMachineName; - Assert-AreEqual $JobDetails.Properties.Values.Contains($VirtualMachineName) "True"; - Assert-AreEqual $JobDetails.ResourceGroupName $ResourceGroupName; - Assert-AreEqual $JobDetails.ResourceName $ResourceName; - Assert-AreEqual $JobDetails.Location $Location; - $endTime = Get-Date -format G; - "Backup-AzureRmBackupItem", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; - } - Catch - { - $endTime = Get-Date -format G; - "Backup-AzureRmBackupItem", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; - $FailFlag = 1; - $FailedAt = $FailedAt + ("Backup-AzureRmBackupItem : " + $_); - } - - Try - { - $startTime = Get-Date -format G; - $item = Get-AzureRmBackupItem -Container $container[0]; - Assert-AreEqual $item.ProtectionStatus "Protected"; - Assert-AreEqual $item.DataSourceStatus "Protected"; - Assert-AreEqual $item.ProtectionPolicyName $ProtectionPolicyName; - Assert-AreEqual $item.RecoveryPointsCount "1"; - Assert-AreEqual $item.ResourceGroupName $ResourceGroupName; - Assert-AreEqual $item.ResourceName $ResourceName; - Assert-AreEqual $item.Location $Location; - $endTime = Get-Date -format G; - "Get-AzureRmBackupItemPostBackup", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; - } - Catch - { - $endTime = Get-Date -format G; - "Get-AzureRmBackupItemPostBackup", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; - $FailFlag = 1; - $FailedAt = $FailedAt + ("Get-AzureRmBackupItemPostBackup : " + $_); - } - - Try - { - $startTime = Get-Date -format G; - $recoveryPoints = Get-AzureRmBackupRecoveryPoint -Item $item[0]; - Assert-NotNull $recoveryPoints.RecoveryPointTime; - Assert-NotNull $recoveryPoints.RecoveryPointName; - # Assert-AreEqual $recoveryPoints.RecoveryPointType "FileSystemConsistent"; - Assert-AreEqual $recoveryPoints.ContainerType "AzureVM"; - Assert-AreEqual $recoveryPoints.ItemName.Contains($VirtualMachineName) "True"; - Assert-AreEqual $recoveryPoints.ItemName.Contains("iaasvmcontainer") "True"; - $endTime = Get-Date -format G; - "Get-AzureRmBackupRecoveryPoint", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; - } - Catch - { - $endTime = Get-Date -format G; - "Get-AzureRmBackupRecoveryPoint", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; - $FailFlag = 1; - $FailedAt = $FailedAt + ("Get-AzureRmBackupRecoveryPoint : " + $_); - } - - Try - { - $startTime = Get-Date -format G; - $Job = Restore-AzureRmBackupItem -RecoveryPoint $recoveryPoints -StorageAccountName $RestoreStorageAccount; - Wait-AzureRmBackupJob -Job $Job; - $JobDetails = Get-AzureRmBackupJobDetails -Vault $vault -JobID $Job.InstanceId; - Assert-AreEqual $JobDetails.Operation "Restore"; - Assert-AreEqual $JobDetails.Status "Completed"; - Assert-NotNull $JobDetails.WorkloadType; - Assert-AreEqual $JobDetails.WorkloadName $VirtualMachineName; - Assert-AreEqual $JobDetails.Properties.Values.Contains($RestoreStorageAccount) "True"; - Assert-AreEqual $JobDetails.Properties.Values.Contains("Recover disks") "True"; - Assert-AreEqual $JobDetails.ResourceGroupName $ResourceGroupName; - Assert-AreEqual $JobDetails.ResourceName $ResourceName; - Assert-AreEqual $JobDetails.Location $Location; - $endTime = Get-Date -format G; - "Restore-AzureRmBackupItem", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; - } - Catch - { - $endTime = Get-Date -format G; - "Restore-AzureRmBackupItem", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; - $FailFlag = 1; - $FailedAt = $FailedAt + ("Restore-AzureRmBackupItem : " + $_); - } - - Try - { - $startTime = Get-Date -format G; - $Job = Disable-AzureRmBackupProtection -RemoveRecoveryPoints -Item $item[0] -Force; - Wait-AzureRmBackupJob -Job $Job; - $JobDetails = Get-AzureRmBackupJobDetails -Vault $vault -JobID $Job.InstanceId; - Assert-AreEqual $JobDetails.Operation "Unprotect"; - Assert-AreEqual $JobDetails.Status "Completed"; - Assert-AreEqual $JobDetails.WorkloadName $VirtualMachineName; - Assert-AreEqual $JobDetails.Properties.Values.Contains($VirtualMachineName) "True"; - Assert-AreEqual $JobDetails.Properties.Keys.Contains("Delete Backup Data") "True"; - Assert-AreEqual $JobDetails.ResourceGroupName $ResourceGroupName; - Assert-AreEqual $JobDetails.ResourceName $ResourceName; - Assert-AreEqual $JobDetails.Location $Location; - $endTime = Get-Date -format G; - "Disable-AzureRmBackupProtection", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; - } - Catch - { - $endTime = Get-Date -format G; - "Disable-AzureRmBackupProtection", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; - $FailFlag = 1; - $FailedAt = $FailedAt + ("Disable-AzureRmBackupProtection : " + $_); - } - - Try - { - $startTime = Get-Date -format G; - $Job = Unregister-AzureRmBackupContainer -Container $container[0]; - Wait-AzureRmBackupJob -Job $Job; - $JobDetails = Get-AzureRmBackupJobDetails -Vault $vault -JobId $Job.InstanceId; - Assert-AreEqual $JobDetails.Operation "UnRegister"; - Assert-AreEqual $JobDetails.Status "Completed"; - Assert-AreEqual $JobDetails.WorkloadName $VirtualMachineName; - $endTime = Get-Date -format G; - "Unregister-AzureRmBackupContaine", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; - } - Catch - { - $endTime = Get-Date -format G; - "Unregister-AzureRmBackupContaine", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; - $FailFlag = 1; - $FailedAt = $FailedAt + ("Unregister-AzureRmBackupContaine : " + $_); - } - - Try - { - $startTime = Get-Date -format G; - Remove-AzureRmBackupProtectionPolicy -ProtectionPolicy $protectionpolicy -Force; - $endTime = Get-Date -format G; - "Remove-AzureRmBackupProtectionPolicy", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; - } - Catch - { - $endTime = Get-Date -format G; - "Remove-AzureRmBackupProtectionPolicy", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; - $FailFlag = 1; - $FailedAt = $FailedAt + ("Remove-AzureRmBackupProtectionPolicy : " + $_); - } - - Try - { - $startTime = Get-Date -format G; - Remove-AzureRmBackupVault -Vault $vault; - $deletedVault = Get-AzureRmBackupVault -Name $ResourceName; - Assert-Null $deletedVault; - $endTime = Get-Date -format G; - "Remove-AzureRmBackupVault", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; - } - Catch - { - $endTime = Get-Date -format G; - "Remove-AzureRmBackupVault", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; - $FailFlag = 1; - $FailedAt = $FailedAt + ("Remove-AzureRmBackupVault : " + $_); - } - - Try - { - $startTime = Get-Date -format G; - Remove-AzureResourceGroup -Name $ResourceGroupName -Force; - $endTime = Get-Date -format G; - "Remove-AzureResourceGroup", "Pass", $startTime, $endTime -join "," >> $ResultTxtFile; - } - Catch - { - $endTime = Get-Date -format G; - "Remove-AzureResourceGroup", "Fail", $startTime, $endTime -join "," >> $ResultTxtFile; - $FailFlag = 1; - $FailedAt = $FailedAt + ("Remove-AzureResourceGroup : " + $_); - } - - import-csv $ResultTxtFile -delimiter "," | export-csv $ResultCsvFile -NoTypeInformation; - - if ($FailFlag -eq 1) - { - throw $FailedAt; - } -} \ No newline at end of file From af0e6b621e0ec83ff54d5459894514b434b1c170 Mon Sep 17 00:00:00 2001 From: pragrawa Date: Thu, 24 Sep 2015 19:49:12 +0530 Subject: [PATCH 20/24] TestCases --- .../Commands.AzureBackup.Test.csproj | 6 +- .../AzureBackupItemTestCases.ps1 | 2 +- .../ScenarioTests/AzureBackupPolicyTests.ps1 | 2 +- .../DisableAzureBackupProtectionTest.json | 138 ++++++++---- .../EnableAzureBackupProtectionTest.json | 206 ++++++++++++------ .../ListAzureBackupItemTests.json | 52 ++--- .../ListProtectionPolicyByNameTests.json | 70 +++--- .../ListProtectionPolicyTests.json | 70 +++--- .../NewProtectionPolicyTests.json | 118 +++++----- .../RemoveProtectionPolicyTests.json | 118 +++++----- .../SetProtectionPolicyTests.json | 144 ++++++------ 11 files changed, 525 insertions(+), 401 deletions(-) diff --git a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/Commands.AzureBackup.Test.csproj b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/Commands.AzureBackup.Test.csproj index 0d7daab37859..550f54aafcd1 100644 --- a/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/Commands.AzureBackup.Test.csproj +++ b/src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/Commands.AzureBackup.Test.csproj @@ -130,7 +130,6 @@ - @@ -172,9 +171,6 @@ Always - - Always - Always @@ -259,7 +255,7 @@ - - + diff --git a/setup-powershellget/Setup/ShortcutStartup.ps1 b/setup-powershellget/Setup/ShortcutStartup.ps1 index 9ff5d31478bc..f50ca1a4bf9a 100644 --- a/setup-powershellget/Setup/ShortcutStartup.ps1 +++ b/setup-powershellget/Setup/ShortcutStartup.ps1 @@ -26,26 +26,19 @@ Finalizing installation of Azure PowerShell. Installing Azure Modules from PowerShell Gallery. This may take some time... "@ + $env:PSModulePath = "$env:HOME\Documents\WindowsPowerShell\Modules;$env:ProgramFiles\WindowsPowerShell\Modules;$env:SystemRoot\system32\WindowsPowerShell\v1.0\Modules\" + Import-Module PackageManagement $result = Get-PackageProvider -Name NuGet -ForceBootstrap Import-Module PowerShellGet - $NuGetPublishingSource = $env:NuGetPublishingSource - if ([string]::IsNullOrWhiteSpace($NuGetPublishingSource)) { - Install-Module Azure - Write-Output "Azure $((Get-InstalledModule -Name Azure)[0].Version) installed..." - Install-Module AzureRM - Write-Output "AzureRM $((Get-InstalledModule -Name AzureRM)[0].Version) installed..." - Update-AzureRM - } else { - Install-Module Azure -Repository $NuGetPublishingSource - Write-Output "Azure $((Get-InstalledModule -Name Azure)[0].Version) installed..." - Install-Module AzureRM -Repository $NuGetPublishingSource - Write-Output "AzureRM $((Get-InstalledModule -Name AzureRM)[0].Version) installed..." - Update-AzureRM -Repository $NuGetPublishingSource - } + Install-Module Azure + Write-Output "Azure $((Get-InstalledModule -Name Azure)[0].Version) installed..." + Install-Module AzureRM + Write-Output "AzureRM $((Get-InstalledModule -Name AzureRM)[0].Version) installed..." + Update-AzureRM } else { cd c:\ $welcomeMessage = @" diff --git a/tools/PublishModules.ps1 b/tools/PublishModules.ps1 index ef28708f0d1c..c6e74e4ac62a 100644 --- a/tools/PublishModules.ps1 +++ b/tools/PublishModules.ps1 @@ -15,28 +15,25 @@ param( [Parameter(Mandatory = $false, Position = 0)] [string] $buildConfig, - [Parameter(Mandatory = $false, Position = 1)] + [Parameter(Mandatory = $false, Position = 1)] [string] $apiKey, - [Parameter(Mandatory = $false, Position = 2)] - [string] $repository + [Parameter(Mandatory = $false, Position = 2)] + [string] $repositoryLocation ) if ([string]::IsNullOrEmpty($buildConfig)) { - Write-Verbose "Setting build configuration to 'Release'" - $buildConfig = 'Release' + Write-Verbose "Setting build configuration to 'Release'" + $buildConfig = "Release" } if ([string]::IsNullOrEmpty($repositoryLocation)) { - Write-Verbose "Setting repository location to 'https://dtlgalleryint.cloudapp.net/api/v2'" + Write-Verbose "Setting repository location to 'https://dtlgalleryint.cloudapp.net/api/v2'" - $repository = 'https://dtlgalleryint.cloudapp.net' + $repositoryLocation = "https://dtlgalleryint.cloudapp.net/api/v2" } -$repositoryLocation = '$repository/api/v2/' -$repositoryPackageLocation = '$repository/api/v2/package' - $packageFolder = "$PSScriptRoot\..\src\Package" @@ -45,7 +42,7 @@ if ($repo -ne $null) { $repoName = $repo.Name } else { $repoName = $(New-Guid).ToString() - Register-PSRepository -Name $repoName -SourceLocation $repositoryLocation -PublishLocation $repositoryPackageLocation -InstallationPolicy Trusted + Register-PSRepository -Name $repoName -SourceLocation $repositoryLocation -PublishLocation $repositoryLocation/package -InstallationPolicy Trusted } $modulePath = "$packageFolder\$buildConfig\ServiceManagement\Azure" # Publish Azure module @@ -64,10 +61,10 @@ Write-Host "Published AzureRM.Profile module" # Publish AzureRM modules $resourceManagerModules = Get-ChildItem -Path "$packageFolder\$buildConfig\ResourceManager\AzureResourceManager" -Directory foreach ($module in $resourceManagerModules) { - if ($module -ne "AzureRM.Profile") { - $modulePath = $module.FullName - Write-Host "Publishing $module module from $modulePath" + if ($module -ne "AzureRM.Profile") { + $modulePath = $module.FullName + Write-Host "Publishing $module module from $modulePath" Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName -Tags ("Azure", "AzureRM") - Write-Host "Published $module module" - } -} \ No newline at end of file + Write-Host "Published $module module" + } +} From 44704ab80a3935ab50f3d4d9f466be3a32e1c0d6 Mon Sep 17 00:00:00 2001 From: stankovski Date: Fri, 25 Sep 2015 11:34:28 -0700 Subject: [PATCH 24/24] Removed Install-Module Azure from the shortcut --- setup-powershellget/Setup/ShortcutStartup.ps1 | 5 +- tools/AzureRM/AzureRM.psm1 | 62 +++++++++---------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/setup-powershellget/Setup/ShortcutStartup.ps1 b/setup-powershellget/Setup/ShortcutStartup.ps1 index f50ca1a4bf9a..c8dafd9404e9 100644 --- a/setup-powershellget/Setup/ShortcutStartup.ps1 +++ b/setup-powershellget/Setup/ShortcutStartup.ps1 @@ -34,8 +34,6 @@ This may take some time... Import-Module PowerShellGet - Install-Module Azure - Write-Output "Azure $((Get-InstalledModule -Name Azure)[0].Version) installed..." Install-Module AzureRM Write-Output "AzureRM $((Get-InstalledModule -Name AzureRM)[0].Version) installed..." Update-AzureRM @@ -44,6 +42,9 @@ This may take some time... $welcomeMessage = @" For a list of all Azure cmdlets type 'help azure'. For a list of Azure Pack cmdlets type 'Get-Command *wapack*'. + +To use Azure Service Management cmdlets please execute the following cmdlet: + Install-Module Azure "@ Write-Output $welcomeMessage diff --git a/tools/AzureRM/AzureRM.psm1 b/tools/AzureRM/AzureRM.psm1 index 9b3e46003bad..5f14bb0197b2 100644 --- a/tools/AzureRM/AzureRM.psm1 +++ b/tools/AzureRM/AzureRM.psm1 @@ -1,29 +1,29 @@ -$AzureRMModules = ( - "Azure.Storage", - "AzureRM.ApiManagement", - "AzureRM.Automation", - "AzureRM.Backup", - "AzureRM.Batch", - "AzureRM.Compute", - "AzureRM.DataFactories", - "AzureRM.Dns", - "AzureRM.HDInsight", - "AzureRM.Insights", - "AzureRM.KeyVault", - "AzureRM.Network", - "AzureRM.OperationalInsights", - "AzureRM.Profile", - "AzureRM.RedisCache", - "AzureRM.Resources", - "AzureRM.SiteRecovery", - "AzureRM.Sql", - "AzureRM.Storage", - "AzureRM.StreamAnalytics", - "AzureRM.Tags", - "AzureRM.TrafficManager", - "AzureRM.UsageAggregates", - "AzureRM.Websites" -) +$AzureRMModules = @{ + "Azure.Storage" = "0.9.8"; + "AzureRM.ApiManagement" = "0.9.8"; + "AzureRM.Automation" = "0.9.8"; + "AzureRM.Backup" = "0.9.8"; + "AzureRM.Batch" = "0.9.8"; + "AzureRM.Compute" = "0.9.8"; + "AzureRM.DataFactories" = "0.9.8"; + "AzureRM.Dns" = "0.9.8"; + "AzureRM.HDInsight" = "0.9.8"; + "AzureRM.Insights" = "0.9.8"; + "AzureRM.KeyVault" = "0.9.8"; + "AzureRM.Network" = "0.9.8"; + "AzureRM.OperationalInsights" = "0.9.8"; + "AzureRM.Profile" = "0.9.8"; + "AzureRM.RedisCache" = "0.9.8"; + "AzureRM.Resources" = "0.9.8"; + "AzureRM.SiteRecovery" = "0.9.8"; + "AzureRM.Sql" = "0.9.8"; + "AzureRM.Storage" = "0.9.8"; + "AzureRM.StreamAnalytics" = "0.9.8"; + "AzureRM.Tags" = "0.9.8"; + "AzureRM.TrafficManager" = "0.9.8"; + "AzureRM.UsageAggregates" = "0.9.8"; + "AzureRM.Websites" = "0.9.8" +} <# .Synopsis @@ -41,12 +41,12 @@ $AzureRMModules = ( function Update-AzureRM { param( - [Parameter(Position=0, Mandatory = $false)] + [Parameter(Position=0; Mandatory = $false)] [string] - $Repository, + $Repository; - [Parameter(Position=1, Mandatory = $false)] - [ValidateSet("CurrentUser","AllUsers")] + [Parameter(Position=1; Mandatory = $false)] + [ValidateSet("CurrentUser";"AllUsers")] [string] $Scope) @@ -67,7 +67,7 @@ function Update-AzureRM } $v = (Get-InstalledModule -Name $args[0])[0].Version.ToString() Write-Output "$($args[0]) $v installed..." - } -ArgumentList $_, $Repository, $Scope } + } -ArgumentList $_; $Repository; $Scope } $AzureRMModules | ForEach {Get-Job -Name $_ | Wait-Job | Receive-Job } }