Skip to content

Commit d9d406e

Browse files
committed
Merge conflicts from dev1
2 parents 21842f7 + 61569f7 commit d9d406e

File tree

74 files changed

+1110
-878
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1110
-878
lines changed

setup/azurecmdfiles.wxi

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,9 +2002,6 @@
20022002
<Component Id="cmp131A9DE83A67006D51F1314A42E399CA" Guid="*">
20032003
<File Id="filA2C0D97A8033046D96249BA12C24D9D4" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.RecoveryServices.Backup\AzureRM.RecoveryServices.Backup.psd1" />
20042004
</Component>
2005-
<Component Id="cmpEB886EAAAF58ED0808ACCABDCC7707CA" Guid="*">
2006-
<File Id="filB0E96893813842B67380A6863ABBCC0D" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.RecoveryServices.Backup\AzureRM.RecoveryServices.psd1" />
2007-
</Component>
20082005
<Component Id="cmpB35FF47D728C871816F14A3529260DE9" Guid="*">
20092006
<File Id="fil4BCDE7803B14A0BC88A83E82379716A7" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.RecoveryServices.Backup\Hyak.Common.dll" />
20102007
</Component>
@@ -5717,7 +5714,6 @@
57175714
<ComponentRef Id="cmpC00974919B90C9055BED1F2A9DA95441" />
57185715
<ComponentRef Id="cmpE300D8B185C427E05E95BA97413F6CC8" />
57195716
<ComponentRef Id="cmp131A9DE83A67006D51F1314A42E399CA" />
5720-
<ComponentRef Id="cmpEB886EAAAF58ED0808ACCABDCC7707CA" />
57215717
<ComponentRef Id="cmpB35FF47D728C871816F14A3529260DE9" />
57225718
<ComponentRef Id="cmp99A277F4A4EF20D7BFBB171691A4B7E7" />
57235719
<ComponentRef Id="cmp1675F88279F58B72A180AF1411111337" />

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Helpers/Conversions/ConversionHelpers.cs

Lines changed: 51 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
using System.Text;
1919
using System.Threading.Tasks;
2020
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
21+
using CmdletModels = Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
2122
using Microsoft.Azure.Commands.RecoveryServices.Backup.Properties;
22-
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
23+
using ServiceClientModel = Microsoft.Azure.Management.RecoveryServices.Backup.Models;
2324

2425
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers
2526
{
@@ -33,18 +34,18 @@ public class ConversionHelpers
3334
/// <summary>
3435
/// Helper function to convert ps backup container model from service response.
3536
/// </summary>
36-
public static AzureRmRecoveryServicesBackupContainerBase GetContainerModel(ProtectionContainerResource protectionContainer)
37+
public static ContainerBase GetContainerModel(ServiceClientModel.ProtectionContainerResource protectionContainer)
3738
{
38-
AzureRmRecoveryServicesBackupContainerBase containerModel = null;
39+
ContainerBase containerModel = null;
3940

4041
if (protectionContainer != null &&
4142
protectionContainer.Properties != null)
4243
{
43-
if (protectionContainer.Properties.GetType().IsSubclassOf(typeof(AzureIaaSVMProtectionContainer)))
44+
if (protectionContainer.Properties.GetType().IsSubclassOf(typeof(ServiceClientModel.AzureIaaSVMProtectionContainer)))
4445
{
45-
containerModel = new AzureRmRecoveryServicesBackupIaasVmContainer(protectionContainer);
46+
containerModel = new AzureVmContainer(protectionContainer);
4647
}
47-
if (protectionContainer.Properties.GetType() == typeof(MabProtectionContainer))
48+
if (protectionContainer.Properties.GetType() == typeof(ServiceClientModel.MabProtectionContainer))
4849
{
4950
containerModel = new AzureRmRecoveryServicesBackupMabContainer(protectionContainer);
5051
}
@@ -56,18 +57,18 @@ public static AzureRmRecoveryServicesBackupContainerBase GetContainerModel(Prote
5657
/// <summary>
5758
/// Helper function to convert ps backup engine model from service response.
5859
/// </summary>
59-
public static AzureRmRecoveryServicesBackupEngineBase GetBackupEngineModel(BackupEngineResource backupEngine)
60+
public static BackupEngineBase GetBackupEngineModel(ServiceClientModel.BackupEngineResource backupEngine)
6061
{
61-
AzureRmRecoveryServicesBackupEngineBase backupEngineModel = null;
62+
BackupEngineBase backupEngineModel = null;
6263

6364
if (backupEngine != null &&
6465
backupEngine.Properties != null)
6566
{
66-
if (backupEngine.Properties.GetType() == (typeof(DpmBackupEngine)))
67+
if (backupEngine.Properties.GetType() == (typeof(ServiceClientModel.DpmBackupEngine)))
6768
{
68-
backupEngineModel = new AzureRmRecoveryServicesBackupDpmBackupEngine(backupEngine);
69+
backupEngineModel = new DpmBackupEngine(backupEngine);
6970
}
70-
else if (backupEngine.Properties.GetType() == (typeof(AzureBackupServerEngine)))
71+
else if (backupEngine.Properties.GetType() == (typeof(ServiceClientModel.AzureBackupServerEngine)))
7172
{
7273
backupEngineModel = new AzureRmRecoveryServicesBackupAzureBackupServerEngine(backupEngine);
7374
}
@@ -79,9 +80,9 @@ public static AzureRmRecoveryServicesBackupEngineBase GetBackupEngineModel(Backu
7980
/// <summary>
8081
/// Helper function to convert ps backup container model list from service response.
8182
/// </summary>
82-
public static List<AzureRmRecoveryServicesBackupContainerBase> GetContainerModelList(IEnumerable<ProtectionContainerResource> protectionContainers)
83+
public static List<ContainerBase> GetContainerModelList(IEnumerable<ServiceClientModel.ProtectionContainerResource> protectionContainers)
8384
{
84-
List<AzureRmRecoveryServicesBackupContainerBase> containerModels = new List<AzureRmRecoveryServicesBackupContainerBase>();
85+
List<ContainerBase> containerModels = new List<ContainerBase>();
8586

8687
foreach (var protectionContainer in protectionContainers)
8788
{
@@ -94,9 +95,9 @@ public static List<AzureRmRecoveryServicesBackupContainerBase> GetContainerModel
9495
/// <summary>
9596
/// Helper function to convert ps backup engine model list from service response.
9697
/// </summary>
97-
public static List<AzureRmRecoveryServicesBackupEngineBase> GetBackupEngineModelList(IEnumerable<BackupEngineResource> backupEngines)
98+
public static List<BackupEngineBase> GetBackupEngineModelList(IEnumerable<ServiceClientModel.BackupEngineResource> backupEngines)
9899
{
99-
List<AzureRmRecoveryServicesBackupEngineBase> backupEngineModel = new List<AzureRmRecoveryServicesBackupEngineBase>();
100+
List<BackupEngineBase> backupEngineModel = new List<BackupEngineBase>();
100101

101102
foreach (var backupEngine in backupEngines)
102103
{
@@ -113,78 +114,78 @@ public static List<AzureRmRecoveryServicesBackupEngineBase> GetBackupEngineModel
113114
/// <summary>
114115
/// Helper function to convert ps backup policy model from service response.
115116
/// </summary>
116-
public static AzureRmRecoveryServicesBackupPolicyBase GetPolicyModel(ProtectionPolicyResource hydraResponse)
117+
public static PolicyBase GetPolicyModel(ServiceClientModel.ProtectionPolicyResource serviceClientResponse)
117118
{
118-
AzureRmRecoveryServicesBackupPolicyBase policyModel = null;
119+
PolicyBase policyModel = null;
119120

120-
if (hydraResponse == null || hydraResponse.Properties == null)
121+
if (serviceClientResponse == null || serviceClientResponse.Properties == null)
121122
{
122-
Logger.Instance.WriteDebug("Policy Hydra response is Null/Empty");
123-
throw new ArgumentException(Resources.EmptyHydraResponseException);
123+
Logger.Instance.WriteDebug("Policy Service Client response is Null/Empty");
124+
throw new ArgumentException(Resources.EmptyServiceClientResponseException);
124125
}
125126

126-
if (hydraResponse.Properties.GetType() == typeof(AzureIaaSVMProtectionPolicy))
127+
if (serviceClientResponse.Properties.GetType() == typeof(ServiceClientModel.AzureIaaSVMProtectionPolicy))
127128
{
128-
if (((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).RetentionPolicy.GetType() !=
129-
typeof(LongTermRetentionPolicy))
129+
if (((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).RetentionPolicy.GetType() !=
130+
typeof(ServiceClientModel.LongTermRetentionPolicy))
130131
{
131132
Logger.Instance.WriteDebug("Unknown RetentionPolicy object received: " +
132-
((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).RetentionPolicy.GetType());
133+
((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).RetentionPolicy.GetType());
133134
Logger.Instance.WriteWarning(Resources.UpdateToNewAzurePowershellWarning);
134135
return null;
135136
}
136137

137-
if (((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).SchedulePolicy.GetType() !=
138-
typeof(SimpleSchedulePolicy))
138+
if (((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).SchedulePolicy.GetType() !=
139+
typeof(ServiceClientModel.SimpleSchedulePolicy))
139140
{
140141
Logger.Instance.WriteDebug("Unknown SchedulePolicy object received: " +
141-
((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).SchedulePolicy.GetType());
142+
((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).SchedulePolicy.GetType());
142143
Logger.Instance.WriteWarning(Resources.UpdateToNewAzurePowershellWarning);
143144
return null;
144145
}
145146

146-
policyModel = new AzureRmRecoveryServicesBackupIaasVmPolicy();
147-
AzureRmRecoveryServicesBackupIaasVmPolicy iaasPolicyModel = policyModel as AzureRmRecoveryServicesBackupIaasVmPolicy;
147+
policyModel = new AzureVmPolicy();
148+
AzureVmPolicy iaasPolicyModel = policyModel as AzureVmPolicy;
148149
iaasPolicyModel.WorkloadType = Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.WorkloadType.AzureVM;
149150
iaasPolicyModel.BackupManagementType = Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.BackupManagementType.AzureVM;
150-
iaasPolicyModel.RetentionPolicy = PolicyHelpers.GetPSLongTermRetentionPolicy((LongTermRetentionPolicy)
151-
((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).RetentionPolicy);
152-
iaasPolicyModel.SchedulePolicy = PolicyHelpers.GetPSSimpleSchedulePolicy((SimpleSchedulePolicy)
153-
((AzureIaaSVMProtectionPolicy)hydraResponse.Properties).SchedulePolicy);
151+
iaasPolicyModel.RetentionPolicy = PolicyHelpers.GetPSLongTermRetentionPolicy((ServiceClientModel.LongTermRetentionPolicy)
152+
((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).RetentionPolicy);
153+
iaasPolicyModel.SchedulePolicy = PolicyHelpers.GetPSSimpleSchedulePolicy((ServiceClientModel.SimpleSchedulePolicy)
154+
((ServiceClientModel.AzureIaaSVMProtectionPolicy)serviceClientResponse.Properties).SchedulePolicy);
154155
}
155156
else
156157
{
157158
// we will enter this case when service supports new workload and customer
158159
// still using old version of azure powershell. Trace warning message, ignore and return
159160
Logger.Instance.WriteDebug("Unknown Policy object received: " +
160-
hydraResponse.Properties.GetType());
161+
serviceClientResponse.Properties.GetType());
161162
Logger.Instance.WriteWarning(Resources.UpdateToNewAzurePowershellWarning);
162163
return null;
163164
}
164165

165-
policyModel.Name = hydraResponse.Name;
166-
policyModel.Id = hydraResponse.Id;
166+
policyModel.Name = serviceClientResponse.Name;
167+
policyModel.Id = serviceClientResponse.Id;
167168

168169
return policyModel;
169170
}
170171

171172
/// <summary>
172173
/// Helper function to convert ps backup policy list model from service response.
173174
/// </summary>
174-
public static List<AzureRmRecoveryServicesBackupPolicyBase> GetPolicyModelList(
175-
ProtectionPolicyListResponse hydraListResponse)
175+
public static List<PolicyBase> GetPolicyModelList(
176+
ServiceClientModel.ProtectionPolicyListResponse serviceClientListResponse)
176177
{
177-
if (hydraListResponse == null || hydraListResponse.ItemList == null ||
178-
hydraListResponse.ItemList.Value == null || hydraListResponse.ItemList.Value.Count == 0)
178+
if (serviceClientListResponse == null || serviceClientListResponse.ItemList == null ||
179+
serviceClientListResponse.ItemList.Value == null || serviceClientListResponse.ItemList.Value.Count == 0)
179180
{
180181
Logger.Instance.WriteDebug("Received empty list of policies from service");
181182
return null;
182183
}
183184

184-
List<AzureRmRecoveryServicesBackupPolicyBase> policyModels = new List<AzureRmRecoveryServicesBackupPolicyBase>();
185-
AzureRmRecoveryServicesBackupPolicyBase policyModel = null;
185+
List<PolicyBase> policyModels = new List<PolicyBase>();
186+
PolicyBase policyModel = null;
186187

187-
foreach (ProtectionPolicyResource resource in hydraListResponse.ItemList.Value)
188+
foreach (ServiceClientModel.ProtectionPolicyResource resource in serviceClientListResponse.ItemList.Value)
188189
{
189190
policyModel = GetPolicyModel(resource);
190191
if (policyModel != null)
@@ -204,17 +205,17 @@ public static List<AzureRmRecoveryServicesBackupPolicyBase> GetPolicyModelList(
204205
/// <summary>
205206
/// Helper function to convert ps backup policy item from service response.
206207
/// </summary>
207-
public static AzureRmRecoveryServicesBackupItemBase GetItemModel(ProtectedItemResource protectedItem)
208+
public static ItemBase GetItemModel(ServiceClientModel.ProtectedItemResource protectedItem)
208209
{
209-
AzureRmRecoveryServicesBackupItemBase itemModel = null;
210+
ItemBase itemModel = null;
210211

211212
if (protectedItem != null &&
212213
protectedItem.Properties != null)
213214
{
214-
if (protectedItem.Properties.GetType().IsSubclassOf(typeof(AzureIaaSVMProtectedItem)))
215+
if (protectedItem.Properties.GetType().IsSubclassOf(typeof(ServiceClientModel.AzureIaaSVMProtectedItem)))
215216
{
216217
string policyName = null;
217-
string policyId = ((AzureIaaSVMProtectedItem)protectedItem.Properties).PolicyId;
218+
string policyId = ((ServiceClientModel.AzureIaaSVMProtectedItem)protectedItem.Properties).PolicyId;
218219
if (!string.IsNullOrEmpty(policyId))
219220
{
220221
Dictionary<UriEnums, string> keyValueDict =
@@ -226,7 +227,7 @@ public static AzureRmRecoveryServicesBackupItemBase GetItemModel(ProtectedItemRe
226227
HelperUtils.ParseUri(protectedItem.Id),
227228
protectedItem.Id);
228229

229-
itemModel = new AzureRmRecoveryServicesBackupIaasVmItem(
230+
itemModel = new AzureVmItem(
230231
protectedItem,
231232
IdUtils.GetNameFromUri(containerUri),
232233
Cmdlets.Models.ContainerType.AzureVM,
@@ -240,9 +241,9 @@ public static AzureRmRecoveryServicesBackupItemBase GetItemModel(ProtectedItemRe
240241
/// <summary>
241242
/// Helper function to convert ps backup policy item list from service response.
242243
/// </summary>
243-
public static List<AzureRmRecoveryServicesBackupItemBase> GetItemModelList(IEnumerable<ProtectedItemResource> protectedItems)
244+
public static List<ItemBase> GetItemModelList(IEnumerable<ServiceClientModel.ProtectedItemResource> protectedItems)
244245
{
245-
List<AzureRmRecoveryServicesBackupItemBase> itemModels = new List<AzureRmRecoveryServicesBackupItemBase>();
246+
List<ItemBase> itemModels = new List<ItemBase>();
246247

247248
foreach (var protectedItem in protectedItems)
248249
{

0 commit comments

Comments
 (0)