Skip to content

Commit

Permalink
Merge pull request Azure#10 from romahamu/makar/format_fix
Browse files Browse the repository at this point in the history
Formatting fixes and get-azhpccachesku test
  • Loading branch information
rebecca-makar authored Feb 18, 2020
2 parents 31e3c23 + d45fa64 commit d66eb2c
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ Tests GetAzSku
#>
function Test-GetSku {
# ListSku
$skulist = Get-AzSku
$skulist = Get-AzHpcCacheSku
Assert-False {$skulist -eq $null}
}
6 changes: 3 additions & 3 deletions src/StorageCache/HPCCache/Commands/GetAzHpcCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Microsoft.Azure.Commands.HPCCache
/// </summary>
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "HpcCache")]
[OutputType(typeof(PSHPCCache))]
public class GetAzHPCCaches : HpcCacheBaseCmdlet
public class GetAzHpcCache : HpcCacheBaseCmdlet
{
/// <summary>
/// Gets or sets resource Group Name.
Expand Down Expand Up @@ -52,9 +52,9 @@ public override void ExecuteCmdlet()
else
{
var resourgeGroupCaches = this.HpcCacheClient.Caches.ListByResourceGroup(this.ResourceGroupName);
foreach(var cache in resourgeGroupCaches.Value)
foreach (var cache in resourgeGroupCaches.Value)
{
this.WriteObject(new PSHPCCache(cache, cache.MountAddresses),true);
this.WriteObject(new PSHPCCache(cache, cache.MountAddresses), true);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/StorageCache/HPCCache/Commands/GetAzHpcCacheSku.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ namespace Microsoft.Azure.Commands.HPCCache
/// </summary>
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "HpcCacheSku")]
[OutputType(typeof(PSSku))]
public class GetAzSku : HpcCacheBaseCmdlet
public class GetAzHpcCacheSku : HpcCacheBaseCmdlet
{
/// <inheritdoc/>
public override void ExecuteCmdlet()
{
var resourceSkus = this.HpcCacheClient.Skus.List().Value;
foreach(var sku in resourceSkus)
foreach (var sku in resourceSkus)
{
this.WriteObject(new PSSku(sku));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Microsoft.Azure.Commands.HPCCache
/// Get UsageModels related to HPC Cache Storage Target.
/// </summary>
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "HpcCacheUsageModels")]
public class GetAzUsageModels : HpcCacheBaseCmdlet
public class GetAzHpcCacheUsageModels : HpcCacheBaseCmdlet
{
/// <summary>
/// Returns Usage Models.
Expand Down
11 changes: 4 additions & 7 deletions src/StorageCache/HPCCache/Commands/NewAzHpcCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@
// ----------------------------------------------------------------------------------
namespace Microsoft.Azure.Commands.HPCCache
{
using System;
using System.Collections;
using System.Management.Automation;
using System.Net;
using Microsoft.Azure.Common.Properties;
using Microsoft.Azure.Management.StorageCache;
using Microsoft.Azure.Commands.HPCCache;
using Microsoft.Azure.Management.StorageCache.Models;
using Microsoft.Azure.PowerShell.Cmdlets.HPCCache.Models;
using Microsoft.Rest.Azure;
Expand Down Expand Up @@ -74,7 +70,7 @@ public class NewAzHpcCache : HpcCacheBaseCmdlet
public string Location { get; set; }

/// <summary>
/// The tags to associate with HPC Cache.
/// Gets or sets the tags to associate with HPC Cache.
/// </summary>
[Parameter(Mandatory = false, HelpMessage = "The tags to associate with HPC Cache.")]
public Hashtable Tag { get; set; }
Expand All @@ -96,10 +92,11 @@ public override void ExecuteCmdlet()
throw;
}
}

Utility.ValidateResourceGroup(this.ResourceGroupName);
var cacheSku = new CacheSku() { Name = this.Sku };
var Tag = this.Tag.ToDictionaryTags();
var cacheParameters = new Cache() { CacheSizeGB = this.CacheSize, Location = this.Location, Sku = cacheSku, Subnet = this.SubnetUri, Tags = Tag};
var tag = this.Tag.ToDictionaryTags();
var cacheParameters = new Cache() { CacheSizeGB = this.CacheSize, Location = this.Location, Sku = cacheSku, Subnet = this.SubnetUri, Tags = tag };
var cache = this.HpcCacheClient.Caches.CreateOrUpdate(this.ResourceGroupName, this.CacheName, cacheParameters);
this.WriteObject(new PSHPCCache(cache, cache.MountAddresses));
}
Expand Down
4 changes: 2 additions & 2 deletions src/StorageCache/HPCCache/Commands/RemoveAzHpcCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public class RemoveAzHpcCache : HpcCacheBaseCmdlet
public string CacheName { get; set; }

/// <summary>
/// Delete Force - always set to false.
/// Gets or sets Delete Force - always set to false.
/// </summary>
[Parameter(Mandatory = false, HelpMessage = "Indicates that the cmdlet does not prompt you for confirmation. By default, this cmdlet prompts you to confirm that you want to delete the cache.")]
public SwitchParameter Force { get; set; }

/// <summary>
/// Switch parameter if you do not want to wait till success.
/// Gets or sets Switch parameter if you do not want to wait till success.
/// </summary>
[Parameter(Mandatory = false, HelpMessage = "This Cmdlet does not return an object by default. If this switch is specified, it returns true if successful.")]
public SwitchParameter PassThru { get; set; }
Expand Down
11 changes: 3 additions & 8 deletions src/StorageCache/HPCCache/Commands/UpdateAzHpcCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,11 @@
// ----------------------------------------------------------------------------------
namespace Microsoft.Azure.Commands.HPCCache
{
using System;
using System.Collections;
using System.Management.Automation;
using System.Net;
using Microsoft.Azure.Common.Properties;
using Microsoft.Azure.Management.StorageCache;
using Microsoft.Azure.Commands.HPCCache;
using Microsoft.Azure.Management.StorageCache.Models;
using Microsoft.Azure.PowerShell.Cmdlets.HPCCache.Models;
using Microsoft.Rest.Azure;

/// <summary>
/// NewHPCCache comandlet.
Expand All @@ -46,7 +41,7 @@ public class UpdateAzHpcCache : HpcCacheBaseCmdlet
public string CacheName { get; set; }

/// <summary>
/// The tags to associate with HPC Cache.
/// Gets or sets the tags to associate with HPC Cache.
/// </summary>
[Parameter(Mandatory = false, HelpMessage = "The tags to associate with HPC Cache that are getting updated.")]
public Hashtable Tag { get; set; }
Expand All @@ -63,8 +58,8 @@ public override void ExecuteCmdlet()
var cacheSize = cacheExists.CacheSizeGB;
var sku = cacheExists.Sku;
var subnet = cacheExists.Subnet;
var Tag = this.Tag.ToDictionaryTags();
var cacheParameters = new Cache() { CacheSizeGB = cacheSize, Location = location, Sku = sku, Subnet = subnet, Tags = Tag };
var tag = this.Tag.ToDictionaryTags();
var cacheParameters = new Cache() { CacheSizeGB = cacheSize, Location = location, Sku = sku, Subnet = subnet, Tags = tag };
var cache = this.HpcCacheClient.Caches.CreateOrUpdate(this.ResourceGroupName, this.CacheName, cacheParameters);
this.WriteObject(new PSHPCCache(cache, cache.MountAddresses));
}
Expand Down
6 changes: 3 additions & 3 deletions src/StorageCache/HPCCache/Models/PSHpcCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class PSHPCCache
/// Initializes a new instance of the <see cref="PSHPCCache"/> class.
/// </summary>
/// <param name="cache">cache object.</param>
/// <param name="mountAddresses"> IListstring mountAddresses.</param>
public PSHPCCache(StorageCacheModels.Cache cache, IList<string> mountAddresses)
{
this.ResourceGroupName = new ResourceIdentifier(cache.Id).ResourceGroupName;
Expand Down Expand Up @@ -80,10 +81,10 @@ public PSHPCCache(StorageCacheModels.Cache cache, IList<string> mountAddresses)
public string HealthState { get; set; }

/// <summary>
/// Gets or Sets HealthStatusDescription
/// Gets or Sets HealthStatusDescription.
/// </summary>

public string HealthStatusDescription { get; set; }

/// <summary>
/// Gets or Sets MountAddresses.
/// </summary>
Expand All @@ -92,7 +93,6 @@ public PSHPCCache(StorageCacheModels.Cache cache, IList<string> mountAddresses)
/// <summary>
/// Gets or Sets Cache ProvisioningState.
/// </summary>

public string ProvisioningState { get; set; }

/// <summary>
Expand Down
17 changes: 15 additions & 2 deletions src/StorageCache/HPCCache/Models/PSHpcCacheUsageModels.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------
namespace Microsoft.Azure.Commands.HPCCache
{
using Microsoft.Azure.Management.StorageCache.Models;
Expand All @@ -9,7 +22,7 @@ public class PSHpcCacheUsageModels
{
/// <summary>
/// Initializes a new instance of the <see cref="PSHpcCacheUsageModels"/> class.
/// PSHpcCacheUsageModels
/// PSHpcCacheUsageModels.
/// </summary>
/// <param name="usagemodel"> usagemodel.</param>
public PSHpcCacheUsageModels(UsageModel usagemodel)
Expand All @@ -33,7 +46,7 @@ public PSHpcCacheUsageModels(UsageModel usagemodel)
public string TargetType { get; set; }

/// <summary>
/// Gets or sets Display
/// Gets or sets Display.
/// </summary>
public string Display { get; set; }
}
Expand Down
17 changes: 16 additions & 1 deletion src/StorageCache/HPCCache/Models/PSSku.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public PSSku(ResourceSku sku)
{
if (sku != null)
{
//this.NextLink = sku.NextLink;
this.Name = sku.Name;
this.Locations = sku.Locations;
this.ResourceType = sku.ResourceType;
Expand All @@ -47,9 +46,25 @@ public PSSku(ResourceSku sku)
/// Gets or sets get or sets value.
/// </summary>
public string Name { get; set; }

/// <summary>
/// Gets or sets get or sets Location.
/// </summary>
public IList<string> Locations { get; set; }

/// <summary>
/// Gets or sets get or sets ResourceType.
/// </summary>
public string ResourceType { get; set; }

/// <summary>
/// Gets or sets get or sets Restrictions.
/// </summary>
public IList<Management.StorageCache.Models.Restriction> Restrictions { get; set; }

/// <summary>
/// Gets or sets get or sets Capabilities.
/// </summary>
public IList<ResourceSkuCapabilities> Capabilities { get; set; }
}
}
25 changes: 17 additions & 8 deletions src/StorageCache/HPCCache/Models/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,22 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Microsoft.Azure.Commands.HPCCache

{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

/// <summary>
/// Utility Class.
/// </summary>
public static class Utility
{
/// <summary>
/// Validate Resource Group.
/// </summary>
/// <param name="resourceGroupName"> string resourceGroupName.</param>
public static void ValidateResourceGroup(string resourceGroupName)
{
if (resourceGroupName != null && resourceGroupName.Contains("/"))
Expand All @@ -32,6 +36,11 @@ public static void ValidateResourceGroup(string resourceGroupName)
}
}

/// <summary>
/// Convert tags to dictionary.
/// </summary>
/// <param name="table"> Hashtable table. </param>
/// <returns>dictionary of tags. </returns>
public static IDictionary<string, string> ToDictionaryTags(this Hashtable table)
{
return table?.Cast<DictionaryEntry>()
Expand Down

0 comments on commit d66eb2c

Please sign in to comment.