forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from balukambala/dev
pull request to Dev for dsc cmdlets
- Loading branch information
Showing
23 changed files
with
1,923 additions
and
9 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
...r/Automation/Commands.Automation/Cmdlet/GetAzureAutomationAgentRegistrationInformation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
src/ResourceManager/Automation/Commands.Automation/Cmdlet/GetAzureAutomationConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
103 changes: 103 additions & 0 deletions
103
...ourceManager/Automation/Commands.Automation/Cmdlet/GetAzureAutomationDscCompilationJob.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...anager/Automation/Commands.Automation/Cmdlet/GetAzureAutomationDscCompilationJobOutput.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
...ceManager/Automation/Commands.Automation/Cmdlet/GetAzureAutomationDscNodeConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
Oops, something went wrong.