Skip to content

AzureRT PR - CLU Compute Cmdlets (alpha) #1500

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 38 commits into from
Dec 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
eb785d7
First CLU Build of Compute Commands
huangpf Dec 4, 2015
d4e7826
+Compute NuSpec Template
huangpf Dec 4, 2015
7a473d3
Fix
huangpf Dec 4, 2015
a12b2bf
Merge branch 'clu' of https://github.com/Azure/azure-powershell into clu
huangpf Dec 8, 2015
95795de
Remove azure.bat like Storage's project does
huangpf Dec 8, 2015
f150c73
Merge pull request #235 from Azure/clu
huangpf Dec 9, 2015
04abbc0
Merge pull request #236 from Azure/clu
huangpf Dec 9, 2015
dd65f07
Update
huangpf Dec 9, 2015
cd34ad9
Merge branch 'clu' of https://github.com/huangpf/azure-powershell int…
huangpf Dec 9, 2015
e7d5d78
+AVSet Cmdlets
huangpf Dec 9, 2015
c4e41e5
Merge pull request #237 from Azure/clu
huangpf Dec 10, 2015
e705592
Update
huangpf Dec 10, 2015
fda6cdf
Update
huangpf Dec 10, 2015
0295eb0
Merge pull request #240 from Azure/clu
huangpf Dec 11, 2015
c32badf
Remove launchSettings.json
huangpf Dec 11, 2015
08cfe16
Update
huangpf Dec 11, 2015
f8adcbf
Image Commands
huangpf Dec 11, 2015
8112575
Extension Image Cmdlets
huangpf Dec 11, 2015
55ee202
VM Commands:
huangpf Dec 12, 2015
2c742d0
Merge pull request #241 from Azure/clu
huangpf Dec 12, 2015
ffc1b23
Merge pull request #242 from Azure/clu
huangpf Dec 12, 2015
2f5f42c
Merge pull request #243 from Azure/clu
huangpf Dec 12, 2015
088280c
Extension
huangpf Dec 14, 2015
8ebd9b5
Merge pull request #244 from Azure/clu
huangpf Dec 14, 2015
2e9c777
Merge branch 'clu' of https://github.com/huangpf/azure-powershell int…
huangpf Dec 14, 2015
abd104b
Merge pull request #245 from Azure/clu
huangpf Dec 15, 2015
b01f050
Merge branch 'clu' of https://github.com/huangpf/azure-powershell int…
huangpf Dec 15, 2015
28b0ba3
Merge pull request #248 from Azure/clu
huangpf Dec 15, 2015
0102299
Merge branch 'clu' of https://github.com/huangpf/azure-powershell int…
huangpf Dec 15, 2015
4305c9b
Merge pull request #249 from Azure/clu
huangpf Dec 15, 2015
880f175
Merge branch 'clu' of https://github.com/huangpf/azure-powershell int…
huangpf Dec 15, 2015
f59fe4c
Add Compute to BuildAndInstallClu.bat
huangpf Dec 15, 2015
048629a
Add Files
huangpf Dec 15, 2015
b96778d
Update
huangpf Dec 16, 2015
b311f0a
Merge branch 'clu' of https://github.com/Azure/azure-powershell into clu
huangpf Dec 16, 2015
a30581d
Update Tests
huangpf Dec 16, 2015
8d0190f
Update project.json
huangpf Dec 16, 2015
cf66893
Update Test project.json
huangpf Dec 16, 2015
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
24 changes: 24 additions & 0 deletions src/CLU/CLUCoreCLR.sln
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.CLU", "Microsoft.
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.CLU.Test", "Microsoft.CLU.Test\Microsoft.CLU.Test.xproj", "{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Azure.Commands.Compute", "Microsoft.Azure.Commands.Compute\Microsoft.Azure.Commands.Compute.xproj", "{04F9968A-5662-4508-BEE2-31F56848FCBA}"
ProjectSection(ProjectDependencies) = postProject
{99B1290D-A073-4907-8018-51C714431778} = {99B1290D-A073-4907-8018-51C714431778}
{3910613E-4ED2-49E2-8CCF-966D586665AC} = {3910613E-4ED2-49E2-8CCF-966D586665AC}
{81A48E48-89A7-4B93-8207-4F8FA6DC251B} = {81A48E48-89A7-4B93-8207-4F8FA6DC251B}
{45B05B68-516F-4D74-897F-56D12894946C} = {45B05B68-516F-4D74-897F-56D12894946C}
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Azure.Commands.Compute.Test", "Microsoft.Azure.Commands.Compute.Test\Microsoft.Azure.Commands.Compute.Test.xproj", "{13C34370-51A4-4726-81B8-BE0996FC9CFF}"
ProjectSection(ProjectDependencies) = postProject
{3910613E-4ED2-49E2-8CCF-966D586665AC} = {3910613E-4ED2-49E2-8CCF-966D586665AC}
{81A48E48-89A7-4B93-8207-4F8FA6DC251B} = {81A48E48-89A7-4B93-8207-4F8FA6DC251B}
{A9CC2879-D45D-4DCB-A405-6EEDB749B15F} = {A9CC2879-D45D-4DCB-A405-6EEDB749B15F}
{04F9968A-5662-4508-BEE2-31F56848FCBA} = {04F9968A-5662-4508-BEE2-31F56848FCBA}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -117,6 +133,14 @@ Global
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Release|Any CPU.Build.0 = Release|Any CPU
{04F9968A-5662-4508-BEE2-31F56848FCBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{04F9968A-5662-4508-BEE2-31F56848FCBA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04F9968A-5662-4508-BEE2-31F56848FCBA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04F9968A-5662-4508-BEE2-31F56848FCBA}.Release|Any CPU.Build.0 = Release|Any CPU
{13C34370-51A4-4726-81B8-BE0996FC9CFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{13C34370-51A4-4726-81B8-BE0996FC9CFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{13C34370-51A4-4726-81B8-BE0996FC9CFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{13C34370-51A4-4726-81B8-BE0996FC9CFF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,11 @@ public static void SetCommandRuntimeMock(this PSCmdlet cmdlet, ICommandRuntime v
var property = GetInternalProperty("CommandRuntime", typeof (ICommandRuntime));
property.SetValue(cmdlet, value);
}

public static ICommandRuntime GetCommandRuntimeMock(this PSCmdlet cmdlet)
{
var property = GetInternalProperty("CommandRuntime", typeof(ICommandRuntime));
return (ICommandRuntime)property.GetValue(cmdlet);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
// ----------------------------------------------------------------------------------
//
// 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.Compute;
using Microsoft.Azure.Commands.ScenarioTest;
using Microsoft.Azure.Commands.Compute.ScenarioTest;
using Microsoft.Azure.Management.Authorization;
using Microsoft.Azure.Management.Compute;
using Microsoft.Azure.Management.Compute.Models;
using Microsoft.Rest.Azure;
using Moq;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
using Microsoft.Azure.Commands.Common.Test.Mocks;
using Microsoft.Azure.Commands.Common.Authentication.Models;
using Microsoft.Azure.Commands.Utilities.Common;

namespace Microsoft.Azure.Commands.Compute.Test
{
public class GetAzureVMSizeCommandTests
{
private MemoryDataStore _dataStore;
private MockCommandRuntime _commandRuntimeMock;

private Mock<IVirtualMachineSizesOperations> vmSizesMock;

public GetAzureVMSizeCommandTests()
{
_dataStore = new MemoryDataStore();
_commandRuntimeMock = new MockCommandRuntime();
}
private IPage<T> GetPagableType<T>(List<T> collection)
{
var pagableResult = new Page<T>();
pagableResult.SetItemValue<T>(collection);
return pagableResult;
}

private void SetupListForVirtualMachineSizeAsync(string name, List<VirtualMachineSize> result)
{
vmSizesMock.Setup(f => f.ListWithHttpMessagesAsync(name, null, new CancellationToken()))
.Returns(Task.Factory.StartNew(() =>
new AzureOperationResponse<IPage<VirtualMachineSize>>
{
Body = GetPagableType(result)
}));
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void GetVirtualMachineSizesFromLocation()
{
var computeManagementClientMock = new Mock<IComputeManagementClient>();
vmSizesMock = new Mock<IVirtualMachineSizesOperations>();
computeManagementClientMock.Setup(f => f.VirtualMachineSizes).Returns(vmSizesMock.Object);
var vmSizeList = new List<VirtualMachineSize>
{
new VirtualMachineSize
{
Name = "1",
MaxDataDiskCount = 1,
MemoryInMB = 1,
NumberOfCores = 1,
OsDiskSizeInMB = 1,
ResourceDiskSizeInMB = 1
},
new VirtualMachineSize
{
Name = "2",
MaxDataDiskCount = 2,
MemoryInMB = 2,
NumberOfCores = 2,
OsDiskSizeInMB = 2,
ResourceDiskSizeInMB = 2
}
};
SetupListForVirtualMachineSizeAsync("westus", vmSizeList);

var progressLoggerMock = new Mock<Action<string>>();
var errorLoggerMock = new Mock<Action<string>>();
var computeClient = new ComputeClient(computeManagementClientMock.Object)
{
VerboseLogger = progressLoggerMock.Object,
ErrorLogger = errorLoggerMock.Object
};

var profile = new AzureRMProfile(_dataStore);
profile.Environments.Add("foo", AzureEnvironment.PublicEnvironments.Values.FirstOrDefault());
profile.Context = new AzureContext(new AzureSubscription(), new AzureAccount(), profile.Environments["foo"]);
GetAzureVMSizeCommand cmdlet = new GetAzureVMSizeCommand
{
ComputeClient = computeClient,
Location = "westus"
};
cmdlet.DataStore = _dataStore;
cmdlet.SetCommandRuntimeMock(_commandRuntimeMock);
cmdlet.DefaultProfile = profile;

// Act
cmdlet.InvokeBeginProcessing();
cmdlet.ExecuteCmdlet();
cmdlet.InvokeEndProcessing();

var runtime = cmdlet.GetCommandRuntimeMock() as MockCommandRuntime;
Assert.True(runtime.OutputPipeline.Count == vmSizeList.Count);
for (int i = 0; i < runtime.OutputPipeline.Count; i++)
{
var item = runtime.OutputPipeline[i] as VirtualMachineSize;
Assert.True(item.Name == vmSizeList[i].Name);
Assert.True(item.MaxDataDiskCount == vmSizeList[i].MaxDataDiskCount);
Assert.True(item.MemoryInMB == vmSizeList[i].MemoryInMB);
Assert.True(item.NumberOfCores == vmSizeList[i].NumberOfCores);
Assert.True(item.OsDiskSizeInMB == vmSizeList[i].OsDiskSizeInMB);
Assert.True(item.ResourceDiskSizeInMB == vmSizeList[i].ResourceDiskSizeInMB);
}

return;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0.23107" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.23107</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>13c34370-51a4-4726-81b8-be0996fc9cff</ProjectGuid>
<RootNamespace>Microsoft.Azure.Commands.Compute.Test</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
28 changes: 28 additions & 0 deletions src/CLU/Microsoft.Azure.Commands.Compute.Test/PageExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// ----------------------------------------------------------------------------------
//
// 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.Management.Compute.Models;
using System.Collections.Generic;
using System.Reflection;

namespace Microsoft.Azure.Commands.Compute.ScenarioTest
{
public static class PageExtensions
{
public static void SetItemValue<T> (this Page<T> pagableObj, List<T> collection) {
var property = typeof(Page<T>).GetProperty("Items", BindingFlags.Instance | BindingFlags.NonPublic);
property.SetValue(pagableObj, collection);
}
}
}
73 changes: 73 additions & 0 deletions src/CLU/Microsoft.Azure.Commands.Compute.Test/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"version": "1.0.0-*",
"description": "Tests for Compute Resource Provider Cmdlets",
"authors": [ "huangpf", "markcowl", "hovsepm" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"frameworks": {
"dnxcore50": {
"dependencies": {
"Microsoft.NETCore": "5.0.1-beta-23516",
"Microsoft.NETCore.Platforms": "1.0.1-beta-23516",
"Microsoft.CSharp": "4.0.1-beta-23516"
}
}
},
"dependencies": {
"AutoMapper": "4.1.1",
"Commands.Common": "",
"Commands.Common.Authentication": "",
"Commands.Common.Storage": "",
"Commands.ResourceManager.Common": "",
"Commands.ResourceManager.Cmdlets": "",
"Commands.ScenarioTests.ResourceManager.Common": "",
"Microsoft.Azure.Commands.Profile": "",
"Microsoft.Azure.Commands.Resources": "",
"Microsoft.Azure.Management.Compute": "11.0.0-prerelease",
"Microsoft.Azure.Management.Network": "3.0.3-preview",
"Microsoft.Azure.Management.Storage": "4.0.0-preview",
"Microsoft.IdentityModel.Clients.ActiveDirectory": "3.6.212041202-alpha",
"Microsoft.Rest.ClientRuntime": "1.8.0",
"Newtonsoft.Json": "7.0.1",
"System.Collections": "4.0.11-beta-23516",
"System.Collections.Concurrent": "4.0.11-beta-23516",
"System.Diagnostics.Tools": "4.0.1-beta-23516",
"System.Diagnostics.TraceSource": "4.0.0-beta-23516",
"System.Diagnostics.Tracing": "4.0.21-beta-23516",
"System.IO": "4.0.11-beta-23516",
"System.IO.FileSystem": "4.0.1-beta-23516",
"System.Net.Http": "4.0.1-beta-23516",
"System.Net.WebHeaderCollection": "4.0.1-beta-23516",
"System.Reflection": "4.1.0-beta-23516",
"System.Reflection.Extensions": "4.0.1-beta-23516",
"System.Reflection.Primitives": "4.0.1-beta-23516",
"System.Reflection.TypeExtensions": "4.1.0-beta-23516",
"System.Runtime": "4.0.21-beta-23516",
"System.Runtime.Extensions": "4.0.11-beta-23516",
"System.Runtime.Serialization.Json": "4.0.1-beta-23516",
"System.Runtime.Serialization.Primitives": "4.1.0-beta-23516",
"System.Runtime.Serialization.Xml": "4.1.0-beta-23516",
"System.Security.Cryptography.Algorithms": "4.0.0-beta-23516",
"System.Security.Cryptography.X509Certificates": "4.0.0-beta-23516",
"System.Text.Encoding": "4.0.11-beta-23516",
"System.Text.Encoding.Extensions": "4.0.11-beta-23516",
"System.Threading": "4.0.11-beta-23516",
"System.Threading.Tasks": "4.0.11-beta-23516",
"System.Threading.Thread": "4.0.0-beta-23516",
"System.Xml.ReaderWriter": "4.0.11-beta-23516",
"xunit": "2.1.0",
"xunit.assert": "2.1.0",
"xunit.runner.dnx": "2.1.0-rc1-build204",
"moq.netcore": "4.4.0-beta8",
"Microsoft.CLU": "1.0.0",
"System.Linq": "4.0.1-beta-23409",
"System.Xml.XmlDocument": "4.0.1-beta-23516",
"System.Xml.XPath.XmlDocument": "4.0.1-beta-23516",
"WindowsAzure.Storage": "6.1.1-preview",
"Microsoft.Azure.Commands.Compute": "1.0.0-*"
},
"commands": {
"test": "xunit.runner.dnx"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// ----------------------------------------------------------------------------------
//
// 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.Management.Compute;

namespace Microsoft.Azure.Commands.Compute
{
public abstract class AvailabilitySetBaseCmdlet : ComputeClientBaseCmdlet
{
public IAvailabilitySetsOperations AvailabilitySetClient
{
get
{
return ComputeClient.ComputeManagementClient.AvailabilitySets;
}
}
}
}
Loading