Skip to content

Commit 5d233d9

Browse files
committed
Merge pull request Azure#38 from hyonholee/dev
Test fixes
2 parents 0e653f5 + 94916b9 commit 5d233d9

37 files changed

+1250
-693
lines changed

setup/azurecmdfiles.wxi

Lines changed: 781 additions & 237 deletions
Large diffs are not rendered by default.

src/Common/Storage/Azure.Storage.psd1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ ScriptsToProcess = @()
5555

5656
# Type files (.ps1xml) to be loaded when importing this module
5757
TypesToProcess = @(
58-
'.\Microsoft.WindowsAzure.Commands.Storage.Types.ps1xml'
58+
'.\Microsoft.WindowsAzure.Commands.Storage.Types.ps1xml'
5959
)
6060

6161
# Format files (.ps1xml) to be loaded when importing this module
6262
FormatsToProcess = @(
63-
'.\Microsoft.WindowsAzure.Commands.Storage.format.ps1xml'
63+
'.\Microsoft.WindowsAzure.Commands.Storage.format.ps1xml'
6464
)
6565

6666
# Modules to import as nested modules of the module specified in ModuleToProcess
6767
NestedModules = @(
68-
'.\Microsoft.WindowsAzure.Commands.Storage.dll',
68+
'.\Microsoft.WindowsAzure.Commands.Storage.dll'
6969
)
7070

7171
# Functions to export from this module
@@ -79,7 +79,7 @@ VariablesToExport = '*'
7979

8080
# Aliases to export from this module
8181
AliasesToExport = @(
82-
'Get-AzureRMStorageContainerAcl',
82+
'Get-AzureRMStorageContainerAcl',
8383
'Start-CopyAzureStorageBlob',
8484
'Stop-CopyAzureStorageBlob'
8585
)

src/ResourceManager/AzureBackup/Commands.AzureBackup/Commands.AzureBackup.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<DebugSymbols>true</DebugSymbols>
2020
<DebugType>full</DebugType>
2121
<Optimize>false</Optimize>
22-
<OutputPath>..\..\..\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.AzureBackup\</OutputPath>
22+
<OutputPath>..\..\..\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.Backup\</OutputPath>
2323
<DefineConstants>DEBUG;TRACE</DefineConstants>
2424
<ErrorReport>prompt</ErrorReport>
2525
<WarningLevel>4</WarningLevel>
@@ -30,7 +30,7 @@
3030
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
3131
</PropertyGroup>
3232
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
33-
<OutputPath>..\..\..\Package\Release\ResourceManager\AzureResourceManager\AzureRM.AzureBackup\</OutputPath>
33+
<OutputPath>..\..\..\Package\Release\ResourceManager\AzureResourceManager\AzureRM.Backup\</OutputPath>
3434
<DefineConstants>TRACE;SIGN</DefineConstants>
3535
<Optimize>true</Optimize>
3636
<DebugType>pdbonly</DebugType>
@@ -192,8 +192,8 @@
192192
<Compile Include="Properties\AssemblyInfo.cs" />
193193
</ItemGroup>
194194
<ItemGroup>
195-
<None Include="..\AzureRM.AzureBackup.psd1">
196-
<Link>AzureRM.AzureBackup.psd1</Link>
195+
<None Include="..\AzureRM.Backup.psd1">
196+
<Link>AzureRM.Backup.psd1</Link>
197197
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
198198
</None>
199199
<None Include="Microsoft.Azure.Commands.AzureBackup.dll-help.psd1" />

src/ResourceManager/AzureBatch/Commands.Batch/Commands.Batch.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<DebugSymbols>true</DebugSymbols>
2020
<DebugType>full</DebugType>
2121
<Optimize>false</Optimize>
22-
<OutputPath>..\..\..\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.AzureBatch\</OutputPath>
22+
<OutputPath>..\..\..\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.Batch\</OutputPath>
2323
<DefineConstants>TRACE;DEBUG;CODE_ANALYSIS</DefineConstants>
2424
<ErrorReport>prompt</ErrorReport>
2525
<WarningLevel>4</WarningLevel>
@@ -30,7 +30,7 @@
3030
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
3131
<DebugType>pdbonly</DebugType>
3232
<Optimize>true</Optimize>
33-
<OutputPath>..\..\..\Package\Release\ResourceManager\AzureResourceManager\AzureRM.AzureBatch\</OutputPath>
33+
<OutputPath>..\..\..\Package\Release\ResourceManager\AzureResourceManager\AzureRM.Batch\</OutputPath>
3434
<DefineConstants>TRACE;SIGN</DefineConstants>
3535
<ErrorReport>prompt</ErrorReport>
3636
<WarningLevel>4</WarningLevel>

src/ResourceManager/Compute/Commands.Compute/Commands.Compute.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,15 @@
293293
<Compile Include="Models\PSVirtualMachineSize.cs" />
294294
<Compile Include="Common\LocationStringExtensions.cs" />
295295
<Compile Include="Models\UploadParameters.cs" />
296+
<Compile Include="Models\VhdDownloadContext.cs" />
297+
<Compile Include="Models\VhdDownloaderModel.cs" />
296298
<Compile Include="Models\VhdUploadContext.cs" />
297299
<Compile Include="Models\VhdUploaderModel.cs" />
298300
<Compile Include="RemoteDesktop\VirtualMachineRemoteDesktopBaseCmdlet.cs" />
299301
<Compile Include="RemoteDesktop\GetAzureRemoteDesktopFileCommand.cs" />
300302
<Compile Include="StorageServices\AddAzureVhdCommand.cs" />
301303
<Compile Include="StorageServices\CloudPageBlobObjectFactory.cs" />
304+
<Compile Include="StorageServices\SaveAzureVhdCommand.cs" />
302305
<Compile Include="StorageServices\StorageCredentialsFactory.cs" />
303306
<Compile Include="Usage\GetAzureVMUsageCommand.cs" />
304307
<Compile Include="Usage\VirtualMachineUsageBaseCmdlet.cs" />

src/ResourceManager/Compute/Commands.Compute/Common/ConstantStringTypes.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public static class ValidateSetValues
4747
{
4848
public const string ReadOnly = "ReadOnly";
4949
public const string ReadWrite = "ReadWrite";
50+
public const string None = "None";
5051
}
5152

5253
public static class ProfileNouns
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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.IO;
17+
18+
namespace Microsoft.Azure.Commands.Compute.Models
19+
{
20+
public class VhdDownloadContext
21+
{
22+
public FileInfo LocalFilePath { get; set; }
23+
public Uri Source { get; set; }
24+
}
25+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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.WindowsAzure.Commands.Sync;
16+
using Microsoft.WindowsAzure.Commands.Sync.Download;
17+
using System.IO;
18+
19+
namespace Microsoft.Azure.Commands.Compute.Models
20+
{
21+
public class VhdDownloaderModel
22+
{
23+
public static VhdDownloadContext Download(DownloaderParameters downloadParameters, ComputeClientBaseCmdlet cmdlet)
24+
{
25+
Program.SyncOutput = new PSSyncOutputEvents(cmdlet);
26+
27+
downloadParameters.ProgressDownloadComplete = Program.SyncOutput.ProgressDownloadComplete;
28+
downloadParameters.ProgressDownloadStatus = Program.SyncOutput.ProgressDownloadStatus;
29+
30+
var downloader = new Downloader(downloadParameters);
31+
downloader.Download();
32+
33+
return new VhdDownloadContext
34+
{
35+
LocalFilePath = new FileInfo(downloadParameters.LocalFilePath),
36+
Source = downloadParameters.BlobUri.Uri
37+
};
38+
}
39+
}
40+
}

src/ResourceManager/Compute/Commands.Compute/StorageServices/AddAzureVhdCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public UploadParameters ValidateParameters()
131131
}
132132
}
133133

134-
var storageCredentialsFactory = CreateStorageCredentialsFactory(destinationUri);
134+
var storageCredentialsFactory = CreateStorageCredentialsFactory();
135135

136136
PathIntrinsics currentPath = SessionState.Path;
137137
var filePath = new FileInfo(currentPath.GetUnresolvedProviderPathFromPSPath(LocalFilePath.ToString()));
@@ -147,7 +147,7 @@ public UploadParameters ValidateParameters()
147147
return parameters;
148148
}
149149

150-
private StorageCredentialsFactory CreateStorageCredentialsFactory(BlobUri destinationUri)
150+
private StorageCredentialsFactory CreateStorageCredentialsFactory()
151151
{
152152
StorageCredentialsFactory storageCredentialsFactory;
153153

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
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.Compute.Common;
16+
using Microsoft.Azure.Commands.Compute.Models;
17+
using Microsoft.Azure.Common.Authentication;
18+
using Microsoft.Azure.Common.Authentication.Models;
19+
using Microsoft.Azure.Management.Storage;
20+
using Microsoft.WindowsAzure.Commands.Sync.Download;
21+
using System;
22+
using System.IO;
23+
using System.Management.Automation;
24+
25+
namespace Microsoft.Azure.Commands.Compute.StorageServices
26+
{
27+
[Cmdlet(VerbsData.Save, ProfileNouns.Vhd), OutputType(typeof(VhdDownloadContext))]
28+
public class SaveAzureVhdCommand : ComputeClientBaseCmdlet
29+
{
30+
private const int DefaultNumberOfUploaderThreads = 8;
31+
private const string ResourceGroupParameterSet = "ResourceGroupParameterSetName";
32+
private const string StorageKeyParameterSet = "StorageKeyParameterSetName";
33+
34+
[Parameter(
35+
Position = 0,
36+
Mandatory = true,
37+
ParameterSetName = ResourceGroupParameterSet,
38+
ValueFromPipelineByPropertyName = true)]
39+
[ValidateNotNullOrEmpty]
40+
public string ResourceGroupName { get; set; }
41+
42+
[Parameter(
43+
Position = 0,
44+
Mandatory = true,
45+
ParameterSetName = StorageKeyParameterSet,
46+
HelpMessage = "Key of the storage account")]
47+
[ValidateNotNullOrEmpty]
48+
[Alias("sk")]
49+
public string StorageKey
50+
{
51+
get;
52+
set;
53+
}
54+
55+
[Parameter(
56+
Position = 1,
57+
Mandatory = true,
58+
ValueFromPipelineByPropertyName = true,
59+
HelpMessage = "Uri to blob")]
60+
[ValidateNotNullOrEmpty]
61+
[Alias("src")]
62+
public Uri Source
63+
{
64+
get;
65+
set;
66+
}
67+
68+
[Parameter(
69+
Position = 2,
70+
Mandatory = true,
71+
HelpMessage = "Local path of the vhd file")]
72+
[ValidateNotNullOrEmpty]
73+
[Alias("lf")]
74+
public FileInfo LocalFilePath
75+
{
76+
get;
77+
set;
78+
}
79+
80+
private int numberOfThreads = DefaultNumberOfUploaderThreads;
81+
82+
[Parameter(
83+
Position = 3,
84+
Mandatory = false,
85+
HelpMessage = "Number of downloader threads")]
86+
[ValidateNotNullOrEmpty]
87+
[ValidateRange(1, 64)]
88+
[Alias("th")]
89+
public int NumberOfThreads
90+
{
91+
get { return this.numberOfThreads; }
92+
set { this.numberOfThreads = value; }
93+
}
94+
95+
[Parameter(
96+
Position = 4,
97+
Mandatory = false,
98+
HelpMessage = "Delete the local file if already exists")]
99+
[ValidateNotNullOrEmpty]
100+
[Alias("o")]
101+
public SwitchParameter OverWrite
102+
{
103+
get;
104+
set;
105+
}
106+
107+
protected override void ProcessRecord()
108+
{
109+
BlobUri blobUri;
110+
if (!BlobUri.TryParseUri(Source, out blobUri))
111+
{
112+
throw new ArgumentOutOfRangeException("Source", Source.ToString());
113+
}
114+
115+
var storageKey = this.StorageKey;
116+
if (this.StorageKey == null)
117+
{
118+
var storageClient = AzureSession.ClientFactory.CreateClient<StorageManagementClient>(
119+
DefaultProfile.Context, AzureEnvironment.Endpoint.ResourceManager);
120+
121+
122+
var storageService = storageClient.StorageAccounts.GetProperties(this.ResourceGroupName, blobUri.StorageAccountName);
123+
if (storageService != null)
124+
{
125+
var storageKeys = storageClient.StorageAccounts.ListKeys(this.ResourceGroupName, storageService.StorageAccount.Name);
126+
storageKey = storageKeys.StorageAccountKeys.Key1;
127+
}
128+
}
129+
130+
var downloaderParameters = new DownloaderParameters
131+
{
132+
BlobUri = blobUri,
133+
LocalFilePath = LocalFilePath.FullName,
134+
ConnectionLimit = NumberOfThreads,
135+
StorageAccountKey = storageKey,
136+
ValidateFreeDiskSpace = true,
137+
OverWrite = OverWrite
138+
};
139+
140+
var vhdDownloadContext = VhdDownloaderModel.Download(downloaderParameters, this);
141+
WriteObject(vhdDownloadContext);
142+
}
143+
}
144+
}

src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Config/AddAzureVMDataDiskCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class AddAzureVMDataDiskCommand : Microsoft.Azure.Commands.ResourceManage
6060
ValueFromPipelineByPropertyName = true,
6161
HelpMessage = HelpMessages.VMDataDiskCaching)]
6262
[ValidateNotNullOrEmpty]
63-
[ValidateSet(ValidateSetValues.ReadOnly, ValidateSetValues.ReadWrite)]
63+
[ValidateSet(ValidateSetValues.ReadOnly, ValidateSetValues.ReadWrite, ValidateSetValues.None)]
6464
public string Caching { get; set; }
6565

6666
[Parameter(

src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Config/SetAzureVMDataDiskCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class SetAzureVMDataDiskCommand : Microsoft.Azure.Commands.ResourceManage
6868
ValueFromPipelineByPropertyName = true,
6969
HelpMessage = HelpMessages.VMDataDiskCaching)]
7070
[ValidateNotNullOrEmpty]
71-
[ValidateSet(ValidateSetValues.ReadOnly, ValidateSetValues.ReadWrite)]
71+
[ValidateSet(ValidateSetValues.ReadOnly, ValidateSetValues.ReadWrite, ValidateSetValues.None)]
7272
public string Caching { get; set; }
7373

7474
[Parameter(

src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Config/SetAzureVMOSDiskCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public class SetAzureVMOSDiskCommand : Microsoft.Azure.Commands.ResourceManager.
6565
ValueFromPipelineByPropertyName = true,
6666
HelpMessage = HelpMessages.VMOSDiskCaching)]
6767
[ValidateNotNullOrEmpty]
68-
[ValidateSet(ValidateSetValues.ReadOnly, ValidateSetValues.ReadWrite)]
68+
[ValidateSet(ValidateSetValues.ReadOnly, ValidateSetValues.ReadWrite, ValidateSetValues.None)]
6969
public string Caching { get; set; }
7070

7171
[Alias("SourceImage")]

src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Operation/NewAzureVMCommand.cs

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

15+
using AutoMapper;
1516
using Microsoft.Azure.Commands.Compute.Common;
1617
using Microsoft.Azure.Commands.Compute.Models;
17-
using Microsoft.Azure.Commands.Tags.Model;
1818
using Microsoft.Azure.Management.Compute;
1919
using Microsoft.Azure.Management.Compute.Models;
2020
using System.Collections;
@@ -23,6 +23,7 @@
2323
namespace Microsoft.Azure.Commands.Compute
2424
{
2525
[Cmdlet(VerbsCommon.New, ProfileNouns.VirtualMachine)]
26+
[OutputType(typeof(PSComputeLongRunningOperation))]
2627
public class NewAzureVMCommand : VirtualMachineBaseCmdlet
2728
{
2829
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true)]
@@ -61,7 +62,8 @@ protected override void ProcessRecord()
6162
};
6263

6364
var op = this.VirtualMachineClient.CreateOrUpdate(this.ResourceGroupName, parameters);
64-
WriteObject(op);
65+
var result = Mapper.Map<PSComputeLongRunningOperation>(op);
66+
WriteObject(result);
6567
});
6668
}
6769
}

0 commit comments

Comments
 (0)