Skip to content

Commit

Permalink
Merge pull request #2 from psap/dev
Browse files Browse the repository at this point in the history
 Dsc Node, Dsc Configurations and Dsc MetaConfig cmdlets
  • Loading branch information
safeermohammed committed Apr 14, 2015
2 parents e89a6f0 + cb6d075 commit 561fa8c
Show file tree
Hide file tree
Showing 22 changed files with 1,192 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,8 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
/// </summary>
[Cmdlet(VerbsCommon.Get, "AzureAutomationRegistrationInfo")]
[OutputType(typeof(AgentRegistration))]
public class GetAzureAutomationAgentRegistrationInformation : AzureAutomationBaseCmdlet
public class GetAzureAutomationRegistrationInfo : 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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,8 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
/// </summary>
[Cmdlet(VerbsCommon.Get, "AzureAutomationDscConfiguration", DefaultParameterSetName = AutomationCmdletParameterSets.ByAll)]
[OutputType(typeof(DscConfiguration))]
public class GetAzureAutomationConfiguration : AzureAutomationBaseCmdlet
public class GetAzureAutomationDscConfiguration : 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>
Expand All @@ -59,7 +52,7 @@ public override void ExecuteCmdlet()
}
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByAll)
{
ret = this.AutomationClient.ListAutomationConfigurations(this.ResourceGroupName, this.AutomationAccountName);
ret = this.AutomationClient.ListDscConfigurations(this.ResourceGroupName, this.AutomationAccountName);
}

this.GenerateCmdletOutput(ret);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
[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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
[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>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// ----------------------------------------------------------------------------------
//
// 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.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 dsc node.
/// </summary>
[Cmdlet(VerbsCommon.Get, "AzureAutomationDscNode", DefaultParameterSetName = AutomationCmdletParameterSets.ByAll)]
[OutputType(typeof(DscNode))]
public class GetAzureAutomationDscNode : AzureAutomationBaseCmdlet
{
/// <summary>
/// Gets or sets the job id.
/// </summary>
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ById, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The dsc node id.")]
[Alias("NodeId")]
public Guid Id { get; set; }

/// <summary>
/// Gets or sets the status of a dsc node.
/// </summary>
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByName, Mandatory = false, HelpMessage = "Filter dsc nodes based on their status.")]
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByNodeConfiguration, Mandatory = false, HelpMessage = "Filter dsc nodes based on their status.")]
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByAll, Mandatory = false, HelpMessage = "Filter dsc nodes based on their status.")]
[ValidateSet("Compliant", "Not Compliant", "Failed", "Pending", "Received", "Unresponsive")]
public string Status { get; set; }

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

/// <summary>
/// Gets or sets the nodeconfiguration name.
/// </summary>
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByNodeConfiguration, Mandatory = true, HelpMessage = "The nodeconfiguration name.")]
[ValidateNotNullOrEmpty]
public string NodeConfigurationName { get; set; }

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

if (this.ParameterSetName == AutomationCmdletParameterSets.ById)
{
ret = new List<DscNode>
{
this.AutomationClient.GetDscNodeById(this.ResourceGroupName, this.AutomationAccountName, this.Id)
};
}
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByName)
{
ret = this.AutomationClient.ListDscNodesByName(
this.ResourceGroupName,
this.AutomationAccountName,
this.Name,
this.Status);
}
else if (this.ParameterSetName == AutomationCmdletParameterSets.ByNodeConfiguration)
{
ret = this.AutomationClient.ListDscNodesByNodeConfiguration(
this.ResourceGroupName,
this.AutomationAccountName,
this.NodeConfigurationName,
this.Status);
}
else
{
// ByAll
ret = this.AutomationClient.ListDscNodes(this.ResourceGroupName, this.AutomationAccountName, this.Status);
}

this.GenerateCmdletOutput(ret);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
[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>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// ----------------------------------------------------------------------------------
//
// 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.Generic;
using System.Globalization;
using System.IO;
using System.Management.Automation;
using System.Security.Permissions;
using Microsoft.Azure.Commands.Automation.Common;
using Microsoft.Azure.Commands.Automation.Model;
using Microsoft.Azure.Commands.Automation.Properties;
using Microsoft.WindowsAzure.Commands.Utilities.Common;

namespace Microsoft.Azure.Commands.Automation.Cmdlet
{
/// <summary>
/// Gets azure automation dsc onboarding meta configuration information for a given account.
/// </summary>
[Cmdlet(VerbsCommon.Get, "AzureAutomationDscOnboardingMetaconfig")]
[OutputType(typeof(DscOnboardingMetaconfig))]
public class GetAzureAutomationDscOnboardingMetaconfig : AzureAutomationBaseCmdlet
{
/// <summary>
/// True to overwrite the existing meta.mof; false otherwise.
/// </summary>
private bool overwriteExistingFile;

/// <summary>
/// Gets or sets the output folder for the metaconfig mof files
/// </summary>
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The folder where metaconfig mof files to be placed.")]
public string OutputFolder { get; set; }

/// <summary>
/// Gets or sets the list of computer names
/// </summary>
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The names of computers. If not specified Localhost will be used.")]
[Alias("ComputerName")]
public string[] ComputerNames { get; set; }

/// <summary>
/// Gets or sets switch parameter to confirm overwriting of existing configurations.
/// </summary>
[Parameter(Mandatory = false, HelpMessage = "Overwrites an existing configuration with same name.")]
public SwitchParameter Force
{
get { return this.overwriteExistingFile; }
set { this.overwriteExistingFile = value; }
}

/// <summary>
/// Execute this cmdlet.
/// </summary>
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
public override void ExecuteCmdlet()
{
var ret =
this.AutomationClient.GetDscMetaConfig(this.ResourceGroupName, this.AutomationAccountName, this.OutputFolder, this.ComputerNames, this.Force);

this.WriteObject(ret, true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Collections.Generic;
using System.Management.Automation;
using System.Security.Permissions;
Expand All @@ -29,55 +31,77 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
public class ImportAzureAutomationDscConfiguration : 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; }
/// True to overwrite the existing configuration; false otherwise.
/// </summary>
private bool overwriteExistingConfiguration;

/// <summary>
/// Gets or sets the configuration name.
/// </summary>
[Parameter(Position = 2, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The configuration name.")]
public string ConfigurationName { get; set; }
/// True to publish the configuration; false otherwise.
/// </summary>
private bool publishConfiguration;

/// <summary>
/// Gets or sets the source path.
/// </summary>
[Parameter(Position = 3, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The source path for importing the configuration script.")]
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The source path for importing the configuration script.")]
[ValidateNotNullOrEmpty]
public string SourcePath { get; set; }

/// <summary>
/// Gets or sets the configuration tags.
/// </summary>
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The dsc configuration tags.")]
[Alias("Tag")]
public IDictionary Tags { get; set; }

/// <summary>
/// Gets or sets the description.
/// </summary>
[Parameter(Position = 4, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The description of the configuration being imported.")]
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The description of the configuration being imported.")]
public string Description { get; set; }

/// <summary>
/// Gets or sets the switch parameter to
/// Gets or sets the switch parameter to publish the configuration
/// </summary>
[Parameter(Position = 5, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Import the configuration in published state.")]
public SwitchParameter Published { get; set; }
[Parameter(Mandatory = false, HelpMessage = "Import the configuration in published state.")]
public SwitchParameter Published
{
get { return this.publishConfiguration; }
set { this.publishConfiguration = value; }
}

/// <summary>
/// Gets or sets switch parameter to confirm overwriting of existing configurations.
/// </summary>
[Parameter(Position = 6, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Overwrites an existing configuration with same name.")]
public SwitchParameter Overwrite { get; set; }
[Parameter(Mandatory = false, HelpMessage = "Overwrites an existing configuration with same name.")]
public SwitchParameter Overwrite
{
get { return this.overwriteExistingConfiguration; }
set { this.overwriteExistingConfiguration = value; }
}

/// <summary>
/// Gets or sets a value indicating whether verbose logging should be turned on or off.
/// </summary>
[Parameter(Position = 7, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Indicate whether verbose logging should be turned on or off.")]
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Indicate whether verbose logging should be turned on or off.")]
public bool? LogVerbose { get; set; }

/// <summary>
/// Execute this cmdlet.
/// </summary>
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
public override void ExecuteCmdlet()
{
var configuration = this.AutomationClient.CreateConfiguration(this.ResourceGroupName, this.AutomationAccountName, this.ConfigurationName, this.SourcePath, this.Description, this.LogVerbose);
var configuration = this.AutomationClient.CreateConfiguration(
this.ResourceGroupName,
this.AutomationAccountName,
this.SourcePath,
this.Tags,
this.Description,
this.LogVerbose,
this.Published,
this.Overwrite);

this.WriteObject(configuration);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ namespace Microsoft.Azure.Commands.Automation.Cmdlet
[OutputType(typeof(AgentRegistration))]
public class NewAzureAutomationKey : 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 KeyType.
/// </summary>
Expand Down
Loading

0 comments on commit 561fa8c

Please sign in to comment.