Skip to content

Commit 58c02d4

Browse files
committed
Enable Protection Validation and TBDs implementation
1 parent 17d2ef9 commit 58c02d4

File tree

7 files changed

+239
-49
lines changed

7 files changed

+239
-49
lines changed

src/ResourceManager/RecoveryServices.Backup/Cmdlets/Item/EnableAzureRmRecoveryServicesProtection.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
2222
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ProviderModel;
2323
using Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers;
24+
using HydraModel = Microsoft.Azure.Management.RecoveryServices.Backup.Models;
2425

2526
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets
2627
{
@@ -30,8 +31,8 @@ namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets
3031
[Cmdlet(VerbsLifecycle.Enable, "AzureRmRecoveryServicesProtection", DefaultParameterSetName = ModifyProtectionParameterSet), OutputType(typeof(AzureRmRecoveryServicesJobBase))]
3132
public class EnableAzureRmRecoveryServicesProtection : RecoveryServicesBackupCmdletBase
3233
{
33-
internal const string AzureVMClassicComputeParameterSet = "AzureVMClassicCompute";
34-
internal const string AzureVMComputeParameterSet = "AzureVMCompute";
34+
internal const string AzureVMClassicComputeParameterSet = "AzureVMClassicComputeEnableProtection";
35+
internal const string AzureVMComputeParameterSet = "AzureVMComputeEnableProtection";
3536
internal const string ModifyProtectionParameterSet = "ModifyProtection";
3637

3738
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = AzureVMClassicComputeParameterSet, HelpMessage = ParamHelpMsg.Item.AzureVMName)]
@@ -44,15 +45,15 @@ public class EnableAzureRmRecoveryServicesProtection : RecoveryServicesBackupCmd
4445
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = AzureVMComputeParameterSet, HelpMessage = ParamHelpMsg.Item.AzureVMResourceGroupName)]
4546
public string ResourceGroupName { get; set; }
4647

47-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = AzureVMClassicComputeParameterSet, HelpMessage = ParamHelpMsg.Common.WorkloadType)]
48-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = AzureVMComputeParameterSet, HelpMessage = ParamHelpMsg.Common.WorkloadType)]
48+
[Parameter(Mandatory = true, ParameterSetName = AzureVMClassicComputeParameterSet, HelpMessage = ParamHelpMsg.Common.WorkloadType)]
49+
[Parameter(Mandatory = true, ParameterSetName = AzureVMComputeParameterSet, HelpMessage = ParamHelpMsg.Common.WorkloadType)]
4950
public WorkloadType WorkLoadType { get; set; }
5051

5152
[Parameter(Mandatory = true, HelpMessage = ParamHelpMsg.Policy.ProtectionPolicy)]
5253
[ValidateNotNullOrEmpty]
5354
public AzureRmRecoveryServicesPolicyBase Policy { get; set; }
5455

55-
[Parameter(Mandatory = false, HelpMessage = ParamHelpMsg.Item.ProtectedItem, ValueFromPipeline = true)]
56+
[Parameter(Mandatory = true, ParameterSetName = ModifyProtectionParameterSet, HelpMessage = ParamHelpMsg.Item.ProtectedItem, ValueFromPipeline = true)]
5657
[ValidateNotNullOrEmpty]
5758
public AzureRmRecoveryServicesItemBase Item { get; set; }
5859

@@ -90,10 +91,10 @@ public override void ExecuteCmdlet()
9091

9192
if(response.OperationStatus.Status == "Completed")
9293
{
93-
// TBD -- Hydra change to add jobId in OperationStatusExtendedInfo
94-
string jobId = ""; //response.OperationStatus.Properties.jobId;
94+
var jobStatusResponse = (HydraModel.OperationStatusJobExtendedInfo)response.OperationStatus.Properties;
95+
string jobId = jobStatusResponse.JobId;
9596
var job = HydraAdapter.GetJob(jobId);
96-
//WriteObject(ConversionHelpers.GetJobModel(job));
97+
WriteObject(JobConversions.GetPSJob(job));
9798
}
9899
});
99100
}

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Logger/Commands.RecoveryServices.Backup.Logger.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<ItemGroup>
3333
<Reference Include="System" />
3434
<Reference Include="System.Core" />
35+
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
3536
<Reference Include="System.Xml.Linq" />
3637
<Reference Include="System.Data.DataSetExtensions" />
3738
<Reference Include="Microsoft.CSharp" />

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/Properties/Resources.Designer.cs

Lines changed: 96 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/Properties/Resources.resx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,4 +288,39 @@
288288
<data name="ScheduleTimeNotInUTCTimeZoneException" xml:space="preserve">
289289
<value>ScheduleRunTimes in Schedule Policy should be in UTC Timezone</value>
290290
</data>
291+
<data name="InvalidProtectionItemException" xml:space="preserve">
292+
<value>Invalid Item - either NULL or NOT of type: {0}</value>
293+
</data>
294+
<data name="DiscoveryFailure" xml:space="preserve">
295+
<value>Failed to discover VM {0} under {1} {2}. Please make sure names are correct and VM is not deleted"</value>
296+
</data>
297+
<data name="DiscoveryFailureErrorCode" xml:space="preserve">
298+
<value>Discovery operation failed with ErrorCode: {0}</value>
299+
</data>
300+
<data name="DiscoveryFailureErrorMessage" xml:space="preserve">
301+
<value>Going to retry Discovery if retry count is not exceeded"</value>
302+
</data>
303+
<data name="ContainerCountAfterFilter" xml:space="preserve">
304+
<value>Count of containers after BackupManagementType and friendlyName filter = {0}</value>
305+
</data>
306+
<data name="ContainerNotDiscovered" xml:space="preserve">
307+
<value>Container is not discovered</value>
308+
</data>
309+
<data name="VMNotDiscovered" xml:space="preserve">
310+
<value>VM {0} is not yet discovered. Triggering Discovery</value>
311+
</data>
312+
<data name="AzureVMNotFound" xml:space="preserve">
313+
<value>The specified Azure Virtual Machine Not Found. Possible causes are
314+
1. VM does not exist
315+
2. The VM name or the Service name needs to be case sensitive
316+
3. VM is already Protected with same or other Vault. Please Unprotect VM first and then try to protect it again.
317+
318+
Please contact Microsoft for further assistant.</value>
319+
</data>
320+
<data name="InvalidAzureVMName" xml:space="preserve">
321+
<value>Azure VM name can not be null or empty</value>
322+
</data>
323+
<data name="BothCloudServiceNameAndResourceGroupNameShouldNotEmpty" xml:space="preserve">
324+
<value>For Azure VM, both cloud service name and resource group name can not be empty</value>
325+
</data>
291326
</root>

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Providers/Commands.RecoveryServices.Backup.Providers.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
</Reference>
4747
<Reference Include="System" />
4848
<Reference Include="System.Core" />
49+
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
4950
<Reference Include="System.Net" />
5051
<Reference Include="System.Xml.Linq" />
5152
<Reference Include="System.Data.DataSetExtensions" />
@@ -88,6 +89,10 @@
8889
<Project>{30b92759-50b3-494e-b9f0-ec9a2ce9d57b}</Project>
8990
<Name>Commands.RecoveryServices.Backup.Models</Name>
9091
</ProjectReference>
92+
<ProjectReference Include="..\Commands.RecoveryServices.Backup.Logger\Commands.RecoveryServices.Backup.Logger.csproj">
93+
<Project>{5e675749-6139-464a-904c-59c0ffdfec82}</Project>
94+
<Name>Commands.RecoveryServices.Backup.Logger</Name>
95+
</ProjectReference>
9196
</ItemGroup>
9297
<ItemGroup>
9398
<None Include="packages.config" />

0 commit comments

Comments
 (0)