Skip to content

Commit e89a6f0

Browse files
Merge pull request #1 from balukambala/dev
pull request to Dev for dsc cmdlets
2 parents ccff761 + b373fab commit e89a6f0

23 files changed

+1923
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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 System.Collections.Generic;
16+
using System.Management.Automation;
17+
using System.Security.Permissions;
18+
using Microsoft.Azure.Commands.Automation.Common;
19+
using Microsoft.Azure.Commands.Automation.Model;
20+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
21+
22+
namespace Microsoft.Azure.Commands.Automation.Cmdlet
23+
{
24+
/// <summary>
25+
/// Gets azure automation agent registration information for a given account.
26+
/// </summary>
27+
[Cmdlet(VerbsCommon.Get, "AzureAutomationRegistrationInfo")]
28+
[OutputType(typeof(AgentRegistration))]
29+
public class GetAzureAutomationAgentRegistrationInformation : AzureAutomationBaseCmdlet
30+
{
31+
/// <summary>
32+
/// Gets or sets the automation account name.
33+
/// </summary>
34+
[Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
35+
[ValidateNotNullOrEmpty]
36+
public string AutomationAccountName { get; set; }
37+
38+
/// <summary>
39+
/// Execute this cmdlet.
40+
/// </summary>
41+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
42+
public override void ExecuteCmdlet()
43+
{
44+
IEnumerable<AgentRegistration> ret = null;
45+
46+
ret = new List<AgentRegistration>
47+
{
48+
this.AutomationClient.GetAgentRegistration(
49+
this.ResourceGroupName,
50+
this.AutomationAccountName)
51+
};
52+
53+
this.GenerateCmdletOutput(ret);
54+
}
55+
56+
}
57+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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 System.Collections.Generic;
16+
using System.Management.Automation;
17+
using System.Security.Permissions;
18+
using Microsoft.Azure.Commands.Automation.Common;
19+
using Microsoft.Azure.Commands.Automation.Model;
20+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
21+
22+
namespace Microsoft.Azure.Commands.Automation.Cmdlet
23+
{
24+
/// <summary>
25+
/// Gets azure automation configurations for a given account.
26+
/// </summary>
27+
[Cmdlet(VerbsCommon.Get, "AzureAutomationDscConfiguration", DefaultParameterSetName = AutomationCmdletParameterSets.ByAll)]
28+
[OutputType(typeof(DscConfiguration))]
29+
public class GetAzureAutomationConfiguration : AzureAutomationBaseCmdlet
30+
{
31+
/// <summary>
32+
/// Gets or sets the automation account name.
33+
/// </summary>
34+
[Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
35+
[ValidateNotNullOrEmpty]
36+
public string AutomationAccountName { get; set; }
37+
38+
/// <summary>
39+
/// Gets or sets the configuration name.
40+
/// </summary>
41+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Position = 2, Mandatory = true, ValueFromPipeline = true, HelpMessage = "The configuration name.")]
42+
[Alias("ConfigurationName")]
43+
[ValidateNotNullOrEmpty]
44+
public string Name { get; set; }
45+
46+
/// <summary>
47+
/// Execute this cmdlet.
48+
/// </summary>
49+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
50+
public override void ExecuteCmdlet()
51+
{
52+
IEnumerable<DscConfiguration> ret = null;
53+
if (this.ParameterSetName == AutomationCmdletParameterSets.ByConfigurationName)
54+
{
55+
ret = new List<DscConfiguration>
56+
{
57+
this.AutomationClient.GetConfiguration(this.ResourceGroupName, this.AutomationAccountName, this.Name)
58+
};
59+
}
60+
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByAll)
61+
{
62+
ret = this.AutomationClient.ListAutomationConfigurations(this.ResourceGroupName, this.AutomationAccountName);
63+
}
64+
65+
this.GenerateCmdletOutput(ret);
66+
}
67+
}
68+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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 System;
16+
using System.Collections;
17+
using System.Collections.Generic;
18+
using System.Management.Automation;
19+
using System.Security.Permissions;
20+
using Microsoft.Azure.Commands.Automation.Common;
21+
using Microsoft.Azure.Commands.Automation.Model;
22+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
23+
24+
namespace Microsoft.Azure.Commands.Automation.Cmdlet
25+
{
26+
/// <summary>
27+
/// Gets Azure automation compilation job
28+
/// </summary>
29+
[Cmdlet(VerbsCommon.Get, "AzureAutomationDscCompilationJob", DefaultParameterSetName = AutomationCmdletParameterSets.ByAll)]
30+
[OutputType(typeof(CompilationJob))]
31+
public class GetAzureAutomationDscCompilationJob : AzureAutomationBaseCmdlet
32+
{
33+
/// <summary>
34+
/// Gets or sets the automation account name.
35+
/// </summary>
36+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
37+
[ValidateNotNullOrEmpty]
38+
public string AutomationAccountName { get; set; }
39+
40+
/// <summary>
41+
/// Gets or sets the job id.
42+
/// </summary>
43+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByJobId, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The dsc compilation job id.")]
44+
[Alias("JobId")]
45+
public Guid Id { get; set; }
46+
47+
/// <summary>
48+
/// Gets or sets the runbook name of the job.
49+
/// </summary>
50+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = true, HelpMessage = "The configuration name of the job.")]
51+
[Alias("Name")]
52+
public string ConfigurationName { get; set; }
53+
54+
/// <summary>
55+
/// Gets or sets the status of a job.
56+
/// </summary>
57+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = false, HelpMessage = "The configuration name of the job.")]
58+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter jobs based on their status.")]
59+
[ValidateSet("Completed", "Failed", "Queued", "Starting", "Resuming", "Running", "Stopped", "Stopping", "Suspended", "Suspending", "Activating")]
60+
public string Status { get; set; }
61+
62+
/// <summary>
63+
/// Gets or sets the start time filter.
64+
/// </summary>
65+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = false, HelpMessage = "The configuration name of the job.")]
66+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter jobs so that job start time >= StartTime.")]
67+
public DateTimeOffset? StartTime { get; set; }
68+
69+
/// <summary>
70+
/// Gets or sets the end time filter.
71+
/// </summary>
72+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = false, HelpMessage = "The configuration name of the job.")]
73+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter jobs so that job end time <= EndTime.")]
74+
public DateTimeOffset? EndTime { get; set; }
75+
76+
/// <summary>
77+
/// Execute this cmdlet.
78+
/// </summary>
79+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
80+
protected override void AutomationExecuteCmdlet()
81+
{
82+
IEnumerable<CompilationJob> jobs;
83+
84+
if (this.Id != null && !Guid.Empty.Equals(this.Id))
85+
{
86+
// ByJobId
87+
jobs = new List<CompilationJob> { this.AutomationClient.GetCompilationJob(this.ResourceGroupName, this.AutomationAccountName, this.Id) };
88+
}
89+
else if (this.ConfigurationName != null)
90+
{
91+
// ByConfiguration
92+
jobs = this.AutomationClient.ListCompilationJobsByConfigurationName(this.ResourceGroupName, this.AutomationAccountName, this.ConfigurationName, this.StartTime, this.EndTime, this.Status);
93+
}
94+
else
95+
{
96+
// ByAll
97+
jobs = this.AutomationClient.ListCompilationJobs(this.ResourceGroupName, this.AutomationAccountName, this.StartTime, this.EndTime, this.Status);
98+
}
99+
100+
this.WriteObject(jobs, true);
101+
}
102+
}
103+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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 System;
16+
using System.Collections;
17+
using System.Collections.Generic;
18+
using System.Management.Automation;
19+
using System.Security.Permissions;
20+
using Microsoft.Azure.Commands.Automation.Common;
21+
using Microsoft.Azure.Commands.Automation.Model;
22+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
23+
24+
namespace Microsoft.Azure.Commands.Automation.Cmdlet
25+
{
26+
/// <summary>
27+
/// Gets stream for a compilation job
28+
/// </summary>
29+
[Cmdlet(VerbsCommon.Get, "AzureAutomationDscCompilationJobOutput")]
30+
[OutputType(typeof(JobStream))]
31+
public class GetAzureAutomationDscCompilationJobOutput : AzureAutomationBaseCmdlet
32+
{
33+
/// <summary>
34+
/// Gets or sets the automation account name.
35+
/// </summary>
36+
[Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
37+
[ValidateNotNullOrEmpty]
38+
public string AutomationAccountName { get; set; }
39+
40+
/// <summary>
41+
/// Gets or sets the job id
42+
/// </summary>
43+
[Alias("JobId")]
44+
[Parameter(Mandatory = true, Position = 2, ValueFromPipelineByPropertyName = true, HelpMessage = "The job Id")]
45+
public Guid Id { get; set; }
46+
47+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The stream type. Defaults to Any.")]
48+
public StreamType Stream { get; set; }
49+
50+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Retrieves output created after this time")]
51+
public DateTimeOffset? StartTime { get; set; }
52+
53+
/// <summary>
54+
/// Execute this cmdlet.
55+
/// </summary>
56+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
57+
protected override void AutomationExecuteCmdlet()
58+
{
59+
var ret = this.AutomationClient.GetDscCompilationJobStream(this.ResourceGroupName, this.AutomationAccountName, this.Id, this.StartTime, this.Stream.ToString());
60+
61+
this.GenerateCmdletOutput(ret);
62+
}
63+
}
64+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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 System;
16+
using System.Collections;
17+
using System.Collections.Generic;
18+
using System.Management.Automation;
19+
using System.Security.Permissions;
20+
using Microsoft.Azure.Commands.Automation.Common;
21+
using Microsoft.Azure.Commands.Automation.Model;
22+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
23+
24+
namespace Microsoft.Azure.Commands.Automation.Cmdlet
25+
{
26+
/// <summary>
27+
/// Gets Azure automation node configurations
28+
/// </summary>
29+
[Cmdlet(VerbsCommon.Get, "AzureAutomationDscNodeConfiguration", DefaultParameterSetName = AutomationCmdletParameterSets.ByAll)]
30+
[OutputType(typeof(CompilationJob))]
31+
public class GetAzureAutomationDscNodeConfiguration : AzureAutomationBaseCmdlet
32+
{
33+
/// <summary>
34+
/// Gets or sets the automation account name.
35+
/// </summary>
36+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The automation account name.")]
37+
[ValidateNotNullOrEmpty]
38+
public string AutomationAccountName { get; set; }
39+
40+
/// <summary>
41+
/// Gets or sets the job id.
42+
/// </summary>
43+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByNodeConfigurationName, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The dsc node configuration name.")]
44+
[Alias("NodeConfigurationName")]
45+
public string Name { get; set; }
46+
47+
/// <summary>
48+
/// Gets or sets the runbook name of the job.
49+
/// </summary>
50+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByConfigurationName, Mandatory = true, HelpMessage = "The configuration name.")]
51+
public string ConfigurationName { get; set; }
52+
53+
/// <summary>
54+
/// Execute this cmdlet.
55+
/// </summary>
56+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
57+
protected override void AutomationExecuteCmdlet()
58+
{
59+
IEnumerable<NodeConfiguration> nodeConfigurations;
60+
61+
if (this.Name != null && !Guid.Empty.Equals(this.Name))
62+
{
63+
// ByJobId
64+
nodeConfigurations = new List<NodeConfiguration> { this.AutomationClient.GetNodeConfiguration(this.ResourceGroupName, this.AutomationAccountName, this.Name) };
65+
}
66+
else if (this.ConfigurationName != null)
67+
{
68+
// ByConfiguration
69+
nodeConfigurations = this.AutomationClient.ListNodeConfigurationsByConfigurationName(this.ResourceGroupName, this.AutomationAccountName, this.ConfigurationName);
70+
}
71+
else
72+
{
73+
// ByAll
74+
nodeConfigurations = this.AutomationClient.ListNodeConfigurations(this.ResourceGroupName, this.AutomationAccountName);
75+
}
76+
77+
this.WriteObject(nodeConfigurations, true);
78+
}
79+
}
80+
}

0 commit comments

Comments
 (0)