@@ -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 = "" ;
@@ -587,6 +586,7 @@ private void ValidateAzureVMContainerType(Microsoft.Azure.Commands.RecoveryServi
587
586
type . ToString ( ) ) ) ;
588
587
}
589
588
}
589
+
590
590
private void ValidateAzureVMProtectionPolicy ( AzureRmRecoveryServicesPolicyBase policy )
591
591
{
592
592
if ( policy == null || policy . GetType ( ) != typeof ( AzureRmRecoveryServicesIaasVmPolicy ) )
@@ -625,10 +625,9 @@ private void ValidateAzureVMRetentionPolicy(AzureRmRecoveryServicesRetentionPoli
625
625
policy . Validate ( ) ;
626
626
}
627
627
628
- private void ValidateAzureVMEnableProtectionRequest ( string vmName , string rgName , string serviceName ,
628
+ private void ValidateAzureVMEnableProtectionRequest ( string vmName , string serviceName , string rgName ,
629
629
AzureRmRecoveryServicesPolicyBase policy )
630
630
{
631
- ValidateAzureVMProtectionPolicy ( policy ) ;
632
631
if ( string . IsNullOrEmpty ( vmName ) )
633
632
{
634
633
throw new ArgumentException ( string . Format ( Resources . InvalidAzureVMName ) ) ;
@@ -642,8 +641,6 @@ private void ValidateAzureVMEnableProtectionRequest(string vmName, string rgName
642
641
private void ValidateAzureVMModifyProtectionRequest ( AzureRmRecoveryServicesItemBase itemBase ,
643
642
AzureRmRecoveryServicesPolicyBase policy )
644
643
{
645
- ValidateAzureVMProtectionPolicy ( policy ) ;
646
-
647
644
if ( itemBase == null || itemBase . GetType ( ) != typeof ( AzureRmRecoveryServicesIaasVmItem ) )
648
645
{
649
646
throw new ArgumentException ( string . Format ( Resources . InvalidProtectionPolicyException ,
@@ -716,8 +713,10 @@ private bool IsDiscoveryNeeded(string vmName, string rgName, bool isComputeAzure
716
713
vmVersion = ( isComputeAzureVM ) == true ? computeAzureVMVersion : classicComputeAzureVMVersion ;
717
714
718
715
ProtectableObjectListQueryParameters queryParam = new ProtectableObjectListQueryParameters ( ) ;
719
- queryParam . ProviderType = ProviderType . AzureIaasVM . ToString ( ) ;
720
- queryParam . FriendlyName = vmName ;
716
+ // --- TBD To be added once bug is fixed in hydra and service
717
+ //queryParam.ProviderType = ProviderType.AzureIaasVM.ToString();
718
+ //queryParam.FriendlyName = vmName;
719
+
721
720
// No need to use skip or top token here as no pagination support of IaaSVM PO.
722
721
723
722
//First check if container is discovered or not
@@ -736,8 +735,9 @@ private bool IsDiscoveryNeeded(string vmName, string rgName, bool isComputeAzure
736
735
{
737
736
AzureIaaSVMProtectableItem iaaSVMProtectableItem = ( AzureIaaSVMProtectableItem ) protectableItem . Properties ;
738
737
if ( iaaSVMProtectableItem != null &&
739
- iaaSVMProtectableItem . FriendlyName == vmName && iaaSVMProtectableItem . ResourceGroup == rgName
740
- && iaaSVMProtectableItem . VirtualMachineVersion == vmVersion )
738
+ string . Compare ( iaaSVMProtectableItem . FriendlyName , vmName , true ) == 0
739
+ && string . Compare ( iaaSVMProtectableItem . ResourceGroup , rgName , true ) == 0
740
+ && string . Compare ( iaaSVMProtectableItem . VirtualMachineVersion , vmVersion , true ) == 0 )
741
741
{
742
742
protectableObject = iaaSVMProtectableItem ;
743
743
isDiscoveryNeed = false ;
@@ -751,18 +751,12 @@ private bool IsDiscoveryNeeded(string vmName, string rgName, bool isComputeAzure
751
751
752
752
private void RefreshContainer ( )
753
753
{
754
- bool isRetryNeeded = true ;
755
- int retryCount = 1 ;
756
- bool isDiscoverySuccessful = true ;
754
+ bool isDiscoverySuccessful = false ;
757
755
string errorMessage = string . Empty ;
758
- while ( ! isDiscoverySuccessful && retryCount <= 3 )
759
- {
760
- var refreshContainerJobResponse = HydraAdapter . RefreshContainers ( ) ;
756
+ var refreshContainerJobResponse = HydraAdapter . RefreshContainers ( ) ;
761
757
762
- //Now wait for the operation to Complete
763
- isRetryNeeded = WaitForDiscoveryToComplete ( refreshContainerJobResponse . Location , out isDiscoverySuccessful , out errorMessage ) ;
764
- retryCount ++ ;
765
- }
758
+ //Now wait for the operation to Complete
759
+ WaitForDiscoveryToComplete ( refreshContainerJobResponse . Location , out isDiscoverySuccessful , out errorMessage ) ;
766
760
767
761
if ( ! isDiscoverySuccessful )
768
762
{
@@ -778,7 +772,7 @@ private bool WaitForDiscoveryToComplete(string locationUri, out bool isDiscovery
778
772
779
773
isDiscoverySuccessful = true ;
780
774
//If operation fails check if retry is needed or not
781
- if ( status != HttpStatusCode . OK )
775
+ if ( status != HttpStatusCode . NoContent )
782
776
{
783
777
isDiscoverySuccessful = false ;
784
778
errorMessage = String . Format ( Resources . DiscoveryFailureErrorMessage , status ) ;
0 commit comments