Skip to content

Commit c2cf2c1

Browse files
committed
Merge pull request #127 from Azure/dev
.
2 parents 67d29f1 + 4a788ac commit c2cf2c1

File tree

54 files changed

+17634
-1410
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+17634
-1410
lines changed

src/ResourceManager/Automation/Commands.Automation.Test/Commands.Automation.Test.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
<Compile Include="UnitTests\RegisterAzureAutomationScheduledRunbookTest.cs" />
158158
<Compile Include="UnitTests\RemoveAzureAutomationAccountTest.cs" />
159159
<Compile Include="UnitTests\RemoveAzureAutomationCertificateTest.cs" />
160+
<Compile Include="UnitTests\RemoveAzureAutomationConnectionTypeTest.cs" />
160161
<Compile Include="UnitTests\RemoveAzureAutomationConnectionTest.cs" />
161162
<Compile Include="UnitTests\RemoveAzureAutomationModuleTest.cs" />
162163
<Compile Include="UnitTests\RemoveAzureAutomationRunbookTest.cs" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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 Microsoft.Azure.Commands.Automation.Cmdlet;
16+
using Microsoft.Azure.Commands.Automation.Common;
17+
using Microsoft.VisualStudio.TestTools.UnitTesting;
18+
using Microsoft.WindowsAzure.Commands.Common.Test.Mocks;
19+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
20+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
21+
using Moq;
22+
23+
namespace Microsoft.Azure.Commands.ResourceManager.Automation.Test.UnitTests
24+
{
25+
[TestClass]
26+
public class RemoveAzureAutomationConnectionTypeTest : RMTestBase
27+
{
28+
private Mock<IAutomationClient> mockAutomationClient;
29+
30+
private MockCommandRuntime mockCommandRuntime;
31+
32+
private RemoveAzureAutomationConnectionType cmdlet;
33+
34+
[TestInitialize]
35+
public void SetupTest()
36+
{
37+
this.mockAutomationClient = new Mock<IAutomationClient>();
38+
this.mockCommandRuntime = new MockCommandRuntime();
39+
this.cmdlet = new RemoveAzureAutomationConnectionType
40+
{
41+
AutomationClient = this.mockAutomationClient.Object,
42+
CommandRuntime = this.mockCommandRuntime
43+
};
44+
}
45+
46+
[TestMethod]
47+
public void RemoveAzureAutomationConnectionTypeByNameSuccessfull()
48+
{
49+
// Setup
50+
string resourceGroupName = "resourceGroup";
51+
string accountName = "automation";
52+
string connectionTypeName = "connectionType";
53+
54+
this.mockAutomationClient.Setup(f => f.DeleteConnectionType(resourceGroupName, accountName, connectionTypeName));
55+
56+
// Test
57+
this.cmdlet.ResourceGroupName = resourceGroupName;
58+
this.cmdlet.AutomationAccountName = accountName;
59+
this.cmdlet.Name = connectionTypeName;
60+
this.cmdlet.Force = true;
61+
this.cmdlet.ExecuteCmdlet();
62+
63+
// Assert
64+
this.mockAutomationClient.Verify(f => f.DeleteConnectionType(resourceGroupName, accountName, connectionTypeName), Times.Once());
65+
}
66+
}
67+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
/// Imports dsc node configuration script
28+
/// </summary>
29+
[Cmdlet(VerbsData.Import, "AzureRmAutomationDscNodeConfiguration")]
30+
[OutputType(typeof(NodeConfiguration))]
31+
public class ImportAzureAutomationDscNodeConfiguration : AzureAutomationBaseCmdlet
32+
{
33+
/// <summary>
34+
/// True to overwrite the existing configuration; false otherwise.
35+
/// </summary>
36+
private bool overwriteExistingConfiguration;
37+
38+
/// <summary>
39+
/// Gets or sets the source path.
40+
/// </summary>
41+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Path to the node configuration .mof to import.")]
42+
[ValidateNotNullOrEmpty]
43+
public string Path { get; set; }
44+
45+
/// <summary>
46+
/// Gets or sets the configuration name for the node configuration.
47+
/// </summary>
48+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The name of the DSC Configuration to import the Node Configuration under. All Node Configurations in Azure Automation must exist under a Configuration. The name of the Configuration will become the namespace of the imported Node Configuration, in the form of 'ConfigurationName.MofFileName'")]
49+
public string ConfigurationName { get; set; }
50+
51+
52+
/// <summary>
53+
/// Gets or sets switch parameter to confirm overwriting of existing configurations.
54+
/// </summary>
55+
[Parameter(Mandatory = false, HelpMessage = "Forces the command to overwrite an existing Node Configuration.")]
56+
public SwitchParameter Force
57+
{
58+
get { return this.overwriteExistingConfiguration; }
59+
set { this.overwriteExistingConfiguration = value; }
60+
}
61+
62+
/// <summary>
63+
/// Execute this cmdlet.
64+
/// </summary>
65+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
66+
protected override void ProcessRecord()
67+
{
68+
var nodeConfiguration = this.AutomationClient.CreateNodeConfiguration(
69+
this.ResourceGroupName,
70+
this.AutomationAccountName,
71+
this.Path,
72+
this.ConfigurationName,
73+
this.Force);
74+
75+
this.WriteObject(nodeConfiguration);
76+
}
77+
}
78+
}

src/ResourceManager/Automation/Commands.Automation/Cmdlet/ImportAzureAutomationRunbook.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ public class ImportAzureAutomationRunbook : AzureAutomationBaseCmdlet
4343
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The runbook description.")]
4444
public string Description { get; set; }
4545

46+
/// <summary>
47+
/// Gets or sets the runbook name
48+
/// </summary>
49+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The name of the runbook to import, if different from the file name. Not supported for PowerShell Workflow runbooks.")]
50+
[Alias("RunbookName")]
51+
public string Name { get; set; }
52+
4653
/// <summary>
4754
/// Gets or sets the runbook tags.
4855
/// </summary>
@@ -98,7 +105,8 @@ protected override void AutomationProcessRecord()
98105
this.LogProgress,
99106
this.LogVerbose,
100107
this.Published.IsPresent,
101-
this.Force.IsPresent);
108+
this.Force.IsPresent,
109+
this.Name);
102110

103111
this.WriteObject(runbook);
104112
}

src/ResourceManager/Automation/Commands.Automation/Cmdlet/NewAzureAutomationWebhook.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
using Microsoft.Azure.Commands.Automation.Properties;
1717
using Microsoft.WindowsAzure.Commands.Common;
1818
using System;
19-
using System.Collections.Generic;
19+
using System.Collections;
2020
using System.Management.Automation;
2121
using System.Security.Permissions;
2222

@@ -66,7 +66,7 @@ public class NewAzureAutomationWebhook : AzureAutomationBaseCmdlet
6666
/// </summary>
6767
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true,
6868
HelpMessage = "The Runbook parameters name/value.")]
69-
public IDictionary<string, string> Parameters { get; set; }
69+
public IDictionary Parameters { get; set; }
7070

7171
[Parameter(Mandatory = false, HelpMessage = "Skip warning message about one-time viewable webhook URL")]
7272
public SwitchParameter Force { get; set; }
@@ -91,7 +91,7 @@ protected override void AutomationProcessRecord()
9191
this.RunbookName,
9292
this.IsEnabled,
9393
this.ExpiryTime,
94-
this.Parameters.ToHashtable())));
94+
this.Parameters)));
9595

9696
}
9797
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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.Linq;
17+
using System.Management.Automation;
18+
using System.Security.Permissions;
19+
using Microsoft.Azure.Commands.Automation.Common;
20+
using Microsoft.Azure.Commands.Automation.Properties;
21+
22+
namespace Microsoft.Azure.Commands.Automation.Cmdlet
23+
{
24+
/// <summary>
25+
/// Removes a Connection type for automation.
26+
/// </summary>
27+
[Cmdlet(VerbsCommon.Remove, "AzureRmAutomationConnectionType", DefaultParameterSetName = AutomationCmdletParameterSets.ByName)]
28+
public class RemoveAzureAutomationConnectionType : AzureAutomationBaseCmdlet
29+
{
30+
/// <summary>
31+
/// Gets or sets the connection name.
32+
/// </summary>
33+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByName, Position = 2, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The connection type name.")]
34+
[ValidateNotNullOrEmpty]
35+
public string Name { get; set; }
36+
37+
[Parameter(ParameterSetName = AutomationCmdletParameterSets.ByName, Position = 3, HelpMessage = "Confirm the removal of the connection type")]
38+
public SwitchParameter Force { get; set; }
39+
40+
/// <summary>
41+
/// Execute this cmdlet.
42+
/// </summary>
43+
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
44+
protected override void AutomationProcessRecord()
45+
{
46+
var nextLink = string.Empty;
47+
var removeMessageWarning = Resources.RemovingAzureAutomationResourceWarning;
48+
49+
// check if any connections exists that use this connection type
50+
do
51+
{
52+
var ret = this.AutomationClient.ListConnections(this.ResourceGroupName, this.AutomationAccountName, ref nextLink);
53+
54+
if (ret.ToList().Any(connection => 0 ==
55+
string.Compare(connection.ConnectionTypeName, this.Name,
56+
StringComparison.CurrentCultureIgnoreCase)))
57+
{
58+
removeMessageWarning = Resources.RemoveConnectionTypeThatHasConnectionWarning;
59+
break;
60+
}
61+
62+
} while (!string.IsNullOrEmpty(nextLink));
63+
64+
65+
ConfirmAction(
66+
Force.IsPresent,
67+
string.Format(removeMessageWarning, "ConnectionType"),
68+
string.Format(Resources.RemoveAzureAutomationResourceDescription, "ConnectionType"),
69+
Name,
70+
() => this.AutomationClient.DeleteConnectionType(this.ResourceGroupName, this.AutomationAccountName, Name));
71+
}
72+
}
73+
}

src/ResourceManager/Automation/Commands.Automation/Cmdlet/SetAzureAutomationWebhook.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using System.Collections;
1516
using Microsoft.Azure.Commands.Automation.Model;
1617
using Microsoft.WindowsAzure.Commands.Common;
17-
using System.Collections.Generic;
1818
using System.Management.Automation;
1919
using System.Security.Permissions;
2020

@@ -48,7 +48,7 @@ public class SetAzureAutomationWebhook : AzureAutomationBaseCmdlet
4848
/// </summary>
4949
[Parameter(Position = 4, Mandatory = false, ValueFromPipelineByPropertyName = true,
5050
HelpMessage = "The Runbook parameters name/value.")]
51-
public IDictionary<string, string> Parameters { get; set; }
51+
public IDictionary Parameters { get; set; }
5252

5353
/// <summary>
5454
/// Execute this cmdlet.
@@ -60,7 +60,7 @@ protected override void AutomationProcessRecord()
6060
this.ResourceGroupName,
6161
this.AutomationAccountName,
6262
this.Name,
63-
this.Parameters.ToHashtable(),
63+
this.Parameters,
6464
this.IsEnabled);
6565
this.WriteObject(updatedWebhook);
6666
}

src/ResourceManager/Automation/Commands.Automation/Cmdlet/StartAzureAutomationDscCompilationJob.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using System;
1516
using System.Collections;
1617
using System.Collections.Generic;
18+
using System.Globalization;
1719
using System.Management.Automation;
1820
using System.Security.Permissions;
1921
using Microsoft.Azure.Commands.Automation.Common;
2022
using Microsoft.Azure.Commands.Automation.Model;
23+
using Microsoft.Azure.Commands.Automation.Properties;
2124
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2225

2326
namespace Microsoft.Azure.Commands.Automation.Cmdlet
@@ -42,6 +45,12 @@ public class StartAzureAutomationDscCompilationJob : AzureAutomationBaseCmdlet
4245
[Parameter(Mandatory = false, HelpMessage = "The compilation job parameters.")]
4346
public IDictionary Parameters { get; set; }
4447

48+
/// <summary>
49+
/// Gets or sets the configuration data.
50+
/// </summary>
51+
[Parameter(Mandatory = false, HelpMessage = "The compilation job configuration data.")]
52+
public IDictionary ConfigurationData { get; set; }
53+
4554
/// <summary>
4655
/// Execute this cmdlet.
4756
/// </summary>
@@ -50,7 +59,15 @@ protected override void AutomationProcessRecord()
5059
{
5160
CompilationJob job = null;
5261

53-
job = this.AutomationClient.StartCompilationJob(this.ResourceGroupName, this.AutomationAccountName, this.ConfigurationName, this.Parameters);
62+
if (this.Parameters != null && this.Parameters.Contains("ConfigurationData"))
63+
{
64+
throw new ArgumentException(
65+
string.Format(
66+
CultureInfo.CurrentCulture,
67+
Resources.ConfigurationDataShouldNotBeInJobParameters, "-ConfigurationData"));
68+
}
69+
70+
job = this.AutomationClient.StartCompilationJob(this.ResourceGroupName, this.AutomationAccountName, this.ConfigurationName, this.Parameters, this.ConfigurationData);
5471

5572
this.WriteObject(job);
5673
}

src/ResourceManager/Automation/Commands.Automation/Commands.Automation.csproj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@
6363
<HintPath>..\..\..\packages\Microsoft.Azure.Common.Authentication.1.3.1-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>
6464
<Private>True</Private>
6565
</Reference>
66+
<Reference Include="Microsoft.Azure.Management.Automation, Version=0.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
67+
<SpecificVersion>False</SpecificVersion>
68+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Automation.0.50.2-prerelease\lib\portable-net45+wp8+wpa81+win\Microsoft.Azure.Management.Automation.dll</HintPath>
69+
</Reference>
6670
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6771
<SpecificVersion>False</SpecificVersion>
6872
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.7-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
@@ -79,10 +83,6 @@
7983
<SpecificVersion>False</SpecificVersion>
8084
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
8185
</Reference>
82-
<Reference Include="Microsoft.Azure.Management.Automation, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
83-
<SpecificVersion>False</SpecificVersion>
84-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Automation.0.50.1-prerelease\lib\net40\Microsoft.Azure.Management.Automation.dll</HintPath>
85-
</Reference>
8686
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
8787
<SpecificVersion>False</SpecificVersion>
8888
<HintPath>..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
@@ -127,6 +127,7 @@
127127
</ItemGroup>
128128
<ItemGroup>
129129
<Compile Include="Cmdlet\AzureAutomationBaseCmdlet.cs" />
130+
<Compile Include="Cmdlet\ImportAzureAutomationDscNodeConfiguration.cs" />
130131
<Compile Include="Cmdlet\ExportAzureAutomationDscConfiguration.cs" />
131132
<Compile Include="Cmdlet\ExportAzureAutomationDscNodeReportContent.cs" />
132133
<Compile Include="Cmdlet\GetAzureAutomationCertificate.cs" />
@@ -159,6 +160,7 @@
159160
<Compile Include="Cmdlet\RegisterAzureAutomationDscNode.cs" />
160161
<Compile Include="Cmdlet\RegisterAzureAutomationScheduledRunbook.cs" />
161162
<Compile Include="Cmdlet\RemoveAzureAutomationCertificate.cs" />
163+
<Compile Include="Cmdlet\RemoveAzureAutomationConnectionType.cs" />
162164
<Compile Include="Cmdlet\RemoveAzureAutomationConnection.cs" />
163165
<Compile Include="Cmdlet\RemoveAzureAutomationCredential.cs" />
164166
<Compile Include="Cmdlet\RemoveAzureAutomationModule.cs" />

0 commit comments

Comments
 (0)