Esempio n. 1
0
        public static MappingOperationResponse PairCloudToAzure(
            this SiteRecoveryManagementClient client,
            Fabric primaryFabric,
            ProtectionContainer primaryContainer, 
            Policy policy,
            string armResourceName)
        {
            CreateProtectionContainerMappingInputProperties pairingProps = 
                new CreateProtectionContainerMappingInputProperties()
            {
                PolicyId = policy.Id,
                TargetProtectionContainerId = "Microsoft Azure",
                ProviderSpecificInput = new ReplicationProviderContainerMappingInput()
            };

            CreateProtectionContainerMappingInput pairingInput = 
                new CreateProtectionContainerMappingInput()
            {
                Properties = pairingProps
            };

            return client.ProtectionContainerMapping.ConfigureProtection(
                primaryFabric.Name,
                primaryContainer.Name,
                armResourceName,
                pairingInput,
                GetRequestHeaders()) as MappingOperationResponse;
        }
 /// <summary>
 /// Write Policy.
 /// </summary>
 /// <param name="policy">Policy object</param>
 private void WritePolicy(Policy policy)
 {
     this.WriteObject(new ASRPolicy(policy));
 }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ASRProtectionEntity" /> class when it is protected
        /// </summary>
        /// <param name="pi">Protectable Item to read values from</param>
        /// <param name="rpi">Replication Protected Item to read values from</param>
        public ASRProtectionEntity(ProtectableItem pi, ReplicationProtectedItem rpi, Policy policy = null) : this(pi)
        {
            this.Type = rpi.Type;
            this.ProtectionStateDescription = rpi.Properties.ProtectionStateDescription;

            if (rpi.Properties.AllowedOperations != null)
            {
                this.AllowedOperations = new List<string>();
                foreach (String op in rpi.Properties.AllowedOperations)
                {
                    AllowedOperations.Add(op);
                }
            }
            this.ReplicationProvider = rpi.Properties.ProviderSpecificDetails.InstanceType;
            this.ActiveLocation = rpi.Properties.ActiveLocation;
            this.ReplicationHealth = rpi.Properties.ReplicationHealth;
            this.TestFailoverStateDescription = rpi.Properties.TestFailoverStateDescription;
            this.ProtectionStatus = rpi.Properties.ProtectionState;
            if (policy != null)
            {
                this.Policy = new ASRPolicy(policy);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ASRVirtualMachine" /> class when it is protected
        /// </summary>
        /// <param name="pi">Protectable Item to read values from</param>
        /// <param name="rpi">Replication Protected Item to read values from</param>
        public ASRVirtualMachine(ProtectableItem pi, ReplicationProtectedItem rpi, Policy policy = null)
            : base(pi, rpi, policy)
        {
            if (0 == string.Compare(
                    rpi.Properties.ProviderSpecificDetails.InstanceType,
                    Constants.HyperVReplicaAzure,
                    StringComparison.OrdinalIgnoreCase))
            {
                HyperVReplicaAzureReplicationDetails providerSpecificDetails =
                           (HyperVReplicaAzureReplicationDetails)rpi.Properties.ProviderSpecificDetails;

                RecoveryAzureVMName = providerSpecificDetails.RecoveryAzureVMName;
                RecoveryAzureVMSize = providerSpecificDetails.RecoveryAzureVMSize;
                RecoveryAzureStorageAccount = providerSpecificDetails.RecoveryAzureStorageAccount;
                SelectedRecoveryAzureNetworkId = providerSpecificDetails.SelectedRecoveryAzureNetworkId;
                if (providerSpecificDetails.VMNics != null)
                {
                    NicDetailsList = new List<ASRVMNicDetails>();
                    foreach(VMNicDetails n in providerSpecificDetails.VMNics)
                    {
                        NicDetailsList.Add(new ASRVMNicDetails(n));
                    }
                }
            }
           
        }
Esempio n. 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ASRPolicy" /> class with 
        /// required parameters.
        /// </summary>
        /// <param name="policy">Protection container object</param>
        public ASRPolicy(Policy policy)
        {
            this.ID = policy.Id;
            this.Name = policy.Name;
            this.FriendlyName = policy.Properties.FriendlyName;
            this.Type = policy.Type;
            this.ReplicationProvider = policy.Properties.ProviderSpecificDetails.InstanceType;

            if (policy.Properties.ProviderSpecificDetails.InstanceType == Constants.HyperVReplica2012)
            {
                HyperVReplica2012PolicyDetails details =
                    (HyperVReplica2012PolicyDetails)policy.Properties.ProviderSpecificDetails;

                ASRHyperVReplicaPolicyDetails replicationProviderSettings =
                    new ASRHyperVReplicaPolicyDetails();

                replicationProviderSettings.ReplicaDeletionOption =
                    details.ReplicaDeletionOption;
                replicationProviderSettings.ApplicationConsistentSnapshotFrequencyInHours =
                    details.ApplicationConsistentSnapshotFrequencyInHours;
                replicationProviderSettings.Compression =
                    details.Compression;
                replicationProviderSettings.ReplicationFrequencyInSeconds =
                    300;
                replicationProviderSettings.AllowedAuthenticationType =
                    (details.AllowedAuthenticationType == 1) ?
                    Constants.AuthenticationTypeKerberos :
                    Constants.AuthenticationTypeCertificate;
                replicationProviderSettings.RecoveryPoints = details.RecoveryPoints;
                replicationProviderSettings.InitialReplicationMethod =
                    (string.Compare(details.InitialReplicationMethod, "OverNetwork", StringComparison.OrdinalIgnoreCase) == 0) ?
                    Constants.OnlineReplicationMethod :
                    Constants.OfflineReplicationMethod;
                replicationProviderSettings.ReplicationPort = details.ReplicationPort;
                replicationProviderSettings.OnlineReplicationStartTime = details.OnlineReplicationStartTime;

                this.ReplicationProviderSettings = replicationProviderSettings;
            }
            else if (policy.Properties.ProviderSpecificDetails.InstanceType == Constants.HyperVReplica2012R2)
            {
                HyperVReplica2012R2PolicyDetails details =
                    (HyperVReplica2012R2PolicyDetails)policy.Properties.ProviderSpecificDetails;

                ASRHyperVReplicaPolicyDetails replicationProviderSettings =
                    new ASRHyperVReplicaPolicyDetails();

                replicationProviderSettings.ReplicaDeletionOption =
                    details.ReplicaDeletionOption;
                replicationProviderSettings.ApplicationConsistentSnapshotFrequencyInHours =
                    details.ApplicationConsistentSnapshotFrequencyInHours;
                replicationProviderSettings.Compression =
                    details.Compression;
                replicationProviderSettings.ReplicationFrequencyInSeconds =
                    details.ReplicationFrequencyInSeconds;
                replicationProviderSettings.AllowedAuthenticationType =
                    (details.AllowedAuthenticationType == 1) ?
                    Constants.AuthenticationTypeKerberos :
                    Constants.AuthenticationTypeCertificate;
                replicationProviderSettings.RecoveryPoints = details.RecoveryPoints;
                replicationProviderSettings.InitialReplicationMethod =
                    (string.Compare(details.InitialReplicationMethod, "OverNetwork", StringComparison.OrdinalIgnoreCase) == 0) ?
                    Constants.OnlineReplicationMethod :
                    Constants.OfflineReplicationMethod;
                replicationProviderSettings.ReplicationPort = details.ReplicationPort;
                replicationProviderSettings.OnlineReplicationStartTime = details.OnlineReplicationStartTime;

                this.ReplicationProviderSettings = replicationProviderSettings;
            }
            else if (policy.Properties.ProviderSpecificDetails.InstanceType == Constants.HyperVReplicaAzure)
            {
                HyperVReplicaAzurePolicyDetails details =
                    (HyperVReplicaAzurePolicyDetails)policy.Properties.ProviderSpecificDetails;

                ASRHyperVReplicaAzurePolicyDetails replicationProviderSettings =
                    new ASRHyperVReplicaAzurePolicyDetails();

                replicationProviderSettings.ApplicationConsistentSnapshotFrequencyInHours =
                    details.ApplicationConsistentSnapshotFrequencyInHours;
                replicationProviderSettings.ReplicationFrequencyInSeconds = details.ReplicationInterval;
                replicationProviderSettings.RecoveryPoints = details.RecoveryPointHistoryDurationInHours;
                replicationProviderSettings.OnlineReplicationStartTime = details.OnlineReplicationStartTime;
                replicationProviderSettings.Encryption = details.Encryption;
                replicationProviderSettings.ActiveStorageAccountId =
                    details.ActiveStorageAccountId;

                this.ReplicationProviderSettings = replicationProviderSettings;
            }
        }
Esempio n. 6
0
        public static ReplicationProtectedItemOperationResponse EnableDR(
            this SiteRecoveryManagementClient client,
            Fabric primaryFabric,
            ProtectionContainer protectionContainer,
            Policy policy,
            ProtectableItem protectableItem,
            string armResourceName)
        {
            if (policy.Properties.ProviderSpecificDetails.InstanceType == "HyperVReplicaAzure")
            {
                string vhdId = (protectableItem.Properties.CustomDetails as HyperVVirtualMachineDetails)
                    .DiskDetailsList[0].VhdId;

                DiskDetails osDisk = (protectableItem.Properties.CustomDetails as HyperVVirtualMachineDetails).DiskDetailsList
                    .FirstOrDefault(item => item.VhdType == "OperatingSystem");

                if (osDisk != null)
                {
                    vhdId = osDisk.VhdId;
                }

                HyperVReplicaAzureEnableProtectionInput hvrAEnableDRInput = 
                    new HyperVReplicaAzureEnableProtectionInput()
                {
                    HvHostVmId = (protectableItem.Properties.CustomDetails as HyperVVirtualMachineDetails).SourceItemId,
                    OSType = "Windows",
                    VhdId = vhdId,
                    VmName = protectableItem.Properties.FriendlyName,
                    TargetStorageAccountId = 
                        (policy.Properties.ProviderSpecificDetails as HyperVReplicaAzurePolicyDetails)
                        .ActiveStorageAccountId,
                };

                EnableProtectionInputProperties enableDRProp = new EnableProtectionInputProperties()
                {
                    PolicyId = policy.Id,
                    ProtectableItemId = protectableItem.Id,
                    ProviderSpecificDetails = hvrAEnableDRInput
                };

                EnableProtectionInput enableDRInput = new EnableProtectionInput()
                {
                    Properties = enableDRProp
                };

                return client.ReplicationProtectedItem.EnableProtection(
                    primaryFabric.Name,
                    protectionContainer.Name,
                    armResourceName,
                    enableDRInput,
                    GetRequestHeaders()) as ReplicationProtectedItemOperationResponse;
            }
            else if (policy.Properties.ProviderSpecificDetails.InstanceType == "HyperVReplica2012" ||
                policy.Properties.ProviderSpecificDetails.InstanceType == "HyperVReplica2012R2")
            {
                var enableDRProp = new EnableProtectionInputProperties()
                {
                    PolicyId = policy.Id,
                    ProtectableItemId = protectableItem.Id,
                    ProviderSpecificDetails = new EnableProtectionProviderSpecificInput()
                };

                EnableProtectionInput enableInput = new EnableProtectionInput()
                {
                    Properties = enableDRProp
                };

                return client.ReplicationProtectedItem.EnableProtection(
                    primaryFabric.Name,
                    protectionContainer.Name,
                    armResourceName,
                    enableInput,
                    GetRequestHeaders()) as ReplicationProtectedItemOperationResponse;
            }
            else
            {
                throw new NotImplementedException();
            }
        }