Skip to content
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

Anudeeb1 #62

Merged
merged 4 commits into from
Jun 29, 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 @@ -15,8 +15,8 @@
$ResourceGroupName = "backuprg"
$ResourceName = "backuprn"
$Location = "westus"
$ContainerResourceGroupName = "powershellbvt"
$ContainerResourceName = "powershellbvt"
$ManagedResourceGroupName = "powershellbvt"
$ManagedResourceName = "powershellbvt"

<#
.SYNOPSIS
Expand All @@ -32,10 +32,10 @@ function Test-GetAzureBackupContainerWithoutFilterReturnsNonZeroContainers
function Test-GetAzureBackupContainerWithUniqueFilterReturnsOneContainer
{
$vault = Get-AzureBackupVault -Name $ResourceName;
$container = Get-AzureBackupContainer -vault $vault -ContainerResourceGroupName $ContainerResourceGroupName -ContainerResourceName $ContainerResourceName
$container = Get-AzureBackupContainer -vault $vault -ManagedResourceGroupName $ManagedResourceGroupName -ManagedResourceName $ManagedResourceName
Assert-NotNull $container 'Container should not be null';
Assert-AreEqual $container.ResourceName $ContainerResourceName -CaseSensitive 'Returned container resource name (a.k.a friendly name) does not match the test VM resource name';
Assert-AreEqual $container.ResourceGroupName $ContainerResourceGroupName -CaseSensitive 'Returned container resource group name (a.k.a parent friendly name) does not match the test VM resource group name';
Assert-AreEqual $container.ManagedResourceName $ManagedResourceName -CaseSensitive 'Returned container resource name (a.k.a friendly name) does not match the test VM resource name';
Assert-AreEqual $container.ManagedResourceGroupName $ManagedResourceGroupName -CaseSensitive 'Returned container resource group name (a.k.a parent friendly name) does not match the test VM resource group name';
}

<#
Expand All @@ -44,15 +44,17 @@ Tests to register the container
#>
function Test-RegisterAzureBackupContainer
{
$jobId = Register-AzureBackupContainer -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -location $Location -Name $ContainerResourceName -ServiceName $ContainerResourceGroupName
$vault = Get-AzureBackupVault -Name $ResourceName;
$jobId = Register-AzureBackupContainer -vault $vault -Name $ManagedResourceName -ServiceName $ManagedResourceGroupName

Assert-NotNull $jobId 'JobID should not be null';
}

function Test-UnregisterAzureBackupContainer
{
$container = Get-AzureBackupContainer -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -location $Location -ContainerResourceName $ContainerResourceName -ContainerResourceGroupName $ContainerResourceGroupName
$jobId = Unregister-AzureBackupContainer -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -location $Location -AzureBackupContainer $container
$vault = Get-AzureBackupVault -Name $ResourceName;
$container = Get-AzureBackupContainer -vault $vault -ManagedResourceName $ManagedResourceName -ManagedResourceGroupName $ManagedResourceGroupName
$jobId = Unregister-AzureBackupContainer -vault $vault -AzureBackupContainer $container

Assert-NotNull $jobId 'JobID should not be null';
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $POName = "iaasvmcontainer;dev01testing;dev01testing"

function Test-GetAzureBackupItemTests
{
$azureBackUpContainer = New-Object Microsoft.Azure.Commands.AzureBackup.Cmdlets.AzureBackupContainer
$azureBackUpContainer = New-Object Microsoft.Azure.Commands.AzureBackup.Models.AzureBackupContainer
$azureBackUpContainer.ResourceGroupName = $ResourceGroupName
$azureBackUpContainer.ResourceName = $ResourceName
$azureBackUpContainer.Location = $Location
Expand All @@ -37,7 +37,7 @@ function Test-GetAzureBackupItemTests

function Test-EnableAzureBackupProtection
{
$policy = New-Object Microsoft.Azure.Commands.AzureBackup.Cmdlets.AzureBackupProtectionPolicy
$policy = New-Object Microsoft.Azure.Commands.AzureBackup.Models.AzureBackupProtectionPolicy
$policy.InstanceId = $PolicyId
$policy.Name = $PolicyName
$policy.ResourceGroupName = $ResourceGroupName
Expand All @@ -47,7 +47,7 @@ function Test-EnableAzureBackupProtection
$policy.RetentionType = "1"
$policy.ScheduleRunTimes = "2015-06-13T20:30:00"

$azureBackUpItem = New-Object Microsoft.Azure.Commands.AzureBackup.Cmdlets.AzureBackupItem
$azureBackUpItem = New-Object Microsoft.Azure.Commands.AzureBackup.Models.AzureBackupItem
$azureBackUpItem.ResourceGroupName = $ResourceGroupName
$azureBackUpItem.ResourceName = $ResourceName
$azureBackUpItem.Location = $Location
Expand All @@ -62,7 +62,7 @@ function Test-EnableAzureBackupProtection

function Test-DisableAzureBackupProtection
{
$azureBackUpItem = New-Object Microsoft.Azure.Commands.AzureBackup.Cmdlets.AzureBackupItem
$azureBackUpItem = New-Object Microsoft.Azure.Commands.AzureBackup.Models.AzureBackupItem
$azureBackUpItem.ResourceGroupName = $ResourceGroupName
$azureBackUpItem.ResourceName = $ResourceName
$azureBackUpItem.Location = $Location
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ $POName = "iaasvmcontainer;dev01testing;dev01testing"

function Test-GetAzureBackupJob
{
$vault = Get-AzureBackupVault -Name $ResourceName;
$OneMonthBack = Get-Date;
$OneMonthBack = $OneMonthBack.AddDays(-30);
$jobs = Get-AzureBackupJob -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -From $OneMonthBack -Debug
$jobs = Get-AzureBackupJob -Vault $vault -From $OneMonthBack
Assert-NotNull $jobs 'Jobs list should not be null'
foreach($job in $jobs)
{
Expand All @@ -25,7 +26,7 @@ function Test-GetAzureBackupJob
Assert-NotNull $jobs.Status 'Status should not be null';
Assert-NotNull $jobs.Operation 'Operation should not be null';

$jobDetails = Get-AzureBackupJobDetails -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Job $job
$jobDetails = Get-AzureBackupJobDetails -Job $job
Assert-NotNull $jobDetails.InstanceId 'JobID should not be null';
Assert-NotNull $jobDetails.StartTime 'StartTime should not be null';
Assert-NotNull $jobDetails.WorkloadType 'WorkloadType should not be null';
Expand All @@ -40,13 +41,14 @@ function Test-GetAzureBackupJob

function Test-StopAzureBackupJob
{
$vault = Get-AzureBackupVault -Name $ResourceName;
$OneMonthBack = Get-Date;
$OneMonthBack = $OneMonthBack.AddDays(-30);
#TODO
#Call trigger backup and get an inprogress job
$jobsList = Get-AzureBackupJob -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -From $OneMonthBack #-Operation 'Backup' -Status 'InProgress'
$jobsList = Get-AzureBackupJob -Vault $vault -From $OneMonthBack #-Operation 'Backup' -Status 'InProgress'

Stop-AzureBackupJob -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Job $jobsList[0];
$jobDetails = Get-AzureBackupJobDetails -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Job $jobsList[0];
Stop-AzureBackupJob -Job $jobsList[0];
$jobDetails = Get-AzureBackupJobDetails -Job $jobsList[0];
#Assert-AreEqual 'Cancelling' $jobDetails.Status
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ Tests creating new resource group and a simple resource.
#>
function Test-GetAzureBackupProtectionPolicyTests
{
$protectionPolicies = Get-AzureBackupProtectionPolicy -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location
$vault = Get-AzureBackupVault -Name $ResourceName;
$protectionPolicies = Get-AzureBackupProtectionPolicy -vault $vault
Assert-NotNull $protectionPolicies 'Protection Policies should not be null'
foreach($protectionPolicy in $protectionPolicies)
{
Expand All @@ -51,7 +52,8 @@ function Test-GetAzureBackupProtectionPolicyTests

function Test-GetAzureBackupProtectionPolicyByNameTests
{
$protectionPolicy = Get-AzureBackupProtectionPolicy -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location -Name $PolicyName
$vault = Get-AzureBackupVault -Name $ResourceName;
$protectionPolicy = Get-AzureBackupProtectionPolicy -vault $vault -Name $PolicyName

Assert-NotNull $protectionPolicy.InstanceId 'InstanceId should not be null'
Assert-NotNull $protectionPolicy.Name 'Name should not be null'
Expand All @@ -67,7 +69,8 @@ function Test-GetAzureBackupProtectionPolicyByNameTests

function Test-NewAzureBackupProtectionPolicyTests
{
$protectionPolicy = New-AzureBackupProtectionPolicy -Name $PolicyName -WorkloadType $WorkloadType -BackupType $BackupType -Daily -RetentionType $RetentionType -RetentionDuration $RetentionDuration -ScheduleRunTimes $ScheduleRunTimes -ResourceGroupName $ResourceGroupName -ResourceName $ResourceName -Location $Location
$vault = Get-AzureBackupVault -Name $ResourceName;
$protectionPolicy = New-AzureBackupProtectionPolicy -vault $vault -Name $PolicyName -WorkloadType $WorkloadType -BackupType $BackupType -Daily -RetentionType $RetentionType -RetentionDuration $RetentionDuration -ScheduleRunTimes $ScheduleRunTimes

Assert-NotNull $protectionPolicy.InstanceId 'InstanceId should not be null'
Assert-NotNull $protectionPolicy.Name 'Name should not be null'
Expand All @@ -82,7 +85,7 @@ function Test-NewAzureBackupProtectionPolicyTests

function Test-SetAzureBackupProtectionPolicyTests
{
$policy = New-Object Microsoft.Azure.Commands.AzureBackup.Cmdlets.AzureBackupProtectionPolicy
$policy = New-Object Microsoft.Azure.Commands.AzureBackup.Models.AzureBackupProtectionPolicy
$policy.InstanceId = $PolicyId
$policy.Name = $PolicyName
$policy.ResourceGroupName = $ResourceGroupName
Expand Down Expand Up @@ -110,7 +113,7 @@ function Test-SetAzureBackupProtectionPolicyTests
function Test-RemoveAzureBackupProtectionPolicyTests
{
$policyNewName = "policy09_new"
$policy = New-Object Microsoft.Azure.Commands.AzureBackup.Cmdlets.AzureBackupProtectionPolicy
$policy = New-Object Microsoft.Azure.Commands.AzureBackup.Models.AzureBackupProtectionPolicy
$policy.InstanceId = $PolicyId
$policy.Name = $policyNewName
$policy.ResourceGroupName = $ResourceGroupName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $POName = "iaasvmcontainer;dev01testing;dev01testing"

function Test-BackUpAzureBackUpItem
{
$azureBackUpItem = New-Object Microsoft.Azure.Commands.AzureBackup.Cmdlets.AzureBackupItem
$azureBackUpItem = New-Object Microsoft.Azure.Commands.AzureBackup.Models.AzureBackupItem
$azureBackUpItem.ResourceGroupName = $ResourceGroupName
$azureBackUpItem.ResourceName = $ResourceName
$azureBackUpItem.Location = $Location
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $POName = "iaasvmcontainer;dev01testing;dev01testing"

function Test-GetAzureRecoveryPoint
{
$azureBackUpItem = New-Object Microsoft.Azure.Commands.AzureBackup.Cmdlets.AzureBackupItem
$azureBackUpItem = New-Object Microsoft.Azure.Commands.AzureBackup.Models.AzureBackupItem
$azureBackUpItem.ResourceGroupName = $ResourceGroupName
$azureBackUpItem.ResourceName = $ResourceGroupName
$azureBackUpItem.Location = $Location
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal static class AzureBackupCmdletHelpMessage
public const string Sku = "The SKU of the backup vault instance.";
public const string ResourceTags = "A hash table which represents resource tags.";
public const string TargetLocation = "The directory where the credentials file will be saved. This must be an absolute path.";
public const string ContainerResourceName = "The container resource name aka friendly name.";
public const string ManagedResourceName = "The resource name of the resource being managed by the Azure Backup service (ex: resource name of the VM).";
public const string ContainerId = "The container ID.";
public const string ContainerRegistrationStatus = "The container registration status.";
public const string ContainerType = "The container type.";
Expand Down Expand Up @@ -52,7 +52,7 @@ internal static class AzureBackupCmdletHelpMessage
public const string WaitJobFilterTimeoutHelpMessage = "Maximum number of seconds for which cmdlet should wait before job(s) complete running.";

public const string VirtualMachine = "Virtual Machine.";
public const string ContainerResourceGroupName = "The container resource group name.";
public const string ManagedResourceGroupName = "The resource group name of the resource being managed by the Azure Backup service (ex: resource group name of the VM).";
public const string ProtectionStatus = "Protection Status of the azure backup item.";
public const string AzureBackUpItem = "Azure BackUp Item.";
public const string RecoveryPointId = "Recovery Point Id.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
[Cmdlet(VerbsCommon.Get, "AzureBackupContainer"), OutputType(typeof(AzureBackupContainer), typeof(List<AzureBackupContainer>))]
public class GetAzureBackupContainer : AzureBackupVaultCmdletBase
{
[Parameter(Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.ContainerResourceGroupName)]
[Parameter(Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.ManagedResourceGroupName)]
[ValidateNotNullOrEmpty]
public string ContainerResourceGroupName { get; set; }
public string ManagedResourceGroupName { get; set; }

[Parameter(Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.ContainerResourceName)]
[Parameter(Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.ManagedResourceName)]
[ValidateNotNullOrEmpty]
public string ContainerResourceName { get; set; }
public string ManagedResourceName { get; set; }

[Parameter(Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.ContainerRegistrationStatus)]
[ValidateNotNullOrEmpty]
Expand All @@ -63,11 +63,11 @@ public override void ExecuteCmdlet()

// When resource group name is specified, remove all containers whose resource group name
// doesn't match the given resource group name
if (!string.IsNullOrEmpty(ContainerResourceGroupName))
if (!string.IsNullOrEmpty(ManagedResourceGroupName))
{
containerInfos.RemoveAll(containerInfo =>
{
return containerInfo.ParentContainerName != ContainerResourceGroupName;
return containerInfo.ParentContainerName != ManagedResourceGroupName;
});
WriteDebug(string.Format("Count of containers after resource group filter = {0}", containerInfos.Count));
}
Expand All @@ -81,7 +81,7 @@ public override void ExecuteCmdlet()

// When container resource name and container resource group name are specified, this parameter set
// identifies a container uniquely. Thus, we return just one container instead of a list.
if (!string.IsNullOrEmpty(ContainerResourceName) & !string.IsNullOrEmpty(ContainerResourceGroupName))
if (!string.IsNullOrEmpty(ManagedResourceName) & !string.IsNullOrEmpty(ManagedResourceGroupName))
{
if (containers.Any())
{
Expand Down Expand Up @@ -120,9 +120,9 @@ private string ConstructQueryFilterString()
break;
}

if (!string.IsNullOrEmpty(ContainerResourceName))
if (!string.IsNullOrEmpty(ManagedResourceName))
{
containerQueryObject.ContainerFriendlyNameField = ContainerResourceName;
containerQueryObject.ContainerFriendlyNameField = ManagedResourceName;
}

return ContainerHelpers.GetQueryFilter(containerQueryObject);
Expand Down
Loading