Skip to content

Commit

Permalink
Merge pull request #1 from balukambala/dev
Browse files Browse the repository at this point in the history
pull request to Dev for dsc cmdlets
  • Loading branch information
safeermohammed committed Apr 13, 2015
2 parents ccff761 + b373fab commit e89a6f0
Show file tree
Hide file tree
Showing 23 changed files with 1,923 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// ----------------------------------------------------------------------------------
//
// 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.Collections.Generic;
using System.Management.Automation;
using System.Security.Permissions;
using Microsoft.Azure.Commands.Automation.Common;
using Microsoft.Azure.Commands.Automation.Model;
using Microsoft.WindowsAzure.Commands.Utilities.Common;

namespace Microsoft.Azure.Commands.Automation.Cmdlet
{
/// <summary>
/// Gets azure automation agent registration information for a given account.
/// </summary>
[Cmdlet(VerbsCommon.Get, "AzureAutomationRegistrationInfo")]
[OutputType(typeof(AgentRegistration))]
public class GetAzureAutomationAgentRegistrationInformation : AzureAutomationBaseCmdlet
{
/// <summary>
/// Gets or sets the automation account name.
/// </summary>
[Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
[ValidateNotNullOrEmpty]
public string AutomationAccountName { get; set; }

/// <summary>
/// Execute this cmdlet.
/// </summary>
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
public override void ExecuteCmdlet()
{
IEnumerable<AgentRegistration> ret = null;

ret = new List<AgentRegistration>
{
this.AutomationClient.GetAgentRegistration(
this.ResourceGroupName,
this.AutomationAccountName)
};

this.GenerateCmdletOutput(ret);
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// ----------------------------------------------------------------------------------
//
// 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.Collections.Generic;
using System.Management.Automation;
using System.Security.Permissions;
using Microsoft.Azure.Commands.Automation.Common;
using Microsoft.Azure.Commands.Automation.Model;
using Microsoft.WindowsAzure.Commands.Utilities.Common;

namespace Microsoft.Azure.Commands.Automation.Cmdlet
{
/// <summary>
/// Gets azure automation configurations for a given account.
/// </summary>
[Cmdlet(VerbsCommon.Get, "AzureAutomationDscConfiguration", DefaultParameterSetName = AutomationCmdletParameterSets.ByAll)]
[OutputType(typeof(DscConfiguration))]
public class GetAzureAutomationConfiguration : AzureAutomationBaseCmdlet
{
/// <summary>
/// Gets or sets the automation account name.
/// </summary>
[Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
[ValidateNotNullOrEmpty]
public string AutomationAccountName { get; set; }

/// <summary>
/// Gets or sets the configuration name.
/// </summary>
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Position = 2, Mandatory = true, ValueFromPipeline = true, HelpMessage = "The configuration name.")]
[Alias("ConfigurationName")]
[ValidateNotNullOrEmpty]
public string Name { get; set; }

/// <summary>
/// Execute this cmdlet.
/// </summary>
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
public override void ExecuteCmdlet()
{
IEnumerable<DscConfiguration> ret = null;
if (this.ParameterSetName == AutomationCmdletParameterSets.ByConfigurationName)
{
ret = new List<DscConfiguration>
{
this.AutomationClient.GetConfiguration(this.ResourceGroupName, this.AutomationAccountName, this.Name)
};
}
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByAll)
{
ret = this.AutomationClient.ListAutomationConfigurations(this.ResourceGroupName, this.AutomationAccountName);
}

this.GenerateCmdletOutput(ret);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// ----------------------------------------------------------------------------------
//
// 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 System.Security.Permissions;
using Microsoft.Azure.Commands.Automation.Common;
using Microsoft.Azure.Commands.Automation.Model;
using Microsoft.WindowsAzure.Commands.Utilities.Common;

namespace Microsoft.Azure.Commands.Automation.Cmdlet
{
/// <summary>
/// Gets Azure automation compilation job
/// </summary>
[Cmdlet(VerbsCommon.Get, "AzureAutomationDscCompilationJob", DefaultParameterSetName = AutomationCmdletParameterSets.ByAll)]
[OutputType(typeof(CompilationJob))]
public class GetAzureAutomationDscCompilationJob : AzureAutomationBaseCmdlet
{
/// <summary>
/// Gets or sets the automation account name.
/// </summary>
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
[ValidateNotNullOrEmpty]
public string AutomationAccountName { get; set; }

/// <summary>
/// Gets or sets the job id.
/// </summary>
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByJobId, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The dsc compilation job id.")]
[Alias("JobId")]
public Guid Id { get; set; }

/// <summary>
/// Gets or sets the runbook name of the job.
/// </summary>
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = true, HelpMessage = "The configuration name of the job.")]
[Alias("Name")]
public string ConfigurationName { get; set; }

/// <summary>
/// Gets or sets the status of a job.
/// </summary>
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = false, HelpMessage = "The configuration name of the job.")]
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter jobs based on their status.")]
[ValidateSet("Completed", "Failed", "Queued", "Starting", "Resuming", "Running", "Stopped", "Stopping", "Suspended", "Suspending", "Activating")]
public string Status { get; set; }

/// <summary>
/// Gets or sets the start time filter.
/// </summary>
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = false, HelpMessage = "The configuration name of the job.")]
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter jobs so that job start time >= StartTime.")]
public DateTimeOffset? StartTime { get; set; }

/// <summary>
/// Gets or sets the end time filter.
/// </summary>
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = false, HelpMessage = "The configuration name of the job.")]
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter jobs so that job end time <= EndTime.")]
public DateTimeOffset? EndTime { get; set; }

/// <summary>
/// Execute this cmdlet.
/// </summary>
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
protected override void AutomationExecuteCmdlet()
{
IEnumerable<CompilationJob> jobs;

if (this.Id != null && !Guid.Empty.Equals(this.Id))
{
// ByJobId
jobs = new List<CompilationJob> { this.AutomationClient.GetCompilationJob(this.ResourceGroupName, this.AutomationAccountName, this.Id) };
}
else if (this.ConfigurationName != null)
{
// ByConfiguration
jobs = this.AutomationClient.ListCompilationJobsByConfigurationName(this.ResourceGroupName, this.AutomationAccountName, this.ConfigurationName, this.StartTime, this.EndTime, this.Status);
}
else
{
// ByAll
jobs = this.AutomationClient.ListCompilationJobs(this.ResourceGroupName, this.AutomationAccountName, this.StartTime, this.EndTime, this.Status);
}

this.WriteObject(jobs, true);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// ----------------------------------------------------------------------------------
//
// 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 System.Security.Permissions;
using Microsoft.Azure.Commands.Automation.Common;
using Microsoft.Azure.Commands.Automation.Model;
using Microsoft.WindowsAzure.Commands.Utilities.Common;

namespace Microsoft.Azure.Commands.Automation.Cmdlet
{
/// <summary>
/// Gets stream for a compilation job
/// </summary>
[Cmdlet(VerbsCommon.Get, "AzureAutomationDscCompilationJobOutput")]
[OutputType(typeof(JobStream))]
public class GetAzureAutomationDscCompilationJobOutput : AzureAutomationBaseCmdlet
{
/// <summary>
/// Gets or sets the automation account name.
/// </summary>
[Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
[ValidateNotNullOrEmpty]
public string AutomationAccountName { get; set; }

/// <summary>
/// Gets or sets the job id
/// </summary>
[Alias("JobId")]
[Parameter(Mandatory = true, Position = 2, ValueFromPipelineByPropertyName = true, HelpMessage = "The job Id")]
public Guid Id { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The stream type. Defaults to Any.")]
public StreamType Stream { get; set; }

[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Retrieves output created after this time")]
public DateTimeOffset? StartTime { get; set; }

/// <summary>
/// Execute this cmdlet.
/// </summary>
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
protected override void AutomationExecuteCmdlet()
{
var ret = this.AutomationClient.GetDscCompilationJobStream(this.ResourceGroupName, this.AutomationAccountName, this.Id, this.StartTime, this.Stream.ToString());

this.GenerateCmdletOutput(ret);
}
}
}
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 System.Security.Permissions;
using Microsoft.Azure.Commands.Automation.Common;
using Microsoft.Azure.Commands.Automation.Model;
using Microsoft.WindowsAzure.Commands.Utilities.Common;

namespace Microsoft.Azure.Commands.Automation.Cmdlet
{
/// <summary>
/// Gets Azure automation node configurations
/// </summary>
[Cmdlet(VerbsCommon.Get, "AzureAutomationDscNodeConfiguration", DefaultParameterSetName = AutomationCmdletParameterSets.ByAll)]
[OutputType(typeof(CompilationJob))]
public class GetAzureAutomationDscNodeConfiguration : AzureAutomationBaseCmdlet
{
/// <summary>
/// Gets or sets the automation account name.
/// </summary>
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
[ValidateNotNullOrEmpty]
public string AutomationAccountName { get; set; }

/// <summary>
/// Gets or sets the job id.
/// </summary>
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByNodeConfigurationName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The dsc node configuration name.")]
[Alias("NodeConfigurationName")]
public string Name { get; set; }

/// <summary>
/// Gets or sets the runbook name of the job.
/// </summary>
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = true, HelpMessage = "The configuration name.")]
public string ConfigurationName { get; set; }

/// <summary>
/// Execute this cmdlet.
/// </summary>
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
protected override void AutomationExecuteCmdlet()
{
IEnumerable<NodeConfiguration> nodeConfigurations;

if (this.Name != null && !Guid.Empty.Equals(this.Name))
{
// ByJobId
nodeConfigurations = new List<NodeConfiguration> { this.AutomationClient.GetNodeConfiguration(this.ResourceGroupName, this.AutomationAccountName, this.Name) };
}
else if (this.ConfigurationName != null)
{
// ByConfiguration
nodeConfigurations = this.AutomationClient.ListNodeConfigurationsByConfigurationName(this.ResourceGroupName, this.AutomationAccountName, this.ConfigurationName);
}
else
{
// ByAll
nodeConfigurations = this.AutomationClient.ListNodeConfigurations(this.ResourceGroupName, this.AutomationAccountName);
}

this.WriteObject(nodeConfigurations, true);
}
}
}
Loading

0 comments on commit e89a6f0

Please sign in to comment.