Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ASRProtectionEntity" /> class.
        /// </summary>
        /// <param name="pe">Protection entity object to read values from.</param>
        public ASRProtectionEntity(ProtectionEntity pe)
        {
            this.ID = pe.Id;
            this.ProtectionContainerId = pe.Properties.ProtectionContainerId;
            this.Name = pe.Name;
            this.FriendlyName = pe.Properties.FriendlyName;
            this.Type = pe.Type;
            this.FabricObjectId =
                (0 == string.Compare(this.Type, "VirtualMachine", StringComparison.OrdinalIgnoreCase)) ?
                pe.Properties.FabricObjectId.ToUpper() :
                pe.Properties.FabricObjectId;
            this.ProtectionStatus = pe.Properties.ProtectionStatus;
            this.ProtectionStateDescription = pe.Properties.ProtectionStateDescription;
            // this.CanCommit = pe.CanCommit;
            // this.CanFailover = pe.CanFailover;
            // this.CanReverseReplicate = pe.CanReverseReplicate;
            this.AllowedOperations = pe.Properties.AllowedOperations;
            this.ReplicationProvider = pe.Properties.ReplicationProvider;
            this.ActiveLocation = pe.Properties.ActiveLocation;
            this.ReplicationHealth = pe.Properties.ReplicationHealth;
            this.TestFailoverStateDescription = pe.Properties.TestFailoverStateDescription;

            if (pe.Properties.ReplicationProviderSettings != null)
            {
                if (0 == string.Compare(
                    pe.Properties.ReplicationProvider,
                    Constants.HyperVReplicaAzure,
                    StringComparison.OrdinalIgnoreCase))
                {
                    if (pe.Properties.ReplicationProviderSettings is AzureProtectionEntityProviderSettings)
                    {
                        AzureProtectionEntityProviderSettings providerSettings =
                            (AzureProtectionEntityProviderSettings)pe.Properties.ReplicationProviderSettings;

                        AzureVmDiskDetails diskDetails = providerSettings.VMDiskDetails;
                        this.UpdateDiskDetails(diskDetails);

                        // also take the VM properties
                    }
                    else if (pe.Properties.ReplicationProviderSettings is OnPremProtectionEntityProviderSettings)
                    {
                        OnPremProtectionEntityProviderSettings providerSettings =
                            (OnPremProtectionEntityProviderSettings)pe.Properties.ReplicationProviderSettings;

                        AzureVmDiskDetails diskDetails = providerSettings.VMDiskDetails;
                        this.UpdateDiskDetails(diskDetails);
                    }
                }
                else
                {
                    OnPremProtectionEntityProviderSettings providerSettings =
                        (OnPremProtectionEntityProviderSettings)pe.Properties.ReplicationProviderSettings;

                    AzureVmDiskDetails diskDetails = providerSettings.VMDiskDetails;
                    this.UpdateDiskDetails(diskDetails);
                }
            }

            if (pe.Properties.ProtectionProfile != null &&
                !string.IsNullOrWhiteSpace(pe.Properties.ProtectionProfile.Id))
            {
                this.ProtectionProfile = new ASRProtectionProfile(pe.Properties.ProtectionProfile);
            }
        }
 /// <summary>
 /// Writes Protection Entity.
 /// </summary>
 /// <param name="pe">Protection Entity</param>
 private void WriteProtectionEntity(ProtectionEntity pe)
 {
     this.WriteObject(new ASRProtectionEntity(pe));
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ASRProtectionEntity" /> class.
        /// </summary>
        /// <param name="pe">Protection entity object to read values from.</param>
        public ASRProtectionEntity(ProtectionEntity pe)
        {
            this.ID = pe.Id;
            this.ProtectionContainerId = pe.Properties.ProtectionContainerId;
            this.Name = pe.Name;
            this.FriendlyName = pe.Properties.FriendlyName;
            this.Type = pe.Type;
            this.FabricObjectId =
                (0 == string.Compare(this.Type, "VirtualMachine", StringComparison.OrdinalIgnoreCase)) ?
                pe.Properties.FabricObjectId.ToUpper() :
                pe.Properties.FabricObjectId;
            this.ProtectionStatus = pe.Properties.ProtectionStatus;
            this.ProtectionStateDescription = pe.Properties.ProtectionStateDescription;
            // this.CanCommit = pe.CanCommit;
            // this.CanFailover = pe.CanFailover;
            // this.CanReverseReplicate = pe.CanReverseReplicate;
            this.AllowedOperations = pe.Properties.AllowedOperations;
            this.ReplicationProvider = pe.Properties.ReplicationProvider;
            this.ActiveLocation = pe.Properties.ActiveLocation;
            this.ReplicationHealth = pe.Properties.ReplicationHealth;
            this.TestFailoverStateDescription = pe.Properties.TestFailoverStateDescription;

            /*
            if (!string.IsNullOrWhiteSpace(pe.ReplicationProviderSettings))
            {
                AzureVmDiskDetails diskDetails;
                DataContractUtils.Deserialize<AzureVmDiskDetails>(
                    pe.ReplicationProviderSettings, out diskDetails);

                this.Disks = diskDetails.Disks;
                this.OSDiskId = diskDetails.VHDId;
                this.OSDiskName = diskDetails.OsDisk;
                this.OS = diskDetails.OsType;
            }
            */

            if (pe.Properties.ProtectionProfile != null &&
                !string.IsNullOrWhiteSpace(pe.Properties.ProtectionProfile.Id))
            {
                this.ProtectionProfile = new ASRProtectionProfile(pe.Properties.ProtectionProfile);
            }
        }