Skip to content

Commit fabe186

Browse files
author
Samuel Anudeep
committed
Merge pull request #144 from MabOneSdk/dev1
RI from dev1 into dev1-anudeeb
2 parents 4ab2c88 + 4e0e3d0 commit fabe186

File tree

98 files changed

+48191
-41019
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+48191
-41019
lines changed

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## 2015.09.03 version 0.9.8
2+
13
## 2015.08.17 version 0.9.7
24
* Azure Profile cmdlets
35
* New-AzureProfile

setup/azurecmdfiles.wxi

Lines changed: 100 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Jobs/AzureBackupJobHelper.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using System.Xml;
1919
using System.Linq;
2020
using Mgmt = Microsoft.Azure.Management.BackupServices.Models;
21+
using Microsoft.Azure.Commands.AzureBackup.Models;
2122

2223

2324
namespace Microsoft.Azure.Commands.AzureBackup.Cmdlets
@@ -62,6 +63,30 @@ public static class AzureBackupJobHelper
6263
{
6364
public static DateTime MinimumAllowedDate = new DateTime(DateTime.MinValue.Year, DateTime.MinValue.Month, DateTime.MinValue.Day, DateTime.MinValue.Hour, DateTime.MinValue.Minute, DateTime.MinValue.Second, DateTimeKind.Utc);
6465

66+
public static string GetTypeForPS(string itemType)
67+
{
68+
AzureBackupItemType managedContainerType = (AzureBackupItemType)Enum.Parse(typeof(AzureBackupItemType), itemType, true);
69+
70+
string returnType = string.Empty;
71+
72+
switch (managedContainerType)
73+
{
74+
case AzureBackupItemType.IaasVM:
75+
returnType = "AzureVM";
76+
break;
77+
}
78+
79+
return returnType;
80+
}
81+
82+
public static string GetTypeForService(string itemType)
83+
{
84+
if (itemType.CompareTo("AzureVM") == 0)
85+
return AzureBackupItemType.IaasVM.ToString();
86+
throw new ArgumentException("Invalid value", "itemType");
87+
}
88+
89+
6590
public static bool IsValidStatus(string inputStatus)
6691
{
6792
JobStatus status;

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Jobs/GetAzureRMBackupJob.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class GetAzureRMBackupJob : AzureBackupCmdletBase
5656
public string Status { get; set; }
5757

5858
[Parameter(Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.JobFilterTypeHelpMessage, ParameterSetName = "FiltersSet")]
59-
[ValidateSet("IaasVM")]
59+
[ValidateSet("AzureVM")]
6060
public string Type { get; set; }
6161

6262
[Parameter(Mandatory = false, HelpMessage = AzureBackupCmdletHelpMessage.JobFilterOperationHelpMessage, ParameterSetName = "FiltersSet")]
@@ -79,6 +79,11 @@ public override void ExecuteCmdlet()
7979
JobId = Job.InstanceId;
8080
}
8181

82+
if (Type != null)
83+
{
84+
Type = AzureBackupJobHelper.GetTypeForService(Type);
85+
}
86+
8287
// validations
8388
if (!From.HasValue)
8489
{

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Jobs/GetAzureRMBackupJobDetails.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class GetAzureRMBackupJobDetils : AzureBackupCmdletBase
3535

3636
[Parameter(Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.JobDetailsFilterJobIdHelpMessage, ParameterSetName = "IdFiltersSet")]
3737
[ValidateNotNullOrEmpty]
38-
public string JobID { get; set; }
38+
public string JobId { get; set; }
3939

4040
[Parameter(Mandatory = true, HelpMessage = AzureBackupCmdletHelpMessage.JobDetailsFilterJobHelpMessage, ParameterSetName = "JobsFiltersSet", ValueFromPipeline = true)]
4141
[ValidateNotNull]
@@ -53,12 +53,12 @@ public override void ExecuteCmdlet()
5353
{
5454
if (Job != null)
5555
{
56-
JobID = Job.InstanceId;
56+
JobId = Job.InstanceId;
5757
}
5858

59-
WriteDebug(String.Format(Resources.JobIdFilter, JobID));
59+
WriteDebug(String.Format(Resources.JobIdFilter, JobId));
6060

61-
Mgmt.CSMJobDetailsResponse serviceJobProperties = AzureBackupClient.GetJobDetails(Vault.ResourceGroupName, Vault.Name, JobID);
61+
Mgmt.CSMJobDetailsResponse serviceJobProperties = AzureBackupClient.GetJobDetails(Vault.ResourceGroupName, Vault.Name, JobId);
6262
AzureRMBackupJobDetails jobDetails = new AzureRMBackupJobDetails(Vault, serviceJobProperties.JobDetailedProperties, serviceJobProperties.Name);
6363

6464
WriteDebug(Resources.JobResponse);

src/ResourceManager/AzureBackup/Commands.AzureBackup/Helpers/VaultHelpers.cs

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -54,38 +54,40 @@ public static string GetResourceGroup(string vaultId)
5454
return tokens[3];
5555
}
5656

57+
// NOTE: Commenting code which will be used in a later sprint, but not right now.
58+
5759
/// <summary>
5860
/// Extension to convert enumerable Hashtable into a dictionary
5961
/// </summary>
6062
/// <param name="tags"></param>
6163
/// <returns></returns>
62-
public static Dictionary<string, string> ConvertToDictionary(this Hashtable[] tags)
63-
{
64-
return tags == null
65-
? null
66-
: tags
67-
.CoalesceEnumerable()
68-
.Select(hashTable => hashTable.OfType<DictionaryEntry>()
69-
.ToDictionary(kvp => kvp.Key.ToString(), kvp => kvp.Value))
70-
.Where(tagDictionary => tagDictionary.ContainsKey("Name"))
71-
.Select(tagDictionary => Tuple
72-
.Create(
73-
tagDictionary["Name"].ToString(),
74-
tagDictionary.ContainsKey("Value") ? tagDictionary["Value"].ToString() : string.Empty))
75-
.Distinct(kvp => kvp.Item1)
76-
.ToDictionary(kvp => kvp.Item1, kvp => kvp.Item2);
77-
}
64+
// public static Dictionary<string, string> ConvertToDictionary(this Hashtable[] tags)
65+
// {
66+
// return tags == null
67+
// ? null
68+
// : tags
69+
// .CoalesceEnumerable()
70+
// .Select(hashTable => hashTable.OfType<DictionaryEntry>()
71+
// .ToDictionary(kvp => kvp.Key.ToString(), kvp => kvp.Value))
72+
// .Where(tagDictionary => tagDictionary.ContainsKey("Name"))
73+
// .Select(tagDictionary => Tuple
74+
// .Create(
75+
// tagDictionary["Name"].ToString(),
76+
// tagDictionary.ContainsKey("Value") ? tagDictionary["Value"].ToString() : string.Empty))
77+
// .Distinct(kvp => kvp.Item1)
78+
// .ToDictionary(kvp => kvp.Item1, kvp => kvp.Item2);
79+
// }
7880

7981
/// <summary>
8082
/// Extension to coalesce enumerable
8183
/// </summary>
8284
/// <typeparam name="TSource">Enumerable type</typeparam>
8385
/// <param name="source">Enumerable</param>
8486
/// <returns></returns>
85-
public static IEnumerable<TSource> CoalesceEnumerable<TSource>(this IEnumerable<TSource> source)
86-
{
87-
return source ?? Enumerable.Empty<TSource>();
88-
}
87+
// public static IEnumerable<TSource> CoalesceEnumerable<TSource>(this IEnumerable<TSource> source)
88+
// {
89+
// return source ?? Enumerable.Empty<TSource>();
90+
// }
8991

9092
/// <summary>
9193
/// Extension to remove duplicates from enumerable based on a provided key selector
@@ -95,34 +97,34 @@ public static IEnumerable<TSource> CoalesceEnumerable<TSource>(this IEnumerable<
9597
/// <param name="source">Input enumerable to remove duplicates from</param>
9698
/// <param name="keySelector">Lambda to select key</param>
9799
/// <returns></returns>
98-
public static IEnumerable<TSource> Distinct<TSource, TKeyType>(this IEnumerable<TSource> source, Func<TSource, TKeyType> keySelector)
99-
{
100-
var set = new Dictionary<TKeyType, TSource>(EqualityComparer<TKeyType>.Default);
101-
foreach (TSource element in source)
102-
{
103-
TSource value;
104-
var key = keySelector(element);
105-
if (!set.TryGetValue(key, out value))
106-
{
107-
yield return element;
108-
}
109-
else
110-
{
111-
set[key] = value;
112-
}
113-
}
114-
}
100+
// public static IEnumerable<TSource> Distinct<TSource, TKeyType>(this IEnumerable<TSource> source, Func<TSource, TKeyType> keySelector)
101+
// {
102+
// var set = new Dictionary<TKeyType, TSource>(EqualityComparer<TKeyType>.Default);
103+
// foreach (TSource element in source)
104+
// {
105+
// TSource value;
106+
// var key = keySelector(element);
107+
// if (!set.TryGetValue(key, out value))
108+
// {
109+
// yield return element;
110+
// }
111+
// else
112+
// {
113+
// set[key] = value;
114+
// }
115+
// }
116+
// }
115117

116118
/// <summary>
117119
/// Extension to convert dictionary to hashtable enumerable
118120
/// </summary>
119121
/// <param name="tags"></param>
120122
/// <returns></returns>
121-
public static Hashtable[] GetTagsHashtables(this IDictionary<string, string> tags)
122-
{
123-
return tags == null
124-
? null
125-
: tags.Select(kvp => new Hashtable { { "Name", kvp.Key }, { "Value", kvp.Value } }).ToArray();
126-
}
123+
// public static Hashtable[] GetTagsHashtables(this IDictionary<string, string> tags)
124+
// {
125+
// return tags == null
126+
// ? null
127+
// : tags.Select(kvp => new Hashtable { { "Name", kvp.Key }, { "Value", kvp.Value } }).ToArray();
128+
// }
127129
}
128130
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using Microsoft.Azure.Management.BackupServices;
2222
using Microsoft.Azure.Management.BackupServices;
2323
using Mgmt = Microsoft.Azure.Management.BackupServices.Models;
24+
using Microsoft.Azure.Commands.AzureBackup.Cmdlets;
2425

2526
namespace Microsoft.Azure.Commands.AzureBackup.Models
2627
{
@@ -52,7 +53,7 @@ public AzureRMBackupJob(AzureRMBackupVault vault, Mgmt.CSMJobProperties serviceJ
5253
: base(vault)
5354
{
5455
this.InstanceId = jobName;
55-
this.WorkloadType = serviceJob.WorkloadType;
56+
this.WorkloadType = AzureBackupJobHelper.GetTypeForPS(serviceJob.WorkloadType);
5657
this.WorkloadName = serviceJob.EntityFriendlyName;
5758
this.Operation = serviceJob.Operation;
5859
this.Status = serviceJob.Status;

src/ResourceManager/Compute/Commands.Compute.Test/Commands.Compute.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@
290290
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineDataDisk.json">
291291
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
292292
</None>
293+
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineDataDiskNegative.json">
294+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
295+
</None>
293296
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineImageList.json">
294297
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
295298
</None>

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/AvailabilitySetTests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function Test-AvailabilitySet
2424
try
2525
{
2626
# Common
27-
$loc = 'West US';
27+
$loc = Get-ComputeVMLocation;
2828
New-AzureResourceGroup -Name $rgname -Location $loc -Force;
2929

3030
$asetName = 'avs' + $rgname;

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/ComputeCloudExceptionTests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function Run-ComputeCloudExceptionTests
2020
try
2121
{
2222
# Common
23-
$loc = 'West US';
23+
$loc = Get-ComputeVMLocation;
2424
New-AzureResourceGroup -Name $rgname -Location $loc -Force;
2525

2626
$compare = "Resource*NotFound*OperationID : `'*`'";

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/ComputeTestCommon.ps1

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,3 +394,75 @@ function Get-SasUri
394394

395395
return $uri;
396396
}
397+
398+
# Get a Location according to resource provider.
399+
function Get-ResourceProviderLocation
400+
{
401+
param ([string] $name, [string] $default = "westus", [bool] $canonical = $true)
402+
403+
$loc = Get-AzureLocation | where { $_.Name.Equals($name) };
404+
405+
if ($loc -eq $null)
406+
{
407+
throw 'There is no available locations with given parameters';
408+
}
409+
410+
if ($loc.LocationsString.ToLowerInvariant().Replace(" ", "").Contains($default.ToLowerInvariant().Replace(" ","")))
411+
{
412+
return $default;
413+
}
414+
415+
if ($canonical)
416+
{
417+
return $loc.Locations[0].ToLowerInvariant().Replace(" ", "");
418+
}
419+
else
420+
{
421+
return $loc.Locations[0];
422+
}
423+
}
424+
425+
function Get-ComputeVMLocation
426+
{
427+
Get-ResourceProviderLocation "Microsoft.Compute/virtualMachines";
428+
}
429+
430+
function Get-ComputeAvailabilitySetLocation
431+
{
432+
Get-ResourceProviderLocation "Microsoft.Compute/availabilitySets";
433+
}
434+
435+
function Get-ComputeVMExtensionLocation
436+
{
437+
Get-ResourceProviderLocation "Microsoft.Compute/virtualMachines/extensions";
438+
}
439+
440+
function Get-ComputeVMDiagnosticSettingLocation
441+
{
442+
Get-ResourceProviderLocation "Microsoft.Compute/virtualMachines/diagnosticSettings";
443+
}
444+
445+
function Get-ComputeVMMetricDefinitionLocation
446+
{
447+
Get-ResourceProviderLocation "Microsoft.Compute/virtualMachines/metricDefinitions";
448+
}
449+
450+
function Get-ComputeOperationLocation
451+
{
452+
Get-ResourceProviderLocation "Microsoft.Compute/locations/operations";
453+
}
454+
455+
function Get-ComputeVMSizeLocation
456+
{
457+
Get-ResourceProviderLocation "Microsoft.Compute/locations/vmSizes";
458+
}
459+
460+
function Get-ComputeUsageLocation
461+
{
462+
Get-ResourceProviderLocation "Microsoft.Compute/locations/usages";
463+
}
464+
465+
function Get-ComputePublisherLocation
466+
{
467+
Get-ResourceProviderLocation "Microsoft.Compute/locations/publishers";
468+
}

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineExtensionTests.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function Test-VirtualMachineExtension
2424
try
2525
{
2626
# Common
27-
$loc = 'westus';
27+
$loc = Get-ComputeVMLocation;
2828
New-AzureResourceGroup -Name $rgname -Location $loc -Force;
2929

3030
# VM Profile & Hardware
@@ -163,7 +163,7 @@ function Test-VirtualMachineExtensionUsingHashTable
163163
try
164164
{
165165
# Common
166-
$loc = 'westus';
166+
$loc = Get-ComputeVMLocation;
167167
New-AzureResourceGroup -Name $rgname -Location $loc -Force;
168168

169169
# VM Profile & Hardware
@@ -325,7 +325,7 @@ function Test-VirtualMachineCustomScriptExtension
325325
try
326326
{
327327
# Common
328-
$loc = 'westus';
328+
$loc = Get-ComputeVMLocation;
329329
New-AzureResourceGroup -Name $rgname -Location $loc -Force;
330330

331331
# VM Profile & Hardware
@@ -494,7 +494,7 @@ function Test-VirtualMachineCustomScriptExtensionFileUri
494494
try
495495
{
496496
# Common
497-
$loc = 'westus';
497+
$loc = Get-ComputeVMLocation;
498498
New-AzureResourceGroup -Name $rgname -Location $loc -Force;
499499

500500
# VM Profile & Hardware
@@ -652,7 +652,7 @@ function Test-VirtualMachineAccessExtension
652652
try
653653
{
654654
# Common
655-
$loc = 'westus';
655+
$loc = Get-ComputeVMLocation;
656656
New-AzureResourceGroup -Name $rgname -Location $loc -Force;
657657

658658
# VM Profile & Hardware

0 commit comments

Comments
 (0)