Skip to content

Dev: Azure Automation cmdlet changes #1393

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 23 commits into from
Dec 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
55b6e3a
Job Stream cmdlet
safeermohammed Nov 1, 2015
d4e9046
Job Stream record cmdlet
safeermohammed Nov 1, 2015
6288a03
Job Stream record cmdlet
safeermohammed Nov 1, 2015
452c2fc
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
safeermohammed Nov 1, 2015
16cfc67
Job Stream record cmdlet
safeermohammed Nov 1, 2015
85c69b0
Fixed the cmdlet to use ARM template v2.6
balukambala Nov 4, 2015
9ecd189
removed extra "
balukambala Nov 4, 2015
e4a314a
fixed casing + datetime string
balukambala Nov 5, 2015
0b126a9
Sending date in iso format
balukambala Nov 5, 2015
d5709a7
Correcting typo
safeermohammed Nov 6, 2015
4c5410b
Merge pull request #9 from balukambala/dev
balukambala Nov 9, 2015
e7c2cc2
Merge branch 'dev' of https://github.com/AzureAutomationTeam/azure-po…
safeermohammed Nov 9, 2015
1015341
JobStreamRecord
safeermohammed Nov 13, 2015
0ae93b4
Adding x-ms-activity-id header to RequestSettings
adamblev Nov 16, 2015
bb0a6a4
Merge pull request #10 from adamblev/dev
adamblev Nov 17, 2015
ebb7b94
Saving changes before pull
safeermohammed Nov 18, 2015
448ff80
Merge branch 'dev' of https://github.com/azure/azure-powershell into dev
safeermohammed Nov 18, 2015
587c9b4
Job output changes for returned object
safeermohammed Nov 21, 2015
d52cd35
Hashtable for jobRecords
safeermohammed Nov 26, 2015
0d87453
Merge branch 'dev' of https://github.com/azureautomationteam/azure-po…
safeermohammed Nov 26, 2015
4aa91b2
Added tests
safeermohammed Dec 3, 2015
c21d1ae
Revert "Added tests"
safeermohammed Dec 4, 2015
ee95641
Removed test per azure team
safeermohammed Dec 4, 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
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
<Compile Include="Model\DscOnboardingMetaconfig.cs" />
<Compile Include="Model\Job.cs" />
<Compile Include="Model\JobSchedule.cs" />
<Compile Include="Model\JobStreamRecord.cs" />
<Compile Include="Model\JobStream.cs" />
<Compile Include="Model\Module.cs" />
<Compile Include="Model\NodeConfiguration.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,13 @@ public IEnumerable<JobStream> GetJobStream(string resourceGroupName, string auto
stream => this.CreateJobStreamFromJobStreamModel(stream, resourceGroupName, automationAccountName, jobId));
}

public JobStreamRecord GetJobStreamRecord(string resourceGroupName, string automationAccountName, Guid jobId, string jobStreamId)
{
var response = this.automationManagementClient.JobStreams.Get(resourceGroupName, automationAccountName, jobId, jobStreamId);

return new JobStreamRecord(response.JobStream, resourceGroupName, automationAccountName, jobId);
}

public Job GetJob(string resourceGroupName, string automationAccountName, Guid Id)
{
var job = this.automationManagementClient.Jobs.Get(resourceGroupName, automationAccountName, Id).Job;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,7 @@ public void RegisterDscNode(string resourceGroupName,
templateParameters.Add("rebootNodeIfNeeded", rebootFlag);
templateParameters.Add("actionAfterReboot", actionAfterReboot);
templateParameters.Add("allowModuleOverwrite", moduleOverwriteFlag);
templateParameters.Add("timestamp", DateTimeOffset.UtcNow.ToString("o"));

// invoke the New-AzureRmResourceGroupDeployment cmdlet
using (Pipeline pipe = Runspace.DefaultRunspace.CreateNestedPipeline())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public class Constants

public const string ClientRequestIdHeaderName = "x-ms-client-request-id";

public const string ActivityIdHeaderName = "x-ms-activity-id";

// default schedule expiry time for daily schedule, consistent with UX
// 12/31/9999 12:00:00 AM
public static readonly DateTimeOffset DefaultScheduleExpiryTime = DateTimeOffset.MaxValue;
Expand All @@ -59,13 +61,15 @@ public class AutomationAccountState

public const int PsCommandValueDepth = 10;

public const int JobSummaryLength = 80;

// The template file is a json
public const string TemplateFile = @"https://eus2oaasibizamarketprod1.blob.core.windows.net/automationdscpreview/azuredeploy.json";
public const string TemplateFile = @"https://eus2oaasibizamarketprod1.blob.core.windows.net/automationdscpreview/azuredeployV2.json";

// The metaconfig file
public const string ModulesUrl = @"https://eus2oaasibizamarketprod1.blob.core.windows.net/automationdscpreview/RegistrationMetaConfig.zip";
public const string ModulesUrl = @"https://eus2oaasibizamarketprod1.blob.core.windows.net/automationdscpreview/RegistrationMetaConfigV2.zip";

public const string ConfigurationFunction = @"RegistrationMetaConfig.ps1\RegistrationMetaConfig";
public const string ConfigurationFunction = @"RegistrationMetaConfigV2.ps1\RegistrationMetaConfigV2";


public static class RunbookType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ Model.Webhook CreateWebhook(
IEnumerable<JobStream> GetJobStream(string resourceGroupName, string automationAccountName, Guid jobId,
DateTimeOffset? time, string streamType, ref string nextLink);

JobStreamRecord GetJobStreamRecord(string resourceGroupName, string automationAccountName, Guid jobId, string jobStreamId);

#endregion

#region Certificates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -31,6 +32,11 @@ public RequestSettings(IAutomationManagementClient automationClient)
client = ((AutomationManagementClient)automationClient);
client.HttpClient.DefaultRequestHeaders.Remove(Constants.ClientRequestIdHeaderName);
client.HttpClient.DefaultRequestHeaders.Add(Constants.ClientRequestIdHeaderName, Guid.NewGuid().ToString());

client.HttpClient.DefaultRequestHeaders.Remove(Constants.ActivityIdHeaderName);
var activityId = Guid.NewGuid();
EventProvider.SetActivityId(ref activityId);
client.HttpClient.DefaultRequestHeaders.Add(Constants.ActivityIdHeaderName, activityId.ToString());
}

public void Dispose()
Expand All @@ -43,6 +49,7 @@ protected virtual void Dispose(bool disposing)
if (disposing)
{
client.HttpClient.DefaultRequestHeaders.Remove(Constants.ClientRequestIdHeaderName);
client.HttpClient.DefaultRequestHeaders.Remove(Constants.ActivityIdHeaderName);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public Job(string resourceGroupName, string accountName, Azure.Management.Automa

if (job.Properties == null) return;

this.Id = job.Properties.JobId;
this.JobId = job.Properties.JobId;
this.CreationTime = job.Properties.CreationTime.ToLocalTime();
this.LastModifiedTime = job.Properties.LastModifiedTime.ToLocalTime();
this.StartTime = job.Properties.StartTime.HasValue ? job.Properties.StartTime.Value.ToLocalTime() : (DateTimeOffset?)null;
Expand Down Expand Up @@ -105,7 +105,7 @@ public Job()
/// <summary>
/// Gets or sets the job id.
/// </summary>
public Guid Id { get; set; }
public Guid JobId { get; set; }

/// <summary>
/// Gets or sets the tags.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// ----------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Management.Automation;
using Microsoft.Azure.Commands.Automation.Common;

using AutomationManagement = Microsoft.Azure.Management.Automation;
Expand Down Expand Up @@ -45,13 +47,19 @@ public JobStream(AutomationManagement.Models.JobStream jobStream, string resourc
{
Requires.Argument("jobStream", jobStream).NotNull();

this.JobStreamId = jobStream.Properties.JobStreamId;
this.StreamRecordId = jobStream.Properties.JobStreamId;
this.Type = jobStream.Properties.StreamType;
this.Text = jobStream.Properties.Summary;
this.Time = jobStream.Properties.Time;
this.AutomationAccountName = automationAccountName;
this.ResourceGroupName = resourceGroupName;
this.Id = jobId;
this.JobId = jobId;

if (!String.IsNullOrWhiteSpace(jobStream.Properties.Summary))
{
this.Summary = jobStream.Properties.Summary.Length > Constants.JobSummaryLength ?
jobStream.Properties.Summary.Substring(0, Constants.JobSummaryLength) + "..." :
jobStream.Properties.Summary;
}
}

/// <summary>
Expand All @@ -74,22 +82,22 @@ public JobStream()
/// <summary>
/// Gets or sets the Job Id.
/// </summary>
public Guid Id { get; set; }
public Guid JobId { get; set; }

/// <summary>
/// Gets or sets the stream id
/// Gets or sets the stream record id
/// </summary>
public string JobStreamId { get; set; }
public string StreamRecordId { get; set; }

/// <summary>
/// Gets or sets the stream time.
/// </summary>
public DateTimeOffset Time { get; set; }

/// <summary>
/// Gets or sets the stream text.
/// Gets or sets the summary.
/// </summary>
public string Text { get; set; }
public string Summary { get; set; }

/// <summary>
/// Gets or sets the stream Type.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// ----------------------------------------------------------------------------------
//
// 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 System;
using System.Collections;
using System.Collections.Generic;
using System.Management.Automation;
using Microsoft.Azure.Commands.Automation.Common;

using AutomationManagement = Microsoft.Azure.Management.Automation;

namespace Microsoft.Azure.Commands.Automation.Model
{
/// <summary>
/// The Job Stream Record.
/// </summary>
public class JobStreamRecord : JobStream
{
/// <summary>
/// Initializes a new instance of the <see cref="JobStreamRecord"/> class.
/// </summary>
/// <param name="jobStream">
/// The job stream.
/// </param>
/// <param name="resourceGroupName">
/// The resource group name.
/// </param>
/// <param name="automationAccountName">
/// The automation account name
/// </param>
/// <param name="jobId">
/// The job Id
/// </param>
/// <exception cref="System.ArgumentException">
/// </exception>
public JobStreamRecord(AutomationManagement.Models.JobStream jobStream, string resourceGroupName, string automationAccountName, Guid jobId ) : base (jobStream, resourceGroupName, automationAccountName, jobId)
{
this.Value = new Hashtable();
foreach (var kvp in jobStream.Properties.Value)
{
object paramValue;
try
{
paramValue = ((object)PowerShellJsonConverter.Deserialize(kvp.Value.ToString()));
}
catch (CmdletInvocationException exception)
{
if (!exception.Message.Contains("Invalid JSON primitive"))
throw;

paramValue = kvp.Value;
}
this.Value.Add(kvp.Key, paramValue);
}
}

/// <summary>
/// Initializes a new instance of the <see cref="JobStreamRecord"/> class.
/// </summary>
public JobStreamRecord()
{
}

/// <summary>
/// Gets or sets the stream values.
/// </summary>
public Hashtable Value { get; set; }
}
}