Skip to content

Commit c9081c3

Browse files
committed
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
2 parents 62f6e6b + 01b2fcb commit c9081c3

File tree

391 files changed

+90301
-31282
lines changed

Some content is hidden

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

391 files changed

+90301
-31282
lines changed

ChangeLog.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2015.08.07 version 0.9.6
2+
* Azure Batch cmdlets
3+
* Cmdlets updated to use the general availability API. See http://blogs.technet.com/b/windowshpc/archive/2015/07/10/what-39-s-new-in-azure-batch-july-release-general-availability.aspx
4+
* Breaking changes to cmdlets resulting from API update:
5+
* Workitems have been removed.
6+
* If you were adding all tasks to a single job, use the New-AzureBatchJob cmdlet to directly create your job.
7+
* If you were managing workitems with a recurring schedule defined, use the AzureBatchJobSchedule cmdlets instead.
8+
* If you were using the AzureBatchVM cmdlets, use the AzureBatchComputeNode cmdlets instead.
9+
* The AzureBatchTaskFile and AzureBatchVMFile cmdlets have been consolidated into the AzureBatchNodeFile cmdlets.
10+
* The Name property on most entities has been replaced by an Id property.
11+
112
2015.07.17 version 0.9.5
213
* Azure SQL cmdlets
314
* Allowing to use of Storage V2 accounts in Auditing policies

setup/azurecmdfiles.wxi

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

src/Common/Commands.Common/Commands.Common.csproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,16 @@
103103
<SpecificVersion>False</SpecificVersion>
104104
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
105105
</Reference>
106+
<Reference Include="Microsoft.WindowsAzure.Storage">
107+
<HintPath>..\..\packages\WindowsAzure.Storage.4.0.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
108+
</Reference>
106109
<Reference Include="Newtonsoft.Json">
107110
<HintPath>..\..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
108111
<Private>True</Private>
109112
</Reference>
110113
<Reference Include="System" />
111114
<Reference Include="System.Core" />
115+
<Reference Include="System.IO.Compression.FileSystem" />
112116
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
113117
<Reference Include="System.Net" />
114118
<Reference Include="System.Net.Http" />
@@ -145,6 +149,14 @@
145149
<Compile Include="AzurePowerShell.cs" />
146150
<Compile Include="ComputeCloudException.cs" />
147151
<Compile Include="Constants.cs" />
152+
<Compile Include="Extensions\DSC\DscExtensionCmdletConstants.cs" />
153+
<Compile Include="Extensions\DSC\DscExtensionPrivateSettings.cs" />
154+
<Compile Include="Extensions\DSC\DscExtensionPublicSettings.cs" />
155+
<Compile Include="Extensions\DSC\DscExtensionSettingsSerializer.cs" />
156+
<Compile Include="Extensions\DSC\Exceptions\GetDscResourceException.cs" />
157+
<Compile Include="Extensions\DSC\Publish\ConfigurationParseResult.cs" />
158+
<Compile Include="Extensions\DSC\Publish\ConfigurationParsingHelper.cs" />
159+
<Compile Include="Extensions\DSC\Publish\DscExtensionPublishCmdletCommonBase.cs" />
148160
<Compile Include="SecureStringExtensions.cs" />
149161
<Compile Include="ConversionUtilities.cs" />
150162
<Compile Include="DebugStreamTraceListener.cs" />
@@ -159,6 +171,7 @@
159171
<Compile Include="AzurePSCmdlet.cs" />
160172
<Compile Include="CmdletExtensions.cs" />
161173
<Compile Include="ConfigurationConstants.cs" />
174+
<Compile Include="DiagnosticsHelper.cs" />
162175
<Compile Include="ErrorHelper.cs" />
163176
<Compile Include="IdnHelper.cs" />
164177
<Compile Include="ManagementOperationContext.cs" />
@@ -182,13 +195,15 @@
182195
<EmbeddedResource Include="Properties\Resources.resx">
183196
<Generator>PublicResXFileCodeGenerator</Generator>
184197
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
198+
<SubType>Designer</SubType>
185199
</EmbeddedResource>
186200
</ItemGroup>
187201
<ItemGroup>
188202
<None Include="packages.config">
189203
<SubType>Designer</SubType>
190204
</None>
191205
</ItemGroup>
206+
<ItemGroup />
192207
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
193208
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
194209
<Import Project="..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.WindowsAzure.Commands.Common.Properties;
16+
using System;
17+
using System.Collections;
18+
using System.IO;
19+
using System.Linq;
20+
using System.Text;
21+
using System.Xml;
22+
using Newtonsoft.Json;
23+
24+
namespace Microsoft.WindowsAzure.Commands.Utilities.Common
25+
{
26+
public static class DiagnosticsHelper
27+
{
28+
private static string XmlNamespace = "http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration";
29+
private static string EncodedXmlCfg = "xmlCfg";
30+
private static string StorageAccount = "storageAccount";
31+
private static string Path = "path";
32+
private static string ExpandResourceDirectory = "expandResourceDirectory";
33+
private static string LocalResourceDirectory = "localResourceDirectory";
34+
private static string StorageAccountNameTag = "storageAccountName";
35+
private static string StorageAccountKeyTag = "storageAccountKey";
36+
private static string StorageAccountEndPointTag = "storageAccountEndPoint";
37+
38+
public static string GetJsonSerializedPublicDiagnosticsConfigurationFromFile(string configurationPath,
39+
string storageAccountName)
40+
{
41+
return
42+
JsonConvert.SerializeObject(
43+
DiagnosticsHelper.GetPublicDiagnosticsConfigurationFromFile(configurationPath, storageAccountName));
44+
}
45+
46+
public static Hashtable GetPublicDiagnosticsConfigurationFromFile(string configurationPath, string storageAccountName)
47+
{
48+
using (StreamReader reader = new StreamReader(configurationPath))
49+
{
50+
return GetPublicDiagnosticsConfiguration(reader.ReadToEnd(), storageAccountName);
51+
}
52+
}
53+
54+
public static Hashtable GetPublicDiagnosticsConfiguration(string config, string storageAccountName)
55+
{
56+
// find the <WadCfg> element and extract it
57+
int wadCfgBeginIndex = config.IndexOf("<WadCfg>");
58+
if (wadCfgBeginIndex == -1)
59+
{
60+
throw new ArgumentException(Resources.IaasDiagnosticsBadConfigNoWadCfg);
61+
}
62+
63+
int wadCfgEndIndex = config.IndexOf("</WadCfg>");
64+
if (wadCfgEndIndex == -1)
65+
{
66+
throw new ArgumentException(Resources.IaasDiagnosticsBadConfigNoEndWadCfg);
67+
}
68+
69+
if (wadCfgEndIndex <= wadCfgBeginIndex)
70+
{
71+
throw new ArgumentException(Resources.IaasDiagnosticsBadConfigNoMatchingWadCfg);
72+
}
73+
74+
string encodedConfiguration = Convert.ToBase64String(
75+
Encoding.UTF8.GetBytes(
76+
config.Substring(
77+
wadCfgBeginIndex, wadCfgEndIndex + "</WadCfg>".Length - wadCfgBeginIndex).ToCharArray()));
78+
79+
// Now extract the local resource directory element
80+
XmlDocument doc = new XmlDocument();
81+
XmlNamespaceManager ns = new XmlNamespaceManager(doc.NameTable);
82+
ns.AddNamespace("ns", XmlNamespace);
83+
doc.LoadXml(config);
84+
var node = doc.SelectSingleNode("//ns:LocalResourceDirectory", ns);
85+
string localDirectory = (node != null && node.Attributes != null) ? node.Attributes[Path].Value : null;
86+
string localDirectoryExpand = (node != null && node.Attributes != null)
87+
? node.Attributes["expandEnvironment"].Value
88+
: null;
89+
if (localDirectoryExpand == "0")
90+
{
91+
localDirectoryExpand = "false";
92+
}
93+
if (localDirectoryExpand == "1")
94+
{
95+
localDirectoryExpand = "true";
96+
}
97+
98+
var hashTable = new Hashtable();
99+
hashTable.Add(EncodedXmlCfg, encodedConfiguration);
100+
hashTable.Add(StorageAccount, storageAccountName);
101+
if (!string.IsNullOrEmpty(localDirectory))
102+
{
103+
var localDirectoryHashTable = new Hashtable();
104+
localDirectoryHashTable.Add(Path, localDirectory);
105+
localDirectoryHashTable.Add(ExpandResourceDirectory, localDirectoryExpand);
106+
hashTable.Add(LocalResourceDirectory, localDirectoryHashTable);
107+
}
108+
109+
return hashTable;
110+
}
111+
112+
public static string GetJsonSerializedPrivateDiagnosticsConfiguration(string storageAccountName,
113+
string storageKey, string endpoint)
114+
{
115+
return JsonConvert.SerializeObject(GetPrivateDiagnosticsConfiguration( storageAccountName, storageKey, endpoint));
116+
}
117+
118+
public static Hashtable GetPrivateDiagnosticsConfiguration(string storageAccountName, string storageKey, string endpoint)
119+
{
120+
var hashTable = new Hashtable();
121+
hashTable.Add(StorageAccountNameTag, storageAccountName);
122+
hashTable.Add(StorageAccountKeyTag, storageKey);
123+
hashTable.Add(StorageAccountEndPointTag, endpoint);
124+
return hashTable;
125+
}
126+
}
127+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace Microsoft.WindowsAzure.Commands.Common.Extensions.DSC
5+
{
6+
public static class DscExtensionCmdletConstants
7+
{
8+
//common extension constants
9+
internal static readonly string ExtensionPublishedNamespace = "Microsoft.Powershell";
10+
internal static readonly string ExtensionPublishedName = "DSC";
11+
internal const string DefaultContainerName = "windows-powershell-dsc";
12+
13+
internal const int MinMajorPowerShellVersion = 4;
14+
internal const string ZipFileExtension = ".zip";
15+
internal const string Ps1FileExtension = ".ps1";
16+
internal const string Psm1FileExtension = ".psm1";
17+
18+
19+
internal static readonly HashSet<String> UploadArchiveAllowedFileExtensions =
20+
new HashSet<String>(StringComparer.OrdinalIgnoreCase) { Ps1FileExtension, Psm1FileExtension, ZipFileExtension };
21+
internal static readonly HashSet<String> CreateArchiveAllowedFileExtensions =
22+
new HashSet<String>(StringComparer.OrdinalIgnoreCase) { Ps1FileExtension, Psm1FileExtension };
23+
}
24+
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
namespace Microsoft.Azure.Commands.Compute.Extension.DSC
15+
namespace Microsoft.WindowsAzure.Commands.Common.Extensions.DSC
1616
{
17-
1817
using System.Collections;
1918

2019
/// <summary>
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
using System.Collections;
1717
using System.Collections.Generic;
1818

19-
namespace Microsoft.Azure.Commands.Compute.Extension.DSC
19+
namespace Microsoft.WindowsAzure.Commands.Common.Extensions.DSC
2020
{
2121
/// <summary>
2222
/// Represents public settings. Serialized representation of this object stored as a plain text string on the VM.
@@ -40,21 +40,21 @@ internal class Version1
4040
/// <returns></returns>
4141
public DscExtensionPublicSettings ToCurrentVersion()
4242
{
43-
List<Property> properties = new List<Property>();
44-
foreach (DictionaryEntry p in this.Properties)
43+
var properties = new List<Property>();
44+
foreach (DictionaryEntry p in Properties)
4545
{
46-
properties.Add(new Property()
46+
properties.Add(new Property
4747
{
4848
Name = p.Key.ToString(),
4949
TypeName = p.Value.GetType().ToString(),
5050
Value = p.Value
5151
});
5252
}
53-
return new DscExtensionPublicSettings()
53+
return new DscExtensionPublicSettings
5454
{
55-
SasToken = this.SasToken,
56-
ModulesUrl = this.ModulesUrl,
57-
ConfigurationFunction = this.ConfigurationFunction,
55+
SasToken = SasToken,
56+
ModulesUrl = ModulesUrl,
57+
ConfigurationFunction = ConfigurationFunction,
5858
Properties = properties.ToArray(),
5959
ProtocolVersion = new Version(1, 0, 0, 0)
6060
};

src/ResourceManager/Compute/Commands.Compute/Extension/DSC/DscSettingsSerializer.cs renamed to src/Common/Commands.Common/Extensions/DSC/DscExtensionSettingsSerializer.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,27 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
15+
using Newtonsoft.Json;
1616
using System;
1717
using System.Collections;
1818
using System.Collections.Generic;
1919
using System.Globalization;
2020
using System.Management.Automation;
2121
using System.Runtime.InteropServices;
2222
using System.Security;
23-
using Newtonsoft.Json;
2423

25-
namespace Microsoft.Azure.Commands.Compute.Extension.DSC
24+
namespace Microsoft.WindowsAzure.Commands.Common.Extensions.DSC
2625
{
27-
public class DscSettingsSerializer
26+
public class DscExtensionSettingsSerializer
2827
{
2928
/// <summary>
30-
/// Serialize DscPublicSettings to string.
29+
/// Serialize DscExtensionPublicSettings to string.
3130
/// </summary>
32-
/// <param name="publicSettings"></param>
31+
/// <param name="extensionPublicSettings"></param>
3332
/// <returns></returns>
34-
public static string SerializePublicSettings(DscExtensionPublicSettings publicSettings)
33+
public static string SerializePublicSettings(DscExtensionPublicSettings extensionPublicSettings)
3534
{
36-
return JsonConvert.SerializeObject(publicSettings);
35+
return JsonConvert.SerializeObject(extensionPublicSettings);
3736
}
3837

3938
/// <summary>
@@ -48,10 +47,10 @@ public static string SerializePrivateSettings(DscExtensionPrivateSettings privat
4847

4948
public static DscExtensionPublicSettings DeserializePublicSettings(string publicSettingsString)
5049
{
51-
DscExtensionPublicSettings publicSettings;
50+
DscExtensionPublicSettings extensionPublicSettings;
5251
try
5352
{
54-
publicSettings = string.IsNullOrEmpty(publicSettingsString)
53+
extensionPublicSettings = string.IsNullOrEmpty(publicSettingsString)
5554
? null
5655
: JsonConvert.DeserializeObject<DscExtensionPublicSettings>(publicSettingsString);
5756
}
@@ -62,14 +61,14 @@ public static DscExtensionPublicSettings DeserializePublicSettings(string public
6261
{
6362
DscExtensionPublicSettings.Version1 publicSettingsV1 =
6463
JsonConvert.DeserializeObject<DscExtensionPublicSettings.Version1>(publicSettingsString);
65-
publicSettings = publicSettingsV1.ToCurrentVersion();
64+
extensionPublicSettings = publicSettingsV1.ToCurrentVersion();
6665
}
6766
catch (JsonException)
6867
{
6968
throw;
7069
}
7170
}
72-
return publicSettings;
71+
return extensionPublicSettings;
7372
}
7473

7574
/// <summary>

src/ResourceManager/Compute/Commands.Compute/Extension/DSC/GetDscResourceException.cs renamed to src/Common/Commands.Common/Extensions/DSC/Exceptions/GetDscResourceException.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
using System;
1616
using System.Globalization;
1717

18-
namespace Microsoft.Azure.Commands.Compute.Extension.DSC
18+
19+
namespace Microsoft.WindowsAzure.Commands.Common.Extensions.DSC.Exceptions
1920
{
2021
[Serializable]
2122
public class GetDscResourceException : UnauthorizedAccessException

src/ResourceManager/Compute/Commands.Compute/Extension/DSC/ConfigurationParseResult.cs renamed to src/Common/Commands.Common/Extensions/DSC/Publish/ConfigurationParseResult.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,16 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System;
1615
using System.Collections.Generic;
1716
using System.Management.Automation.Language;
1817

19-
namespace Microsoft.Azure.Commands.Compute.Extension.DSC
18+
namespace Microsoft.WindowsAzure.Commands.Common.Extensions.DSC.Publish
2019
{
2120
public class ConfigurationParseResult
2221
{
2322
public string Path { get; set; }
2423
public ParseError[] Errors { get; set; }
25-
public List<String> RequiredModules { get; set; }
24+
public Dictionary<string,string> RequiredModules { get; set; }
2625

2726
}
2827
}

0 commit comments

Comments
 (0)