Skip to content

Implementing Code Review Comments #308

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 12 commits into from
Apr 27, 2016
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
4 changes: 0 additions & 4 deletions setup/azurecmdfiles.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -2002,9 +2002,6 @@
<Component Id="cmp131A9DE83A67006D51F1314A42E399CA" Guid="*">
<File Id="filA2C0D97A8033046D96249BA12C24D9D4" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.RecoveryServices.Backup\AzureRM.RecoveryServices.Backup.psd1" />
</Component>
<Component Id="cmpEB886EAAAF58ED0808ACCABDCC7707CA" Guid="*">
<File Id="filB0E96893813842B67380A6863ABBCC0D" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.RecoveryServices.Backup\AzureRM.RecoveryServices.psd1" />
</Component>
<Component Id="cmpB35FF47D728C871816F14A3529260DE9" Guid="*">
<File Id="fil4BCDE7803B14A0BC88A83E82379716A7" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.RecoveryServices.Backup\Hyak.Common.dll" />
</Component>
Expand Down Expand Up @@ -5717,7 +5714,6 @@
<ComponentRef Id="cmpC00974919B90C9055BED1F2A9DA95441" />
<ComponentRef Id="cmpE300D8B185C427E05E95BA97413F6CC8" />
<ComponentRef Id="cmp131A9DE83A67006D51F1314A42E399CA" />
<ComponentRef Id="cmpEB886EAAAF58ED0808ACCABDCC7707CA" />
<ComponentRef Id="cmpB35FF47D728C871816F14A3529260DE9" />
<ComponentRef Id="cmp99A277F4A4EF20D7BFBB171691A4B7E7" />
<ComponentRef Id="cmp1675F88279F58B72A180AF1411111337" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<Reference Include="Microsoft.Azure.Common">
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.RecoveryServices.Backup, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Reference Include="Microsoft.Azure.Management.RecoveryServices.Backup, Version=0.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RecoveryServices.Backup.0.1.0-preview\lib\net40\Microsoft.Azure.Management.RecoveryServices.Backup.dll</HintPath>
</Reference>
Expand All @@ -52,23 +52,19 @@
<ItemGroup>
<Compile Include="Conversions\JobConversions.cs" />
<Compile Include="Conversions\RecoveryPointConversions.cs" />
<Compile Include="Utils.cs" />
<Compile Include="HelperUtils.cs" />
<Compile Include="Validations\PolicyValidations.cs" />
<Compile Include="Conversions\SchedulePolicyConversions.cs" />
<Compile Include="Conversions\RetentionPolicyConversions.cs" />
<Compile Include="Conversions\ConversionHelpers.cs" />
<Compile Include="HydraHelpers.cs" />
<Compile Include="ServiceClientHelpers.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Common\Commands.Common\Commands.Common.csproj">
<Project>{5ee72c53-1720-4309-b54b-5fb79703195f}</Project>
<Name>Commands.Common</Name>
</ProjectReference>
<ProjectReference Include="..\Commands.RecoveryServices.Backup.HydraAdapter\Commands.RecoveryServices.Backup.HydraAdapter.csproj">
<Project>{b758fec1-35c1-4f93-a954-66dd33f6e0ec}</Project>
<Name>Commands.RecoveryServices.Backup.HydraAdapter</Name>
</ProjectReference>
<ProjectReference Include="..\Commands.RecoveryServices.Backup.Logger\Commands.RecoveryServices.Backup.Logger.csproj">
<Project>{5e675749-6139-464a-904c-59c0ffdfec82}</Project>
<Name>Commands.RecoveryServices.Backup.Logger</Name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@
using System.Threading.Tasks;
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
using Microsoft.Azure.Commands.RecoveryServices.Backup.Properties;
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
using ServiceClientModel = Microsoft.Azure.Management.RecoveryServices.Backup.Models;

namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers
{
public class ConversionHelpers
{
#region containers
public static AzureRmRecoveryServicesBackupContainerBase GetContainerModel(ProtectionContainerResource protectionContainer)
public static ContainerBase GetContainerModel(ServiceClientModel.ProtectionContainerResource protectionContainer)
{
AzureRmRecoveryServicesBackupContainerBase containerModel = null;
ContainerBase containerModel = null;

if (protectionContainer != null &&
protectionContainer.Properties != null)
{
if (protectionContainer.Properties.GetType().IsSubclassOf(typeof(AzureIaaSVMProtectionContainer)))
if (protectionContainer.Properties.GetType().IsSubclassOf(typeof(ServiceClientModel.AzureIaaSVMProtectionContainer)))
{
containerModel = new AzureRmRecoveryServicesBackupIaasVmContainer(protectionContainer);
containerModel = new AzureVmContainer(protectionContainer);
}
if (protectionContainer.Properties.GetType() == typeof(MabProtectionContainer))
if (protectionContainer.Properties.GetType() == typeof(ServiceClientModel.MabProtectionContainer))
{
containerModel = new AzureRmRecoveryServicesBackupMabContainer(protectionContainer);
}
Expand All @@ -46,18 +46,18 @@ public static AzureRmRecoveryServicesBackupContainerBase GetContainerModel(Prote
return containerModel;
}

public static AzureRmRecoveryServicesBackupEngineBase GetBackupEngineModel(BackupEngineResource backupEngine)
public static BackupEngineBase GetBackupEngineModel(ServiceClientModel.BackupEngineResource backupEngine)
{
AzureRmRecoveryServicesBackupEngineBase backupEngineModel = null;
BackupEngineBase backupEngineModel = null;

if (backupEngine != null &&
backupEngine.Properties != null)
{
if (backupEngine.Properties.GetType() == (typeof(DpmBackupEngine)))
if (backupEngine.Properties.GetType() == (typeof(ServiceClientModel.DpmBackupEngine)))
{
backupEngineModel = new AzureRmRecoveryServicesBackupDpmBackupEngine(backupEngine);
backupEngineModel = new DpmBackupEngine(backupEngine);
}
else if (backupEngine.Properties.GetType() == (typeof(AzureBackupServerEngine)))
else if (backupEngine.Properties.GetType() == (typeof(ServiceClientModel.AzureBackupServerEngine)))
{
backupEngineModel = new AzureRmRecoveryServicesBackupAzureBackupServerEngine(backupEngine);
}
Expand All @@ -66,9 +66,9 @@ public static AzureRmRecoveryServicesBackupEngineBase GetBackupEngineModel(Backu
return backupEngineModel;
}

public static List<AzureRmRecoveryServicesBackupContainerBase> GetContainerModelList(IEnumerable<ProtectionContainerResource> protectionContainers)
public static List<ContainerBase> GetContainerModelList(IEnumerable<ServiceClientModel.ProtectionContainerResource> protectionContainers)
{
List<AzureRmRecoveryServicesBackupContainerBase> containerModels = new List<AzureRmRecoveryServicesBackupContainerBase>();
List<ContainerBase> containerModels = new List<ContainerBase>();

foreach (var protectionContainer in protectionContainers)
{
Expand All @@ -78,9 +78,9 @@ public static List<AzureRmRecoveryServicesBackupContainerBase> GetContainerModel
return containerModels;
}

public static List<AzureRmRecoveryServicesBackupEngineBase> GetBackupEngineModelList(IEnumerable<BackupEngineResource> backupEngines)
public static List<BackupEngineBase> GetBackupEngineModelList(IEnumerable<ServiceClientModel.BackupEngineResource> backupEngines)
{
List<AzureRmRecoveryServicesBackupEngineBase> backupEngineModel = new List<AzureRmRecoveryServicesBackupEngineBase>();
List<BackupEngineBase> backupEngineModel = new List<BackupEngineBase>();

foreach (var backupEngine in backupEngines)
{
Expand All @@ -93,75 +93,75 @@ public static List<AzureRmRecoveryServicesBackupEngineBase> GetBackupEngineModel
#endregion

#region policy
public static AzureRmRecoveryServicesBackupPolicyBase GetPolicyModel(ProtectionPolicyResource hydraResponse)
public static PolicyBase GetPolicyModel(ServiceClientModel.ProtectionPolicyResource serviceClientResponse)
{
AzureRmRecoveryServicesBackupPolicyBase policyModel = null;
PolicyBase policyModel = null;

if (hydraResponse == null || hydraResponse.Properties == null)
if (serviceClientResponse == null || serviceClientResponse.Properties == null)
{
Logger.Instance.WriteDebug("Policy Hydra response is Null/Empty");
throw new ArgumentException(Resources.EmptyHydraResponseException);
Logger.Instance.WriteDebug("Policy Service Client response is Null/Empty");
throw new ArgumentException(Resources.EmptyServiceClientResponseException);
}

if (hydraResponse.Properties.GetType() == typeof(AzureIaaSVMProtectionPolicy))
if (serviceClientResponse.Properties.GetType() == typeof(ServiceClientModel.AzureIaaSVMProtectionPolicy))
{
if (((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).RetentionPolicy.GetType() !=
typeof(LongTermRetentionPolicy))
if (((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).RetentionPolicy.GetType() !=
typeof(ServiceClientModel.LongTermRetentionPolicy))
{
Logger.Instance.WriteDebug("Unknown RetentionPolicy object received: " +
((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).RetentionPolicy.GetType());
((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).RetentionPolicy.GetType());
Logger.Instance.WriteWarning(Resources.UpdateToNewAzurePowershellWarning);
return null;
}

if (((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).SchedulePolicy.GetType() !=
typeof(SimpleSchedulePolicy))
if (((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).SchedulePolicy.GetType() !=
typeof(ServiceClientModel.SimpleSchedulePolicy))
{
Logger.Instance.WriteDebug("Unknown SchedulePolicy object received: " +
((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).SchedulePolicy.GetType());
((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).SchedulePolicy.GetType());
Logger.Instance.WriteWarning(Resources.UpdateToNewAzurePowershellWarning);
return null;
}

policyModel = new AzureRmRecoveryServicesBackupIaasVmPolicy();
AzureRmRecoveryServicesBackupIaasVmPolicy iaasPolicyModel = policyModel as AzureRmRecoveryServicesBackupIaasVmPolicy;
policyModel = new AzureVmPolicy();
AzureVmPolicy iaasPolicyModel = policyModel as AzureVmPolicy;
iaasPolicyModel.WorkloadType = Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.WorkloadType.AzureVM;
iaasPolicyModel.BackupManagementType = Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.BackupManagementType.AzureVM;
iaasPolicyModel.RetentionPolicy = PolicyHelpers.GetPSLongTermRetentionPolicy((LongTermRetentionPolicy)
((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).RetentionPolicy);
iaasPolicyModel.SchedulePolicy = PolicyHelpers.GetPSSimpleSchedulePolicy((SimpleSchedulePolicy)
((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).SchedulePolicy);
iaasPolicyModel.RetentionPolicy = PolicyHelpers.GetPSLongTermRetentionPolicy((ServiceClientModel.LongTermRetentionPolicy)
((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).RetentionPolicy);
iaasPolicyModel.SchedulePolicy = PolicyHelpers.GetPSSimpleSchedulePolicy((ServiceClientModel.SimpleSchedulePolicy)
((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).SchedulePolicy);
}
else
{
// we will enter this case when service supports new workload and customer
// still using old version of azure powershell. Trace warning message, ignore and return
Logger.Instance.WriteDebug("Unknown Policy object received: " +
hydraResponse.Properties.GetType());
serviceClientResponse.Properties.GetType());
Logger.Instance.WriteWarning(Resources.UpdateToNewAzurePowershellWarning);
return null;
}

policyModel.Name = hydraResponse.Name;
policyModel.Id = hydraResponse.Id;
policyModel.Name = serviceClientResponse.Name;
policyModel.Id = serviceClientResponse.Id;

return policyModel;
}

public static List<AzureRmRecoveryServicesBackupPolicyBase> GetPolicyModelList(
ProtectionPolicyListResponse hydraListResponse)
public static List<PolicyBase> GetPolicyModelList(
ServiceClientModel.ProtectionPolicyListResponse serviceClientListResponse)
{
if (hydraListResponse == null || hydraListResponse.ItemList == null ||
hydraListResponse.ItemList.Value == null || hydraListResponse.ItemList.Value.Count == 0)
if (serviceClientListResponse == null || serviceClientListResponse.ItemList == null ||
serviceClientListResponse.ItemList.Value == null || serviceClientListResponse.ItemList.Value.Count == 0)
{
Logger.Instance.WriteDebug("Received empty list of policies from service");
return null;
}

List<AzureRmRecoveryServicesBackupPolicyBase> policyModels = new List<AzureRmRecoveryServicesBackupPolicyBase>();
AzureRmRecoveryServicesBackupPolicyBase policyModel = null;
List<PolicyBase> policyModels = new List<PolicyBase>();
PolicyBase policyModel = null;

foreach (ProtectionPolicyResource resource in hydraListResponse.ItemList.Value)
foreach (ServiceClientModel.ProtectionPolicyResource resource in serviceClientListResponse.ItemList.Value)
{
policyModel = GetPolicyModel(resource);
if (policyModel != null)
Expand All @@ -178,17 +178,17 @@ public static List<AzureRmRecoveryServicesBackupPolicyBase> GetPolicyModelList(

#region Item

public static AzureRmRecoveryServicesBackupItemBase GetItemModel(ProtectedItemResource protectedItem)
public static ItemBase GetItemModel(ServiceClientModel.ProtectedItemResource protectedItem)
{
AzureRmRecoveryServicesBackupItemBase itemModel = null;
ItemBase itemModel = null;

if (protectedItem != null &&
protectedItem.Properties != null)
{
if (protectedItem.Properties.GetType().IsSubclassOf(typeof(AzureIaaSVMProtectedItem)))
if (protectedItem.Properties.GetType().IsSubclassOf(typeof(ServiceClientModel.AzureIaaSVMProtectedItem)))
{
string policyName = null;
string policyId = ((AzureIaaSVMProtectedItem)protectedItem.Properties).PolicyId;
string policyId = ((ServiceClientModel.AzureIaaSVMProtectedItem)protectedItem.Properties).PolicyId;
if (!string.IsNullOrEmpty(policyId))
{
Dictionary<UriEnums, string> keyValueDict =
Expand All @@ -200,7 +200,7 @@ public static AzureRmRecoveryServicesBackupItemBase GetItemModel(ProtectedItemRe
HelperUtils.ParseUri(protectedItem.Id),
protectedItem.Id);

itemModel = new AzureRmRecoveryServicesBackupIaasVmItem(
itemModel = new AzureVmItem(
protectedItem,
IdUtils.GetNameFromUri(containerUri),
Cmdlets.Models.ContainerType.AzureVM,
Expand All @@ -211,9 +211,9 @@ public static AzureRmRecoveryServicesBackupItemBase GetItemModel(ProtectedItemRe
return itemModel;
}

public static List<AzureRmRecoveryServicesBackupItemBase> GetItemModelList(IEnumerable<ProtectedItemResource> protectedItems)
public static List<ItemBase> GetItemModelList(IEnumerable<ServiceClientModel.ProtectedItemResource> protectedItems)
{
List<AzureRmRecoveryServicesBackupItemBase> itemModels = new List<AzureRmRecoveryServicesBackupItemBase>();
List<ItemBase> itemModels = new List<ItemBase>();

foreach (var protectedItem in protectedItems)
{
Expand Down
Loading