Skip to content

Commit

Permalink
Merge pull request Azure#38 from hyonholee/dev
Browse files Browse the repository at this point in the history
Test fixes
  • Loading branch information
AzureRT committed Sep 22, 2015
2 parents 0e653f5 + 94916b9 commit 5d233d9
Show file tree
Hide file tree
Showing 37 changed files with 1,250 additions and 693 deletions.
1,018 changes: 781 additions & 237 deletions setup/azurecmdfiles.wxi

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/Common/Storage/Azure.Storage.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
TypesToProcess = @(
'.\Microsoft.WindowsAzure.Commands.Storage.Types.ps1xml'
'.\Microsoft.WindowsAzure.Commands.Storage.Types.ps1xml'
)

# Format files (.ps1xml) to be loaded when importing this module
FormatsToProcess = @(
'.\Microsoft.WindowsAzure.Commands.Storage.format.ps1xml'
'.\Microsoft.WindowsAzure.Commands.Storage.format.ps1xml'
)

# Modules to import as nested modules of the module specified in ModuleToProcess
NestedModules = @(
'.\Microsoft.WindowsAzure.Commands.Storage.dll',
'.\Microsoft.WindowsAzure.Commands.Storage.dll'
)

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

# Aliases to export from this module
AliasesToExport = @(
'Get-AzureRMStorageContainerAcl',
'Get-AzureRMStorageContainerAcl',
'Start-CopyAzureStorageBlob',
'Stop-CopyAzureStorageBlob'
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.AzureBackup\</OutputPath>
<OutputPath>..\..\..\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.Backup\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -30,7 +30,7 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>..\..\..\Package\Release\ResourceManager\AzureResourceManager\AzureRM.AzureBackup\</OutputPath>
<OutputPath>..\..\..\Package\Release\ResourceManager\AzureResourceManager\AzureRM.Backup\</OutputPath>
<DefineConstants>TRACE;SIGN</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
Expand Down Expand Up @@ -192,8 +192,8 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="..\AzureRM.AzureBackup.psd1">
<Link>AzureRM.AzureBackup.psd1</Link>
<None Include="..\AzureRM.Backup.psd1">
<Link>AzureRM.Backup.psd1</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Microsoft.Azure.Commands.AzureBackup.dll-help.psd1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.AzureBatch\</OutputPath>
<OutputPath>..\..\..\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.Batch\</OutputPath>
<DefineConstants>TRACE;DEBUG;CODE_ANALYSIS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -30,7 +30,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\..\Package\Release\ResourceManager\AzureResourceManager\AzureRM.AzureBatch\</OutputPath>
<OutputPath>..\..\..\Package\Release\ResourceManager\AzureResourceManager\AzureRM.Batch\</OutputPath>
<DefineConstants>TRACE;SIGN</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,15 @@
<Compile Include="Models\PSVirtualMachineSize.cs" />
<Compile Include="Common\LocationStringExtensions.cs" />
<Compile Include="Models\UploadParameters.cs" />
<Compile Include="Models\VhdDownloadContext.cs" />
<Compile Include="Models\VhdDownloaderModel.cs" />
<Compile Include="Models\VhdUploadContext.cs" />
<Compile Include="Models\VhdUploaderModel.cs" />
<Compile Include="RemoteDesktop\VirtualMachineRemoteDesktopBaseCmdlet.cs" />
<Compile Include="RemoteDesktop\GetAzureRemoteDesktopFileCommand.cs" />
<Compile Include="StorageServices\AddAzureVhdCommand.cs" />
<Compile Include="StorageServices\CloudPageBlobObjectFactory.cs" />
<Compile Include="StorageServices\SaveAzureVhdCommand.cs" />
<Compile Include="StorageServices\StorageCredentialsFactory.cs" />
<Compile Include="Usage\GetAzureVMUsageCommand.cs" />
<Compile Include="Usage\VirtualMachineUsageBaseCmdlet.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public static class ValidateSetValues
{
public const string ReadOnly = "ReadOnly";
public const string ReadWrite = "ReadWrite";
public const string None = "None";
}

public static class ProfileNouns
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ----------------------------------------------------------------------------------
//
// 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.IO;

namespace Microsoft.Azure.Commands.Compute.Models
{
public class VhdDownloadContext
{
public FileInfo LocalFilePath { get; set; }
public Uri Source { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// ----------------------------------------------------------------------------------
//
// 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 Microsoft.WindowsAzure.Commands.Sync;
using Microsoft.WindowsAzure.Commands.Sync.Download;
using System.IO;

namespace Microsoft.Azure.Commands.Compute.Models
{
public class VhdDownloaderModel
{
public static VhdDownloadContext Download(DownloaderParameters downloadParameters, ComputeClientBaseCmdlet cmdlet)
{
Program.SyncOutput = new PSSyncOutputEvents(cmdlet);

downloadParameters.ProgressDownloadComplete = Program.SyncOutput.ProgressDownloadComplete;
downloadParameters.ProgressDownloadStatus = Program.SyncOutput.ProgressDownloadStatus;

var downloader = new Downloader(downloadParameters);
downloader.Download();

return new VhdDownloadContext
{
LocalFilePath = new FileInfo(downloadParameters.LocalFilePath),
Source = downloadParameters.BlobUri.Uri
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public UploadParameters ValidateParameters()
}
}

var storageCredentialsFactory = CreateStorageCredentialsFactory(destinationUri);
var storageCredentialsFactory = CreateStorageCredentialsFactory();

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

private StorageCredentialsFactory CreateStorageCredentialsFactory(BlobUri destinationUri)
private StorageCredentialsFactory CreateStorageCredentialsFactory()
{
StorageCredentialsFactory storageCredentialsFactory;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
// ----------------------------------------------------------------------------------
//
// 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 Microsoft.Azure.Commands.Compute.Common;
using Microsoft.Azure.Commands.Compute.Models;
using Microsoft.Azure.Common.Authentication;
using Microsoft.Azure.Common.Authentication.Models;
using Microsoft.Azure.Management.Storage;
using Microsoft.WindowsAzure.Commands.Sync.Download;
using System;
using System.IO;
using System.Management.Automation;

namespace Microsoft.Azure.Commands.Compute.StorageServices
{
[Cmdlet(VerbsData.Save, ProfileNouns.Vhd), OutputType(typeof(VhdDownloadContext))]
public class SaveAzureVhdCommand : ComputeClientBaseCmdlet
{
private const int DefaultNumberOfUploaderThreads = 8;
private const string ResourceGroupParameterSet = "ResourceGroupParameterSetName";
private const string StorageKeyParameterSet = "StorageKeyParameterSetName";

[Parameter(
Position = 0,
Mandatory = true,
ParameterSetName = ResourceGroupParameterSet,
ValueFromPipelineByPropertyName = true)]
[ValidateNotNullOrEmpty]
public string ResourceGroupName { get; set; }

[Parameter(
Position = 0,
Mandatory = true,
ParameterSetName = StorageKeyParameterSet,
HelpMessage = "Key of the storage account")]
[ValidateNotNullOrEmpty]
[Alias("sk")]
public string StorageKey
{
get;
set;
}

[Parameter(
Position = 1,
Mandatory = true,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Uri to blob")]
[ValidateNotNullOrEmpty]
[Alias("src")]
public Uri Source
{
get;
set;
}

[Parameter(
Position = 2,
Mandatory = true,
HelpMessage = "Local path of the vhd file")]
[ValidateNotNullOrEmpty]
[Alias("lf")]
public FileInfo LocalFilePath
{
get;
set;
}

private int numberOfThreads = DefaultNumberOfUploaderThreads;

[Parameter(
Position = 3,
Mandatory = false,
HelpMessage = "Number of downloader threads")]
[ValidateNotNullOrEmpty]
[ValidateRange(1, 64)]
[Alias("th")]
public int NumberOfThreads
{
get { return this.numberOfThreads; }
set { this.numberOfThreads = value; }
}

[Parameter(
Position = 4,
Mandatory = false,
HelpMessage = "Delete the local file if already exists")]
[ValidateNotNullOrEmpty]
[Alias("o")]
public SwitchParameter OverWrite
{
get;
set;
}

protected override void ProcessRecord()
{
BlobUri blobUri;
if (!BlobUri.TryParseUri(Source, out blobUri))
{
throw new ArgumentOutOfRangeException("Source", Source.ToString());
}

var storageKey = this.StorageKey;
if (this.StorageKey == null)
{
var storageClient = AzureSession.ClientFactory.CreateClient<StorageManagementClient>(
DefaultProfile.Context, AzureEnvironment.Endpoint.ResourceManager);


var storageService = storageClient.StorageAccounts.GetProperties(this.ResourceGroupName, blobUri.StorageAccountName);
if (storageService != null)
{
var storageKeys = storageClient.StorageAccounts.ListKeys(this.ResourceGroupName, storageService.StorageAccount.Name);
storageKey = storageKeys.StorageAccountKeys.Key1;
}
}

var downloaderParameters = new DownloaderParameters
{
BlobUri = blobUri,
LocalFilePath = LocalFilePath.FullName,
ConnectionLimit = NumberOfThreads,
StorageAccountKey = storageKey,
ValidateFreeDiskSpace = true,
OverWrite = OverWrite
};

var vhdDownloadContext = VhdDownloaderModel.Download(downloaderParameters, this);
WriteObject(vhdDownloadContext);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class AddAzureVMDataDiskCommand : Microsoft.Azure.Commands.ResourceManage
ValueFromPipelineByPropertyName = true,
HelpMessage = HelpMessages.VMDataDiskCaching)]
[ValidateNotNullOrEmpty]
[ValidateSet(ValidateSetValues.ReadOnly, ValidateSetValues.ReadWrite)]
[ValidateSet(ValidateSetValues.ReadOnly, ValidateSetValues.ReadWrite, ValidateSetValues.None)]
public string Caching { get; set; }

[Parameter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class SetAzureVMDataDiskCommand : Microsoft.Azure.Commands.ResourceManage
ValueFromPipelineByPropertyName = true,
HelpMessage = HelpMessages.VMDataDiskCaching)]
[ValidateNotNullOrEmpty]
[ValidateSet(ValidateSetValues.ReadOnly, ValidateSetValues.ReadWrite)]
[ValidateSet(ValidateSetValues.ReadOnly, ValidateSetValues.ReadWrite, ValidateSetValues.None)]
public string Caching { get; set; }

[Parameter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class SetAzureVMOSDiskCommand : Microsoft.Azure.Commands.ResourceManager.
ValueFromPipelineByPropertyName = true,
HelpMessage = HelpMessages.VMOSDiskCaching)]
[ValidateNotNullOrEmpty]
[ValidateSet(ValidateSetValues.ReadOnly, ValidateSetValues.ReadWrite)]
[ValidateSet(ValidateSetValues.ReadOnly, ValidateSetValues.ReadWrite, ValidateSetValues.None)]
public string Caching { get; set; }

[Alias("SourceImage")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using AutoMapper;
using Microsoft.Azure.Commands.Compute.Common;
using Microsoft.Azure.Commands.Compute.Models;
using Microsoft.Azure.Commands.Tags.Model;
using Microsoft.Azure.Management.Compute;
using Microsoft.Azure.Management.Compute.Models;
using System.Collections;
Expand All @@ -23,6 +23,7 @@
namespace Microsoft.Azure.Commands.Compute
{
[Cmdlet(VerbsCommon.New, ProfileNouns.VirtualMachine)]
[OutputType(typeof(PSComputeLongRunningOperation))]
public class NewAzureVMCommand : VirtualMachineBaseCmdlet
{
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true)]
Expand Down Expand Up @@ -61,7 +62,8 @@ protected override void ProcessRecord()
};

var op = this.VirtualMachineClient.CreateOrUpdate(this.ResourceGroupName, parameters);
WriteObject(op);
var result = Mapper.Map<PSComputeLongRunningOperation>(op);
WriteObject(result);
});
}
}
Expand Down
Loading

0 comments on commit 5d233d9

Please sign in to comment.