@@ -64,7 +64,6 @@ public BaseRecoveryServicesJobResponse EnableProtection()
64
64
AzureRmRecoveryServicesIaasVmItem item = ( AzureRmRecoveryServicesIaasVmItem )
65
65
ProviderData . ProviderParameters [ ItemParams . Item ] ;
66
66
// do validations
67
-
68
67
69
68
string containerUri = "" ;
70
69
string protectedItemUri = "" ;
@@ -613,6 +612,7 @@ private void ValidateAzureVMContainerType(Microsoft.Azure.Commands.RecoveryServi
613
612
type . ToString ( ) ) ) ;
614
613
}
615
614
}
615
+
616
616
private void ValidateAzureVMProtectionPolicy ( AzureRmRecoveryServicesPolicyBase policy )
617
617
{
618
618
if ( policy == null || policy . GetType ( ) != typeof ( AzureRmRecoveryServicesIaasVmPolicy ) )
@@ -651,10 +651,9 @@ private void ValidateAzureVMRetentionPolicy(AzureRmRecoveryServicesRetentionPoli
651
651
policy . Validate ( ) ;
652
652
}
653
653
654
- private void ValidateAzureVMEnableProtectionRequest ( string vmName , string rgName , string serviceName ,
654
+ private void ValidateAzureVMEnableProtectionRequest ( string vmName , string serviceName , string rgName ,
655
655
AzureRmRecoveryServicesPolicyBase policy )
656
656
{
657
- ValidateAzureVMProtectionPolicy ( policy ) ;
658
657
if ( string . IsNullOrEmpty ( vmName ) )
659
658
{
660
659
throw new ArgumentException ( string . Format ( Resources . InvalidAzureVMName ) ) ;
@@ -668,8 +667,6 @@ private void ValidateAzureVMEnableProtectionRequest(string vmName, string rgName
668
667
private void ValidateAzureVMModifyProtectionRequest ( AzureRmRecoveryServicesItemBase itemBase ,
669
668
AzureRmRecoveryServicesPolicyBase policy )
670
669
{
671
- ValidateAzureVMProtectionPolicy ( policy ) ;
672
-
673
670
if ( itemBase == null || itemBase . GetType ( ) != typeof ( AzureRmRecoveryServicesIaasVmItem ) )
674
671
{
675
672
throw new ArgumentException ( string . Format ( Resources . InvalidProtectionPolicyException ,
@@ -742,8 +739,10 @@ private bool IsDiscoveryNeeded(string vmName, string rgName, bool isComputeAzure
742
739
vmVersion = ( isComputeAzureVM ) == true ? computeAzureVMVersion : classicComputeAzureVMVersion ;
743
740
744
741
ProtectableObjectListQueryParameters queryParam = new ProtectableObjectListQueryParameters ( ) ;
745
- queryParam . ProviderType = ProviderType . AzureIaasVM . ToString ( ) ;
746
- queryParam . FriendlyName = vmName ;
742
+ // --- TBD To be added once bug is fixed in hydra and service
743
+ //queryParam.ProviderType = ProviderType.AzureIaasVM.ToString();
744
+ //queryParam.FriendlyName = vmName;
745
+
747
746
// No need to use skip or top token here as no pagination support of IaaSVM PO.
748
747
749
748
//First check if container is discovered or not
@@ -762,8 +761,9 @@ private bool IsDiscoveryNeeded(string vmName, string rgName, bool isComputeAzure
762
761
{
763
762
AzureIaaSVMProtectableItem iaaSVMProtectableItem = ( AzureIaaSVMProtectableItem ) protectableItem . Properties ;
764
763
if ( iaaSVMProtectableItem != null &&
765
- iaaSVMProtectableItem . FriendlyName == vmName && iaaSVMProtectableItem . ResourceGroup == rgName
766
- && iaaSVMProtectableItem . VirtualMachineVersion == vmVersion )
764
+ string . Compare ( iaaSVMProtectableItem . FriendlyName , vmName , true ) == 0
765
+ && string . Compare ( iaaSVMProtectableItem . ResourceGroup , rgName , true ) == 0
766
+ && string . Compare ( iaaSVMProtectableItem . VirtualMachineVersion , vmVersion , true ) == 0 )
767
767
{
768
768
protectableObject = iaaSVMProtectableItem ;
769
769
isDiscoveryNeed = false ;
@@ -777,18 +777,12 @@ private bool IsDiscoveryNeeded(string vmName, string rgName, bool isComputeAzure
777
777
778
778
private void RefreshContainer ( )
779
779
{
780
- bool isRetryNeeded = true ;
781
- int retryCount = 1 ;
782
- bool isDiscoverySuccessful = true ;
780
+ bool isDiscoverySuccessful = false ;
783
781
string errorMessage = string . Empty ;
784
- while ( ! isDiscoverySuccessful && retryCount <= 3 )
785
- {
786
- var refreshContainerJobResponse = HydraAdapter . RefreshContainers ( ) ;
782
+ var refreshContainerJobResponse = HydraAdapter . RefreshContainers ( ) ;
787
783
788
- //Now wait for the operation to Complete
789
- isRetryNeeded = WaitForDiscoveryToComplete ( refreshContainerJobResponse . Location , out isDiscoverySuccessful , out errorMessage ) ;
790
- retryCount ++ ;
791
- }
784
+ //Now wait for the operation to Complete
785
+ WaitForDiscoveryToComplete ( refreshContainerJobResponse . Location , out isDiscoverySuccessful , out errorMessage ) ;
792
786
793
787
if ( ! isDiscoverySuccessful )
794
788
{
@@ -804,7 +798,7 @@ private bool WaitForDiscoveryToComplete(string locationUri, out bool isDiscovery
804
798
805
799
isDiscoverySuccessful = true ;
806
800
//If operation fails check if retry is needed or not
807
- if ( status != HttpStatusCode . OK )
801
+ if ( status != HttpStatusCode . NoContent )
808
802
{
809
803
isDiscoverySuccessful = false ;
810
804
errorMessage = String . Format ( Resources . DiscoveryFailureErrorMessage , status ) ;
0 commit comments