15
15
using System ;
16
16
using System . Collections . Generic ;
17
17
using System . Diagnostics . CodeAnalysis ;
18
+ using System . IO ;
18
19
using System . Runtime . Serialization ;
20
+ using System . Xml ;
21
+ using System . Xml . Serialization ;
19
22
using Microsoft . Azure . Common . Authentication ;
20
23
using Microsoft . Azure . Portal . RecoveryServices . Models . Common ;
21
24
using Microsoft . WindowsAzure . Management . RecoveryServices . Models ;
@@ -910,14 +913,69 @@ public ASRProtectionEntity(ProtectionEntity pe)
910
913
911
914
if ( ! string . IsNullOrWhiteSpace ( pe . ReplicationProviderSettings ) )
912
915
{
913
- AzureVmDiskDetails diskDetails ;
914
- DataContractUtils . Deserialize < AzureVmDiskDetails > (
915
- pe . ReplicationProviderSettings , out diskDetails ) ;
916
-
917
- this . Disks = diskDetails . Disks ;
918
- this . OSDiskId = diskDetails . VHDId ;
919
- this . OSDiskName = diskDetails . OsDisk ;
920
- this . OS = diskDetails . OsType ;
916
+ if ( pe . ReplicationProvider == Constants . HyperVReplicaAzure )
917
+ {
918
+ ReplicationProviderSpecificSettings providerDetails ;
919
+ DataContractUtils . Deserialize < ReplicationProviderSpecificSettings > (
920
+ pe . ReplicationProviderSettings , out providerDetails ) ;
921
+
922
+ this . RecoveryAzureVMName = providerDetails . VMProperties . RecoveryAzureVMName ;
923
+ this . RecoveryAzureVMSize = providerDetails . VMProperties . RecoveryAzureVMSize ;
924
+ this . SelectedRecoveryAzureNetworkId =
925
+ providerDetails . VMProperties . SelectedRecoveryAzureNetworkId ;
926
+ this . VMNics = new List < VMNic > ( ) ;
927
+
928
+ // Missing Nic details on serializing, going with the below workaround.
929
+ XmlDocument xmlDoc = new XmlDocument ( ) ;
930
+ xmlDoc . LoadXml ( pe . ReplicationProviderSettings ) ;
931
+ XmlNodeList parentNode = xmlDoc . GetElementsByTagName ( "VMNicDetails" ) ;
932
+ foreach ( XmlNode childrenNode in parentNode )
933
+ {
934
+ VMNic vmnicDetails = new VMNic ( ) ;
935
+ foreach ( XmlNode childNode in childrenNode . ChildNodes )
936
+ {
937
+ switch ( childNode . Name )
938
+ {
939
+ case "NicId" :
940
+ vmnicDetails . NicId = childNode . InnerText ;
941
+ break ;
942
+ case "VMSubnetName" :
943
+ vmnicDetails . VMSubnetName = childNode . InnerText ;
944
+ break ;
945
+ case "VMNetworkName" :
946
+ vmnicDetails . VMNetworkName = childNode . InnerText ;
947
+ break ;
948
+ case "RecoveryVMNetworkId" :
949
+ vmnicDetails . RecoveryVMNetworkId = childNode . InnerText ;
950
+ break ;
951
+ case "RecoveryVMSubnetName" :
952
+ vmnicDetails . RecoveryVMSubnetName = childNode . InnerText ;
953
+ break ;
954
+ case "ReplicaNicStaticIPAddress" :
955
+ vmnicDetails . RecoveryNicStaticIPAddress = childNode . InnerText ;
956
+ break ;
957
+ }
958
+ }
959
+
960
+ this . VMNics . Add ( vmnicDetails ) ;
961
+ }
962
+
963
+ this . Disks = providerDetails . AzureVMDiskDetails . Disks ;
964
+ this . OSDiskId = providerDetails . AzureVMDiskDetails . VHDId ;
965
+ this . OSDiskName = providerDetails . AzureVMDiskDetails . OsDisk ;
966
+ this . OS = providerDetails . AzureVMDiskDetails . OsType ;
967
+ }
968
+ else
969
+ {
970
+ AzureVmDiskDetails diskDetails ;
971
+ DataContractUtils . Deserialize < AzureVmDiskDetails > (
972
+ pe . ReplicationProviderSettings , out diskDetails ) ;
973
+
974
+ this . Disks = diskDetails . Disks ;
975
+ this . OSDiskId = diskDetails . VHDId ;
976
+ this . OSDiskName = diskDetails . OsDisk ;
977
+ this . OS = diskDetails . OsType ;
978
+ }
921
979
}
922
980
923
981
if ( pe . ProtectionProfile != null &&
@@ -1082,6 +1140,26 @@ public ASRProtectionEntity(
1082
1140
/// Gets or sets Replication provider.
1083
1141
/// </summary>
1084
1142
public string ReplicationProvider { get ; set ; }
1143
+
1144
+ /// <summary>
1145
+ /// Gets or sets Recovery Azure VM Name
1146
+ /// </summary>
1147
+ public string RecoveryAzureVMName { get ; set ; }
1148
+
1149
+ /// <summary>
1150
+ /// Gets or sets the Recovery Azure VM size.
1151
+ /// </summary>
1152
+ public string RecoveryAzureVMSize { get ; set ; }
1153
+
1154
+ /// <summary>
1155
+ /// Gets or sets the selected recovery azure network Id.
1156
+ /// </summary>
1157
+ public string SelectedRecoveryAzureNetworkId { get ; set ; }
1158
+
1159
+ /// <summary>
1160
+ /// Gets or sets the list of VM NIC details.
1161
+ /// </summary>
1162
+ public List < VMNic > VMNics { get ; set ; }
1085
1163
}
1086
1164
1087
1165
/// <summary>
@@ -1665,4 +1743,51 @@ public class VirtualHardDisk
1665
1743
[ DataMember ]
1666
1744
public string Name { get ; set ; }
1667
1745
}
1746
+
1747
+ /// <summary>
1748
+ /// Partial details of a NIC of a VM.
1749
+ /// </summary>
1750
+ [ DataContract ( Namespace = "http://schemas.microsoft.com/windowsazure" ) ]
1751
+ [ SuppressMessage (
1752
+ "Microsoft.StyleCop.CSharp.MaintainabilityRules" ,
1753
+ "SA1402:FileMayOnlyContainASingleClass" ,
1754
+ Justification = "Keeping all related classes together." ) ]
1755
+ public class VMNic
1756
+ {
1757
+ /// <summary>
1758
+ /// Gets or sets ID of the NIC.
1759
+ /// </summary>
1760
+ [ DataMember ]
1761
+ public string NicId { get ; set ; }
1762
+
1763
+ /// <summary>
1764
+ /// Gets or sets Name of the VM subnet.
1765
+ /// </summary>
1766
+ [ DataMember ]
1767
+ public string VMSubnetName { get ; set ; }
1768
+
1769
+ /// <summary>
1770
+ /// Gets or sets Name of the VM network.
1771
+ /// </summary>
1772
+ [ DataMember ]
1773
+ public string VMNetworkName { get ; set ; }
1774
+
1775
+ /// <summary>
1776
+ /// Gets or sets Id of the recovery VM Network.
1777
+ /// </summary>
1778
+ [ DataMember ]
1779
+ public string RecoveryVMNetworkId { get ; set ; }
1780
+
1781
+ /// <summary>
1782
+ /// Gets or sets the name of the recovery VM subnet.
1783
+ /// </summary>
1784
+ [ DataMember ]
1785
+ public string RecoveryVMSubnetName { get ; set ; }
1786
+
1787
+ /// <summary>
1788
+ /// Gets or sets the static IP address of the replica NIC.
1789
+ /// </summary>
1790
+ [ DataMember ]
1791
+ public string RecoveryNicStaticIPAddress { get ; set ; }
1792
+ }
1668
1793
}
0 commit comments