Skip to content

. #60

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 14 commits into from
Aug 1, 2015
Merged

. #60

Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2015.08.07 version 0.9.6
* Azure Batch cmdlets
* 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
* Breaking changes to cmdlets resulting from API update:
* Workitems have been removed.
* If you were adding all tasks to a single job, use the New-AzureBatchJob cmdlet to directly create your job.
* If you were managing workitems with a recurring schedule defined, use the AzureBatchJobSchedule cmdlets instead.
* If you were using the AzureBatchVM cmdlets, use the AzureBatchComputeNode cmdlets instead.
* The AzureBatchTaskFile and AzureBatchVMFile cmdlets have been consolidated into the AzureBatchNodeFile cmdlets.
* The Name property on most entities has been replaced by an Id property.

2015.07.17 version 0.9.5
* Azure SQL cmdlets
* Allowing to use of Storage V2 accounts in Auditing policies
Expand Down
84 changes: 84 additions & 0 deletions setup/azurecmdfiles.wxi

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Common/Commands.Common/Commands.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
<Compile Include="AzurePSCmdlet.cs" />
<Compile Include="CmdletExtensions.cs" />
<Compile Include="ConfigurationConstants.cs" />
<Compile Include="DiagnosticsHelper.cs" />
<Compile Include="ErrorHelper.cs" />
<Compile Include="IdnHelper.cs" />
<Compile Include="ManagementOperationContext.cs" />
Expand Down
127 changes: 127 additions & 0 deletions src/Common/Commands.Common/DiagnosticsHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
// ----------------------------------------------------------------------------------
//
// 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.WindowsAzure.Commands.Common.Properties;
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using Newtonsoft.Json;

namespace Microsoft.WindowsAzure.Commands.Utilities.Common
{
public static class DiagnosticsHelper
{
private static string XmlNamespace = "http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration";
private static string EncodedXmlCfg = "xmlCfg";
private static string StorageAccount = "storageAccount";
private static string Path = "path";
private static string ExpandResourceDirectory = "expandResourceDirectory";
private static string LocalResourceDirectory = "localResourceDirectory";
private static string StorageAccountNameTag = "storageAccountName";
private static string StorageAccountKeyTag = "storageAccountKey";
private static string StorageAccountEndPointTag = "storageAccountEndPoint";

public static string GetJsonSerializedPublicDiagnosticsConfigurationFromFile(string configurationPath,
string storageAccountName)
{
return
JsonConvert.SerializeObject(
DiagnosticsHelper.GetPublicDiagnosticsConfigurationFromFile(configurationPath, storageAccountName));
}

public static Hashtable GetPublicDiagnosticsConfigurationFromFile(string configurationPath, string storageAccountName)
{
using (StreamReader reader = new StreamReader(configurationPath))
{
return GetPublicDiagnosticsConfiguration(reader.ReadToEnd(), storageAccountName);
}
}

public static Hashtable GetPublicDiagnosticsConfiguration(string config, string storageAccountName)
{
// find the <WadCfg> element and extract it
int wadCfgBeginIndex = config.IndexOf("<WadCfg>");
if (wadCfgBeginIndex == -1)
{
throw new ArgumentException(Resources.IaasDiagnosticsBadConfigNoWadCfg);
}

int wadCfgEndIndex = config.IndexOf("</WadCfg>");
if (wadCfgEndIndex == -1)
{
throw new ArgumentException(Resources.IaasDiagnosticsBadConfigNoEndWadCfg);
}

if (wadCfgEndIndex <= wadCfgBeginIndex)
{
throw new ArgumentException(Resources.IaasDiagnosticsBadConfigNoMatchingWadCfg);
}

string encodedConfiguration = Convert.ToBase64String(
Encoding.UTF8.GetBytes(
config.Substring(
wadCfgBeginIndex, wadCfgEndIndex + "</WadCfg>".Length - wadCfgBeginIndex).ToCharArray()));

// Now extract the local resource directory element
XmlDocument doc = new XmlDocument();
XmlNamespaceManager ns = new XmlNamespaceManager(doc.NameTable);
ns.AddNamespace("ns", XmlNamespace);
doc.LoadXml(config);
var node = doc.SelectSingleNode("//ns:LocalResourceDirectory", ns);
string localDirectory = (node != null && node.Attributes != null) ? node.Attributes[Path].Value : null;
string localDirectoryExpand = (node != null && node.Attributes != null)
? node.Attributes["expandEnvironment"].Value
: null;
if (localDirectoryExpand == "0")
{
localDirectoryExpand = "false";
}
if (localDirectoryExpand == "1")
{
localDirectoryExpand = "true";
}

var hashTable = new Hashtable();
hashTable.Add(EncodedXmlCfg, encodedConfiguration);
hashTable.Add(StorageAccount, storageAccountName);
if (!string.IsNullOrEmpty(localDirectory))
{
var localDirectoryHashTable = new Hashtable();
localDirectoryHashTable.Add(Path, localDirectory);
localDirectoryHashTable.Add(ExpandResourceDirectory, localDirectoryExpand);
hashTable.Add(LocalResourceDirectory, localDirectoryHashTable);
}

return hashTable;
}

public static string GetJsonSerializedPrivateDiagnosticsConfiguration(string storageAccountName,
string storageKey, string endpoint)
{
return JsonConvert.SerializeObject(GetPrivateDiagnosticsConfiguration( storageAccountName, storageKey, endpoint));
}

public static Hashtable GetPrivateDiagnosticsConfiguration(string storageAccountName, string storageKey, string endpoint)
{
var hashTable = new Hashtable();
hashTable.Add(StorageAccountNameTag, storageAccountName);
hashTable.Add(StorageAccountKeyTag, storageKey);
hashTable.Add(StorageAccountEndPointTag, endpoint);
return hashTable;
}
}
}
27 changes: 27 additions & 0 deletions src/Common/Commands.Common/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/Common/Commands.Common/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1443,4 +1443,13 @@ The file needs to be a PowerShell script (.ps1 or .psm1).</value>
<value>Cannot delete '{0}': {1}</value>
<comment>{0} is the path of a file, {1} is an error message</comment>
</data>
<data name="IaasDiagnosticsBadConfigNoEndWadCfg" xml:space="preserve">
<value>Cannot find the WadCfg end element in the config.</value>
</data>
<data name="IaasDiagnosticsBadConfigNoMatchingWadCfg" xml:space="preserve">
<value>WadCfg start element in the config is not matching the end element.</value>
</data>
<data name="IaasDiagnosticsBadConfigNoWadCfg" xml:space="preserve">
<value>Cannot find the WadCfg element in the config.</value>
</data>
</root>
9 changes: 4 additions & 5 deletions src/ResourceManager.sln
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ Global
{DEA446A1-84E2-46CC-B780-EB4AFDE2460E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DEA446A1-84E2-46CC-B780-EB4AFDE2460E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DEA446A1-84E2-46CC-B780-EB4AFDE2460E}.Release|Any CPU.Build.0 = Release|Any CPU
{127D0D51-FDEA-4E1A-8CD8-34DEB5C2F7F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{127D0D51-FDEA-4E1A-8CD8-34DEB5C2F7F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{127D0D51-FDEA-4E1A-8CD8-34DEB5C2F7F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{127D0D51-FDEA-4E1A-8CD8-34DEB5C2F7F6}.Release|Any CPU.Build.0 = Release|Any CPU
{59D1B5DC-9175-43EC-90C6-CBA601B3565F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{59D1B5DC-9175-43EC-90C6-CBA601B3565F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{59D1B5DC-9175-43EC-90C6-CBA601B3565F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{59D1B5DC-9175-43EC-90C6-CBA601B3565F}.Release|Any CPU.Build.0 = Release|Any CPU
{80A92297-7C92-456B-8EE7-9FB6CE30149D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{80A92297-7C92-456B-8EE7-9FB6CE30149D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80A92297-7C92-456B-8EE7-9FB6CE30149D}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -198,7 +198,6 @@ Global
{080B0477-7E52-4455-90AB-23BD13D1B1CE} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
{56ED8C97-53B9-4DF6-ACB5-7E6800105BF8} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
{7E6683BE-ECFF-4709-89EB-1325E9E70512} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
{127D0D51-FDEA-4E1A-8CD8-34DEB5C2F7F6} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
{13E031E4-8A43-4B87-9D72-D70180C31C11} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
{469F20E0-9D40-41AD-94C3-B47AD15A4C00} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
{133561EC-99AF-4ADC-AF41-39C4D3AD323B} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
Expand Down
Loading