Skip to content

Commit 83131be

Browse files
committed
enable protection
enable protection 14/8 updated trigger discovery file->files added tracker for enquiry added tracking for register container minor changes fix for classic storage accounts rebase changes rebase changes addressed comments used storageaccountRg instead of Rg blank lines added to file share provider removed storageaccountresourcegroupname dependancy resolved issues during rebase resolved issues during rebase rebase changes Review comments
1 parent 9b6f41f commit 83131be

File tree

15 files changed

+412
-135
lines changed

15 files changed

+412
-135
lines changed

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Backup.Helpers/TrackingHelpers.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,34 @@ public static RestAzureNS.AzureOperationResponse GetOperationResult(
110110
return opStatusResponse;
111111
}
112112

113+
/// <summary>
114+
/// Block to track the operation to completion.
115+
/// Waits till the HTTP status code of the operation becomes something other than Accepted.
116+
/// </summary>
117+
/// <param name="response">Response of the operation returned by the service.</param>
118+
/// <param name="getOpStatus">Delegate method to fetch the operation status of the operation.</param>
119+
/// <returns>Result of the operation once it completes.</returns>
120+
public static RestAzureNS.AzureOperationResponse<T> GetOperationResult<T>(
121+
RestAzureNS.AzureOperationResponse<T> response,
122+
Func<string, RestAzureNS.AzureOperationResponse<T>> getOpStatus)
123+
where T: ServiceClientModel.ProtectionContainerResource
124+
{
125+
var operationId = response.Response.Headers.GetOperationResultId();
126+
127+
var opStatusResponse = getOpStatus(operationId);
128+
129+
while (opStatusResponse.Response.StatusCode == SystemNet.HttpStatusCode.Accepted)
130+
{
131+
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);
132+
133+
opStatusResponse = getOpStatus(operationId);
134+
}
135+
136+
opStatusResponse = getOpStatus(operationId);
137+
138+
return opStatusResponse;
139+
}
140+
113141
/// <summary>
114142
/// Retries request to URL for specified no. of tries in case of failure
115143
/// </summary>

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Backup.Models/AzureFileShareModels/AzureFileShareItem.cs

Lines changed: 7 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,14 @@
1818
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
1919
{
2020
/// <summary>
21-
/// Azure File Share Item Class
21+
/// Azure files Item Class
2222
/// </summary>
23-
public class AzureFileShareItem : ItemBase
23+
public class AzureFileShareItem : AzureItem
2424
{
2525
/// <summary>
26-
/// Protection Status of the item
26+
/// Container id of item
2727
/// </summary>
28-
public ItemProtectionStatus ProtectionStatus { get; set; }
29-
30-
/// <summary>
31-
/// Protection State of the item
32-
/// </summary>
33-
public ItemProtectionState ProtectionState { get; set; }
34-
35-
/// <summary>
36-
/// Last Backup Status for the item
37-
/// </summary>
38-
public string LastBackupStatus { get; set; }
39-
40-
/// <summary>
41-
/// Last Backup Time for the item
42-
/// </summary>
43-
public DateTime? LastBackupTime { get; set; }
44-
45-
/// <summary>
46-
/// Protection Policy Name for the Item
47-
/// </summary>
48-
public string ProtectionPolicyName { get; set; }
49-
50-
/// <summary>
51-
/// ExtendedInfo for the Item
52-
/// </summary
53-
public AzureFileShareItemExtendedInfo ExtendedInfo { get; set; }
28+
public string ParentContainerFabricId { get; set; }
5429

5530
/// <summary>
5631
/// Constructor. Takes the service client object representing the protected item
@@ -62,12 +37,11 @@ public class AzureFileShareItem : ItemBase
6237
/// <param name="policyName">Name of the protection policy associated with this protected item</param>
6338
public AzureFileShareItem(ProtectedItemResource protectedItemResource,
6439
string containerName, ContainerType containerType, string policyName)
65-
: base(protectedItemResource, containerName, containerType)
40+
: base(protectedItemResource, containerName, containerType, policyName)
6641
{
6742
AzureFileshareProtectedItem protectedItem = (AzureFileshareProtectedItem)protectedItemResource.Properties;
6843
LastBackupStatus = protectedItem.LastBackupStatus;
6944
LastBackupTime = protectedItem.LastBackupTime;
70-
ProtectionPolicyName = policyName;
7145
ProtectionState =
7246
EnumUtils.GetEnum<ItemProtectionState>(protectedItem.ProtectionState.ToString());
7347
ProtectionStatus = EnumUtils.GetEnum<ItemProtectionStatus>(protectedItem.ProtectionStatus);
@@ -77,21 +51,6 @@ public AzureFileShareItem(ProtectedItemResource protectedItemResource,
7751
/// <summary>
7852
/// Azure File Share Item ExtendedInfo Class
7953
/// </summary>
80-
public class AzureFileShareItemExtendedInfo : ItemExtendedInfoBase
81-
{
82-
/// <summary>
83-
/// Oldest Recovery Point for the Item
84-
/// </summary
85-
public DateTime? OldestRecoveryPoint { get; set; }
86-
87-
/// <summary>
88-
/// Recovery Points Count for the Item
89-
/// </summary
90-
public int RecoveryPointCount { get; set; }
91-
92-
/// <summary>
93-
/// PolicyState for the Item
94-
/// </summary
95-
public string PolicyState { get; set; }
96-
}
54+
public class AzureFileShareExtendedInfo : AzureItemExtendedInfo
55+
{ }
9756
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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 System;
16+
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
17+
18+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
19+
{
20+
/// <summary>
21+
/// Base class for Azure items(AzureVM, AzureFiles)
22+
/// </summary>
23+
public class AzureItem : ItemBase
24+
{
25+
/// <summary>
26+
/// Protection Status of the item
27+
/// </summary>
28+
public ItemProtectionStatus ProtectionStatus { get; set; }
29+
30+
/// <summary>
31+
/// Protection State of the item
32+
/// </summary>
33+
public ItemProtectionState ProtectionState { get; set; }
34+
35+
/// <summary>
36+
/// Last Backup Status for the item
37+
/// </summary>
38+
public string LastBackupStatus { get; set; }
39+
40+
/// <summary>
41+
/// Last Backup Time for the item
42+
/// </summary>
43+
public DateTime? LastBackupTime { get; set; }
44+
45+
/// <summary>
46+
/// Protection Policy Name for the Item
47+
/// </summary>
48+
public string ProtectionPolicyName { get; set; }
49+
50+
/// <summary>
51+
/// ExtendedInfo for the Item
52+
/// </summary
53+
public AzureItemExtendedInfo ExtendedInfo { get; set; }
54+
55+
public AzureItem(ProtectedItemResource protectedItemResource,
56+
string containerName, ContainerType containerType, string policyName)
57+
: base(protectedItemResource, containerName, containerType)
58+
{
59+
ProtectionPolicyName = policyName;
60+
}
61+
}
62+
public class AzureItemExtendedInfo : ItemExtendedInfoBase
63+
{
64+
/// <summary>
65+
/// Oldest Recovery Point for the Item
66+
/// </summary
67+
public DateTime? OldestRecoveryPoint { get; set; }
68+
69+
/// <summary>
70+
/// Recovery Points Count for the Item
71+
/// </summary
72+
public int RecoveryPointCount { get; set; }
73+
74+
/// <summary>
75+
/// PolicyState for the Item
76+
/// </summary
77+
public string PolicyState { get; set; }
78+
}
79+
}

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Backup.Models/AzureVmModels/AzureVmItem.cs

Lines changed: 5 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -20,40 +20,10 @@ namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
2020
/// <summary>
2121
/// IaaSVM Item Class
2222
/// </summary>
23-
public class AzureVmItem : ItemBase
23+
public class AzureVmItem : AzureItem
2424
{
2525
public string VirtualMachineId { get; set; }
26-
27-
/// <summary>
28-
/// Protection Status of the item
29-
/// </summary>
30-
public ItemProtectionStatus ProtectionStatus { get; set; }
31-
32-
/// <summary>
33-
/// Protection State of the item
34-
/// </summary>
35-
public ItemProtectionState ProtectionState { get; set; }
36-
37-
/// <summary>
38-
/// Last Backup Status for the item
39-
/// </summary>
40-
public string LastBackupStatus { get; set; }
41-
42-
/// <summary>
43-
/// Last Backup Time for the item
44-
/// </summary>
45-
public DateTime? LastBackupTime { get; set; }
46-
47-
/// <summary>
48-
/// Protection Policy Name for the Item
49-
/// </summary>
50-
public string ProtectionPolicyName { get; set; }
51-
52-
/// <summary>
53-
/// ExtendedInfo for the Item
54-
/// </summary
55-
public AzureVmItemExtendedInfo ExtendedInfo { get; set; }
56-
26+
5727
/// <summary>
5828
/// Constructor. Takes the service client object representing the protected item
5929
/// and converts it in to the PS protected item model
@@ -64,12 +34,11 @@ public class AzureVmItem : ItemBase
6434
/// <param name="policyName">Name of the protection policy associated with this protected item</param>
6535
public AzureVmItem(ProtectedItemResource protectedItemResource,
6636
string containerName, ContainerType containerType, string policyName)
67-
: base(protectedItemResource, containerName, containerType)
37+
: base(protectedItemResource, containerName, containerType, policyName)
6838
{
6939
AzureIaaSVMProtectedItem protectedItem = (AzureIaaSVMProtectedItem)protectedItemResource.Properties;
7040
LastBackupStatus = protectedItem.LastBackupStatus;
7141
LastBackupTime = protectedItem.LastBackupTime;
72-
ProtectionPolicyName = policyName;
7342
ProtectionState =
7443
EnumUtils.GetEnum<ItemProtectionState>(protectedItem.ProtectionState.ToString());
7544
ProtectionStatus = EnumUtils.GetEnum<ItemProtectionStatus>(protectedItem.ProtectionStatus);
@@ -80,21 +49,6 @@ public AzureVmItem(ProtectedItemResource protectedItemResource,
8049
/// <summary>
8150
/// IaaSVM Item ExtendedInfo Class
8251
/// </summary>
83-
public class AzureVmItemExtendedInfo : ItemExtendedInfoBase
84-
{
85-
/// <summary>
86-
/// Oldest Recovery Point for the Item
87-
/// </summary
88-
public DateTime? OldestRecoveryPoint { get; set; }
89-
90-
/// <summary>
91-
/// Recovery Points Count for the Item
92-
/// </summary
93-
public int RecoveryPointCount { get; set; }
94-
95-
/// <summary>
96-
/// PolicyState for the Item
97-
/// </summary
98-
public string PolicyState { get; set; }
99-
}
52+
public class AzureVmItemExtendedInfo : AzureItemExtendedInfo
53+
{ }
10054
}

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Backup.Models/CmdletParamEnums.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ public enum ItemParams
8686
ExpiryDateTimeUTC,
8787
AzureFileShareName,
8888
StorageAccountName,
89-
StorageAccountResourceGroupName,
9089
}
9190

9291
public enum ProtectionCheckParams

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Backup.Models/Commands.RecoveryServices.Backup.Models.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@
4747
<Reference Include="System.Xml" />
4848
</ItemGroup>
4949
<ItemGroup>
50+
<Compile Include="AzureFileShareModels\AzureFileShareContainer.cs" />
5051
<Compile Include="AzureFileShareModels\AzureFileSharePolicy.cs" />
5152
<Compile Include="AzureFileShareModels\AzureFileShareItem.cs" />
52-
<Compile Include="AzureFileShareModels\AzureFileShareContainer.cs" />
5353
<Compile Include="AzureModels\AzureContainer.cs" />
54+
<Compile Include="AzureModels\AzureItem.cs" />
5455
<Compile Include="AzureSqlModels\AzureSqlContainer.cs" />
5556
<Compile Include="AzureSqlModels\AzureSqlItem.cs" />
5657
<Compile Include="AzureSqlModels\AzureSqlPolicy.cs" />

0 commit comments

Comments
 (0)