Skip to content

Commit 7dbf8b0

Browse files
committed
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
2 parents ede83f6 + f81965f commit 7dbf8b0

File tree

129 files changed

+17825
-15230
lines changed

Some content is hidden

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

129 files changed

+17825
-15230
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
This repository contains a set of PowerShell cmdlets for developers and administrators to develop, deploy and manage Microsoft Azure applications.
55

6-
* For documentation on how to build and deploy applications to Microsoft Azure please see the [Microsoft Azure Documentation Center](http://azure.microsoft.com/en-us/documentation/).
7-
* For comprehensive documentation on the developer cmdlets see [How to install and configure Azure PowerShell](http://azure.microsoft.com/en-us/documentation/articles/install-configure-powershell/).
6+
* For documentation on how to build and deploy applications to Microsoft Azure please see the [Microsoft Azure Documentation Center](https://azure.microsoft.com/en-us/documentation/).
7+
* For comprehensive documentation on the developer cmdlets see [How to install and configure Azure PowerShell](https://azure.microsoft.com/en-us/documentation/articles/install-configure-powershell/).
88
* For comprehensive documentation on the full set of Microsoft Azure cmdlets see [Microsoft Azure Management Center](http://go.microsoft.com/fwlink/?linkID=254459&clcid=0x409).
99

1010
## Features
@@ -55,17 +55,17 @@ For detail descriptions and examples of the cmdlets, type
5555

5656
## Supported Environments
5757

58-
* [Microsoft Azure](http://www.azure.microsoft.com)
58+
* [Microsoft Azure](https://azure.microsoft.com)
5959
* [Azure Stack](https://azure.microsoft.com/en-us/overview/azure-stack/)
60-
* [Windows Azure Pack](http://www.microsoft.com/en-us/server-cloud/windows-azure-pack.aspx)
61-
* [Microsoft Azure China](http://www.windowsazure.cn/)
60+
* [Windows Azure Pack](https://www.microsoft.com/en-us/server-cloud/windows-azure-pack.aspx)
61+
* [Microsoft Azure China](https://www.azure.cn/)
6262
* [USGovernment](https://azure.microsoft.com/en-us/features/gov/)
6363

6464
## Installation
6565

6666
### Microsoft Web Platform Installer
6767

68-
1. Install [Microsoft Web Platform Installer](http://www.microsoft.com/web/downloads/platform.aspx).
68+
1. Install [Microsoft Web Platform Installer](https://www.microsoft.com/web/downloads/platform.aspx).
6969
2. Open Microsoft Web Platform Installer and search for __Microsoft Azure PowerShell__.
7070
3. Install.
7171

@@ -84,15 +84,15 @@ You can also find the standalone installers for all the versions at [Downloads](
8484

8585
### Supported PowerShell Versions
8686

87-
* [Windows Management Framework 3] (http://www.microsoft.com/en-us/download/details.aspx?id=34595)
87+
* [Windows Management Framework 3] (https://www.microsoft.com/en-us/download/details.aspx?id=34595)
8888
* [Windows Management Framework 4] (https://www.microsoft.com/en-us/download/details.aspx?id=40855)
8989
* [Windows Management Framework 5] (https://www.microsoft.com/en-us/download/details.aspx?id=50395)
9090

9191
## Get Started
9292

9393
In general, following are the steps to start using Microsoft Azure PowerShell
9494

95-
* Get yourself authenticated with Microsoft Azure. For details, please check out [this article](http://azure.microsoft.com/en-us/documentation/articles/install-configure-powershell/).
95+
* Get yourself authenticated with Microsoft Azure. For details, please check out [this article](https://azure.microsoft.com/en-us/documentation/articles/install-configure-powershell/).
9696
* Option 1: Login with your Microsoft account or Organizational account directly from PowerShell. Microsoft Azure Active Directory authentication is used in this case. No management certificate is needed.
9797
* Starting from 1.0.0, you can use ```Add-AzureRmAccount -Credential``` to avoid the browser pop up for Organizational account.
9898
* To use RDFE cmdlets, use ```Add-AzureAccount```
@@ -120,7 +120,7 @@ New-AzureRmResourceGroup -Name myresourceGroup -Location "West US"
120120
Add-AzureRmAccount -EnvironmentName AzureChinaCloud
121121
122122
# use the cmdlets to manage your services/applications
123-
New-AzureRmResourceGroup -Name myresourceGroup -Location "Chine East"
123+
New-AzureRmResourceGroup -Name myresourceGroup -Location "China East"
124124
```
125125

126126
### Windows Azure Pack
@@ -181,10 +181,10 @@ Be sure to check out the [Microsoft Azure Developer Forums on Stack Overflow](ht
181181

182182
## Contribute Code or Provide Feedback
183183

184-
If you would like to become an active contributor to this project please follow the instructions provided in [Microsoft Azure Projects Contribution Guidelines](http://windowsazure.github.com/guidelines.html).
184+
If you would like to become an active contributor to this project please follow the instructions provided in [Microsoft Azure Projects Contribution Guidelines](https://azure.github.io/guidelines/).
185185

186186
If you encounter any bugs with the library please file an issue in the [Issues](https://github.com/Azure/azure-powershell/issues) section of the project.
187187

188188
# Learn More
189189

190-
* [Microsoft Azure Script Center](http://www.azure.microsoft.com/en-us/documentation/scripts/)
190+
* [Microsoft Azure Script Center](https://azure.microsoft.com/en-us/documentation/scripts/)

src/ResourceManager/AzureBackup/Commands.AzureBackup.Test/ScenarioTests/AzureBackupTestBase.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using System.Net.Security;
2525
using System.Reflection;
2626
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
27+
using System.Collections.Generic;
2728

2829
namespace Microsoft.Azure.Commands.AzureBackup.Test.ScenarioTests
2930
{
@@ -58,6 +59,14 @@ protected void SetupManagementClients()
5859

5960
protected void RunPowerShellTest(params string[] scripts)
6061
{
62+
Dictionary<string, string> d = new Dictionary<string, string>();
63+
d.Add("Microsoft.Resources", null);
64+
d.Add("Microsoft.Features", null);
65+
d.Add("Microsoft.Authorization", null);
66+
d.Add("Microsoft.Compute", null);
67+
var providersToIgnore = new Dictionary<string, string>();
68+
providersToIgnore.Add("Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01");
69+
HttpMockServer.Matcher = new PermissiveRecordMatcherWithApiExclusion(true, d, providersToIgnore);
6170
using (UndoContext context = UndoContext.Current)
6271
{
6372
context.Start(TestUtilities.GetCallingClass(2), TestUtilities.GetCurrentMethodName(2));

src/ResourceManager/HDInsight/Commands.HDInsight.Test/Commands.HDInsight.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
</Reference>
5757
<Reference Include="Microsoft.Azure.Management.HDInsight.Job">
5858
<SpecificVersion>False</SpecificVersion>
59-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.HDInsight.Job.1.1.0-preview\lib\net40\Microsoft.Azure.Management.HDInsight.Job.dll</HintPath>
59+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.HDInsight.Job.2.0.0-preview\lib\net40\Microsoft.Azure.Management.HDInsight.Job.dll</HintPath>
6060
</Reference>
6161
<Reference Include="Microsoft.Azure.Management.Storage">
6262
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.2.4.0-preview\lib\net40\Microsoft.Azure.Management.Storage.dll</HintPath>

src/ResourceManager/HDInsight/Commands.HDInsight.Test/HDInsightTestBase.cs

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

15+
using System;
16+
using System.Collections.Generic;
1517
using System.Management.Automation;
1618
using Hyak.Common;
1719
using Microsoft.Azure.Commands.HDInsight.Models;
1820
using Microsoft.Azure.Management.HDInsight.Models;
19-
using Microsoft.WindowsAzure.Commands.Common;
2021
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
2122
using Moq;
2223

@@ -41,9 +42,51 @@ public virtual void SetupTestsForManagement()
4142

4243
public virtual void SetupTestsForData()
4344
{
45+
hdinsightManagementMock = new Mock<AzureHdInsightManagementClient>();
4446
var cred = new BasicAuthenticationCloudCredentials {Username = "username", Password = "Password1!"};
4547
hdinsightJobManagementMock = new Mock<AzureHdInsightJobManagementClient>(ClusterName, cred);
4648
commandRuntimeMock = new Mock<ICommandRuntime>();
4749
}
50+
51+
public virtual void SetupManagementClientForJobTests()
52+
{
53+
// Update HDInsight Management properties for Job.
54+
var cluster1 = new Cluster
55+
{
56+
Id = "/subscriptions/" + Guid.NewGuid() + "/resourceGroups/" + ResourceGroupName + "/providers/Microsoft.HDInsight/clusters/" + ClusterName,
57+
Name = ClusterName,
58+
Location = Location,
59+
Properties = new ClusterGetProperties
60+
{
61+
ClusterVersion = "3.2",
62+
ClusterState = "Running",
63+
ClusterDefinition = new ClusterDefinition
64+
{
65+
ClusterType = ClusterType
66+
},
67+
QuotaInfo = new QuotaInfo
68+
{
69+
CoresUsed = 24
70+
},
71+
OperatingSystemType = OSType.Windows,
72+
ConnectivityEndpoints = new List<ConnectivityEndpoint> { new ConnectivityEndpoint { Location = ClusterName, Name = "HTTPS" } }
73+
}
74+
};
75+
76+
var listresponse = new ClusterListResponse { Clusters = new[] { cluster1 } };
77+
hdinsightManagementMock.Setup(c => c.ListClusters())
78+
.Returns(listresponse)
79+
.Verifiable();
80+
81+
hdinsightManagementMock.Setup(c => c.GetCluster(It.IsAny<string>(), It.IsAny<string>()))
82+
.Returns(new List<Cluster> { cluster1 })
83+
.Verifiable();
84+
85+
var configurationResponse = new Dictionary<string, string>();
86+
87+
hdinsightManagementMock.Setup(c => c.GetClusterConfigurations(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()))
88+
.Returns(configurationResponse)
89+
.Verifiable();
90+
}
4891
}
4992
}

src/ResourceManager/HDInsight/Commands.HDInsight.Test/UnitTests/JobTests.cs

Lines changed: 122 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
using System.Collections.Generic;
1616
using System.Management.Automation;
1717
using System.Net;
18+
using System.Linq;
1819
using Microsoft.Azure.Commands.HDInsight.Models;
1920
using Microsoft.Azure.Management.HDInsight.Job.Models;
2021
using Microsoft.WindowsAzure.Commands.Common;
2122
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2223
using Moq;
2324
using Xunit;
25+
using Microsoft.Azure.Management.HDInsight.Models;
2426

2527
namespace Microsoft.Azure.Commands.HDInsight.Test
2628
{
@@ -195,14 +197,93 @@ public void CreateStreamingJob()
195197
job.Reducer == reducer && job.Defines.Count == defines.Count)));
196198
}
197199

198-
[Fact(Skip = "Test requires setting env variable, TODO remove that constraint")]
200+
[Fact]
201+
[Trait(Category.AcceptanceType, Category.CheckIn)]
202+
public void GetJobWithIdProvided()
203+
{
204+
// Update HDInsight Management properties for Job.
205+
SetupManagementClientForJobTests();
206+
207+
var jobId = "jobid_1984120_001";
208+
var cmdlet = GetJobCommandDefinition();
209+
cmdlet.JobId = jobId;
210+
211+
// Setup Job Management mocks
212+
var jobResponse = new JobGetResponse
213+
{
214+
JobDetail = new JobDetailRootJsonObject { Id = jobId, Status = new Status(), Userargs = new Userargs() }
215+
};
216+
217+
hdinsightJobManagementMock.Setup(c => c.GetJob(It.IsAny<string>()))
218+
.Returns(jobResponse)
219+
.Verifiable();
220+
221+
cmdlet.ExecuteCmdlet();
222+
commandRuntimeMock.VerifyAll();
223+
commandRuntimeMock.Verify(
224+
f =>
225+
f.WriteObject(It.Is<AzureHDInsightJob>(job => job.JobId.Equals(jobId))));
226+
}
227+
228+
[Fact]
229+
[Trait(Category.AcceptanceType, Category.CheckIn)]
230+
public void ListJobs()
231+
{
232+
// Update HDInsight Management properties for Job.
233+
SetupManagementClientForJobTests();
234+
235+
var cmdlet = GetJobCommandDefinition();
236+
237+
// Setup Job Management mocks
238+
var jobListResponse = GetJobListResponse();
239+
240+
hdinsightJobManagementMock.Setup(c => c.ListJobs())
241+
.Returns(jobListResponse)
242+
.Verifiable();
243+
244+
cmdlet.ExecuteCmdlet();
245+
commandRuntimeMock.VerifyAll();
246+
commandRuntimeMock.Verify(
247+
f =>
248+
f.WriteObject(It.Is<IEnumerable<string>>(job => job.ElementAt(0).Equals(jobListResponse.ElementAt(0).Detail.Id) && job.ElementAt(1).Equals(jobListResponse.ElementAt(1).Detail.Id)), true));
249+
}
250+
251+
[Fact]
252+
[Trait(Category.AcceptanceType, Category.CheckIn)]
253+
public void ListJobsAfterJobId()
254+
{
255+
// Update HDInsight Management properties for Job.
256+
SetupManagementClientForJobTests();
257+
258+
var cmdlet = GetJobCommandDefinition();
259+
cmdlet.NumOfJobs = 2;
260+
261+
// Setup Job Management mocks
262+
var jobListResponse = GetJobListResponse();
263+
264+
hdinsightJobManagementMock.Setup(c => c.ListJobsAfterJobId(It.IsAny<string>(), It.IsAny<int>()))
265+
.Returns(jobListResponse)
266+
.Verifiable();
267+
268+
cmdlet.ExecuteCmdlet();
269+
commandRuntimeMock.VerifyAll();
270+
commandRuntimeMock.Verify(
271+
f =>
272+
f.WriteObject(It.Is<IEnumerable<AzureHDInsightJob>>(job => job.ElementAt(0).JobId.Equals(jobListResponse.ElementAt(0).Detail.Id) && job.ElementAt(1).JobId.Equals(jobListResponse.ElementAt(1).Detail.Id)), true));
273+
}
274+
275+
[Fact]
199276
[Trait(Category.AcceptanceType, Category.CheckIn)]
200277
public void StartJob()
201278
{
279+
// Update HDInsight Management properties for Job.
280+
SetupManagementClientForJobTests();
281+
202282
var cmdlet = new StartAzureHDInsightJobCommand
203283
{
204284
CommandRuntime = commandRuntimeMock.Object,
205285
HDInsightJobClient = hdinsightJobManagementMock.Object,
286+
HDInsightManagementClient = hdinsightManagementMock.Object,
206287
HttpCredential = new PSCredential("httpuser", string.Format("Password1!").ConvertToSecureString()),
207288
ClusterName = ClusterName
208289
};
@@ -246,7 +327,9 @@ public void StartJob()
246327
{
247328
Completed = "false",
248329
User = cmdlet.HttpCredential.UserName,
249-
Id = jobid
330+
Id = jobid,
331+
Status = new Status(),
332+
Userargs = new Userargs()
250333
}
251334
};
252335
hdinsightJobManagementMock.Setup(c => c.GetJob(jobsub.JobSubmissionJsonResponse.Id)).Returns(getresponse).Verifiable();
@@ -259,5 +342,42 @@ public void StartJob()
259342
It.Is<AzureHDInsightJob>(
260343
job => job.Cluster == ClusterName && job.JobId == jobid && job.Completed == "false")));
261344
}
345+
346+
public JobListResponse GetJobListResponse()
347+
{
348+
var jobListobject1 = new JobListJsonObject
349+
{
350+
Detail = new JobDetailRootJsonObject { Id = "jobid_1984120_001", Status = new Status(), Userargs = new Userargs() },
351+
Id = "jobid_1984120_001"
352+
};
353+
354+
var jobListobject2 = new JobListJsonObject
355+
{
356+
Detail = new JobDetailRootJsonObject { Id = "jobid_1984120_002", Status = new Status(), Userargs = new Userargs() },
357+
Id = "jobid_1984120_002"
358+
};
359+
360+
var jobListResponse = new JobListResponse
361+
{
362+
JobList = new List<JobListJsonObject> { jobListobject1, jobListobject2 },
363+
StatusCode = HttpStatusCode.OK
364+
};
365+
366+
return jobListResponse;
367+
}
368+
369+
public GetAzureHDInsightJobCommand GetJobCommandDefinition()
370+
{
371+
var cmdlet = new GetAzureHDInsightJobCommand
372+
{
373+
CommandRuntime = commandRuntimeMock.Object,
374+
HDInsightJobClient = hdinsightJobManagementMock.Object,
375+
HDInsightManagementClient = hdinsightManagementMock.Object,
376+
HttpCredential = new PSCredential("httpuser", string.Format("Password1!").ConvertToSecureString()),
377+
ClusterName = ClusterName
378+
};
379+
380+
return cmdlet;
381+
}
262382
}
263383
}

src/ResourceManager/HDInsight/Commands.HDInsight.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net45" />
88
<package id="Microsoft.Azure.Management.Authorization" version="0.18.2-preview" targetFramework="net45" />
99
<package id="Microsoft.Azure.Management.HDInsight" version="1.0.10-preview" targetFramework="net45" />
10-
<package id="Microsoft.Azure.Management.HDInsight.Job" version="1.1.0-preview" targetFramework="net45" />
10+
<package id="Microsoft.Azure.Management.HDInsight.Job" version="2.0.0-preview" targetFramework="net45" />
1111
<package id="Microsoft.Azure.Management.Resources" version="2.19.0-preview" targetFramework="net45" />
1212
<package id="Microsoft.Azure.Management.Storage" version="2.4.0-preview" targetFramework="net45" />
1313
<package id="Microsoft.Azure.Test.Framework" version="1.0.5896.19355-prerelease" targetFramework="net45" />

src/ResourceManager/HDInsight/Commands.HDInsight/Commands.HDInsight.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
</Reference>
128128
<Reference Include="Microsoft.Azure.Management.HDInsight.Job">
129129
<SpecificVersion>False</SpecificVersion>
130-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.HDInsight.Job.1.1.0-preview\lib\net40\Microsoft.Azure.Management.HDInsight.Job.dll</HintPath>
130+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.HDInsight.Job.2.0.0-preview\lib\net40\Microsoft.Azure.Management.HDInsight.Job.dll</HintPath>
131131
</Reference>
132132
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
133133
<SpecificVersion>False</SpecificVersion>

src/ResourceManager/HDInsight/Commands.HDInsight/HDInsightCmdletBase.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using Microsoft.Azure.Commands.HDInsight.Models;
1919
using Microsoft.Azure.Commands.ResourceManager.Common;
2020
using Microsoft.WindowsAzure.Commands.Utilities.Common;
21+
using Microsoft.Azure.Management.HDInsight;
2122

2223
namespace Microsoft.Azure.Commands.HDInsight.Commands
2324
{
@@ -99,5 +100,28 @@ protected string GetResourceGroupByAccountName(string clusterName)
99100
}
100101
}
101102

103+
protected AzureHDInsightDefaultStorageAccount GetDefaultStorageAccount(string resourceGroupName, string clusterName)
104+
{
105+
var result = HDInsightManagementClient.GetCluster(resourceGroupName, clusterName);
106+
107+
if (result == null || result.Count == 0)
108+
{
109+
throw new CloudException(string.Format("Couldn't find cluster {0}", clusterName));
110+
}
111+
112+
var cluster = result.FirstOrDefault();
113+
var configuration = HDInsightManagementClient.GetClusterConfigurations(resourceGroupName, cluster.Name, ConfigurationKey.CoreSite);
114+
115+
var DefaultStorageAccount = ClusterConfigurationUtils.GetDefaultStorageAccountDetails(
116+
configuration,
117+
cluster.Properties.ClusterVersion);
118+
119+
if (DefaultStorageAccount == null)
120+
{
121+
throw new CloudException(string.Format("Couldn't find storage information for cluster {0}", clusterName));
122+
}
123+
124+
return DefaultStorageAccount;
125+
}
102126
}
103127
}

0 commit comments

Comments
 (0)