Skip to content

Commit 2f1d561

Browse files
committed
Merge pull request #114 from MabOneSdk/dev1-pikumar-git2
changing IaasVM to AzureVM
2 parents b5889e0 + 6c85210 commit 2f1d561

File tree

5 files changed

+65
-5
lines changed

5 files changed

+65
-5
lines changed

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Item/GetAzureRMBackupItem.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class GetAzureRMBackupItem : AzureBackupContainerCmdletBase
4040
public string Status { get; set; }
4141

4242
[Parameter(Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.Type)]
43-
[ValidateSet("IaasVM")]
43+
[ValidateSet("AzureVM")]
4444
public string Type { get; set; }
4545

4646
public override void ExecuteCmdlet()
@@ -57,13 +57,13 @@ public override void ExecuteCmdlet()
5757
{
5858
ProtectionStatus = this.ProtectionStatus,
5959
Status = this.Status,
60-
Type = this.Type
60+
Type = GetItemType(this.Type)
6161
};
6262

6363
CSMItemQueryObject POQueryParam = new CSMItemQueryObject()
6464
{
6565
Status = this.ProtectionStatus,
66-
Type = this.Type
66+
Type = GetItemType(this.Type)
6767
};
6868

6969
var azureBackupDatasourceListResponse = AzureBackupClient.ListDataSources(Container.ResourceGroupName, Container.ResourceName, DSQueryParam);
@@ -127,5 +127,17 @@ public void WriteAzureBackupItem(List<CSMProtectedItemResponse> sourceDataSource
127127
}
128128
}
129129

130+
public string GetItemType(string sourceType)
131+
{
132+
string result = null;
133+
134+
if(sourceType == "AzureVM")
135+
{
136+
result = AzureBackupItemType.IaasVM.ToString();
137+
}
138+
139+
return result;
140+
}
141+
130142
}
131143
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
<Compile Include="Cmdlets\Vault\RemoveAzureRMBackupVault.cs" />
158158
<Compile Include="Cmdlets\Vault\SetAzureRMBackupVault.cs" />
159159
<Compile Include="Helpers\ContainerHelpers.cs" />
160+
<Compile Include="Helpers\ItemHelpers.cs" />
160161
<Compile Include="Helpers\ProtectionPolicyHelpers.cs" />
161162
<Compile Include="Helpers\VaultHelpers.cs" />
162163
<Compile Include="Library\CertUtils.cs" />
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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.AzureBackup.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.AzureBackup.Helpers
23+
{
24+
internal class ItemHelpers
25+
{
26+
internal static string GetTypeForItem(string typeFromServiceRespone)
27+
{
28+
AzureBackupItemType managedContainerType = (AzureBackupItemType)Enum.Parse(typeof(AzureBackupItemType), typeFromServiceRespone, true);
29+
30+
string itemType = string.Empty;
31+
32+
switch (managedContainerType)
33+
{
34+
case AzureBackupItemType.IaasVM:
35+
itemType = "AzureVM";
36+
break;
37+
}
38+
39+
return itemType;
40+
}
41+
}
42+
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupEnums.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,8 @@ public enum RetentionFormat
109109
Weekly
110110
}
111111

112+
public enum AzureBackupItemType
113+
{
114+
IaasVM = 0
115+
}
112116
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/Models/AzureBackupItem.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using System.Text;
1919
using System.Threading.Tasks;
2020
using Microsoft.Azure.Management.BackupServices.Models;
21+
using Microsoft.Azure.Commands.AzureBackup.Helpers;
2122

2223
namespace Microsoft.Azure.Commands.AzureBackup.Models
2324
{
@@ -81,7 +82,7 @@ public AzureRMBackupItem(CSMProtectedItemResponse datasource, AzureRMBackupConta
8182

8283
ProtectionPolicyId = datasource.Properties.ProtectionPolicyId;
8384
RecoveryPointsCount = datasource.Properties.RecoveryPointsCount;
84-
Type = datasource.Properties.ItemType;
85+
Type = ItemHelpers.GetTypeForItem(datasource.Properties.ItemType);
8586
}
8687

8788
public AzureRMBackupItem(CSMItemResponse pPOItem, AzureRMBackupContainer azureBackupContainer)
@@ -90,7 +91,7 @@ public AzureRMBackupItem(CSMItemResponse pPOItem, AzureRMBackupContainer azureBa
9091
ProtectionStatus = pPOItem.Properties.Status;
9192
ItemName = pPOItem.Name;
9293
Name = pPOItem.Properties.FriendlyName;
93-
Type = pPOItem.Properties.ItemType;
94+
Type = ItemHelpers.GetTypeForItem(pPOItem.Properties.ItemType);
9495
}
9596
}
9697
}

0 commit comments

Comments
 (0)