Skip to content

Commit 8c79e67

Browse files
author
dragonfly91
committed
Adding Enable-Reregister cmdlet
1 parent bf2bf42 commit 8c79e67

File tree

6 files changed

+173
-0
lines changed

6 files changed

+173
-0
lines changed

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupContainerTests.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ function Test-AzureBackupMarsContainerScenario
4242
Assert-AreEqual $container.ResourceName $vault.Name;
4343
Assert-AreEqual $container.Status $ContainerStatus;
4444

45+
Enable-AzureBackupContainerReregistration -Container $container
46+
4547
Unregister-AzureBackupContainer -Container $container -Force
4648

4749
$unregContainers = Get-AzureBackupContainer -vault $vault -type $ContainerType -name $ContainerName

src/ResourceManager/AzureBackup/Commands.AzureBackup/AzureBackupClientAdapter/ContainerAdapter.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,15 @@ public void UnregisterMachineContainer(long containerId)
6363
{
6464
AzureBackupVaultClient.Container.UnregisterMarsContainer(containerId.ToString(), GetCustomRequestHeaders());
6565
}
66+
67+
/// <summary>
68+
/// Enable container reregistration
69+
/// </summary>
70+
/// <param name="containerId"></param>
71+
/// <returns></returns>
72+
public void EnableMachineContainerReregistration(long containerId)
73+
{
74+
AzureBackupVaultClient.Container.EnableMarsContainerReregistration(containerId.ToString(), GetCustomRequestHeaders());
75+
}
6676
}
6777
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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.Web;
17+
using System.Collections.Generic;
18+
using System.Collections.Specialized;
19+
using System.Linq;
20+
using System.Management.Automation;
21+
using System.Text;
22+
using System.Threading.Tasks;
23+
using Microsoft.Azure.Management.BackupServices.Models;
24+
using MBS = Microsoft.Azure.Management.BackupServices;
25+
using Microsoft.WindowsAzure.Commands.ServiceManagement.Model;
26+
using Microsoft.Azure.Commands.AzureBackup.Properties;
27+
using Microsoft.Azure.Commands.AzureBackup.Models;
28+
using Microsoft.Azure.Commands.AzureBackup.Helpers;
29+
using Microsoft.Azure.Management.BackupServices;
30+
31+
namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
32+
{
33+
/// <summary>
34+
/// Enables reregistration of a machine container
35+
/// </summary>
36+
[Cmdlet(VerbsLifecycle.Enable, "AzureBackupContainerReregistration")]
37+
public class EnableAzureBackupContainerReregistration : AzureBackupContainerCmdletBase
38+
{
39+
public override void ExecuteCmdlet()
40+
{
41+
ExecutionBlock(() =>
42+
{
43+
base.ExecuteCmdlet();
44+
45+
AzureBackupContainerType containerType = (AzureBackupContainerType)Enum.Parse(typeof(AzureBackupContainerType), Container.ContainerType);
46+
switch (containerType)
47+
{
48+
case AzureBackupContainerType.Windows:
49+
case AzureBackupContainerType.SCDPM:
50+
AzureBackupClient.EnableMachineContainerReregistration(Container.Id);
51+
break;
52+
default:
53+
throw new ArgumentException("Reregistration can be enable only for machine containers.");
54+
}
55+
});
56+
}
57+
}
58+
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
<Compile Include="AzureBackupVaultCmdletBase.cs" />
123123
<Compile Include="AzureBackupCmdletBase.cs" />
124124
<Compile Include="AzureBackupCmdletHelpMessage.cs" />
125+
<Compile Include="Cmdlets\Container\EnableAzureBackupContainerReregistration.cs" />
125126
<Compile Include="Cmdlets\Container\GetAzureBackupContainer.cs" />
126127
<Compile Include="Cmdlets\Container\UnregisterAzureBackupContainer.cs" />
127128
<Compile Include="Cmdlets\VaultCredentials\GetAzureBackupVaultCredentials.cs" />

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

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,106 @@
11
<?xml version="1.0" encoding="utf-8"?><helpItems schema="maml">
2+
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
3+
<!--Generated by PS Cmdlet Help Editor-->
4+
<command:details>
5+
<command:name>Enable-AzureBackupContainerReregistration</command:name>
6+
<maml:description>
7+
<maml:para>Allow re-registration of the server to connect the server back to the vault and continue the backup points chain.</maml:para>
8+
</maml:description>
9+
<maml:copyright>
10+
<maml:para />
11+
</maml:copyright>
12+
<command:verb>Enable</command:verb>
13+
<command:noun>AzureBackupContainerReregistration</command:noun>
14+
<dev:version />
15+
</command:details>
16+
<maml:description>
17+
<maml:para>When a server is destroyed, all its cloud backup points remain in the Azure Backup vault. If the server is rebuilt and given the same FQDN, it is possible to connect it back to the same vault. This will allow the server to continue taking backups and adding new backup points to the existing set - essentially continuing where it was left off in the backup chain.</maml:para>
18+
<maml:para>To make this connection, the AzureBackupContainer has to be primed for &quot;re-registration&quot;. Without this step, you can lose all the existing data as a part of the registration process. The commandlet tells the service that the next time the container is registered, it should continue the backup chain.</maml:para>
19+
</maml:description>
20+
<command:syntax>
21+
<command:syntaxItem>
22+
<maml:name>Enable-AzureBackupContainerReregistration</maml:name>
23+
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="0">
24+
<maml:name>Container</maml:name>
25+
<maml:description>
26+
<maml:para>An object referencing the container for which re-registration is being requested</maml:para>
27+
</maml:description>
28+
<command:parameterValue required="true" variableLength="false">AzureBackupContainer</command:parameterValue>
29+
</command:parameter>
30+
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
31+
<maml:name>Profile</maml:name>
32+
<maml:description>
33+
<maml:para>Non-mandatory AzureProfile input object</maml:para>
34+
</maml:description>
35+
<command:parameterValue required="true" variableLength="false">AzureProfile</command:parameterValue>
36+
</command:parameter>
37+
</command:syntaxItem>
38+
</command:syntax>
39+
<command:parameters>
40+
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="0">
41+
<maml:name>Container</maml:name>
42+
<maml:description>
43+
<maml:para>An object referencing the container for which re-registration is being requested</maml:para>
44+
</maml:description>
45+
<command:parameterValue required="true" variableLength="false">AzureBackupContainer</command:parameterValue>
46+
<dev:type>
47+
<maml:name>AzureBackupContainer</maml:name>
48+
<maml:uri/>
49+
</dev:type>
50+
<dev:defaultValue></dev:defaultValue>
51+
</command:parameter>
52+
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
53+
<maml:name>Profile</maml:name>
54+
<maml:description>
55+
<maml:para>Non-mandatory AzureProfile input object</maml:para>
56+
</maml:description>
57+
<command:parameterValue required="true" variableLength="false">AzureProfile</command:parameterValue>
58+
<dev:type>
59+
<maml:name>AzureProfile</maml:name>
60+
<maml:uri/>
61+
</dev:type>
62+
<dev:defaultValue></dev:defaultValue>
63+
</command:parameter>
64+
</command:parameters>
65+
<command:inputTypes>
66+
<command:inputType>
67+
<dev:type>
68+
<maml:name>AzureBackupContainer</maml:name>
69+
<maml:uri></maml:uri>
70+
<maml:description/>
71+
</dev:type>
72+
<maml:description>
73+
<maml:para>
74+
This section details out the type of the objects that you can pipe to the cmdlet.
75+
</maml:para>
76+
</maml:description>
77+
</command:inputType>
78+
</command:inputTypes>
79+
<command:returnValues>
80+
<command:returnValue>
81+
<dev:type>
82+
<maml:name>None</maml:name>
83+
<maml:uri></maml:uri>
84+
<maml:description/>
85+
</dev:type>
86+
<maml:description>
87+
<maml:para>This section details out the type of the objects that the cmdlet emits.</maml:para>
88+
</maml:description>
89+
</command:returnValue>
90+
</command:returnValues>
91+
<command:terminatingErrors></command:terminatingErrors>
92+
<command:nonTerminatingErrors></command:nonTerminatingErrors>
93+
<maml:alertSet>
94+
<maml:title></maml:title>
95+
<maml:alert>
96+
<maml:para>None</maml:para>
97+
</maml:alert>
98+
</maml:alertSet>
99+
<command:examples>
100+
</command:examples>
101+
<maml:relatedLinks>
102+
</maml:relatedLinks>
103+
</command:command>
2104
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
3105
<!--Generated by PS Cmdlet Help Editor-->
4106
<command:details>

0 commit comments

Comments
 (0)