Skip to content

[REBASE] afs enable protection #361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,34 @@ public static RestAzureNS.AzureOperationResponse GetOperationResult(
return opStatusResponse;
}

/// <summary>
/// Block to track the operation to completion.
/// Waits till the HTTP status code of the operation becomes something other than Accepted.
/// </summary>
/// <param name="response">Response of the operation returned by the service.</param>
/// <param name="getOpStatus">Delegate method to fetch the operation status of the operation.</param>
/// <returns>Result of the operation once it completes.</returns>
public static RestAzureNS.AzureOperationResponse<T> GetOperationResult<T>(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method looks very similar to this method. Can you confirm why this is needed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its different, the second parameter is different ( RestAzureNS.AzureOperationResponse vs RestAzureNS.AzureOperationResponse)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

closed

RestAzureNS.AzureOperationResponse<T> response,
Func<string, RestAzureNS.AzureOperationResponse<T>> getOpStatus)
where T: ServiceClientModel.ProtectionContainerResource
{
var operationId = response.Response.Headers.GetOperationResultId();

var opStatusResponse = getOpStatus(operationId);

while (opStatusResponse.Response.StatusCode == SystemNet.HttpStatusCode.Accepted)
{
TestMockSupport.Delay(_defaultSleepForOperationTracking * 1000);

opStatusResponse = getOpStatus(operationId);
}

opStatusResponse = getOpStatus(operationId);

return opStatusResponse;
}

/// <summary>
/// Retries request to URL for specified no. of tries in case of failure
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,14 @@
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
{
/// <summary>
/// Azure File Share Item Class
/// Azure files Item Class
/// </summary>
public class AzureFileShareItem : ItemBase
public class AzureFileShareItem : AzureItem
{
/// <summary>
/// Protection Status of the item
/// Container id of item
/// </summary>
public ItemProtectionStatus ProtectionStatus { get; set; }

/// <summary>
/// Protection State of the item
/// </summary>
public ItemProtectionState ProtectionState { get; set; }

/// <summary>
/// Last Backup Status for the item
/// </summary>
public string LastBackupStatus { get; set; }

/// <summary>
/// Last Backup Time for the item
/// </summary>
public DateTime? LastBackupTime { get; set; }

/// <summary>
/// Protection Policy Name for the Item
/// </summary>
public string ProtectionPolicyName { get; set; }

/// <summary>
/// ExtendedInfo for the Item
/// </summary
public AzureFileShareItemExtendedInfo ExtendedInfo { get; set; }
public string ParentContainerFabricId { get; set; }

/// <summary>
/// Constructor. Takes the service client object representing the protected item
Expand All @@ -62,12 +37,11 @@ public class AzureFileShareItem : ItemBase
/// <param name="policyName">Name of the protection policy associated with this protected item</param>
public AzureFileShareItem(ProtectedItemResource protectedItemResource,
string containerName, ContainerType containerType, string policyName)
: base(protectedItemResource, containerName, containerType)
: base(protectedItemResource, containerName, containerType, policyName)
{
AzureFileshareProtectedItem protectedItem = (AzureFileshareProtectedItem)protectedItemResource.Properties;
LastBackupStatus = protectedItem.LastBackupStatus;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the initialization for LastBackupStatus, LastBackupTime, ProtectionState and ProtectionStatus to the base class - both in VM and Files.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

workload specific properties, can't move it to base class

LastBackupTime = protectedItem.LastBackupTime;
ProtectionPolicyName = policyName;
ProtectionState =
EnumUtils.GetEnum<ItemProtectionState>(protectedItem.ProtectionState.ToString());
ProtectionStatus = EnumUtils.GetEnum<ItemProtectionStatus>(protectedItem.ProtectionStatus);
Expand All @@ -77,21 +51,6 @@ public AzureFileShareItem(ProtectedItemResource protectedItemResource,
/// <summary>
/// Azure File Share Item ExtendedInfo Class
/// </summary>
public class AzureFileShareItemExtendedInfo : ItemExtendedInfoBase
{
/// <summary>
/// Oldest Recovery Point for the Item
/// </summary
public DateTime? OldestRecoveryPoint { get; set; }

/// <summary>
/// Recovery Points Count for the Item
/// </summary
public int RecoveryPointCount { get; set; }

/// <summary>
/// PolicyState for the Item
/// </summary
public string PolicyState { get; set; }
}
public class AzureFileShareExtendedInfo : AzureItemExtendedInfo
{ }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;

namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
{
/// <summary>
/// Base class for Azure items(AzureVM, AzureFiles)
/// </summary>
public class AzureItem : ItemBase
{
/// <summary>
/// Protection Status of the item
/// </summary>
public ItemProtectionStatus ProtectionStatus { get; set; }

/// <summary>
/// Protection State of the item
/// </summary>
public ItemProtectionState ProtectionState { get; set; }

/// <summary>
/// Last Backup Status for the item
/// </summary>
public string LastBackupStatus { get; set; }

/// <summary>
/// Last Backup Time for the item
/// </summary>
public DateTime? LastBackupTime { get; set; }

/// <summary>
/// Protection Policy Name for the Item
/// </summary>
public string ProtectionPolicyName { get; set; }

/// <summary>
/// ExtendedInfo for the Item
/// </summary
public AzureItemExtendedInfo ExtendedInfo { get; set; }

public AzureItem(ProtectedItemResource protectedItemResource,
string containerName, ContainerType containerType, string policyName)
: base(protectedItemResource, containerName, containerType)
{
ProtectionPolicyName = policyName;
}
}
public class AzureItemExtendedInfo : ItemExtendedInfoBase
{
/// <summary>
/// Oldest Recovery Point for the Item
/// </summary
public DateTime? OldestRecoveryPoint { get; set; }

/// <summary>
/// Recovery Points Count for the Item
/// </summary
public int RecoveryPointCount { get; set; }

/// <summary>
/// PolicyState for the Item
/// </summary
public string PolicyState { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,10 @@ namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
/// <summary>
/// IaaSVM Item Class
/// </summary>
public class AzureVmItem : ItemBase
public class AzureVmItem : AzureItem
{
public string VirtualMachineId { get; set; }

/// <summary>
/// Protection Status of the item
/// </summary>
public ItemProtectionStatus ProtectionStatus { get; set; }

/// <summary>
/// Protection State of the item
/// </summary>
public ItemProtectionState ProtectionState { get; set; }

/// <summary>
/// Last Backup Status for the item
/// </summary>
public string LastBackupStatus { get; set; }

/// <summary>
/// Last Backup Time for the item
/// </summary>
public DateTime? LastBackupTime { get; set; }

/// <summary>
/// Protection Policy Name for the Item
/// </summary>
public string ProtectionPolicyName { get; set; }

/// <summary>
/// ExtendedInfo for the Item
/// </summary
public AzureVmItemExtendedInfo ExtendedInfo { get; set; }


/// <summary>
/// Constructor. Takes the service client object representing the protected item
/// and converts it in to the PS protected item model
Expand All @@ -64,12 +34,11 @@ public class AzureVmItem : ItemBase
/// <param name="policyName">Name of the protection policy associated with this protected item</param>
public AzureVmItem(ProtectedItemResource protectedItemResource,
string containerName, ContainerType containerType, string policyName)
: base(protectedItemResource, containerName, containerType)
: base(protectedItemResource, containerName, containerType, policyName)
{
AzureIaaSVMProtectedItem protectedItem = (AzureIaaSVMProtectedItem)protectedItemResource.Properties;
LastBackupStatus = protectedItem.LastBackupStatus;
LastBackupTime = protectedItem.LastBackupTime;
ProtectionPolicyName = policyName;
ProtectionState =
EnumUtils.GetEnum<ItemProtectionState>(protectedItem.ProtectionState.ToString());
ProtectionStatus = EnumUtils.GetEnum<ItemProtectionStatus>(protectedItem.ProtectionStatus);
Expand All @@ -80,21 +49,6 @@ public AzureVmItem(ProtectedItemResource protectedItemResource,
/// <summary>
/// IaaSVM Item ExtendedInfo Class
/// </summary>
public class AzureVmItemExtendedInfo : ItemExtendedInfoBase
{
/// <summary>
/// Oldest Recovery Point for the Item
/// </summary
public DateTime? OldestRecoveryPoint { get; set; }

/// <summary>
/// Recovery Points Count for the Item
/// </summary
public int RecoveryPointCount { get; set; }

/// <summary>
/// PolicyState for the Item
/// </summary
public string PolicyState { get; set; }
}
public class AzureVmItemExtendedInfo : AzureItemExtendedInfo
{ }
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public enum ItemParams
ExpiryDateTimeUTC,
AzureFileShareName,
StorageAccountName,
StorageAccountResourceGroupName,
}

public enum ProtectionCheckParams
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AzureFileShareModels\AzureFileShareContainer.cs" />
<Compile Include="AzureFileShareModels\AzureFileSharePolicy.cs" />
<Compile Include="AzureFileShareModels\AzureFileShareItem.cs" />
<Compile Include="AzureFileShareModels\AzureFileShareContainer.cs" />
<Compile Include="AzureModels\AzureContainer.cs" />
<Compile Include="AzureModels\AzureItem.cs" />
<Compile Include="AzureSqlModels\AzureSqlContainer.cs" />
<Compile Include="AzureSqlModels\AzureSqlItem.cs" />
<Compile Include="AzureSqlModels\AzureSqlPolicy.cs" />
Expand Down
Loading