Skip to content

RemoteApp cmdlet bug fixes #297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
</Reference>
<Reference Include="Microsoft.Azure.Management.RemoteApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RemoteApp.1.0.8\lib\net40\Microsoft.Azure.Management.RemoteApp.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RemoteApp.1.0.9\lib\net40\Microsoft.Azure.Management.RemoteApp.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,14 @@ public static int SetUpDefaultRemoteAppCollectionSet(Mock<IRemoteAppManagementCl
new TrackingResult(response)
};

ISetup<IRemoteAppManagementClient, Task<OperationResultWithTrackingId>> setup = clientMock.Setup(c => c.Collections.SetAsync(It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<bool>(), It.IsAny<CollectionCreationDetails>(), It.IsAny<CancellationToken>()));
ISetup<IRemoteAppManagementClient, Task<OperationResultWithTrackingId>> setup =
clientMock.Setup(
c => c.Collections.SetAsync(
collectionName,
It.IsAny<bool>(),
It.IsAny<bool>(),
It.IsAny<CollectionUpdateDetails>(),
It.IsAny<CancellationToken>()));
setup.Returns(Task.Factory.StartNew(() => response));

mockCollectionList = collectionList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected RemoteAppClientTest()
StatusCode = System.Net.HttpStatusCode.OK
};
mgmtClient = new Mock<WindowsAzure.Management.ManagementClient>();
setup = mgmtClient.Setup(c => c.Subscriptions.RegisterResourceAsync(It.IsAny<string>(), It.IsAny<CancellationToken>()));
setup = mgmtClient.Setup(c => c.Subscriptions.RegisterResourceAsync("remoteapp", It.IsAny<CancellationToken>()));
setup.Returns(Task.Factory.StartNew(() => response));

RemoteAppCmdlet = new T()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<package id="Hyak.Common" version="1.0.2" targetFramework="net45" />
<package id="Microsoft.Azure.Common" version="2.0.4" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.RemoteApp" version="1.0.8" targetFramework="net45" />
<package id="Microsoft.Azure.Management.RemoteApp" version="1.0.9" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.RemoteApp;
using Microsoft.Azure.Management.RemoteApp;
using Microsoft.Azure.Management.RemoteApp.Models;
using System;
using System.Management.Automation;
using System.Net;

namespace Microsoft.Azure.Management.RemoteApp.Cmdlets
{
[Cmdlet(VerbsCommon.Set, "AzureRemoteAppCollection"), OutputType(typeof(TrackingResult))]
[Cmdlet(VerbsCommon.Set, "AzureRemoteAppCollection", DefaultParameterSetName = DescriptionOnly), OutputType(typeof(TrackingResult))]
public class SetAzureRemoteAppCollection : RdsCmdlet
{
private const string DomainJoined = "DomainJoined";
private const string NoDomain = "NoDomain";
private const string RdpPropertyOnly = "RdpPropertyOnly";
private const string DescriptionOnly = "DescriptionOnly";
private const string PlanOnly = "PlanOnly";

[Parameter(Mandatory = true,
Position = 0,
Expand All @@ -35,37 +36,38 @@ public class SetAzureRemoteAppCollection : RdsCmdlet
[Alias("Name")]
public string CollectionName { get; set; }

[Parameter(Mandatory = false,
Position = 1,
[Parameter(Mandatory = true,
ValueFromPipelineByPropertyName = true,
ParameterSetName = PlanOnly,
HelpMessage = "Plan to use for this collection. Use Get-AzureRemoteAppPlan to see the plans available.")]
[ValidateNotNullOrEmpty]
public string Plan { get; set; }

[Parameter(Mandatory = false,
Position = 2,
[Parameter(Mandatory = true,
ValueFromPipelineByPropertyName = true,
ParameterSetName = DomainJoined,
HelpMessage = "Credentials of a user that has permission to add computers to the domain.")]
[ValidateNotNull]
public PSCredential Credential { get; set; }

[Parameter(Mandatory = false,
[Parameter(Mandatory = true,
ValueFromPipelineByPropertyName = true,
ParameterSetName = DescriptionOnly,
HelpMessage = "Description of what this collection is used for.")]
[ValidateNotNullOrEmpty]
[ValidateNotNull]
public string Description { get; set; }

[Parameter(Mandatory = false,
[Parameter(Mandatory = true,
ValueFromPipelineByPropertyName = true,
ParameterSetName = RdpPropertyOnly,
HelpMessage = "Used to allow RDP redirection.")]
[ValidateNotNullOrEmpty]
[ValidateNotNull]
public string CustomRdpProperty { get; set; }

public override void ExecuteCmdlet()
{
NetworkCredential creds = null;
CollectionCreationDetails details = null;
CollectionUpdateDetails details = null;
OperationResultWithTrackingId response = null;
Collection collection = null;
bool forceRedeploy = false;
Expand All @@ -76,57 +78,61 @@ public override void ExecuteCmdlet()
return;
}

details = new CollectionCreationDetails()
{
Name = CollectionName,
PlanName = String.IsNullOrWhiteSpace(Plan) ? collection.PlanName : Plan,
Description = String.IsNullOrWhiteSpace(Description) ? collection.Description : Description,
CustomRdpProperty = String.IsNullOrWhiteSpace(CustomRdpProperty) ? collection.CustomRdpProperty : CustomRdpProperty,
TemplateImageName = collection.TemplateImageName
};
details = new CollectionUpdateDetails();

switch (ParameterSetName)
if (Credential != null)
{
case DomainJoined:
{
if (collection.AdInfo == null)
{
ErrorRecord er = RemoteAppCollectionErrorState.CreateErrorRecordFromString(
Commands_RemoteApp.AadInfoCanNotBeAddedToCloudOnlyCollectionMessage,
String.Empty,
Client.Collections,
ErrorCategory.InvalidArgument);
ThrowTerminatingError(er);
}

details.AdInfo = new ActiveDirectoryConfig();
details.VNetName = collection.VNetName;
details.AdInfo.DomainName = collection.AdInfo.DomainName;
details.AdInfo.OrganizationalUnit = collection.AdInfo.OrganizationalUnit;

if (Credential != null)
{
creds = Credential.GetNetworkCredential();
details.AdInfo.UserName = creds.UserName;
details.AdInfo.Password = creds.Password;
}

if (String.Equals("Inactive", collection.Status, StringComparison.OrdinalIgnoreCase))
{
// the collection may have failed due to bad domain join information before,
// re-trying with the new information
forceRedeploy = true;
}

break;
}
if (collection.AdInfo == null)
{
ErrorRecord er = RemoteAppCollectionErrorState.CreateErrorRecordFromString(
Commands_RemoteApp.AadInfoCanNotBeAddedToCloudOnlyCollectionMessage,
String.Empty,
Client.Collections,
ErrorCategory.InvalidArgument);
ThrowTerminatingError(er);
}

details.AdInfo = new ActiveDirectoryConfig();

creds = Credential.GetNetworkCredential();
details.AdInfo.UserName = Credential.UserName;
details.AdInfo.Password = creds.Password;
details.AdInfo.DomainName = collection.AdInfo.DomainName;
details.AdInfo.OrganizationalUnit = collection.AdInfo.OrganizationalUnit;

if (String.Equals("Inactive", collection.Status, StringComparison.OrdinalIgnoreCase))
{
// the collection may have failed due to bad domain join information before,
// re-trying with the new information
forceRedeploy = true;
}
}
else if (Plan != null)
{
details.PlanName = Plan;
}
else if (Description != null)
{
details.Description = Description;
}
else if (CustomRdpProperty != null)
{
details.CustomRdpProperty = CustomRdpProperty;
}
else
{
ErrorRecord er = RemoteAppCollectionErrorState.CreateErrorRecordFromString(
"At least one parameter must be set with this cmdlet",
String.Empty,
Client.Collections,
ErrorCategory.InvalidArgument);
ThrowTerminatingError(er);
}

response = CallClient(() => Client.Collections.Set(CollectionName, forceRedeploy, false, details), Client.Collections);
if (response != null)
{
TrackingResult trackingId = new TrackingResult(response);
WriteObject(trackingId);
WriteTrackingId(response);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,36 +38,35 @@ public class UpdateAzureRemoteAppCollection : RdsCmdlet
public string ImageName { get; set; }

[Parameter(Mandatory = false,
HelpMessage = "Immediately log off users after update has successfully completed")]
HelpMessage = "Log off users immediately after the update has successfully completed")]
public SwitchParameter ForceLogoffWhenUpdateComplete { get; set; }

public override void ExecuteCmdlet()
{
CollectionCreationDetails details = null;
CollectionUpdateDetails details = null;
OperationResultWithTrackingId response = null;
Collection collection = null;

collection = FindCollection(CollectionName);
if (collection == null)
{
return;
}

if (collection != null)
details = new CollectionUpdateDetails()
{
details = new CollectionCreationDetails()
{
Name = CollectionName,
TemplateImageName = ImageName,
PlanName = collection.PlanName,
WaitBeforeShutdownInMinutes = ForceLogoffWhenUpdateComplete ? -1 : 0
};
TemplateImageName = ImageName,
WaitBeforeShutdownInMinutes = ForceLogoffWhenUpdateComplete ? -1 : 0
};

if (ShouldProcess(CollectionName, Commands_RemoteApp.UpdateCollection))
{
response = CallClient(() => Client.Collections.Set(CollectionName, true, false, details), Client.Collections);
}
if (ShouldProcess(CollectionName, Commands_RemoteApp.UpdateCollection))
{
response = CallClient(() => Client.Collections.Set(CollectionName, true, false, details), Client.Collections);
}

if (response != null)
{
WriteTrackingId(response);
}
if (response != null)
{
WriteTrackingId(response);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</Reference>
<Reference Include="Microsoft.Azure.Management.RemoteApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RemoteApp.1.0.8\lib\net40\Microsoft.Azure.Management.RemoteApp.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.RemoteApp.1.0.9\lib\net40\Microsoft.Azure.Management.RemoteApp.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Data.Edm, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Data.Edm.5.6.0\lib\net40\Microsoft.Data.Edm.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,18 +211,6 @@ protected Collection FindCollection(string CollectionName)
ErrorCategory.ObjectNotFound
);

WriteError(er);
}
else if (!String.Equals(response.Collection.Status, "Active", StringComparison.OrdinalIgnoreCase))
{
ErrorRecord er = RemoteAppCollectionErrorState.CreateErrorRecordFromString(
String.Format("Collection {0} is not in the Active state",
response.Collection.Name),
String.Empty,
Client.Collections,
ErrorCategory.InvalidOperation
);

WriteError(er);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<package id="Microsoft.Azure.Common" version="2.0.4" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Authentication" version="1.0.17-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.RemoteApp" version="1.0.8" targetFramework="net45" />
<package id="Microsoft.Azure.Management.RemoteApp" version="1.0.9" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
Expand Down