Skip to content

Commit dfe35d8

Browse files
committed
Merge pull request #83 from MabOneSdk/csmpanbhadev1
Csmpanbhadev1
2 parents 5166435 + 6a503e9 commit dfe35d8

File tree

9 files changed

+133
-10
lines changed

9 files changed

+133
-10
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136
</Compile>
137137
<Compile Include="ScenarioTests\BackupItemTests.cs" />
138138
<Compile Include="ScenarioTests\RecoveryPointTests.cs" />
139+
<Compile Include="ScenarioTests\RestoreItemTests.cs" />
139140
</ItemGroup>
140141
<ItemGroup>
141142
<ProjectReference Include="..\..\..\Common\Commands.Common\Commands.Common.csproj">
@@ -173,6 +174,7 @@
173174
</None>
174175
<None Include="ScenarioTests\BackupItemTests.ps1" />
175176
<None Include="ScenarioTests\RecoveryPointTests.ps1" />
177+
<None Include="ScenarioTests\RestoreItemTests.ps1" />
176178
<None Include="SessionRecords\Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests.AzureBackupContainerTests\AzureBackupMarsContainerScenarioTests.json">
177179
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
178180
</None>

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ $Location = "SouthEast Asia"
88
$PolicyName = "Policy9";
99
$PolicyId = "c87bbada-6e1b-4db2-b76c-9062d28959a4";
1010
$POName = "iaasvmcontainer;dev01testing;dev01testing"
11+
$ItemName = "iaasvmcontainer;dev01testing;dev01testing"
1112

1213

1314
function Test-BackUpAzureBackUpItem
@@ -17,8 +18,6 @@ function Test-BackUpAzureBackUpItem
1718
$azureBackUpItem.ResourceName = $ResourceName
1819
$azureBackUpItem.Location = $Location
1920
$azureBackUpItem.ContainerUniqueName = $ContainerName
20-
$azureBackUpItem.ContainerType = $ContainerType
21-
$azureBackUpItem.DataSourceId = $DataSourceId
22-
$azureBackUpItem.Type = $DataSourceType
21+
$azureBackUpItem.ItemName = $ItemName
2322
$jobId = Backup-AzureBackupItem -Item $azureBackUpItem
2423
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ namespace Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests
1919
{
2020
public class RecoveryPointTests : AzureBackupTestsBase
2121
{
22+
[Fact]
23+
public void GetRecoveryPointsTests()
24+
{
25+
this.RunPowerShellTest("Test-GetAzureRecoveryPoints");
26+
}
27+
2228
[Fact]
2329
public void GetRecoveryPointTests()
2430
{

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

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ $Location = "SouthEast Asia"
88
$PolicyName = "Policy9";
99
$PolicyId = "c87bbada-6e1b-4db2-b76c-9062d28959a4";
1010
$POName = "iaasvmcontainer;dev01testing;dev01testing"
11+
$ItemName = "iaasvmcontainer;dev01testing;dev01testing"
12+
$RecoveryPointName = "12520735098347"
1113

1214

13-
function Test-GetAzureRecoveryPoint
15+
function Test-GetAzureRecoveryPoints
1416
{
1517
$azureBackUpItem = New-Object Microsoft.Azure.Commands.AzureBackup.Models.AzureBackupItem
1618
$azureBackUpItem.ResourceGroupName = $ResourceGroupName
1719
$azureBackUpItem.ResourceName = $ResourceGroupName
1820
$azureBackUpItem.Location = $Location
1921
$azureBackUpItem.ContainerUniqueName = $ContainerName
20-
$azureBackUpItem.ContainerType = $ContainerType
21-
$azureBackUpItem.DataSourceId = $DataSourceId
22-
$azureBackUpItem.Type = $DataSourceType
22+
$azureBackUpItem.ItemName = $ItemName
2323
$recoveryPoints = Get-AzureBackupRecoveryPoint -Item $azureBackUpItem
2424
if (!($recoveryPoints -eq $null))
2525
{
@@ -30,4 +30,21 @@ function Test-GetAzureRecoveryPoint
3030
Assert-NotNull $recoveryPoint.RecoveryPointId 'RecoveryPointId should not be null'
3131
}
3232
}
33+
}
34+
35+
function Test-GetAzureRecoveryPoint
36+
{
37+
$azureBackUpItem = New-Object Microsoft.Azure.Commands.AzureBackup.Models.AzureBackupItem
38+
$azureBackUpItem.ResourceGroupName = $ResourceGroupName
39+
$azureBackUpItem.ResourceName = $ResourceGroupName
40+
$azureBackUpItem.Location = $Location
41+
$azureBackUpItem.ContainerUniqueName = $ContainerName
42+
$azureBackUpItem.ItemName = $ItemName
43+
$recoveryPoint = Get-AzureBackupRecoveryPoint -Item $azureBackUpItem -Id $RecoveryPointName
44+
if (!($recoveryPoint -eq $null))
45+
{
46+
Assert-NotNull $recoveryPoint.RecoveryPointTime 'RecoveryPointTime should not be null'
47+
Assert-NotNull $recoveryPoint.RecoveryPointType 'RecoveryPointType should not be null'
48+
Assert-NotNull $recoveryPoint.RecoveryPointId 'RecoveryPointId should not be null'
49+
}
3350
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
16+
using Xunit;
17+
18+
namespace Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests
19+
{
20+
public class RestoreItemTests : AzureBackupTestsBase
21+
{
22+
[Fact]
23+
public void RestoreAzureBackUpItem()
24+
{
25+
this.RunPowerShellTest("Test-RestoreAzureBackUpItem");
26+
}
27+
}
28+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
$ResourceGroupName = "backuprg"
2+
$ResourceName = "backuprn"
3+
$ContainerName = "iaasvmcontainer;dev01testing;dev01testing"
4+
$ContainerType = "IaasVMContainer"
5+
$DataSourceType = "VM"
6+
$DataSourceId = "17593283453810"
7+
$Location = "southeastasia"
8+
$PolicyName = "Policy9";
9+
$PolicyId = "c87bbada-6e1b-4db2-b76c-9062d28959a4";
10+
$POName = "iaasvmcontainer;dev01testing;dev01testing"
11+
$ItemName = "iaasvmcontainer;dev01testing;dev01testing"
12+
$RecoveryPointName = "12520735098347"
13+
$StorageAccountName = "portalvhds7jzk3jty85qx5"
14+
15+
16+
function Test-RestoreAzureBackUpItem
17+
{
18+
$azureBackUpRecoveryPoint = New-Object Microsoft.Azure.Commands.AzureBackup.Models.AzureBackupRecoveryPoint
19+
$azureBackUpRecoveryPoint.ResourceGroupName = $ResourceGroupName
20+
$azureBackUpRecoveryPoint.ResourceName = $ResourceName
21+
$azureBackUpRecoveryPoint.Location = $Location
22+
$azureBackUpRecoveryPoint.ContainerUniqueName = $ContainerName
23+
$azureBackUpRecoveryPoint.ItemName = $ItemName
24+
$azureBackUpRecoveryPoint.RecoveryPointName = $RecoveryPointName
25+
$jobId = Restore-AzureBackupItem -RecoveryPoint $azureBackUpRecoveryPoint -StorageAccountName $StorageAccountName
26+
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Backup/TriggerBackUp.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public override void ExecuteCmdlet()
4040

4141
WriteDebug(string.Format("Triggered backup. Converting response {0}", operationId));
4242

43-
//var operationStatus = TrackOperation(operationId);
44-
//WriteObject(GetCreatedJobs(new Models.AzurePSBackupVault(Item.ResourceGroupName, Item.ResourceName, Item.Location), operationStatus.JobList).FirstOrDefault());
43+
var operationStatus = TrackOperation(operationId);
44+
WriteObject(GetCreatedJobs(new Models.AzurePSBackupVault(Item.ResourceGroupName, Item.ResourceName, Item.Location), operationStatus.JobList).FirstOrDefault());
4545
});
4646
}
4747
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Restore/TriggerRestore.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@
2020
using Microsoft.Azure.Management.BackupServices.Models;
2121
using MBS = Microsoft.Azure.Management.BackupServices;
2222
using System.Web.Script.Serialization;
23+
using Microsoft.Azure.Commands.AzureBackup.Models;
2324

2425
namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
2526
{
2627
/// <summary>
2728
/// Trigger Restore Job
2829
/// </summary>
29-
[Cmdlet(VerbsData.Restore, "AzureBackupItem"), OutputType(typeof(Guid))]
30+
[Cmdlet(VerbsData.Restore, "AzureBackupItem"), OutputType(typeof(AzureBackupJob))]
3031
public class RestoreAzureBackup : AzureBackupRestoreBase
3132
{
3233
[Parameter(Position = 1, Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.StorageAccountName)]

src/ResourceManager/AzureBackup/Commands.AzureBackup/Microsoft.Azure.Commands.AzureBackup.format.ps1xml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,49 @@
7575
</TableRowEntries>
7676
</TableControl>
7777
</View>
78+
<View>
79+
<Name>Microsoft.Azure.Commands.AzureBackup.Models.AzureBackupRecoveryPoint</Name>
80+
<ViewSelectedBy>
81+
<TypeName>Microsoft.Azure.Commands.AzureBackup.Models.AzureBackupRecoveryPoint</TypeName>
82+
</ViewSelectedBy>
83+
<TableControl>
84+
<TableHeaders>
85+
<TableColumnHeader>
86+
<Label>RecoveryPointId</Label>
87+
<Width>18</Width>
88+
</TableColumnHeader>
89+
<TableColumnHeader>
90+
<Label>RecoveryPointType</Label>
91+
<Width>18</Width>
92+
</TableColumnHeader>
93+
<TableColumnHeader>
94+
<Label>RecoveryPointTime</Label>
95+
<Width>22</Width>
96+
</TableColumnHeader>
97+
<TableColumnHeader>
98+
<Label>ContainerName</Label>
99+
<Width>36</Width>
100+
</TableColumnHeader>
101+
</TableHeaders>
102+
<TableRowEntries>
103+
<TableRowEntry>
104+
<TableColumnItems>
105+
<TableColumnItem>
106+
<PropertyName>RecoveryPointName</PropertyName>
107+
</TableColumnItem>
108+
<TableColumnItem>
109+
<PropertyName>RecoveryPointType</PropertyName>
110+
</TableColumnItem>
111+
<TableColumnItem>
112+
<PropertyName>RecoveryPointTime</PropertyName>
113+
</TableColumnItem>
114+
<TableColumnItem>
115+
<PropertyName>ContainerUniqueName</PropertyName>
116+
</TableColumnItem>
117+
</TableColumnItems>
118+
</TableRowEntry>
119+
</TableRowEntries>
120+
</TableControl>
121+
</View>
78122
</ViewDefinitions>
79123
</Configuration>

0 commit comments

Comments
 (0)