Skip to content

Commit db1f851

Browse files
New-AzureVm SimpleParameterSet, Strategies
1 parent 339519b commit db1f851

File tree

81 files changed

+3583
-125
lines changed

Some content is hidden

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

81 files changed

+3583
-125
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,4 +211,5 @@ FakesAssemblies/
211211
/tools/*.dll
212212
*.GhostDoc.xml
213213
pingme.txt
214-
groupMapping*.json
214+
groupMapping*.json
215+
.vscode/

setup/azurecmdfiles.wxi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@
271271
<Component Id="cmp4677B0CE124023330EDD7AA4FECFF45E" Guid="*">
272272
<File Id="fil58F144170E43C2EFEC66E5F3DE2FA977" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.Compute\AzureRM.Compute.psm1" />
273273
</Component>
274+
<Component Id="cmp32CF42EA1F0A7DA716459A5A6A21C24D" Guid="*">
275+
<File Id="fil5AE28BCCEED67270ECF02C93C9688AD5" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.Compute\Microsoft.Azure.Commands.Common.Strategies.dll" />
276+
</Component>
274277
<Component Id="cmpFBB75A5451448B356C97E62D2C6C10A0" Guid="*">
275278
<File Id="fil24BE7D514EE83ED7D31C68CBFFA8FBB8" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.Compute\Microsoft.Azure.Commands.Compute.dll" />
276279
</Component>
@@ -3148,6 +3151,7 @@
31483151
<ComponentRef Id="cmpD2516E302D41812368A84BD6010FB066" />
31493152
<ComponentRef Id="cmp594709EB2E69BD7173BC8833BE2061B4" />
31503153
<ComponentRef Id="cmp4677B0CE124023330EDD7AA4FECFF45E" />
3154+
<ComponentRef Id="cmp32CF42EA1F0A7DA716459A5A6A21C24D" />
31513155
<ComponentRef Id="cmpFBB75A5451448B356C97E62D2C6C10A0" />
31523156
<ComponentRef Id="cmp1CB1E6D6A2D939FB32D9ACD70681644D" />
31533157
<ComponentRef Id="cmpAA00FCFEE63D9A20C2618B36B1848D7C" />

src/Common/Commands.Common/AzureLongRunningJob.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,13 @@ public static U CopyCmdlet<U>(U cmdlet) where U : AzurePSCmdlet
191191
returnValue.MyInvocation.BoundParameters.Add(parameter.Key, parameter.Value);
192192
}
193193

194-
foreach (var field in returnType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly))
194+
195+
foreach (var field in returnType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
195196
{
196197
field.SafeCopyValue(source: cmdlet, target: returnValue);
197198
}
198199

200+
cmdlet.SafeCopyParameterSet(returnValue);
199201
return returnValue as U;
200202
}
201203

@@ -829,6 +831,9 @@ private bool InvokeShouldMethodAndWaitForResults(Func<Cmdlet, bool> shouldMethod
829831
}
830832
}
831833

834+
/// <summary>
835+
/// Stop job execution
836+
/// </summary>
832837
public override void StopJob()
833838
{
834839
ShouldMethodStreamItem stream;

src/Common/Commands.Common/Extensions/CmdletExtensions.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,30 @@ public static void SafeCopyValue<T>(this FieldInfo field, T source, T target)
178178
}
179179
}
180180

181+
/// <summary>
182+
/// Safely copy the selected parameter set from one cmdlet to another
183+
/// </summary>
184+
/// <typeparam name="T">The cmdlet type</typeparam>
185+
/// <param name="source">The cmdlet to copy the parameter set name from</param>
186+
/// <param name="target">The cmdlet to copy to</param>
187+
public static void SafeCopyParameterSet<T>(this T source, T target) where T: AzurePSCmdlet
188+
{
189+
if (source != null && target != null)
190+
{
191+
if (!string.IsNullOrWhiteSpace(source.ParameterSetName))
192+
{
193+
try
194+
{
195+
target.SetParameterSet(source.ParameterSetName);
196+
}
197+
catch
198+
{
199+
200+
}
201+
}
202+
}
203+
}
204+
181205
public static string AsAbsoluteLocation(this string realtivePath)
182206
{
183207
return Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, realtivePath));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{5C052681-DA3C-4FEA-8E02-7DFBB2A18B22}</ProjectGuid>
7+
<OutputType>Library</OutputType>
8+
<AppDesignerFolder>Properties</AppDesignerFolder>
9+
<RootNamespace>Microsoft.Azure.Commands.Common.Strategies.UnitTest</RootNamespace>
10+
<AssemblyName>Microsoft.Azure.Commands.Common.Strategies.UnitTest</AssemblyName>
11+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
15+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
16+
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
17+
<IsCodedUITest>False</IsCodedUITest>
18+
<TestProjectType>UnitTest</TestProjectType>
19+
</PropertyGroup>
20+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
21+
<DebugSymbols>true</DebugSymbols>
22+
<DebugType>full</DebugType>
23+
<Optimize>false</Optimize>
24+
<OutputPath>bin\Debug\</OutputPath>
25+
<DefineConstants>DEBUG;TRACE</DefineConstants>
26+
<ErrorReport>prompt</ErrorReport>
27+
<WarningLevel>4</WarningLevel>
28+
</PropertyGroup>
29+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
30+
<DebugType>pdbonly</DebugType>
31+
<Optimize>true</Optimize>
32+
<OutputPath>bin\Release\</OutputPath>
33+
<DefineConstants>TRACE</DefineConstants>
34+
<ErrorReport>prompt</ErrorReport>
35+
<WarningLevel>4</WarningLevel>
36+
</PropertyGroup>
37+
<ItemGroup>
38+
<Reference Include="System" />
39+
</ItemGroup>
40+
<Choose>
41+
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
42+
<ItemGroup>
43+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
44+
</ItemGroup>
45+
</When>
46+
<Otherwise>
47+
<ItemGroup>
48+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
49+
</ItemGroup>
50+
</Otherwise>
51+
</Choose>
52+
<ItemGroup>
53+
<Compile Include="TimeSlotTest.cs" />
54+
<Compile Include="Properties\AssemblyInfo.cs" />
55+
</ItemGroup>
56+
<ItemGroup>
57+
<ProjectReference Include="..\Commands.Common.Strategies\Commands.Common.Strategies.csproj">
58+
<Project>{eea69772-d41b-482a-9252-2b4595c59e53}</Project>
59+
<Name>Commands.Common.Strategies</Name>
60+
</ProjectReference>
61+
</ItemGroup>
62+
<Choose>
63+
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
64+
<ItemGroup>
65+
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
66+
<Private>False</Private>
67+
</Reference>
68+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
69+
<Private>False</Private>
70+
</Reference>
71+
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
72+
<Private>False</Private>
73+
</Reference>
74+
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
75+
<Private>False</Private>
76+
</Reference>
77+
</ItemGroup>
78+
</When>
79+
</Choose>
80+
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
81+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
82+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
83+
Other similar extension points exist, see Microsoft.Common.targets.
84+
<Target Name="BeforeBuild">
85+
</Target>
86+
<Target Name="AfterBuild">
87+
</Target>
88+
-->
89+
</Project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("Commands.Common.Strategies.UnitTest")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("Commands.Common.Strategies.UnitTest")]
13+
[assembly: AssemblyCopyright("Copyright © 2017")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("5c052681-da3c-4fea-8e02-7dfbb2a18b22")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
3+
namespace Microsoft.Azure.Commands.Common.Strategies.UnitTest
4+
{
5+
[TestClass]
6+
public class TimeSlotTest
7+
{
8+
[TestMethod]
9+
public void AddTest()
10+
{
11+
var first = new TimeSlot();
12+
13+
Assert.AreEqual(0, first.Duration);
14+
Assert.AreEqual(0, first.TaskCount);
15+
Assert.AreEqual(null, first.Next);
16+
17+
var next = first.AddTask(50);
18+
19+
Assert.AreEqual(50, first.Duration);
20+
Assert.AreEqual(1, first.TaskCount);
21+
Assert.AreEqual(next, first.Next);
22+
23+
Assert.AreEqual(10.0, first.GetTaskProgress(10));
24+
25+
Assert.AreEqual(0, next.Duration);
26+
Assert.AreEqual(0, next.TaskCount);
27+
Assert.AreEqual(null, next.Next);
28+
29+
var next2 = first.AddTask(50);
30+
31+
Assert.AreEqual(50, first.Duration);
32+
Assert.AreEqual(2, first.TaskCount);
33+
Assert.AreEqual(next2, first.Next);
34+
Assert.AreEqual(next, first.Next);
35+
36+
Assert.AreEqual(20.0, first.GetTaskProgress(40));
37+
38+
Assert.AreEqual(0, next2.Duration);
39+
Assert.AreEqual(0, next2.TaskCount);
40+
Assert.AreEqual(null, next2.Next);
41+
42+
var next3 = first.AddTask(30);
43+
Assert.AreEqual(30, first.Duration);
44+
Assert.AreEqual(3, first.TaskCount);
45+
Assert.AreEqual(next3, first.Next);
46+
47+
Assert.AreEqual(3.0, first.GetTaskProgress(9));
48+
49+
Assert.AreEqual(20, next3.Duration);
50+
Assert.AreEqual(2, next3.TaskCount);
51+
Assert.AreEqual(next2, next3.Next);
52+
Assert.AreEqual(next, next3.Next);
53+
54+
Assert.AreEqual(10.0 + 5, first.GetTaskProgress(40));
55+
56+
Assert.AreEqual(0, next2.Duration);
57+
Assert.AreEqual(0, next2.TaskCount);
58+
Assert.AreEqual(null, next2.Next);
59+
60+
var next4 = first.AddTask(75);
61+
Assert.AreEqual(25, next2.Duration);
62+
Assert.AreEqual(1, next2.TaskCount);
63+
Assert.AreEqual(next4, next2.Next);
64+
65+
Assert.AreEqual((30.0 / 4) + (20.0 / 3) + 20, first.GetTaskProgress(70));
66+
67+
Assert.AreEqual(0, next4.Duration);
68+
Assert.AreEqual(0, next4.TaskCount);
69+
Assert.AreEqual(null, next4.Next);
70+
}
71+
}
72+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{EEA69772-D41B-482A-9252-2B4595C59E53}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>Microsoft.Azure.Commands.Common.Strategies</RootNamespace>
11+
<AssemblyName>Microsoft.Azure.Commands.Common.Strategies</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>..\..\..\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.Compute\</OutputPath>
20+
<DefineConstants>TRACE;DEBUG</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
</PropertyGroup>
24+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25+
<DebugType>pdbonly</DebugType>
26+
<Optimize>true</Optimize>
27+
<OutputPath>bin\Release\</OutputPath>
28+
<DefineConstants>TRACE;SIGN</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
<SignAssembly>true</SignAssembly>
32+
<DelaySign>true</DelaySign>
33+
<AssemblyOriginatorKeyFile>MSSharedLibKey.snk</AssemblyOriginatorKeyFile>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
37+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.10\lib\net452\Microsoft.Rest.ClientRuntime.dll</HintPath>
38+
<Private>True</Private>
39+
</Reference>
40+
<Reference Include="Microsoft.Rest.ClientRuntime.Azure, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
41+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.3.3.10\lib\net452\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
42+
<Private>True</Private>
43+
</Reference>
44+
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
45+
<HintPath>..\..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
46+
<Private>True</Private>
47+
</Reference>
48+
<Reference Include="System" />
49+
<Reference Include="System.Core" />
50+
<Reference Include="System.Xml.Linq" />
51+
<Reference Include="System.Data.DataSetExtensions" />
52+
<Reference Include="Microsoft.CSharp" />
53+
<Reference Include="System.Data" />
54+
<Reference Include="System.Net.Http" />
55+
<Reference Include="System.Xml" />
56+
</ItemGroup>
57+
<ItemGroup>
58+
<Compile Include="IReportProgress.cs" />
59+
<Compile Include="IResourceConfig.cs" />
60+
<Compile Include="IResourceConfigVisitor.cs" />
61+
<Compile Include="IResourceStrategy.cs" />
62+
<Compile Include="IShouldProcess.cs" />
63+
<Compile Include="ProgressMap.cs" />
64+
<Compile Include="TimeSlot.cs" />
65+
<Compile Include="StateOperationContext.cs" />
66+
<Compile Include="SyncTaskScheduler.cs" />
67+
<Compile Include="TimeSlotExtensions.cs" />
68+
<Compile Include="UpdateStateExtensions.cs" />
69+
<Compile Include="CreateOrUpdateAsyncParams.cs" />
70+
<Compile Include="EntityConfigExtensions.cs" />
71+
<Compile Include="Extensions.cs" />
72+
<Compile Include="GetStateExtensions.cs" />
73+
<Compile Include="GetAsyncParams.cs" />
74+
<Compile Include="IClient.cs" />
75+
<Compile Include="IEntityConfig.cs" />
76+
<Compile Include="IEntityConfigVisitor.cs" />
77+
<Compile Include="IEntityStrategy.cs" />
78+
<Compile Include="IState.cs" />
79+
<Compile Include="NestedResourceConfigExtensions.cs" />
80+
<Compile Include="ResourceConfigExtensions.cs" />
81+
<Compile Include="StateExtensions.cs" />
82+
<Compile Include="NestedResourceConfig.cs" />
83+
<Compile Include="NestedResourceStrategy.cs" />
84+
<Compile Include="TargetStateExtensions.cs" />
85+
<Compile Include="Properties\AssemblyInfo.cs" />
86+
<Compile Include="ResourceConfig.cs" />
87+
<Compile Include="ResourceStrategy.cs" />
88+
<Compile Include="State.cs" />
89+
<Compile Include="LocationExtensions.cs" />
90+
<Compile Include="Void.cs" />
91+
</ItemGroup>
92+
<ItemGroup>
93+
<None Include="MSSharedLibKey.snk" />
94+
<None Include="packages.config" />
95+
</ItemGroup>
96+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
97+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
98+
Other similar extension points exist, see Microsoft.Common.targets.
99+
<Target Name="BeforeBuild">
100+
</Target>
101+
<Target Name="AfterBuild">
102+
</Target>
103+
-->
104+
</Project>

0 commit comments

Comments
 (0)