-
Notifications
You must be signed in to change notification settings - Fork 2
[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
Conversation
} | ||
|
||
/// <summary> | ||
/// Helper function to convert ps backup container model from service response. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary text should be Helper function to convert PS Protectable Container model from service response.
/// <summary> | ||
/// Helper function to convert ps backup container model from service response. | ||
/// </summary> | ||
public static ContainerBase GetProtectableContainerModel(ServiceClientModel.ProtectableContainerResource protectableContainer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid converting this object as it doesn't need to be exposed to the customer.
@@ -93,7 +111,7 @@ public static ContainerBase GetContainerModel(ServiceClientModel.ProtectionConta | |||
public static List<ContainerBase> GetContainerModelList(IEnumerable<ServiceClientModel.ProtectionContainerResource> protectionContainers) | |||
{ | |||
List<ContainerBase> containerModels = new List<ContainerBase>(); | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Extra white space
/// <summary> | ||
/// Helper function to convert ps backup container model list from service response. | ||
/// </summary> | ||
public static List<ContainerBase> GetProtectableContainerModelList(IEnumerable<ServiceClientModel.ProtectableContainerResource> protectableContainers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid converting this object as it doesn't need to be exposed to the customer.
/// and converts it in to the PS container model | ||
/// </summary> | ||
/// <param name="protectableContainer">Service client object representing the container</param> | ||
public AzureFileShareContainer(ProtectableContainerResource protectableContainer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid converting this object as it doesn't need to be exposed to the customer.
/// <returns>List of protection containers</returns> | ||
public IEnumerable<ProtectableContainerResource> ListUnregisteredContainers( | ||
ODataQuery<BMSContainerQueryObject> queryFilter, | ||
string skipToken = default(string), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
skipToken
is not used anywhere in the method
@@ -138,6 +138,9 @@ public IPsBackupProvider GetProviderInstance(WorkloadType workloadType) | |||
case WorkloadType.AzureVM: | |||
providerType = PsBackupProviderTypes.IaasVm; | |||
break; | |||
case WorkloadType.AzureFiles: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have AzureFiles and AzureFile. Shouldn't they be same?
@@ -23,6 +23,22 @@ namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ServiceClient | |||
{ | |||
public partial class ServiceClientAdapter | |||
{ | |||
|
|||
public RestAzureNS.AzureOperationResponse InquireContainers( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add summary
|
||
public RestAzureNS.AzureOperationResponse InquireContainers( | ||
string containerName, | ||
ODataQuery<BMSContainersInquiryQueryObject> queryFilter, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is BMSContainersInquiryQueryObject
defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -92,6 +136,25 @@ public partial class ServiceClientAdapter | |||
return response; | |||
} | |||
|
|||
/// <summary> | |||
/// Triggers register of container catalog in service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Triggers register of container in service
9a995e1
to
d451bf9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review is incomplete. But you can work on these comments and publish an update and then I'll review the remaining changes as well.
@@ -92,8 +96,7 @@ public static ContainerBase GetContainerModel(ServiceClientModel.ProtectionConta | |||
/// </summary> | |||
public static List<ContainerBase> GetContainerModelList(IEnumerable<ServiceClientModel.ProtectionContainerResource> protectionContainers) | |||
{ | |||
List<ContainerBase> containerModels = new List<ContainerBase>(); | |||
|
|||
List<ContainerBase> containerModels = new List<ContainerBase>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like extra whitespace. One good practice is to run "Ctrl + K + D" in all the touched files.
/// <summary> | ||
/// Helper function to convert ps backup container model list from service response. | ||
/// </summary> | ||
public static List<ServiceClientModel.ProtectableContainerResource> GetProtectableContainerModelList(IEnumerable<ServiceClientModel.ProtectableContainerResource> protectableContainers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this method is not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is being used in AzureFilesPsBackupProvider
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use System.Linq.ToList extension method instead. https://stackoverflow.com/questions/7617771/converting-from-ienumerable-to-list
/// <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>( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
closed
AzureFileshareProtectedItem protectedItem = (AzureFileshareProtectedItem)protectedItemResource.Properties; | ||
LastBackupStatus = protectedItem.LastBackupStatus; | ||
LastBackupTime = protectedItem.LastBackupTime; | ||
ProtectionPolicyName = policyName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be moved to AzureItem ctor
{ | ||
AzureStorageContainer azureStorageContainer = | ||
(AzureStorageContainer)protectionContainer.Properties; | ||
ResourceGroupName = IdUtils.GetResourceGroupName(protectionContainer.Id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property assignment can be moved to AzureContainer ctor
string storageContainer = null; | ||
string classicStorageContainer = null; | ||
List<ContainerBase> registeredStorageAccounts = GetRegisteredStorageAccount(vaultName, resourceGroupName); | ||
foreach (var storageAccount in registeredStorageAccounts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using foreach loop to search, use the C# Find method.
|
||
//get unregistered storage account | ||
if (!isRegistered) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comments apply here as well.
} | ||
|
||
private void TriggerInquiry(string vaultName, string resourceGroupName, | ||
string storageContainer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be storageContainerName
private void TriggerInquiry(string vaultName, string resourceGroupName, | ||
string storageContainer) | ||
{ | ||
ODataQuery<BMSContainersInquiryQueryObject> queryParam = new ODataQuery<BMSContainersInquiryQueryObject>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be queryParams
if (protectableObjectResource == null) | ||
{ | ||
// Container is not discovered. Throw exception | ||
string errMsg = string.Format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readable variable names
1a9323d
to
26b4427
Compare
@siddharth7 Please fix the conflicts. Will review afterward the fix. |
095c6f2
to
c68a8f9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address the comments. Otherwise LGTM.
/// <summary> | ||
/// Helper function to convert ps backup container model list from service response. | ||
/// </summary> | ||
public static List<ServiceClientModel.ProtectableContainerResource> GetProtectableContainerModelList(IEnumerable<ServiceClientModel.ProtectableContainerResource> protectableContainers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use System.Linq.ToList extension method instead. https://stackoverflow.com/questions/7617771/converting-from-ienumerable-to-list
@@ -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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
|
||
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models | ||
{ | ||
public class AzureItem : ItemBase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide summary text for this class.
@@ -12,16 +12,17 @@ | |||
// limitations under the License. | |||
// ---------------------------------------------------------------------------------- | |||
|
|||
using System; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Run refactoring once again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
string storageContainerName = null; | ||
List<ContainerBase> registeredStorageAccounts = GetRegisteredStorageAccounts(vaultName, vaultResourceGroupName); | ||
ContainerBase registeredStorageAccount = registeredStorageAccounts.Find(storageAccount => | ||
string.Compare(storageAccount.Name.Split(';').Last(), storageAccountName) == 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Please fix indent.
|
||
//get protectable item | ||
WorkloadProtectableItemResource protectableObjectResource = null; | ||
protectableObjectResource = TriggerDiscovery(vaultName, vaultResourceGroupName, azureFileShareName, storageAccountName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name should be GetProtectableItem
AzureFileShareProtectableItem azureFileShareProtectableItem = | ||
(AzureFileShareProtectableItem)protectableItem.Properties; | ||
if (azureFileShareProtectableItem != null && | ||
string.Compare(azureFileShareProtectableItem.FriendlyName, azureFileShareName, true) == 0 && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check with PM about how to deal with case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tracking
/// </summary> | ||
[Parameter(Position = 2, Mandatory = true, ValueFromPipelineByPropertyName = true, | ||
ParameterSetName = AzureFileShareParameterSet, HelpMessage = ParamHelpMsgs.Item.AzureFileShareName)] | ||
public string FileShareName { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be Name. Check PM for details.
ParameterSetName = AzureFileShareParameterSet, | ||
HelpMessage = ParamHelpMsgs.Item.AzureFileStorageAccountResourceGroupName)] | ||
[ResourceGroupCompleter] | ||
public string StorageAccountResourceGroupName { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to remove this parameter
@@ -36,7 +36,7 @@ internal static class Common | |||
{ | |||
public const string Vault = "The Azure Backup vault object which is the parent resource."; | |||
public const string VaultId = "Resource ID of the Recovery Services Vault."; | |||
public const string WorkloadType = "Workload type of the resource (for example: AzureVM, WindowsServer, AzureFile)."; | |||
public const string WorkloadType = "Workload type of the resource (for example: AzureVM, WindowsServer, Azure File)."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check for the right values here
6313148
to
b2b88f3
Compare
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
b2b88f3
to
863f285
Compare
Description
This checklist is used to make sure that common guidelines for a pull request are followed. You can find a more complete discussion of PowerShell cmdlet best practices here.
General Guidelines
Testing Guidelines
Cmdlet Signature Guidelines
ShouldProcess
and haveSupportShouldProcess=true
specified in the cmdlet attribute. You can find more information onShouldProcess
here.OutputType
attribute if any output is produced - if the cmdlet produces no output, it should implement aPassThrough
parameter.Cmdlet Parameter Guidelines