/// <summary> /// Update Recovery Plan: By Service object /// </summary> private void UpdateRecoveryPlan(RecoveryPlan recoveryPlan) { UpdateRecoveryPlanInputProperties updateRecoveryPlanInputProperties = new UpdateRecoveryPlanInputProperties() { Groups = recoveryPlan.Properties.Groups, }; UpdateRecoveryPlanInput updateRecoveryPlanInput = new UpdateRecoveryPlanInput() { Properties = updateRecoveryPlanInputProperties }; UpdateRecoveryPlan(recoveryPlan.Name, updateRecoveryPlanInput); }
/// <summary> /// Update Recovery Plan: By powerShell Recovery Plan object /// </summary> private void UpdateRecoveryPlan(ASRRecoveryPlan asrRecoveryPlan) { UpdateRecoveryPlanInputProperties updateRecoveryPlanInputProperties = new UpdateRecoveryPlanInputProperties() { Groups = new List <RecoveryPlanGroup>(), }; foreach (ASRRecoveryPlanGroup asrRecoveryPlanGroup in asrRecoveryPlan.Groups) { RecoveryPlanGroup recoveryPlanGroup = new RecoveryPlanGroup() { GroupType = asrRecoveryPlanGroup.GroupType, // Initialize ReplicationProtectedItems with empty List if asrRecoveryPlanGroup.ReplicationProtectedItems is null // otherwise assign respective values ReplicationProtectedItems = asrRecoveryPlanGroup.ReplicationProtectedItems == null ? new List <RecoveryPlanProtectedItem>() : asrRecoveryPlanGroup.ReplicationProtectedItems.Select(item => { var newItem = new RecoveryPlanProtectedItem(item.Id); string VmId = null; if (item.Properties.ProviderSpecificDetails.GetType() == typeof(HyperVReplicaAzureReplicationDetails)) { VmId = ((HyperVReplicaAzureReplicationDetails)item.Properties.ProviderSpecificDetails).VmId; } else if (item.Properties.ProviderSpecificDetails.GetType() == typeof(HyperVReplica2012ReplicationDetails)) { VmId = ((HyperVReplica2012ReplicationDetails)item.Properties.ProviderSpecificDetails).VmId; } newItem.VirtualMachineId = VmId; return(newItem); }).ToList(), StartGroupActions = asrRecoveryPlanGroup.StartGroupActions, EndGroupActions = asrRecoveryPlanGroup.EndGroupActions }; updateRecoveryPlanInputProperties.Groups.Add(recoveryPlanGroup); } UpdateRecoveryPlanInput updateRecoveryPlanInput = new UpdateRecoveryPlanInput() { Properties = updateRecoveryPlanInputProperties }; UpdateRecoveryPlan(asrRecoveryPlan.Name, updateRecoveryPlanInput); }
/// <summary> /// Update Recovery Plan: By Service object /// </summary> private void UpdateRecoveryPlan( RecoveryPlan recoveryPlan) { var updateRecoveryPlanInputProperties = new UpdateRecoveryPlanInputProperties { Groups = recoveryPlan.Properties.Groups }; var updateRecoveryPlanInput = new UpdateRecoveryPlanInput { Properties = updateRecoveryPlanInputProperties }; this.UpdateRecoveryPlan( recoveryPlan.Name, updateRecoveryPlanInput); }
/// <summary> /// Update Recovery Plan: By powerShell Recovery Plan object /// </summary> private void UpdateRecoveryPlan( ASRRecoveryPlan asrRecoveryPlan) { var updateRecoveryPlanInputProperties = new UpdateRecoveryPlanInputProperties { Groups = new List <RecoveryPlanGroup>() }; foreach (var asrRecoveryPlanGroup in asrRecoveryPlan.Groups) { var recoveryPlanGroup = new RecoveryPlanGroup { GroupType = asrRecoveryPlanGroup.GroupType, // Initialize ReplicationProtectedItems with empty List if asrRecoveryPlanGroup.ReplicationProtectedItems is null // otherwise assign respective values ReplicationProtectedItems = asrRecoveryPlanGroup.ReplicationProtectedItems == null ? new List <RecoveryPlanProtectedItem>() : asrRecoveryPlanGroup .ReplicationProtectedItems.Select( item => { var newItem = new RecoveryPlanProtectedItem(item.ID); string VmId = null; if (item.ProviderSpecificDetails.GetType() == typeof(ASRHyperVReplicaAzureSpecificRPIDetails)) { VmId = ((ASRHyperVReplicaAzureSpecificRPIDetails)item.ProviderSpecificDetails).VmId; } else if (item.ProviderSpecificDetails.GetType() == typeof(ASRHyperVReplicaRPIDetails)) { VmId = ((ASRHyperVReplicaRPIDetails)item.ProviderSpecificDetails).VmId; } else if (item.ProviderSpecificDetails.GetType() == typeof(ASRHyperVReplicaBlueRPIDetails)) { VmId = ((ASRHyperVReplicaBlueRPIDetails)item.ProviderSpecificDetails).VmId; } else if (item.ProviderSpecificDetails.GetType() == typeof(ASRInMageSpecificRPIDetails)) { VmId = ((ASRInMageSpecificRPIDetails)item.ProviderSpecificDetails).VmId; } else if (item.ProviderSpecificDetails.GetType() == typeof(ASRInMageSpecificRPIDetails)) { VmId = ((ASRInMageSpecificRPIDetails)item.ProviderSpecificDetails).VmId; } newItem.VirtualMachineId = VmId; return(newItem); }) .ToList(), StartGroupActions = asrRecoveryPlanGroup.StartGroupActions == null ? null : asrRecoveryPlanGroup.StartGroupActions.ToList().ConvertAll( action => ASRRecoveryPlanAction.GetSrsRecoveryPlanAction(action)), EndGroupActions = asrRecoveryPlanGroup.EndGroupActions == null ? null : asrRecoveryPlanGroup.EndGroupActions.ToList().ConvertAll( action => ASRRecoveryPlanAction.GetSrsRecoveryPlanAction(action)), }; updateRecoveryPlanInputProperties.Groups.Add(recoveryPlanGroup); } var updateRecoveryPlanInput = new UpdateRecoveryPlanInput { Properties = updateRecoveryPlanInputProperties }; this.UpdateRecoveryPlan( asrRecoveryPlan.Name, updateRecoveryPlanInput); }