Skip to content

changing IaasVM to AzureVM #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class GetAzureRMBackupItem : AzureBackupContainerCmdletBase
public string Status { get; set; }

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

public override void ExecuteCmdlet()
Expand All @@ -57,13 +57,13 @@ public override void ExecuteCmdlet()
{
ProtectionStatus = this.ProtectionStatus,
Status = this.Status,
Type = this.Type
Type = GetItemType(this.Type)
};

CSMItemQueryObject POQueryParam = new CSMItemQueryObject()
{
Status = this.ProtectionStatus,
Type = this.Type
Type = GetItemType(this.Type)
};

var azureBackupDatasourceListResponse = AzureBackupClient.ListDataSources(DSQueryParam);
Expand Down Expand Up @@ -127,5 +127,17 @@ public void WriteAzureBackupItem(List<CSMProtectedItemResponse> sourceDataSource
}
}

public string GetItemType(string sourceType)
{
string result = null;

if(sourceType == "AzureVM")
{
result = AzureBackupItemType.IaasVM.ToString();
}

return result;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
<Compile Include="Cmdlets\Vault\RemoveAzureRMBackupVault.cs" />
<Compile Include="Cmdlets\Vault\SetAzureRMBackupVault.cs" />
<Compile Include="Helpers\ContainerHelpers.cs" />
<Compile Include="Helpers\ItemHelpers.cs" />
<Compile Include="Helpers\ProtectionPolicyHelpers.cs" />
<Compile Include="Helpers\VaultHelpers.cs" />
<Compile Include="Library\CertUtils.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.AzureBackup.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Microsoft.Azure.Commands.AzureBackup.Helpers
{
internal class ItemHelpers
{
internal static string GetTypeForItem(string typeFromServiceRespone)
{
AzureBackupItemType managedContainerType = (AzureBackupItemType)Enum.Parse(typeof(AzureBackupItemType), typeFromServiceRespone, true);

string itemType = string.Empty;

switch (managedContainerType)
{
case AzureBackupItemType.IaasVM:
itemType = "AzureVM";
break;
}

return itemType;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,8 @@ public enum RetentionFormat
Weekly
}

public enum AzureBackupItemType
{
IaasVM = 0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure.Management.BackupServices.Models;
using Microsoft.Azure.Commands.AzureBackup.Helpers;

namespace Microsoft.Azure.Commands.AzureBackup.Models
{
Expand Down Expand Up @@ -81,7 +82,7 @@ public AzureRMBackupItem(CSMProtectedItemResponse datasource, AzureRMBackupConta

ProtectionPolicyId = datasource.Properties.ProtectionPolicyId;
RecoveryPointsCount = datasource.Properties.RecoveryPointsCount;
Type = datasource.Properties.ItemType;
Type = ItemHelpers.GetTypeForItem(datasource.Properties.ItemType);
}

public AzureRMBackupItem(CSMItemResponse pPOItem, AzureRMBackupContainer azureBackupContainer)
Expand All @@ -90,7 +91,7 @@ public AzureRMBackupItem(CSMItemResponse pPOItem, AzureRMBackupContainer azureBa
ProtectionStatus = pPOItem.Properties.Status;
ItemName = pPOItem.Name;
Name = pPOItem.Properties.FriendlyName;
Type = pPOItem.Properties.ItemType;
Type = ItemHelpers.GetTypeForItem(pPOItem.Properties.ItemType);
}
}
}