Skip to content

Commit c75b86c

Browse files
authored
Merge pull request #2469 from AsrOneSdk/devBugFixes
Azure Site Recovery Bug Fixes and adding deprecation warning for RDFE cmdlets.
2 parents 8ce4876 + db0da22 commit c75b86c

File tree

57 files changed

+608
-843
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+608
-843
lines changed

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.ServiceClientAdapter/ClientProxyBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ public string GetResourceName()
8181
/// <returns></returns>
8282
public string GetResourceGroupName()
8383
{
84-
if (string.IsNullOrEmpty(PSRecoveryServicesClient.arsVault.ResouceGroupName))
84+
if (string.IsNullOrEmpty(PSRecoveryServicesClient.arsVault.ResourceGroupName))
8585
{
8686
throw new ArgumentException(Resources.SetVaultContextFirst);
8787
}
88-
return PSRecoveryServicesClient.arsVault.ResouceGroupName;
88+
return PSRecoveryServicesClient.arsVault.ResourceGroupName;
8989
}
9090

9191
/// <summary>

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Test/SessionRecords/Microsoft.Azure.Commands.RecoveryServices.Test.ScenarioTests.RecoveryServicesTests/VaultCRUDTests.json

Lines changed: 255 additions & 797 deletions
Large diffs are not rendered by default.

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Common/PSRecoveryServicesVaultExtendedInfoClient.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public ASRVaultCreds GenerateVaultCredential(X509Certificate2 managementCert, AR
9090
// Update vault settings with the working vault to generate file
9191
Utilities.UpdateCurrentVaultContext(new ASRVaultCreds()
9292
{
93-
ResourceGroupName = vault.ResouceGroupName,
93+
ResourceGroupName = vault.ResourceGroupName,
9494
ResourceName = vault.Name,
9595
ResourceNamespace = resourceProviderNamespace,
9696
ARMResourceType = resourceType
@@ -138,7 +138,7 @@ public UploadCertificateResponse UploadCertificate(X509Certificate2 managementCe
138138
certificateArgs.Properties.Add("certificate", Convert.ToBase64String(managementCert.GetRawCertData()));
139139

140140
var response = this.recoveryServicesClient.VaultExtendedInfo.UploadCertificateAsync(
141-
vault.ResouceGroupName,
141+
vault.ResourceGroupName,
142142
vault.Name,
143143
certificateArgs, managementCert.FriendlyName,
144144
this.GetRequestHeaders());
@@ -158,7 +158,7 @@ public ASRVaultCreds ChangeVaultContext(ARSVault vault)
158158
Utilities.GetResourceProviderNamespaceAndType(vault.ID, out resourceProviderNamespace, out resourceType);
159159
Utilities.UpdateCurrentVaultContext(new ASRVaultCreds()
160160
{
161-
ResourceGroupName = vault.ResouceGroupName,
161+
ResourceGroupName = vault.ResourceGroupName,
162162
ResourceName = vault.Name,
163163
ResourceNamespace = resourceProviderNamespace,
164164
ARMResourceType= resourceType
@@ -171,7 +171,7 @@ public ASRVaultCreds ChangeVaultContext(ARSVault vault)
171171
// Update vault settings along with Channel integrity key
172172
Utilities.UpdateCurrentVaultContext(new ASRVaultCreds()
173173
{
174-
ResourceGroupName = vault.ResouceGroupName,
174+
ResourceGroupName = vault.ResourceGroupName,
175175
ResourceName = vault.Name,
176176
ChannelIntegrityKey = getChannelIntegrityKey.Result,
177177
ResourceNamespace = resourceProviderNamespace,
@@ -289,7 +289,7 @@ private ASRVaultCreds GenerateCredentialObject(X509Certificate2 managementCert,
289289
serializedCertifivate,
290290
acsNamespace,
291291
channelIntegrityKey,
292-
vault.ResouceGroupName,
292+
vault.ResourceGroupName,
293293
site.ID,
294294
site.Name,
295295
resourceProviderNamespace,

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Models/PSObjects.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public ARSVault(Vault vault)
7171
this.Name = vault.Name;
7272
this.Type = vault.Type;
7373
this.Location = vault.Location;
74-
this.ResouceGroupName = PSRecoveryServicesClient.GetResourceGroup(vault.Id);
74+
this.ResourceGroupName = PSRecoveryServicesClient.GetResourceGroup(vault.Id);
7575
this.SubscriptionId = PSRecoveryServicesClient.GetSubscriptionId(vault.Id);
7676
this.Properties = new ARSVaultProperties();
7777
this.Properties.ProvisioningState = vault.Properties.ProvisioningState;
@@ -87,7 +87,7 @@ public ARSVault(VaultCreateResponse vault)
8787
this.Name = vault.Name;
8888
this.Type = vault.Type;
8989
this.Location = vault.Location;
90-
this.ResouceGroupName = PSRecoveryServicesClient.GetResourceGroup(vault.Id);
90+
this.ResourceGroupName = PSRecoveryServicesClient.GetResourceGroup(vault.Id);
9191
this.SubscriptionId = PSRecoveryServicesClient.GetSubscriptionId(vault.Id);
9292
this.Properties = new ARSVaultProperties();
9393
this.Properties.ProvisioningState = vault.Properties.ProvisioningState;
@@ -119,7 +119,7 @@ public ARSVault(VaultCreateResponse vault)
119119
/// <summary>
120120
/// Gets or sets Resouce group name.
121121
/// </summary>
122-
public string ResouceGroupName { get; set; }
122+
public string ResourceGroupName { get; set; }
123123

124124
/// <summary>
125125
/// Gets or sets Subscription.

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Vault/GetAzureRMRecoveryServicesVaultSettingsFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public void GetAzureRMRecoveryServicesVaultBackupCredentials()
208208

209209
WriteDebug(string.Format(CultureInfo.InvariantCulture,
210210
Resources.ExecutingGetVaultCredCmdlet,
211-
subscriptionId, this.Vault.ResouceGroupName, this.Vault.Name, targetLocation));
211+
subscriptionId, this.Vault.ResourceGroupName, this.Vault.Name, targetLocation));
212212

213213
// Generate certificate
214214
X509Certificate2 cert = CertUtils.CreateSelfSignedCertificate(

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Vault/GetAzureRmRecoveryServicesBackupProperties.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public override void ExecuteCmdlet()
4646
try
4747
{
4848
GetResourceStorageConfigResponse getStorageResponse = RecoveryServicesClient.GetVaultStorageType(
49-
this.Vault.ResouceGroupName, this.Vault.Name);
49+
this.Vault.ResourceGroupName, this.Vault.Name);
5050
ASRVaultBackupProperties vaultBackupProperties = new ASRVaultBackupProperties();
5151
vaultBackupProperties.BackupStorageRedundancy = getStorageResponse.Properties.StorageType;
5252
this.WriteObject(vaultBackupProperties);

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Vault/RemoveAzureRMRecoveryServicesVault.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public override void ExecuteCmdlet()
4444
{
4545
try
4646
{
47-
RecoveryServicesOperationStatusResponse response = RecoveryServicesClient.DeleteVault(this.Vault.ResouceGroupName, this.Vault.Name);
47+
RecoveryServicesOperationStatusResponse response = RecoveryServicesClient.DeleteVault(this.Vault.ResourceGroupName, this.Vault.Name);
4848

4949
VaultOperationOutput output = new VaultOperationOutput()
5050
{

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Vault/SetAzureRmRecoveryServicesBackupProperties.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public override void ExecuteCmdlet()
5555
vaultStorageRequest.Properties.StorageModelType = BackupStorageRedundancy.ToString();
5656
AzureOperationResponse storageResponse =
5757
RecoveryServicesClient.UpdateVaultStorageType(
58-
this.Vault.ResouceGroupName, this.Vault.Name, vaultStorageRequest);
58+
this.Vault.ResourceGroupName, this.Vault.Name, vaultStorageRequest);
5959
}
6060
else
6161
{

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Vault/SetAzureRmRecoveryServicesVaultContext.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,19 @@ public override void ExecuteCmdlet()
4444
Vault.Name);
4545
}
4646

47-
if (string.IsNullOrEmpty(Vault.ResouceGroupName))
47+
if (string.IsNullOrEmpty(Vault.ResourceGroupName))
4848
{
4949
throw new ArgumentException(
5050
Properties.Resources.ResourceGroupNameNullOrEmpty,
51-
Vault.ResouceGroupName);
51+
Vault.ResourceGroupName);
5252
}
5353

54-
var vault = RecoveryServicesClient.GetVault(Vault.ResouceGroupName, Vault.Name);
54+
var vault = RecoveryServicesClient.GetVault(Vault.ResourceGroupName, Vault.Name);
5555
if(vault == null)
5656
{
5757
throw new ArgumentException(
5858
string.Format(Properties.Resources.VaultNotFound, Vault.Name),
59-
Vault.ResouceGroupName);
59+
Vault.ResourceGroupName);
6060
}
6161

6262
Utilities.UpdateCurrentVaultContext(Vault);

src/ResourceManager/SiteRecovery/Commands.SiteRecovery/Microsoft.Azure.Commands.SiteRecovery.dll-help.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3738,7 +3738,7 @@
37383738
Set-AzureRmSiteRecoveryVaultSettings
37393739
</command:name>
37403740
<maml:description>
3741-
<maml:para>The Set-AzureRmSiteRecoveryVaultSettings cmdlet sets the site recovery vault context for further operations(not applicable to Recovery Services vaults)</maml:para>
3741+
<maml:para>The Set-AzureRmSiteRecoveryVaultSettings cmdlet sets the Classic or ARM vault context for further operations.</maml:para>
37423742
</maml:description>
37433743
<maml:copyright>
37443744
<maml:para></maml:para>
@@ -3757,9 +3757,9 @@
37573757
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="named">
37583758
<maml:name>Vault</maml:name>
37593759
<maml:description>
3760-
<maml:para>Azure Site Recovery Vault object</maml:para>
3760+
<maml:para>Classic or ARM Vault object</maml:para>
37613761
</maml:description>
3762-
<command:parameterValue required="true" variableLength="false">ASRVault</command:parameterValue>
3762+
<command:parameterValue required="true" variableLength="false">Object</command:parameterValue>
37633763
</command:parameter>
37643764
</command:syntaxItem>
37653765
</command:syntax>
@@ -3768,12 +3768,12 @@
37683768
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="named">
37693769
<maml:name>Vault</maml:name>
37703770
<maml:description>
3771-
<maml:para>Azure Site Recovery Vault object</maml:para>
3771+
<maml:para>Classic or ARM Vault object</maml:para>
37723772

37733773
</maml:description>
3774-
<command:parameterValue required="true" variableLength="false">ASRVault</command:parameterValue>
3774+
<command:parameterValue required="true" variableLength="false">Object</command:parameterValue>
37753775
<dev:type>
3776-
<maml:name>ASRVault</maml:name>
3776+
<maml:name>Object</maml:name>
37773777
<maml:uri/>
37783778
</dev:type>
37793779
<dev:defaultValue></dev:defaultValue>

src/ResourceManager/SiteRecovery/Commands.SiteRecovery/Models/PSConstants.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,33 @@ public static class Constants
114114
/// <summary>
115115
/// Represents Optimize value ForDowntime.
116116
/// </summary>
117-
public const string ForDowntime = "ForDowntime";
117+
public const string ForDownTime = "ForDownTime";
118118

119119
/// <summary>
120120
/// Represents Optimize value for Synchronization.
121121
/// </summary>
122122
public const string ForSynchronization = "ForSynchronization";
123123

124+
/// <summary>
125+
/// Represents Yes.
126+
/// </summary>
127+
public const string Yes = "Yes";
128+
129+
/// <summary>
130+
/// Represents No.
131+
/// </summary>
132+
public const string No = "No";
133+
134+
/// <summary>
135+
/// Represents RecoveryVmCreationOption value for CreateVmIfNotFound in failback.
136+
/// </summary>
137+
public const string CreateVmIfNotFound = "CreateVmIfNotFound";
138+
139+
/// <summary>
140+
/// Represents RecoveryVmCreationOption value for NoAction in failback.
141+
/// </summary>
142+
public const string NoAction = "NoAction";
143+
124144
/// <summary>
125145
/// Represents primary location.
126146
/// </summary>

src/ResourceManager/SiteRecovery/Commands.SiteRecovery/Properties/Resources.Designer.cs

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ResourceManager/SiteRecovery/Commands.SiteRecovery/Properties/Resources.resx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,4 +331,16 @@ Please provide a storage account with the same location as that of the vault.</v
331331
<data name="VMNotFoundInGroup" xml:space="preserve">
332332
<value>Virtual Machine "{0}" not found in Group "{1}" for recovery plan "{2}"</value>
333333
</data>
334+
<data name="ImproperServerObjectPassedForHyperVFailback" xml:space="preserve">
335+
<value>Please pass a valid Hyper-V server object if you have set CreateVmIfNotFound to 'Yes' while doing failback in hyper-V to Azure scenario. </value>
336+
</data>
337+
<data name="InvalidParameterSet" xml:space="preserve">
338+
<value>Invalid parameter set used. Please call the cmdlet with a valid parameter set.</value>
339+
</data>
340+
<data name="InvalidVaultObject" xml:space="preserve">
341+
<value>Unsupported vault object is passed. Please pass Claasic or ARM vault object.</value>
342+
</data>
343+
<data name="ParameterWillBeDeprecatedSoon" xml:space="preserve">
344+
<value>Parameter(s) "{0}" will be deprecated soon. Please use use parameter(s) "{1}" instead.</value>
345+
</data>
334346
</root>

src/ResourceManager/SiteRecovery/Commands.SiteRecovery/ProtectionEntity/StartAzureSiteRecoveryPlannedFailoverJob.cs

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,34 @@ public class StartAzureSiteRecoveryPlannedFailoverJob : SiteRecoveryCmdletBase
8282
/// <summary>
8383
/// Gets or sets the Optimize value.
8484
/// </summary>
85-
[Parameter]
86-
[ValidateSet(Constants.ForDowntime, Constants.ForSynchronization)]
85+
[Parameter(Mandatory = false, ValueFromPipeline = false)]
86+
[ValidateSet(Constants.ForDownTime, Constants.ForSynchronization)]
8787
public string Optimize { get; set; }
8888

89+
/// <summary>
90+
/// Gets or sets the recovery vm creation value.
91+
/// </summary>
92+
[Parameter(Mandatory = false, ValueFromPipeline = false)]
93+
[ValidateSet(Constants.Yes, Constants.No)]
94+
public string CreateVmIfNotFound { get; set; }
95+
96+
/// <summary>
97+
/// Gets or sets hyper-V server to create vm on.
98+
/// </summary>
99+
[Parameter(Mandatory = false, ValueFromPipeline = false)]
100+
public ASRServer Server { get; set; }
101+
89102
/// <summary>
90103
/// Gets or sets Data encryption certificate file path for failover of Protected Item.
91104
/// </summary>
92-
[Parameter]
105+
[Parameter(Mandatory = false, ValueFromPipeline = false)]
93106
[ValidateNotNullOrEmpty]
94107
public string DataEncryptionPrimaryCertFile { get; set; }
95108

96109
/// <summary>
97110
/// Gets or sets Data encryption certificate file path for failover of Protected Item.
98111
/// </summary>
99-
[Parameter]
112+
[Parameter(Mandatory = false, ValueFromPipeline = false)]
100113
[ValidateNotNullOrEmpty]
101114
public string DataEncryptionSecondaryCertFile { get; set; }
102115

@@ -184,10 +197,24 @@ private void StartPEPlannedFailover()
184197
{
185198
var failbackInput = new HyperVReplicaAzureFailbackProviderInput()
186199
{
187-
DataSyncOption = this.Optimize == Constants.ForDowntime ? Constants.ForDowntime : Constants.ForSynchronization,
188-
//ProviderIdForAlternateRecovery = "",
189-
RecoveryVmCreationOption = "CreateVmIfNotFound" //CreateVmIfNotFound | NoAction
200+
DataSyncOption = this.Optimize == Constants.ForDownTime ? Constants.ForDownTime : Constants.ForSynchronization,
201+
RecoveryVmCreationOption = String.Compare(this.CreateVmIfNotFound, Constants.Yes, StringComparison.OrdinalIgnoreCase) == 0 ? Constants.CreateVmIfNotFound : Constants.NoAction
190202
};
203+
204+
if (String.Compare(this.CreateVmIfNotFound, Constants.Yes, StringComparison.OrdinalIgnoreCase) == 0 &&
205+
string.Compare(RecoveryServicesClient.GetAzureSiteRecoveryFabric(this.fabricName).Fabric.Properties.CustomDetails.InstanceType, Constants.HyperVSite) == 0)
206+
{
207+
if(this.Server == null || string.Compare(this.Server.FabricType, Constants.HyperVSite) != 0)
208+
{
209+
throw new InvalidOperationException(
210+
Properties.Resources.ImproperServerObjectPassedForHyperVFailback);
211+
}
212+
else
213+
{
214+
failbackInput.ProviderIdForAlternateRecovery = this.Server.ID;
215+
}
216+
}
217+
191218
input.Properties.ProviderSpecificDetails = failbackInput;
192219
}
193220
}
@@ -243,8 +270,8 @@ private void StartRpPlannedFailover()
243270
var recoveryPlanHyperVReplicaAzureFailbackInput = new RecoveryPlanHyperVReplicaAzureFailbackInput()
244271
{
245272
InstanceType = replicationProvider + "Failback",
246-
DataSyncOption = this.Optimize == Constants.ForDowntime ? Constants.ForDowntime : Constants.ForSynchronization,
247-
RecoveryVmCreationOption = "CreateVmIfNotFound" //CreateVmIfNotFound | NoAction
273+
DataSyncOption = this.Optimize == Constants.ForDownTime ? Constants.ForDownTime : Constants.ForSynchronization,
274+
RecoveryVmCreationOption = String.Compare(this.CreateVmIfNotFound, Constants.Yes, StringComparison.OrdinalIgnoreCase) == 0 ? Constants.CreateVmIfNotFound : Constants.NoAction
248275
};
249276
recoveryPlanPlannedFailoverInputProperties.ProviderSpecificDetails.Add(recoveryPlanHyperVReplicaAzureFailbackInput);
250277
}

0 commit comments

Comments
 (0)