Skip to content

Commit 03248ab

Browse files
committed
Merge branch 'dev' into adit-branch
Conflicts: src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/Commands.AzureBackup.Test.csproj src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupTests.cs src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupTests.ps1
2 parents 81db5b2 + 9c9ba36 commit 03248ab

25 files changed

+735
-94
lines changed

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/App.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<appSettings>
4-
<add key="ResourceName" value="swatirn1" />
5-
<add key="ResourceGroupName" value="swatirg1" />
4+
<add key="ResourceName" value="backuprn" />
5+
<add key="ResourceGroupName" value="backuprg" />
66
<add key="ResourceId" value="7368183945769329045" />
77
<add key="ClientSettingsProvider.ServiceUri" value="" />
88
</appSettings>

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/Commands.AzureBackup.Test.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@
154154
<None Include="ScenarioTests\AzureBackupTests.ps1">
155155
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
156156
</None>
157+
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupTests\BackUpAzureBackUpItem.json" />
158+
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupTests\GetRecoveryPointTests.json" />
157159
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupTests\ListProtectionPolicyTests.json">
158160
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
159161
</None>

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public void ListProtectionPolicyTests()
2626
}
2727

2828
[Fact]
29+
2930
public void GetAzureBackupJobTests()
3031
{
3132
this.RunPowerShellTest("Test-GetAzureBackupJob");
@@ -36,5 +37,15 @@ public void StopAzureBackupJobTests()
3637
{
3738
this.RunPowerShellTest("Test-StopAzureBackupJob");
3839
}
40+
public void GetRecoveryPointTests()
41+
{
42+
this.RunPowerShellTest("GetAzureRecoveryPointTest");
43+
}
44+
45+
[Fact]
46+
public void BackUpAzureBackUpItem()
47+
{
48+
this.RunPowerShellTest("BackUpAzureBackUpItemTest");
49+
}
3950
}
4051
}

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupTests.ps1

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@
1212
# limitations under the License.
1313
# ----------------------------------------------------------------------------------
1414

15-
$ResourceGroupName = "swatirg";
16-
$ResourceName = "swatirn"
17-
$Location = "WestUS"
15+
$ResourceGroupName = "backuprg"
16+
$ResourceName = "backuprn"
17+
$ContainerName = "iaasvmcontainer;dev01testing;dev01testing"
18+
$ContainerType = "IaasVMContainer"
19+
$DataSourceType = "VM"
20+
$DataSourceId = "17593283453810"
21+
$Location = "SouthEast Asia"
1822

1923
<#
2024
.SYNOPSIS
@@ -37,6 +41,41 @@ function Test-GetAzureBackupProtectionPolicyTests
3741
}
3842
}
3943

44+
function GetAzureRecoveryPointTest
45+
{
46+
$azureBackUpItem = New-Object Microsoft.Azure.Commands.AzureBackup.Cmdlets.AzureBackupItem
47+
$azureBackUpItem.ResourceGroupName = $ResourceGroupName
48+
$azureBackUpItem.ResourceName = $ResourceGroupName
49+
$azureBackUpItem.Location = $Location
50+
$azureBackUpItem.ContainerUniqueName = $ContainerName
51+
$azureBackUpItem.ContainerType = $ContainerType
52+
$azureBackUpItem.DataSourceId = $DataSourceId
53+
$azureBackUpItem.Type = $DataSourceType
54+
$recoveryPoints = Get-AzureBackupRecoveryPoint -item $azureBackUpItem
55+
if (!($recoveryPoints -eq $null))
56+
{
57+
foreach($recoveryPoint in $recoveryPoints)
58+
{
59+
Assert-NotNull $recoveryPoint.RecoveryPointTime 'RecoveryPointTime should not be null'
60+
Assert-NotNull $recoveryPoint.RecoveryPointType 'RecoveryPointType should not be null'
61+
Assert-NotNull $recoveryPoint.RecoveryPointId 'RecoveryPointId should not be null'
62+
}
63+
}
64+
}
65+
66+
function BackUpAzureBackUpItemTest
67+
{
68+
$azureBackUpItem = New-Object Microsoft.Azure.Commands.AzureBackup.Cmdlets.AzureBackupItem
69+
$azureBackUpItem.ResourceGroupName = $ResourceGroupName
70+
$azureBackUpItem.ResourceName = $ResourceName
71+
$azureBackUpItem.Location = $Location
72+
$azureBackUpItem.ContainerUniqueName = $ContainerName
73+
$azureBackUpItem.ContainerType = $ContainerType
74+
$azureBackUpItem.DataSourceId = $DataSourceId
75+
$azureBackUpItem.Type = $DataSourceType
76+
$jobId = Backup-AzureBackupItem -item $azureBackUpItem
77+
}
78+
4079

4180
function Test-GetAzureBackupJob
4281
{
@@ -77,4 +116,4 @@ function Test-StopAzureBackupJob
77116
Stop-AzureBackupJob -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Job $jobsList[0];
78117
$jobDetails = Get-AzureBackupJobDetails -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Job $jobsList[0];
79118
#Assert-AreEqual 'Cancelling' $jobDetails.Status
80-
}
119+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"Entries": [
3+
{
4+
"RequestUri": "/Subscriptions/f5303a0b-fae4-4cdb-b44d-0e4c032dde26/resourceGroups/backuprg/providers/Microsoft.Backupseadev01/BackupVault/backuprn/containers/iaasvmcontainer%3Bdev01testing%3Bdev01testing/datasources/VM/17593283453810/backup?api-version=2014-09-01",
5+
"EncodedRequestUri": "L1N1YnNjcmlwdGlvbnMvZjUzMDNhMGItZmFlNC00Y2RiLWI0NGQtMGU0YzAzMmRkZTI2L3Jlc291cmNlR3JvdXBzL2JhY2t1cHJnL3Byb3ZpZGVycy9NaWNyb3NvZnQuQmFja3Vwc2VhZGV2MDEvQmFja3VwVmF1bHQvYmFja3Vwcm4vY29udGFpbmVycy9pYWFzdm1jb250YWluZXIlM0JkZXYwMXRlc3RpbmclM0JkZXYwMXRlc3RpbmcvZGF0YXNvdXJjZXMvVk0vMTc1OTMyODM0NTM4MTAvYmFja3VwP2FwaS12ZXJzaW9uPTIwMTQtMDktMDE=",
6+
"RequestMethod": "POST",
7+
"RequestBody": "",
8+
"RequestHeaders": {
9+
"Accept-Language": [
10+
"en-us"
11+
],
12+
"User-Agent": [
13+
"Microsoft.Azure.Management.BackupServices.BackupServicesManagementClient/0.0.0.0"
14+
]
15+
},
16+
"ResponseBody": "\"062c55cd-a201-4464-a628-4ee1cc20397a\"",
17+
"ResponseHeaders": {
18+
"Content-Length": [
19+
"38"
20+
],
21+
"Content-Type": [
22+
"application/json"
23+
],
24+
"Expires": [
25+
"-1"
26+
],
27+
"Pragma": [
28+
"no-cache"
29+
],
30+
"x-ms-request-id": [
31+
"7bd6b748-c6b1-4bf1-8583-841a4292e5aa"
32+
],
33+
"x-ms-client-request-id": [
34+
"76b831b2-0644-4703-becd-5831a9deae65",
35+
"76b831b2-0644-4703-becd-5831a9deae65"
36+
],
37+
"Strict-Transport-Security": [
38+
"max-age=31536000; includeSubDomains"
39+
],
40+
"x-ms-ratelimit-remaining-subscription-writes": [
41+
"1197"
42+
],
43+
"x-ms-correlation-request-id": [
44+
"7bd6b748-c6b1-4bf1-8583-841a4292e5aa"
45+
],
46+
"x-ms-routing-request-id": [
47+
"CENTRALUS:20150612T143521Z:7bd6b748-c6b1-4bf1-8583-841a4292e5aa"
48+
],
49+
"Cache-Control": [
50+
"no-cache"
51+
],
52+
"Date": [
53+
"Fri, 12 Jun 2015 14:35:21 GMT"
54+
],
55+
"Server": [
56+
"Microsoft-IIS/8.0"
57+
],
58+
"X-Powered-By": [
59+
"ASP.NET"
60+
]
61+
},
62+
"StatusCode": 202
63+
}
64+
],
65+
"Names": {},
66+
"Variables": {
67+
"SubscriptionId": "f5303a0b-fae4-4cdb-b44d-0e4c032dde26"
68+
}
69+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"Entries": [
3+
{
4+
"RequestUri": "/Subscriptions/f5303a0b-fae4-4cdb-b44d-0e4c032dde26/resourceGroups/backuprg/providers/Microsoft.Backupseadev01/BackupVault/backuprn/containers/iaasvmcontainer%3Bdev01testing%3Bdev01testing/datasources/VM/17593283453810/recoverypoints?api-version=2014-09-01",
5+
"EncodedRequestUri": "L1N1YnNjcmlwdGlvbnMvZjUzMDNhMGItZmFlNC00Y2RiLWI0NGQtMGU0YzAzMmRkZTI2L3Jlc291cmNlR3JvdXBzL2JhY2t1cHJnL3Byb3ZpZGVycy9NaWNyb3NvZnQuQmFja3Vwc2VhZGV2MDEvQmFja3VwVmF1bHQvYmFja3Vwcm4vY29udGFpbmVycy9pYWFzdm1jb250YWluZXIlM0JkZXYwMXRlc3RpbmclM0JkZXYwMXRlc3RpbmcvZGF0YXNvdXJjZXMvVk0vMTc1OTMyODM0NTM4MTAvcmVjb3Zlcnlwb2ludHM/YXBpLXZlcnNpb249MjAxNC0wOS0wMQ==",
6+
"RequestMethod": "GET",
7+
"RequestBody": "",
8+
"RequestHeaders": {
9+
"Accept-Language": [
10+
"en-us"
11+
],
12+
"User-Agent": [
13+
"Microsoft.Azure.Management.BackupServices.BackupServicesManagementClient/0.0.0.0"
14+
]
15+
},
16+
"ResponseBody": "{\r\n \"Objects\": [\r\n {\r\n \"RecoveryPointType\": \"AppConsistent\",\r\n \"RecoveryPointTime\": \"2015-06-11T10:52:30.0345282Z\",\r\n \"RecoveryPointAdditionalInfo\": \"\",\r\n \"InstanceId\": \"19591702463836\",\r\n \"Name\": null,\r\n \"OperationInProgress\": false\r\n },\r\n {\r\n \"RecoveryPointType\": \"AppConsistent\",\r\n \"RecoveryPointTime\": \"2015-06-12T06:05:46.9189974Z\",\r\n \"RecoveryPointAdditionalInfo\": \"\",\r\n \"InstanceId\": \"20483888156836\",\r\n \"Name\": null,\r\n \"OperationInProgress\": false\r\n },\r\n {\r\n \"RecoveryPointType\": \"AppConsistent\",\r\n \"RecoveryPointTime\": \"2015-06-12T05:49:51.2034409Z\",\r\n \"RecoveryPointAdditionalInfo\": \"\",\r\n \"InstanceId\": \"20920255378610\",\r\n \"Name\": null,\r\n \"OperationInProgress\": false\r\n },\r\n {\r\n \"RecoveryPointType\": \"AppConsistent\",\r\n \"RecoveryPointTime\": \"2015-06-12T06:24:33.0768703Z\",\r\n \"RecoveryPointAdditionalInfo\": \"\",\r\n \"InstanceId\": \"26453384139263\",\r\n \"Name\": null,\r\n \"OperationInProgress\": false\r\n },\r\n {\r\n \"RecoveryPointType\": \"AppConsistent\",\r\n \"RecoveryPointTime\": \"2015-06-11T14:41:46.0950893Z\",\r\n \"RecoveryPointAdditionalInfo\": \"\",\r\n \"InstanceId\": \"32528401668178\",\r\n \"Name\": null,\r\n \"OperationInProgress\": false\r\n }\r\n ],\r\n \"ResultCount\": 5,\r\n \"Skiptoken\": null\r\n}",
17+
"ResponseHeaders": {
18+
"Content-Length": [
19+
"1006"
20+
],
21+
"Content-Type": [
22+
"application/json"
23+
],
24+
"Expires": [
25+
"-1"
26+
],
27+
"Pragma": [
28+
"no-cache"
29+
],
30+
"x-ms-request-id": [
31+
"3e21bbb3-afb6-4d88-a2f7-4af14d817853"
32+
],
33+
"x-ms-client-request-id": [
34+
"0762a614-5fd9-468c-97f1-f0742060deef",
35+
"0762a614-5fd9-468c-97f1-f0742060deef"
36+
],
37+
"Strict-Transport-Security": [
38+
"max-age=31536000; includeSubDomains"
39+
],
40+
"x-ms-ratelimit-remaining-subscription-reads": [
41+
"14996"
42+
],
43+
"x-ms-correlation-request-id": [
44+
"3e21bbb3-afb6-4d88-a2f7-4af14d817853"
45+
],
46+
"x-ms-routing-request-id": [
47+
"CENTRALUS:20150612T133209Z:3e21bbb3-afb6-4d88-a2f7-4af14d817853"
48+
],
49+
"Cache-Control": [
50+
"no-cache"
51+
],
52+
"Date": [
53+
"Fri, 12 Jun 2015 13:32:08 GMT"
54+
],
55+
"Server": [
56+
"Microsoft-IIS/8.0"
57+
],
58+
"X-Powered-By": [
59+
"ASP.NET"
60+
]
61+
},
62+
"StatusCode": 200
63+
}
64+
],
65+
"Names": {},
66+
"Variables": {
67+
"SubscriptionId": "f5303a0b-fae4-4cdb-b44d-0e4c032dde26"
68+
}
69+
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupCmdletHelpMessage.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,13 @@ internal static class AzureBackupCmdletHelpMessage
6262
public const string RemoveProtectionOption = "Remove Protection Option";
6363
public const string Reason = "Reson for removing protection";
6464
public const string Comments = "Comments for for removing protection";
65+
public const string WorkloadType = "Workload type for which the policy is defined.";
66+
public const string BackupType = "Type of backup.";
67+
public const string ScheduleType = "Type of schedule.";
68+
public const string ScheduleRunDays = "Days of week for running backup, required for weekly schedule.";
69+
public const string ScheduleRunTimes = "Times of day for running backup.";
70+
public const string RetentionType = "Unit of retention for the recovery point.";
71+
public const string RententionDuration = "Duration of retention for the recovery point in units specified by RetentionType.";
72+
public const string PolicyInstanceId = "ProtectionPolicy InstanceId";
6573
}
6674
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupContainerCmdletBase.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
2828
{
2929
public abstract class AzureBackupContainerCmdletBase : AzureBackupCmdletBase
3030
{
31-
[Parameter(Position = 0, Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.AzureBackupContainer, ValueFromPipelineByPropertyName = true)]
31+
[Parameter(Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.AzureBackupContainer, ValueFromPipeline = true)]
3232
[ValidateNotNullOrEmpty]
33-
public AzureBackupContainer AzureBackupContainer { get; set; }
33+
public AzureBackupContainer container { get; set; }
3434

3535
public override void ExecuteCmdlet()
3636
{
3737
base.ExecuteCmdlet();
3838

39-
WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}, Location: {2}", AzureBackupContainer.ResourceGroupName, AzureBackupContainer.ResourceName, AzureBackupContainer.Location));
39+
WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}, Location: {2}", container.ResourceGroupName, container.ResourceName, container.Location));
4040

41-
InitializeAzureBackupCmdlet(AzureBackupContainer.ResourceGroupName, AzureBackupContainer.ResourceName, AzureBackupContainer.Location);
41+
InitializeAzureBackupCmdlet(container.ResourceGroupName, container.ResourceName, container.Location);
4242
}
4343
}
4444
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupDSCmdletBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public abstract class AzureBackupDSCmdletBase : AzureBackupCmdletBase
3030
{
3131
// ToDO:
3232
// Correct Help message and other attributes related to paameters
33-
[Parameter(Position = 0, Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.AzureBackUpItem, ValueFromPipelineByPropertyName = true)]
33+
[Parameter(Position = 0, Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.AzureBackUpItem, ValueFromPipeline = true)]
3434
[ValidateNotNullOrEmpty]
3535
public AzureBackupItem item { get; set; }
3636

src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupItemCmdletBase.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ public abstract class AzureBackupItemCmdletBase : AzureBackupCmdletBase
3030
{
3131
// ToDO:
3232
// Correct Help message and other attributes related to paameters
33-
[Parameter(Position = 0, Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.AzureBackupItem, ValueFromPipelineByPropertyName = true)]
33+
[Parameter(Position = 0, Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.AzureBackupItem, ValueFromPipeline = true)]
3434
[ValidateNotNullOrEmpty]
35-
public AzureBackupContainerContextObject Item { get; set; }
35+
public AzureBackupContainerContextObject item { get; set; }
3636

3737
public override void ExecuteCmdlet()
3838
{
3939
base.ExecuteCmdlet();
40-
WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}, Location: {2}", Item.ResourceGroupName, Item.ResourceName, Item.Location));
41-
InitializeAzureBackupCmdlet(Item.ResourceGroupName, Item.ResourceName, Item.Location);
40+
WriteDebug(String.Format("Cmdlet called for ResourceGroupName: {0}, ResourceName: {1}, Location: {2}", item.ResourceGroupName, item.ResourceName, item.Location));
41+
InitializeAzureBackupCmdlet(item.ResourceGroupName, item.ResourceName, item.Location);
4242
}
4343
}
4444
}

0 commit comments

Comments
 (0)