Skip to content

Commit 1f246ec

Browse files
author
Samuel Anudeep
committed
Merge pull request #170 from MabOneSdk/anudeeb-dev1
Undoing RS Vault changes in AzureBackup sln
2 parents da9886f + 56410d2 commit 1f246ec

File tree

68 files changed

+1470
-842
lines changed

Some content is hidden

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

68 files changed

+1470
-842
lines changed

src/ResourceManager/AzureBackup/AzureBackup.sln

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio 2013
3-
VisualStudioVersion = 12.0.40629.0
3+
VisualStudioVersion = 12.0.31101.0
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{95C16AED-FD57-42A0-86C3-2CF4300A4817}"
66
EndProject
@@ -21,8 +21,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{1DB65F
2121
.nuget\packages.config = .nuget\packages.config
2222
EndProjectSection
2323
EndProject
24-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.RecoveryServices", "..\RecoveryServices\Commands.RecoveryServices\Commands.RecoveryServices.csproj", "{604260DC-B392-4CF4-81EC-34B14591E2D2}"
25-
EndProject
2624
Global
2725
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2826
Debug|Any CPU = Debug|Any CPU
@@ -53,10 +51,6 @@ Global
5351
{5EE72C53-1720-4309-B54B-5FB79703195F}.Debug|Any CPU.Build.0 = Debug|Any CPU
5452
{5EE72C53-1720-4309-B54B-5FB79703195F}.Release|Any CPU.ActiveCfg = Release|Any CPU
5553
{5EE72C53-1720-4309-B54B-5FB79703195F}.Release|Any CPU.Build.0 = Release|Any CPU
56-
{604260DC-B392-4CF4-81EC-34B14591E2D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
57-
{604260DC-B392-4CF4-81EC-34B14591E2D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
58-
{604260DC-B392-4CF4-81EC-34B14591E2D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
59-
{604260DC-B392-4CF4-81EC-34B14591E2D2}.Release|Any CPU.Build.0 = Release|Any CPU
6054
EndGlobalSection
6155
GlobalSection(SolutionProperties) = preSolution
6256
HideSolutionNode = FALSE

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupVaultTests.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@ public class AzureBackupVaultTests : AzureBackupTestsBase
2424
public void AzureBackupVaultScenarioTests()
2525
{
2626
this.RunPowerShellTest("Test-AzureBackupVaultScenario");
27-
}
28-
29-
[Fact]
30-
[Trait(Category.AcceptanceType, Category.CheckIn)]
31-
public void AzureRecoveryServiceVaultScenario()
32-
{
33-
this.RunPowerShellTest("Test-AzureRecoveryServiceVaultScenario");
34-
}
27+
}
3528
}
3629
}

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,3 @@ function Test-AzureBackupVaultScenario
4444

4545
Remove-AzureRmBackupVault -Vault $vault;
4646
}
47-
48-
function Test-AzureRecoveryServiceVaultScenario
49-
{
50-
$bvault = New-AzureRmBackupVault -ResourceGroupName $ResourceGroupName -Name $ResourceName -Region $Location -Storage "LocallyRedundant";
51-
$rsvault = New-AzureRmRecoveryServicesVault -ResourceGroupName $ResourceGroupName -Name "rsrnvault" -Location $Location;
52-
53-
$bconts = Get-AzureRmBackupContainer -Vault $bvault -Type AzureVM;
54-
$rsconts = Get-AzureRmBackupContainer -Vault $rsvault -Type AzureVM;
55-
}
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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.Common.Authentication;
16+
using Microsoft.Azure.Management.BackupServices;
17+
using Microsoft.Azure.Management.BackupServices.Models;
18+
using System;
19+
using System.Net;
20+
using System.Threading;
21+
22+
namespace Microsoft.Azure.Commands.AzureBackup.ClientAdapter
23+
{
24+
public partial class AzureBackupClientAdapter
25+
{
26+
/// <summary>
27+
/// Cloud credentials for client calls
28+
/// </summary>
29+
private SubscriptionCloudCredentials cloudCreds { get; set; }
30+
31+
/// <summary>
32+
/// Base URI for client calls
33+
/// </summary>
34+
private Uri baseURI { get; set; }
35+
36+
/// <summary>
37+
/// Client request id.
38+
/// </summary>
39+
private string clientRequestId;
40+
41+
/// <summary>
42+
/// Azure vault backup client to talk to IdMgmt.
43+
/// </summary>
44+
private BackupVaultServicesManagementClient azureBackupVaultClient;
45+
46+
/// <summary>
47+
/// Azure backup client to talk to BMS.
48+
/// </summary>
49+
private BackupServicesManagementClient azureBackupClient;
50+
51+
/// <summary>
52+
/// Cancellation Token Source
53+
/// </summary>
54+
private CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
55+
private CancellationToken CmdletCancellationToken;
56+
57+
/// <summary>
58+
/// Get Azure backup client.
59+
/// </summary>
60+
private BackupVaultServicesManagementClient AzureBackupVaultClient
61+
{
62+
get
63+
{
64+
if (this.azureBackupVaultClient == null)
65+
{
66+
this.azureBackupVaultClient = AzureSession.ClientFactory.CreateCustomClient<BackupVaultServicesManagementClient>(cloudCreds, baseURI);
67+
}
68+
69+
return this.azureBackupVaultClient;
70+
}
71+
}
72+
73+
/// <summary>
74+
/// Get Azure backup client.
75+
/// </summary>
76+
private BackupServicesManagementClient AzureBackupClient
77+
{
78+
get
79+
{
80+
if (this.azureBackupClient == null)
81+
{
82+
this.azureBackupClient = AzureSession.ClientFactory.CreateCustomClient<BackupServicesManagementClient>(cloudCreds, baseURI);
83+
}
84+
85+
return this.azureBackupClient;
86+
}
87+
}
88+
89+
public AzureBackupClientAdapter(SubscriptionCloudCredentials creds, Uri baseUri)
90+
{
91+
cloudCreds = creds;
92+
baseURI = baseUri;
93+
94+
RefreshClientRequestId();
95+
96+
// Temp code to be able to test internal env.
97+
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
98+
}
99+
100+
public void RefreshClientRequestId()
101+
{
102+
clientRequestId = Guid.NewGuid().ToString() + "-" + DateTime.Now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ssZ") + "-PS";
103+
}
104+
105+
public string GetClientRequestId()
106+
{
107+
return clientRequestId;
108+
}
109+
110+
internal CustomRequestHeaders GetCustomRequestHeaders()
111+
{
112+
var hdrs = new CustomRequestHeaders()
113+
{
114+
// ClientRequestId is a unique ID for every request to backend service.
115+
ClientRequestId = this.clientRequestId,
116+
};
117+
118+
return hdrs;
119+
}
120+
}
121+
}
122+
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
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.Management.Automation;
17+
using System.Collections.Generic;
18+
using System.Xml;
19+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
20+
using Microsoft.Azure.Common.Authentication;
21+
using Microsoft.Azure.Common.Authentication.Models;
22+
using System.Threading;
23+
using Hyak.Common;
24+
using Microsoft.Azure.Commands.AzureBackup.Properties;
25+
using System.Net;
26+
using System.Linq;
27+
using Microsoft.WindowsAzure.Management.Scheduler;
28+
using Microsoft.Azure.Management.BackupServices;
29+
using Microsoft.Azure.Management.BackupServices.Models;
30+
using Microsoft.Azure.Commands.AzureBackup.Models;
31+
32+
namespace Microsoft.Azure.Commands.AzureBackup.ClientAdapter
33+
{
34+
public partial class AzureBackupClientAdapter
35+
{
36+
/// <summary>
37+
/// Gets all MARS containers in the vault
38+
/// </summary>
39+
/// <returns></returns>
40+
public IEnumerable<MarsContainerResponse> ListMachineContainers(string resourceGroupName, string resourceName)
41+
{
42+
var listResponse = AzureBackupVaultClient.Container.ListMarsContainersByType(resourceGroupName, resourceName, MarsContainerType.Machine, GetCustomRequestHeaders());
43+
return listResponse.ListMarsContainerResponse.Value;
44+
}
45+
46+
/// <summary>
47+
/// Gets all MARS containers in the vault which match the friendly name
48+
/// </summary>
49+
/// <param name="friendlyName">The friendly name of the container</param>
50+
/// <returns></returns>
51+
public IEnumerable<MarsContainerResponse> ListMachineContainers(string resourceGroupName, string resourceName, string friendlyName)
52+
{
53+
var listResponse = AzureBackupVaultClient.Container.ListMarsContainersByTypeAndFriendlyName(resourceGroupName, resourceName, MarsContainerType.Machine, friendlyName, GetCustomRequestHeaders());
54+
return listResponse.ListMarsContainerResponse.Value;
55+
}
56+
57+
/// <summary>
58+
/// UnRegister container
59+
/// </summary>
60+
/// <param name="containerId"></param>
61+
/// <returns></returns>
62+
public void UnregisterMachineContainer(string resourceGroupName, string resourceName, long containerId)
63+
{
64+
AzureBackupVaultClient.Container.UnregisterMarsContainer(resourceGroupName, resourceName, containerId.ToString(), GetCustomRequestHeaders());
65+
}
66+
67+
/// <summary>
68+
/// Enable container reregistration
69+
/// </summary>
70+
/// <param name="containerId"></param>
71+
/// <returns></returns>
72+
public void EnableMachineContainerReregistration(string resourceGroupName, string resourceName, long containerId)
73+
{
74+
EnableReregistrationRequest request = new EnableReregistrationRequest()
75+
{
76+
ContainerReregistrationState = new ContainerReregistrationState()
77+
{
78+
EnableReregistration = true,
79+
},
80+
};
81+
82+
AzureBackupVaultClient.Container.EnableMarsContainerReregistration(resourceGroupName, resourceName, containerId.ToString(), request, GetCustomRequestHeaders());
83+
}
84+
85+
/// <summary>
86+
/// Gets all IaaSVM containers in the vault by friendly name
87+
/// </summary>
88+
/// <param name="parameters"></param>
89+
/// <returns></returns>
90+
public IEnumerable<CSMContainerResponse> ListContainers(string resourceGroupName, string resourceName, ContainerQueryParameters parameters)
91+
{
92+
var listResponse = AzureBackupClient.Container.ListAsync(resourceGroupName, resourceName, parameters, GetCustomRequestHeaders(), CmdletCancellationToken).Result;
93+
return listResponse.CSMContainerListResponse.Value;
94+
}
95+
96+
/// <summary>
97+
/// Register container
98+
/// </summary>
99+
/// <param name="containerName"></param>
100+
/// <returns></returns>
101+
public Guid RegisterContainer(string resourceGroupName, string resourceName, string containerName)
102+
{
103+
var response = AzureBackupClient.Container.RegisterAsync(resourceGroupName, resourceName, containerName, GetCustomRequestHeaders(), CmdletCancellationToken).Result;
104+
return response.OperationId;
105+
}
106+
107+
/// <summary>
108+
/// UnRegister container
109+
/// </summary>
110+
/// <param name="containerName"></param>
111+
/// <returns></returns>
112+
public Guid UnRegisterContainer(string resourceGroupName, string resourceName, string containerName)
113+
{
114+
var response = AzureBackupClient.Container.UnregisterAsync(resourceGroupName, resourceName, containerName, GetCustomRequestHeaders(), CmdletCancellationToken).Result;
115+
return response.OperationId;
116+
}
117+
118+
/// <summary>
119+
/// Refresh container list in service
120+
/// </summary>
121+
/// <returns></returns>
122+
public Guid RefreshContainers(string resourceGroupName, string resourceName)
123+
{
124+
var response = AzureBackupClient.Container.RefreshAsync(resourceGroupName, resourceName, GetCustomRequestHeaders(), CmdletCancellationToken).Result;
125+
return response.OperationId;
126+
}
127+
}
128+
}

0 commit comments

Comments
 (0)