Skip to content

Dev1 pikumar #95

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 5 commits into from
Aug 4, 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 @@ -32,10 +32,10 @@ namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets.DataSource
public class DisableAzureBackupProtection : AzureBackupDSCmdletBase
{
[Parameter(Position = 1, Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.RemoveProtectionOption)]
public SwitchParameter RemoveRecoveryPoints
public SwitchParameter RemoveRecoveryPoints
{
get { return DeleteBackupData; }
set { DeleteBackupData = value; }
set { DeleteBackupData = value; }
}
private bool DeleteBackupData;

Expand All @@ -46,15 +46,16 @@ public SwitchParameter RemoveRecoveryPoints
public string Comments { get; set; }

public override void ExecuteCmdlet()
{
{
ExecutionBlock(() =>
{
base.ExecuteCmdlet();
Guid operationId = Guid.Empty;
WriteDebug("Making client call");

if(!this.DeleteBackupData)
if (!this.DeleteBackupData)
{
//Calling update protection with policy Id as empty.
CSMUpdateProtectionRequest input = new CSMUpdateProtectionRequest()
{
Properties = new CSMUpdateProtectionRequestProperties(string.Empty)
Expand All @@ -65,6 +66,7 @@ public override void ExecuteCmdlet()

else
{
//Calling disable protection
operationId = AzureBackupClient.DisableProtection(Item.ContainerUniqueName, Item.ItemName);
}

Expand All @@ -75,4 +77,4 @@ public override void ExecuteCmdlet()
});
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,20 @@ public override void ExecuteCmdlet()

WriteDebug("Making client call");
string itemName = string.Empty;

CSMSetProtectionRequest input = new CSMSetProtectionRequest();
input.Properties.PolicyId = Policy.InstanceId;
input.Properties = new CSMSetProtectionRequestProperties();
input.Properties.PolicyId = Policy.PolicyId;

if (Item.GetType() == typeof(AzureBackupItem))
{
itemName = (Item as AzureBackupItem).ItemName;
}

else if (Item.GetType() == typeof(AzureBackupContainer))
{
WriteDebug("Input is container Type = " + Item.GetType());
if ((Item as AzureBackupContainer).ContainerType == ManagedContainerType.IaasVMContainer.ToString())
if ((Item as AzureBackupContainer).ContainerType == ManagedContainerType.IaasVM.ToString())
{
itemName = (Item as AzureBackupContainer).ContainerUniqueName;
}
Expand All @@ -61,17 +65,18 @@ public override void ExecuteCmdlet()
throw new Exception("Uknown item type");
}
}

else
{
throw new Exception("Uknown item type");
}

var operationId = AzureBackupClient.EnableProtection(Item.ContainerUniqueName,itemName, input);
var operationId = AzureBackupClient.EnableProtection(Item.ContainerUniqueName, itemName, input);
WriteDebug("Received enable azure backup protection response");

var operationStatus = GetOperationStatus(operationId);
this.WriteObject(GetCreatedJobs(new Models.AzurePSBackupVault(Item.ResourceGroupName, Item.ResourceName, Item.Location), operationStatus.JobList).FirstOrDefault());
});
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
public class GetAzureBackupItem : AzureBackupContainerCmdletBase
{
[Parameter(Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.ProtectionStatus)]
[ValidateSet("Protected","Protecting","NotProtected")]
[ValidateSet("Protected", "Protecting", "NotProtected")]
public string ProtectionStatus { get; set; }

[Parameter(Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.Status)]
[ValidateSet("IRPending", "ProtectionStopped", "ProtectionError", "Protected")]
[ValidateSet("IRPending", "ProtectionStopped", "ProtectionError", "Protected")]
public string Status { get; set; }

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

public override void ExecuteCmdlet()
Expand All @@ -55,8 +55,8 @@ public override void ExecuteCmdlet()
WriteDebug("Making client call");
CSMProtectedItemQueryObject DSQueryParam = new CSMProtectedItemQueryObject()
{
ProtectionStatus = this.Status,
Status = this.ProtectionStatus,
ProtectionStatus = this.ProtectionStatus,
Status = this.Status,
Type = this.Type
};

Expand All @@ -68,12 +68,18 @@ public override void ExecuteCmdlet()

var azureBackupDatasourceListResponse = AzureBackupClient.ListDataSources(DSQueryParam);

azureBackupDatasourceObjects = azureBackupDatasourceListResponse.Where(x => x.Properties.ContainerId.Split('/').Last().Equals(Container.ContainerUniqueName, System.StringComparison.InvariantCultureIgnoreCase)).ToList();
if (azureBackupDatasourceListResponse != null)
{
azureBackupDatasourceObjects = azureBackupDatasourceListResponse.Where(x => x.Properties.ContainerId.Split('/').Last().Equals(Container.ContainerUniqueName, System.StringComparison.InvariantCultureIgnoreCase)).ToList();
}

if (this.Status == null)
{
var azureBackupPOListResponse = AzureBackupClient.ListProtectableObjects(POQueryParam);
azureBackupPOObjects = azureBackupPOListResponse.Where(x => x.Properties.ContainerId.Split('/').Last().Equals(Container.ContainerUniqueName, System.StringComparison.InvariantCultureIgnoreCase)).ToList();
if (azureBackupPOListResponse != null)
{
azureBackupPOObjects = azureBackupPOListResponse.Where(x => x.Properties.ContainerId.Split('/').Last().Equals(Container.ContainerUniqueName, System.StringComparison.InvariantCultureIgnoreCase)).ToList();
}
}

WriteDebug("Received azure backup item response");
Expand All @@ -90,17 +96,20 @@ public void WriteAzureBackupItem(List<CSMProtectedItemResponse> sourceDataSource
{
List<AzureBackupItem> targetList = new List<AzureBackupItem>();

foreach (var item in sourceDataSourceList)
if (sourceDataSourceList != null)
{
targetList.Add(new AzureBackupItem(item, azureBackupContainer));
foreach (var item in sourceDataSourceList)
{
targetList.Add(new AzureBackupItem(item, azureBackupContainer));
}
}

if (sourcePOList != null)
{
foreach (var item in sourcePOList)
{
//If user has stopped protection for some datasoure then we will have duplicate items(po and ds).
//So in this case removing poitems from the list.
//So in this case removing po items from the list.
if (targetList.FindIndex(element => element.ItemName == item.Name) < 0)
{
targetList.Add(new AzureBackupItem(item, azureBackupContainer));
Expand All @@ -119,4 +128,4 @@ public void WriteAzureBackupItem(List<CSMProtectedItemResponse> sourceDataSource
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,12 @@
<Compile Include="AzureBackupClientAdapter\ItemAdapter.cs" />
<Compile Include="AzureBackupClientAdapter\JobAdapter.cs" />
<Compile Include="AzureBackupClientAdapter\OperationStatusAdapter.cs" />
<Compile Include="AzureBackupClientAdapter\PolicyAdapter.cs" />
<Compile Include="AzureBackupClientAdapter\VaultAdapter.cs" />
<Compile Include="AzureBackupContainerCmdletBase.cs" />
<Compile Include="AzureBackupDSCmdletBase.cs" />
<Compile Include="AzureBackupItemCmdletBase.cs" />
<Compile Include="AzureBackupPolicyCmdletBase.cs" />
<Compile Include="AzureBackUpRestoreBase.cs" />
<Compile Include="AzureBackupVaultCmdletBase.cs" />
<Compile Include="AzureBackupCmdletBase.cs" />
Expand All @@ -134,11 +136,19 @@
<Compile Include="Cmdlets\Container\GetAzureBackupContainer.cs" />
<Compile Include="Cmdlets\Container\RegisterAzureBackupContainer.cs" />
<Compile Include="Cmdlets\Container\UnregisterAzureBackupContainer.cs" />
<Compile Include="Cmdlets\Item\Disable-AzureBackupProtection .cs" />
<Compile Include="Cmdlets\Item\Enable-AzureBackupProtection .cs" />
<Compile Include="Cmdlets\Item\GetAzureBackupItem.cs" />
<Compile Include="Cmdlets\Jobs\AzureBackupJobHelper.cs" />
<Compile Include="Cmdlets\Jobs\GetAzureBackupJob.cs" />
<Compile Include="Cmdlets\Jobs\GetAzureBackupJobDetails.cs" />
<Compile Include="Cmdlets\Jobs\StopAzureBackukpJob.cs" />
<Compile Include="Cmdlets\Jobs\WaitAzureBackupJob.cs" />
<Compile Include="Cmdlets\ProtectionPolicy\GetAzureBackupProtectionPolicy.cs" />
<Compile Include="Cmdlets\ProtectionPolicy\NewAzureBackupProtectionPolicy.cs" />
<Compile Include="Cmdlets\ProtectionPolicy\NewAzureBackupRetentionPolicyObject.cs" />
<Compile Include="Cmdlets\ProtectionPolicy\RemoveAzureBackupProtectionPolicy.cs" />
<Compile Include="Cmdlets\ProtectionPolicy\SetAzureBackupProtectionPolicy.cs" />
<Compile Include="Cmdlets\RecoveryPoint\GetAzureBackupRecoveryPoint.cs" />
<Compile Include="Cmdlets\Restore\TriggerRestore.cs" />
<Compile Include="Cmdlets\VaultCredentials\GetAzureBackupVaultCredentials.cs" />
Expand All @@ -147,6 +157,7 @@
<Compile Include="Cmdlets\Vault\SetAzureBackupVault.cs" />
<Compile Include="Cmdlets\Vault\NewAzureBackupVault.cs" />
<Compile Include="Helpers\ContainerHelpers.cs" />
<Compile Include="Helpers\ProtectionPolicyHelpers.cs" />
<Compile Include="Helpers\VaultHelpers.cs" />
<Compile Include="Library\CertUtils.cs" />
<Compile Include="Models\AzureBackupBaseObjects.cs" />
Expand All @@ -157,6 +168,7 @@
<Compile Include="Models\AzurePSBackupVault.cs" />
<Compile Include="Models\JobObjects.cs" />
<Compile Include="Models\ListContainerQueryParameter.cs" />
<Compile Include="Models\ProtectionPolicy.cs" />
<Compile Include="Models\VaultCredentials.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
Expand Down Expand Up @@ -200,6 +212,9 @@
<Name>Commands.Utilities</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Cmdlets\RegisterContainer\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Import Project="..\..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@ public enum ManagedContainerType
IaasVMService,
}

public enum ScheduleType
{
Invalid = 0,
Daily = 1,
Weekly = 2
}

public enum RetentionType
{
Invalid = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@ public class AzureBackupItem : AzureBackupItemContextObject
public string ProtectionStatus { get; set; }

/// <summary>
/// DataSourceId of Azure Backup Item
/// </summary>
public string DataSourceId { get; set; }

/// <summary>
/// DataSourceId of Azure Backup Item
/// Type of Azure Backup Item
/// </summary>
public string Type { get; set; }

Expand Down Expand Up @@ -72,16 +67,23 @@ public AzureBackupItem(CSMProtectedItemResponse datasource, AzureBackupContainer
DataSourceStatus = datasource.Properties.ProtectionStatus;
ProtectionStatus = datasource.Properties.Status;
ItemName = datasource.Name;
ProtectionPolicyName = datasource.Properties.ProtectionPolicyId;

if (datasource.Properties.ProtectionPolicyId != null)
{
ProtectionPolicyName = datasource.Properties.ProtectionPolicyId.Split('/').Last();
}

ProtectionPolicyId = datasource.Properties.ProtectionPolicyId;
RecoveryPointsCount = datasource.Properties.RecoveryPointsCount;
Type = datasource.Properties.ItemType;
}

public AzureBackupItem(CSMItemResponse pPOItem, AzureBackupContainer azureBackupContainer)
: base(pPOItem, azureBackupContainer)
{
ProtectionStatus = pPOItem.Properties.Status;
ItemName = pPOItem.Name;
Type = pPOItem.Properties.ItemType;
}
}
}
Binary file not shown.