@@ -93,24 +93,24 @@ public static AzureRmRecoveryServicesBackupPolicyBase GetPolicyModel(ProtectionP
93
93
{
94
94
AzureRmRecoveryServicesBackupPolicyBase policyModel = null ;
95
95
96
- if ( hydraResponse == null || hydraResponse . Properties == null )
96
+ if ( hydraResponse == null || hydraResponse . Properties == null )
97
97
{
98
98
Logger . Instance . WriteDebug ( "Policy Hydra response is Null/Empty" ) ;
99
99
throw new ArgumentException ( Resources . EmptyHydraResponseException ) ;
100
100
}
101
101
102
102
if ( hydraResponse . Properties . GetType ( ) == typeof ( AzureIaaSVMProtectionPolicy ) )
103
103
{
104
- if ( ( ( AzureIaaSVMProtectionPolicy ) hydraResponse . Properties ) . RetentionPolicy . GetType ( ) !=
104
+ if ( ( ( AzureIaaSVMProtectionPolicy ) hydraResponse . Properties ) . RetentionPolicy . GetType ( ) !=
105
105
typeof ( LongTermRetentionPolicy ) )
106
106
{
107
107
Logger . Instance . WriteDebug ( "Unknown RetentionPolicy object received: " +
108
- ( ( AzureIaaSVMProtectionPolicy ) hydraResponse . Properties ) . RetentionPolicy . GetType ( ) ) ;
108
+ ( ( AzureIaaSVMProtectionPolicy ) hydraResponse . Properties ) . RetentionPolicy . GetType ( ) ) ;
109
109
Logger . Instance . WriteWarning ( Resources . UpdateToNewAzurePowershellWarning ) ;
110
110
return null ;
111
111
}
112
112
113
- if ( ( ( AzureIaaSVMProtectionPolicy ) hydraResponse . Properties ) . SchedulePolicy . GetType ( ) !=
113
+ if ( ( ( AzureIaaSVMProtectionPolicy ) hydraResponse . Properties ) . SchedulePolicy . GetType ( ) !=
114
114
typeof ( SimpleSchedulePolicy ) )
115
115
{
116
116
Logger . Instance . WriteDebug ( "Unknown SchedulePolicy object received: " +
@@ -129,7 +129,7 @@ public static AzureRmRecoveryServicesBackupPolicyBase GetPolicyModel(ProtectionP
129
129
( ( AzureIaaSVMProtectionPolicy ) hydraResponse . Properties ) . SchedulePolicy ) ;
130
130
}
131
131
else
132
- {
132
+ {
133
133
// we will enter this case when service supports new workload and customer
134
134
// still using old version of azure powershell. Trace warning message, ignore and return
135
135
Logger . Instance . WriteDebug ( "Unknown Policy object received: " +
@@ -147,7 +147,7 @@ public static AzureRmRecoveryServicesBackupPolicyBase GetPolicyModel(ProtectionP
147
147
public static List < AzureRmRecoveryServicesBackupPolicyBase > GetPolicyModelList (
148
148
ProtectionPolicyListResponse hydraListResponse )
149
149
{
150
- if ( hydraListResponse == null || hydraListResponse . ItemList == null ||
150
+ if ( hydraListResponse == null || hydraListResponse . ItemList == null ||
151
151
hydraListResponse . ItemList . Value == null || hydraListResponse . ItemList . Value . Count == 0 )
152
152
{
153
153
Logger . Instance . WriteDebug ( "Received empty list of policies from service" ) ;
@@ -157,10 +157,10 @@ public static List<AzureRmRecoveryServicesBackupPolicyBase> GetPolicyModelList(
157
157
List < AzureRmRecoveryServicesBackupPolicyBase > policyModels = new List < AzureRmRecoveryServicesBackupPolicyBase > ( ) ;
158
158
AzureRmRecoveryServicesBackupPolicyBase policyModel = null ;
159
159
160
- foreach ( ProtectionPolicyResource resource in hydraListResponse . ItemList . Value )
160
+ foreach ( ProtectionPolicyResource resource in hydraListResponse . ItemList . Value )
161
161
{
162
162
policyModel = GetPolicyModel ( resource ) ;
163
- if ( policyModel != null )
163
+ if ( policyModel != null )
164
164
{
165
165
policyModels . Add ( policyModel ) ;
166
166
}
@@ -183,10 +183,14 @@ public static AzureRmRecoveryServicesItemBase GetItemModel(ProtectedItemResource
183
183
{
184
184
if ( protectedItem . Properties . GetType ( ) . IsSubclassOf ( typeof ( AzureIaaSVMProtectedItem ) ) )
185
185
{
186
+ string policyName = null ;
186
187
string policyId = ( ( AzureIaaSVMProtectedItem ) protectedItem . Properties ) . PolicyId ;
187
- Dictionary < UriEnums , string > keyVauleDict =
188
+ if ( policyId != null )
189
+ {
190
+ Dictionary < UriEnums , string > keyVauleDict =
188
191
HelperUtils . ParseUri ( policyId ) ;
189
- string policyName = HelperUtils . GetPolicyNameFromPolicyId ( keyVauleDict , policyId ) ;
192
+ policyName = HelperUtils . GetPolicyNameFromPolicyId ( keyVauleDict , policyId ) ;
193
+ }
190
194
itemModel = new AzureRmRecoveryServicesIaasVmItem ( protectedItem , container , policyName ) ;
191
195
}
192
196
}
0 commit comments