Skip to content

Commit b0dd393

Browse files
author
Samuel Anudeep
committed
Merge pull request #239 from MabOneSdk/dev1
FI from dev1 to release
2 parents af97ca8 + d2a7d8f commit b0dd393

File tree

73 files changed

+168181
-299
lines changed

Some content is hidden

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

73 files changed

+168181
-299
lines changed

setup/azurecmdfiles.wxi

Lines changed: 122 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/RecoveryServices.Backup/CmdletParameterHelpMessages.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@ internal static class Container
2828
public const string ResourceGroupName = "The ResourceGroup of the resource being managed by the Azure Backup service (for example: ResourceGroup name of the VM).";
2929
public const string Status = "The registration status of the Azure Backup container.";
3030
public const string ContainerType = "The type of the Azure Backup container. This can be a Windows Server, an Azure IaaS VM, or a Data Protection Manager server.";
31+
public const string BackupManagementType = "The backup management type of the Azure Backup container";
32+
public const string RegisteredContainer = "The recovery services backup container.";
3133
}
3234

3335
internal static class Common
3436
{
3537
public const string Vault = "The Azure Backup vault object which is the parent resource.";
3638
public const string WorkloadType = "Workload type of the resource (for example: AzureVM, WindowsServer).";
3739
public const string BackupManagementType = "Backup Management type of the resource (for example: MAB, DPM).";
40+
public const string ConfirmationMessage = "Don't ask for confirmation.";
3841
}
3942

4043
internal static class Policy
@@ -69,6 +72,22 @@ internal static class Item
6972
public const string ProtectionStatus = "Protection status of Item";
7073
public const string Status = "Status of the data source";
7174
public const string Container = "Container where the item resides";
75+
public const string RemoveProtectionOption = "If this option is used, all the backup data for this item will also be deleted and restoring data will not be possible.";
76+
public const string ExpiryDate = "Retention period for the recovery points created by this backup operaiton";
77+
}
78+
79+
internal static class RecoveryPoint
80+
{
81+
public const string StartDate = "Start time of Time range for which recovery point need to be fetched";
82+
public const string EndDate = "End time of Time range for which recovery point need to be fetched";
83+
public const string Item = "Protected Item object for which recovery point need to be fetched";
84+
public const string RecoveryPointId = "Recovery point Id for which detail is needed";
85+
}
86+
87+
internal static class RestoreDisk
88+
{
89+
public const string RecoveryPoint = "Recovery point objected to be restored";
90+
public const string StorageAccountName = "Storage account name where the disk need to be recovered";
7291
}
7392
}
7493
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
16+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ProviderModel;
17+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers;
18+
using System;
19+
using System.Collections.Generic;
20+
using System.Linq;
21+
using System.Management.Automation;
22+
using System.Text;
23+
using System.Threading.Tasks;
24+
25+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets
26+
{
27+
/// <summary>
28+
/// Get list of containers
29+
/// </summary>
30+
[Cmdlet(VerbsCommon.Get, "AzureRmBackupManagementServer"), OutputType(typeof(List<AzureRmRecoveryServicesContainerBase>), typeof(AzureRmRecoveryServicesContainerBase))]
31+
public class GetAzureRmBackupManagementServer : RecoveryServicesBackupCmdletBase
32+
{
33+
[Parameter(Mandatory = true, HelpMessage = ParamHelpMsg.Container.Name)]
34+
[ValidateNotNullOrEmpty]
35+
public string Name { get; set; }
36+
37+
public override void ExecuteCmdlet()
38+
{
39+
ExecutionBlock(() =>
40+
{
41+
base.ExecuteCmdlet();
42+
43+
PsBackupProviderManager providerManager = new PsBackupProviderManager(new Dictionary<System.Enum, object>()
44+
{
45+
{ContainerParams.ContainerType, ContainerType.Windows},
46+
{ContainerParams.BackupManagementType, BackupManagementType.Scdpm},
47+
{ContainerParams.Name, Name}
48+
}, HydraAdapter);
49+
50+
IPsBackupProvider psBackupProvider = providerManager.GetProviderInstance(ContainerType.Windows, BackupManagementType.Scdpm);
51+
52+
var containerModels = psBackupProvider.ListProtectionContainers();
53+
54+
if (containerModels.Count == 1)
55+
{
56+
WriteObject(containerModels.First());
57+
}
58+
else
59+
{
60+
WriteObject(containerModels);
61+
}
62+
});
63+
}
64+
}
65+
}

src/ResourceManager/RecoveryServices.Backup/Cmdlets/Container/GetAzureRmRecoveryServicesContainer.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ public class GetAzureRmRecoveryServicesContainer : RecoveryServicesBackupCmdletB
3434
[ValidateNotNullOrEmpty]
3535
public ContainerType ContainerType { get; set; }
3636

37+
[Parameter(Mandatory = false, HelpMessage = ParamHelpMsg.Container.BackupManagementType)]
38+
[ValidateNotNullOrEmpty]
39+
public BackupManagementType BackupManagementType { get; set; }
40+
3741
[Parameter(Mandatory = false, HelpMessage = ParamHelpMsg.Container.Name)]
3842
[ValidateNotNullOrEmpty]
3943
public string Name { get; set; }
@@ -55,12 +59,13 @@ public override void ExecuteCmdlet()
5559
PsBackupProviderManager providerManager = new PsBackupProviderManager(new Dictionary<System.Enum, object>()
5660
{
5761
{ContainerParams.ContainerType, ContainerType},
62+
{ContainerParams.BackupManagementType, BackupManagementType},
5863
{ContainerParams.Name, Name},
5964
{ContainerParams.ResourceGroupName, ResourceGroupName},
6065
{ContainerParams.Status, Status},
6166
}, HydraAdapter);
6267

63-
IPsBackupProvider psBackupProvider = providerManager.GetProviderInstance(ContainerType);
68+
IPsBackupProvider psBackupProvider = providerManager.GetProviderInstance(ContainerType, BackupManagementType);
6469
var containerModels = psBackupProvider.ListProtectionContainers();
6570

6671
if (containerModels.Count == 1)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
16+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ProviderModel;
17+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers;
18+
using System;
19+
using System.Collections.Generic;
20+
using System.Linq;
21+
using System.Management.Automation;
22+
using System.Text;
23+
using System.Threading.Tasks;
24+
25+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Container
26+
{
27+
[Cmdlet(VerbsLifecycle.Unregister, "AzureRmBackupManagementServer")]
28+
public class UnregisterAzureRmBackupManagementServer : RecoveryServicesBackupCmdletBase
29+
{
30+
[Parameter(Mandatory = true, HelpMessage = ParamHelpMsg.Container.RegisteredContainer)]
31+
[ValidateNotNullOrEmpty]
32+
public AzureRmRecoveryServicesContainerBase Container { get; set; }
33+
34+
public override void ExecuteCmdlet()
35+
{
36+
ExecutionBlock(() =>
37+
{
38+
base.ExecuteCmdlet();
39+
40+
if (Container.ContainerType != ContainerType.Windows || Container.BackupManagementType != BackupManagementType.Scdpm)
41+
{
42+
throw new ArgumentException(String.Format("Please provide Container of containerType Windows and backupManagementType Scdpm. Provided Container has containerType {0} and backupManagementType {1}", Container.ContainerType, Container.BackupManagementType));
43+
}
44+
45+
string containerName = Container.Name;
46+
HydraAdapter.UnregisterContainers(containerName);
47+
});
48+
}
49+
}
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
16+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ProviderModel;
17+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers;
18+
using System;
19+
using System.Collections.Generic;
20+
using System.Linq;
21+
using System.Management.Automation;
22+
using System.Text;
23+
using System.Threading.Tasks;
24+
25+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets
26+
{
27+
/// <summary>
28+
/// Get list of containers
29+
/// </summary>
30+
[Cmdlet(VerbsLifecycle.Unregister, "AzureRmRecoveryServicesBackupContainer")]
31+
public class UnregisterAzureRmRecoveryServicesBackupContainer : RecoveryServicesBackupCmdletBase
32+
{
33+
[Parameter(Mandatory = true, HelpMessage = ParamHelpMsg.Container.RegisteredContainer)]
34+
[ValidateNotNullOrEmpty]
35+
public AzureRmRecoveryServicesContainerBase Container { get; set; }
36+
37+
public override void ExecuteCmdlet()
38+
{
39+
ExecutionBlock(() =>
40+
{
41+
base.ExecuteCmdlet();
42+
43+
if (Container.ContainerType != ContainerType.Windows || Container.BackupManagementType != BackupManagementType.Mars)
44+
{
45+
throw new ArgumentException(String.Format("Please provide Container of containerType Windows and backupManagementType Mars. Provided Container has containerType {0} and backupManagementType {1}", Container.ContainerType, Container.BackupManagementType));
46+
}
47+
string containerName = Container.Name;
48+
HydraAdapter.UnregisterContainers(containerName);
49+
});
50+
}
51+
}
52+
}
53+
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Linq;
17+
using System.Text;
18+
using System.Threading.Tasks;
19+
using System.Collections.Generic;
20+
using System.Management.Automation;
21+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
22+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ProviderModel;
23+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Properties;
24+
using Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers;
25+
using HydraModel = Microsoft.Azure.Management.RecoveryServices.Backup.Models;
26+
27+
28+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets
29+
{
30+
/// <summary>
31+
/// Enable Azure Backup protection
32+
/// </summary>
33+
[Cmdlet(VerbsLifecycle.Disable, "AzureRmRecoveryServicesProtection"), OutputType(typeof(AzureRmRecoveryServicesJobBase))]
34+
public class DisableAzureRmRecoveryServicesProtection : RecoveryServicesBackupCmdletBase
35+
{
36+
[Parameter(Position = 1, Mandatory = true, HelpMessage = ParamHelpMsg.Item.ProtectedItem, ValueFromPipeline = true)]
37+
[ValidateNotNullOrEmpty]
38+
public AzureRmRecoveryServicesItemBase Item { get; set; }
39+
40+
[Parameter(Position = 2, Mandatory = false, HelpMessage = ParamHelpMsg.Item.RemoveProtectionOption)]
41+
public SwitchParameter RemoveRecoveryPoints
42+
{
43+
get { return DeleteBackupData; }
44+
set { DeleteBackupData = value; }
45+
}
46+
47+
[Parameter(Mandatory = false, HelpMessage = "Don't ask for confirmation.")]
48+
public SwitchParameter Force { get; set; }
49+
50+
private bool DeleteBackupData;
51+
52+
public override void ExecuteCmdlet()
53+
{
54+
ConfirmAction(
55+
Force.IsPresent,
56+
string.Format(Resources.DisableProtectionWarning, Item.Name),
57+
Resources.DisableProtectionMessage,
58+
Item.Name, () =>
59+
{
60+
ExecutionBlock(() =>
61+
{
62+
base.ExecuteCmdlet();
63+
PsBackupProviderManager providerManager = new PsBackupProviderManager(new Dictionary<System.Enum, object>()
64+
{
65+
{ItemParams.Item, Item},
66+
{ItemParams.DeleteBackupData, this.DeleteBackupData},
67+
}, HydraAdapter);
68+
69+
IPsBackupProvider psBackupProvider = providerManager.GetProviderInstance(Item.WorkloadType, Item.BackupManagementType);
70+
71+
var itemResponse = psBackupProvider.DisableProtection();
72+
73+
// Track Response and display job details
74+
75+
HandleCreatedJob(itemResponse, Resources.DisableProtectionOperation);
76+
});
77+
});
78+
79+
}
80+
}
81+
}

0 commit comments

Comments
 (0)