Skip to content

Commit aa520c1

Browse files
author
dragonfly91
committed
[RSBackup] Added Provider Model Basics
1 parent 4f74881 commit aa520c1

File tree

9 files changed

+252
-3
lines changed

9 files changed

+252
-3
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 System;
18+
using System.Collections.Generic;
19+
using System.Linq;
20+
using System.Text;
21+
using System.Threading.Tasks;
22+
23+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets
24+
{
25+
class GetAzureRmRecoveryServicesContainer : RecoveryServicesBackupCmdletBase
26+
{
27+
PsBackupProviderManager providerManager = new PsBackupProviderManager(new Dictionary<string, object>()
28+
{
29+
{GetContainerParams.Name.ToString(), "Param1Value"},
30+
{GetContainerParams.Status.ToString(), "Param2Value"}
31+
});
32+
33+
public override void ExecuteCmdlet()
34+
{
35+
base.ExecuteCmdlet();
36+
IPsBackupProvider psBackupProvider = providerManager.GetProviderInstance(ContainerType.AzureVM);
37+
}
38+
}
39+
}

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<Reference Include="System.Xml" />
4949
</ItemGroup>
5050
<ItemGroup>
51+
<Compile Include="Cmdlets\Container\GetAzureRmRecoveryServicesContainer.cs" />
5152
<Compile Include="Properties\AssemblyInfo.cs" />
5253
<Compile Include="Properties\Resources.Designer.cs">
5354
<AutoGen>True</AutoGen>
@@ -58,7 +59,6 @@
5859
</ItemGroup>
5960
<ItemGroup>
6061
<Folder Include="Cmdlets\Backup\" />
61-
<Folder Include="Cmdlets\Container\" />
6262
<Folder Include="Cmdlets\Item\" />
6363
<Folder Include="Cmdlets\Jobs\" />
6464
<Folder Include="Cmdlets\ProtectionPolicy\" />
@@ -74,6 +74,18 @@
7474
<Project>{3819d8a7-c62c-4c47-8ddd-0332d9ce1252}</Project>
7575
<Name>Commands.ResourceManager.Common</Name>
7676
</ProjectReference>
77+
<ProjectReference Include="Commands.RecoveryServices.Backup.Helpers\Commands.RecoveryServices.Backup.Helpers.csproj">
78+
<Project>{0e1d3f36-e6c8-4764-8c7d-6f9ee537490c}</Project>
79+
<Name>Commands.RecoveryServices.Backup.Helpers</Name>
80+
</ProjectReference>
81+
<ProjectReference Include="Commands.RecoveryServices.Backup.Models\Commands.RecoveryServices.Backup.Models.csproj">
82+
<Project>{30b92759-50b3-494e-b9f0-ec9a2ce9d57b}</Project>
83+
<Name>Commands.RecoveryServices.Backup.Models</Name>
84+
</ProjectReference>
85+
<ProjectReference Include="Commands.RecoveryServices.Backup.Providers\Commands.RecoveryServices.Backup.Providers.csproj">
86+
<Project>{02234e90-bcde-4b20-b1f5-01b1005821db}</Project>
87+
<Name>Commands.RecoveryServices.Backup.Providers</Name>
88+
</ProjectReference>
7789
</ItemGroup>
7890
<ItemGroup>
7991
<EmbeddedResource Include="Properties\Resources.resx">
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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.Collections.Generic;
17+
using System.Linq;
18+
using System.Text;
19+
using System.Threading.Tasks;
20+
21+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
22+
{
23+
public enum GetContainerParams
24+
{
25+
Vault,
26+
ContainerType,
27+
BackupManagementType,
28+
BackupManagementServer,
29+
Name,
30+
ResourceGroupName,
31+
Status,
32+
}
33+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
</ItemGroup>
4141
<ItemGroup>
4242
<Compile Include="BaseObjects.cs" />
43-
<Compile Include="Enums.cs" />
43+
<Compile Include="CmdletParamEnums.cs" />
44+
<Compile Include="CommonEnums.cs" />
4445
<Compile Include="IaasVmModels\Container.cs" />
4546
<Compile Include="Properties\AssemblyInfo.cs" />
4647
</ItemGroup>

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/Enums.cs renamed to src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/CommonEnums.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,16 @@
2020

2121
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
2222
{
23-
public class Enums
23+
public enum ContainerType
24+
{
25+
AzureVM,
26+
}
27+
28+
public enum BackupManagementType
29+
{
30+
}
31+
32+
public enum WorkloadType
2433
{
2534
}
2635
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
<WarningLevel>4</WarningLevel>
3131
</PropertyGroup>
3232
<ItemGroup>
33+
<Reference Include="Microsoft.Azure.Management.RecoveryServicesBackupManagement, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
34+
<SpecificVersion>False</SpecificVersion>
35+
<HintPath>..\Commands.RecoveryServices.Backup.HydraAdapter\Resources\Microsoft.Azure.Management.RecoveryServicesBackupManagement.dll</HintPath>
36+
</Reference>
3337
<Reference Include="System" />
3438
<Reference Include="System.Core" />
3539
<Reference Include="System.Xml.Linq" />
@@ -41,9 +45,15 @@
4145
<ItemGroup>
4246
<Compile Include="IPsBackupProvider.cs" />
4347
<Compile Include="Properties\AssemblyInfo.cs" />
48+
<Compile Include="PsBackupProviderManager.cs" />
49+
<Compile Include="PsBackupProviderDC.cs" />
4450
<Compile Include="Providers\IaasVmPsBackupProvider.cs" />
4551
</ItemGroup>
4652
<ItemGroup>
53+
<ProjectReference Include="..\Commands.RecoveryServices.Backup.Helpers\Commands.RecoveryServices.Backup.Helpers.csproj">
54+
<Project>{0e1d3f36-e6c8-4764-8c7d-6f9ee537490c}</Project>
55+
<Name>Commands.RecoveryServices.Backup.Helpers</Name>
56+
</ProjectReference>
4757
<ProjectReference Include="..\Commands.RecoveryServices.Backup.HydraAdapter\Commands.RecoveryServices.Backup.HydraAdapter.csproj">
4858
<Project>{b758fec1-35c1-4f93-a954-66dd33f6e0ec}</Project>
4959
<Name>Commands.RecoveryServices.Backup.HydraAdapter</Name>

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Providers/IPsBackupProvider.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
1516
using System;
1617
using System.Collections.Generic;
1718
using System.Linq;
@@ -22,5 +23,22 @@ namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ProviderModel
2223
{
2324
public interface IPsBackupProvider
2425
{
26+
void Initialize(ProviderData providerData);
27+
28+
BaseRecoveryServicesJobResponse EnableProtection();
29+
30+
BaseRecoveryServicesJobResponse DisableProtection();
31+
32+
BaseRecoveryServicesJobResponse TriggerBackup();
33+
34+
BaseRecoveryServicesJobResponse TriggerRestore();
35+
36+
ProtectedItemResponse GetProtectedItem();
37+
38+
RecoveryPointResponse GetRecoveryPoint();
39+
40+
ProtectionPolicyResponse CreatePolicy();
41+
42+
ProtectionPolicyResponse ModifyPolicy();
2543
}
2644
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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.Collections.Generic;
17+
using System.Linq;
18+
using System.Text;
19+
using System.Threading.Tasks;
20+
21+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ProviderModel
22+
{
23+
public enum PsBackupProviderTypes
24+
{
25+
IaasVm = 1,
26+
}
27+
28+
public class ProviderData
29+
{
30+
Dictionary<string, object> providerParameters;
31+
32+
public Dictionary<string, object> ProviderParameters
33+
{
34+
get
35+
{
36+
return providerParameters;
37+
}
38+
}
39+
40+
public ProviderData(Dictionary<string, object> inProviderParameters)
41+
{
42+
providerParameters = inProviderParameters;
43+
}
44+
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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 System;
17+
using System.Collections.Generic;
18+
using System.Linq;
19+
using System.Text;
20+
using System.Threading.Tasks;
21+
22+
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ProviderModel
23+
{
24+
public class PsBackupProviderManager
25+
{
26+
ProviderData providerData;
27+
28+
public PsBackupProviderManager(Dictionary<string, object> providerParams)
29+
{
30+
providerData = new ProviderData(providerParams);
31+
}
32+
33+
public PsBackupProviderManager(ProviderData providerDataIn)
34+
{
35+
providerData = providerDataIn;
36+
}
37+
38+
public IPsBackupProvider GetProviderInstance(ContainerType containerType)
39+
{
40+
PsBackupProviderTypes providerType = 0;
41+
42+
switch (containerType)
43+
{
44+
case ContainerType.AzureVM:
45+
providerType = PsBackupProviderTypes.IaasVm;
46+
break;
47+
default:
48+
break;
49+
}
50+
51+
return GetProviderInstance(providerType);
52+
}
53+
54+
public IPsBackupProvider GetProviderInstance(ContainerType containerType, BackupManagementType backupManagementType)
55+
{
56+
throw new NotImplementedException();
57+
}
58+
59+
public IPsBackupProvider GetProviderInstance(ContainerType containerType, WorkloadType workloadType)
60+
{
61+
throw new NotImplementedException();
62+
}
63+
64+
public IPsBackupProvider GetProviderInstance(PsBackupProviderTypes providerType)
65+
{
66+
IPsBackupProvider psBackupProvider = null;
67+
68+
switch (providerType)
69+
{
70+
case PsBackupProviderTypes.IaasVm:
71+
psBackupProvider = new IaasVmPsBackupProvider();
72+
break;
73+
default:
74+
break;
75+
}
76+
77+
psBackupProvider.Initialize(providerData);
78+
79+
return psBackupProvider;
80+
}
81+
}
82+
}

0 commit comments

Comments
 (0)