Skip to content

V2A AAD Changes #4843

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 8 commits into from
Nov 6, 2017
Merged

V2A AAD Changes #4843

merged 8 commits into from
Nov 6, 2017

Conversation

viverm
Copy link
Contributor

@viverm viverm commented Oct 24, 2017

Description


This checklist is used to make sure that common guidelines for a pull request are followed. You can find a more complete discussion of PowerShell cmdlet best practices here.

General Guidelines

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.
  • The pull request does not introduce breaking changes (unless a major version change occurs in the assembly and module).

Testing Guidelines

  • Pull request includes test coverage for the included changes.
  • PowerShell scripts used in tests should do any necessary setup as part of the test or suite setup, and should not use hard-coded values for locations or existing resources.

Cmdlet Signature Guidelines

  • New cmdlets that make changes or have side effects should implement ShouldProcess and have SupportShouldProcess=true specified in the cmdlet attribute. You can find more information on ShouldProcess here.
  • Cmdlet specifies OutputType attribute if any output is produced - if the cmdlet produces no output, it should implement a PassThru parameter.

Cmdlet Parameter Guidelines

  • Parameter types should not expose types from the management library - complex parameter types should be defined in the module.
  • Complex parameter types are discouraged - a parameter type should be simple types as often as possible. If complex types are used, they should be shallow and easily creatable from a constructor or another cmdlet.
  • Cmdlet parameter sets should be mutually exclusive - each parameter set must have at least one mandatory parameter not in other parameter sets.

Copy link
Member

@cormacpayne cormacpayne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm some comments that need to be addressed

In addition, please make sure of the following:

  1. You have updated the RecoveryServices.SiteRecovery change log with information about the changes being made in this PR

  2. You have enabled all three piping scenarios (where applicable) to the New/Remove/Set/Start/Stop/Update, etc cmdlets (I left a comment for this one somewhere in the PR)

  3. Please cleanup the commits in this PR so that it is easier to review for both sides. I would split them up so one commit has test changes, one has the test json files, one has the new cmdlets, and another has miscellaneous updates made. You can read about how to update your commits here

@@ -12,7 +12,7 @@
# RootModule = ''

# Version number of this module.
ModuleVersion = '0.1.6'
ModuleVersion = '0.1.5'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm looks like a bad merge caused some unnecessary changes in this file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to 0.1.6

FileAccess.Read,
FileShare.Read))
{
if (File.ReadAllText(this.vaultSettingsFilePath).ToLower().Contains("<asrvaultcreds"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm to read from/write to files, use DataStore.ReadFromFileStream() from in the FileUtilities class in Commands.Common

https://github.com/Azure/azure-powershell/blob/preview/src/Common/Commands.Common/Utilities/FileUtilities.cs#L41

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used FileUtilities.DataStore.ReadFileAsText method

/// <summary>
/// Sets Azure Site Revcovery Notification / Alert.
/// </summary>
[Cmdlet(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm it looks like you're missing the SupportsShouldProcess property in this cmdlt attribute

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was the miss . Added that again.

/// Gets or sets EmailSubscriptionOwner .Mail to subscription owner.
/// </summary>
[Parameter(ParameterSetName = ASRParameterSets.EmailToSubscriptionOwner, Mandatory = true)]
public SwitchParameter EmailSubscriptionOwners { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm this should be renamed to EnableEmailSubscriptionOwners

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

VerbsCommon.Set))
{
base.ExecuteSiteRecoveryCmdlet();
if (this.ShouldProcess(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm why is there two calls to this.ShouldProcess and base.ExecuteSiteRecoveryCmdlet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

[Parameter(ParameterSetName = ASRParameterSets.ByParam)]
[Parameter(ParameterSetName = ASRParameterSets.ByFabricId)]
[ValidateNotNullOrEmpty]
public ASRFabric Fabric { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm does Fabric contain a FabricId?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

/// Gets or sets Resource Id.
/// </summary>
[Parameter(ParameterSetName = ASRParameterSets.ByFabricId, Mandatory = true)]
public string FabricId { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm what exactly is FabricId?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Id of ASRFabric.

[Parameter(ParameterSetName = ASRParameterSets.ByParam)]
[Parameter(ParameterSetName = ASRParameterSets.ByFabricId)]
[ValidateNotNullOrEmpty]
public DateTime StartTime { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm should there be a corresponding EndTime parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already there . But reordered below StartTime to give better visibility.

/// Gets or sets Resource Id.
/// </summary>
[Parameter(ParameterSetName = ASRParameterSets.ByResourceId, Mandatory = true)]
public string ResourceId { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm anywhere that you are using a ResourceId parameter, it should have the property ValueFromPipelineByPropertyName = true so users are able to pipe the result of Get/Find-AzureRmResource to a cmdlet with a ResourceId parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

/// </summary>
[Parameter(Mandatory = true, ValueFromPipeline = true)]
[ValidateNotNullOrEmpty]
public ASRFabric Fabric { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm parameter set for ResourceId of Fabric being provided? Please make sure that all cmldets that should support piping have the following three scenarios enabled:

  1. By object - involves using an InputObject parameter that has ValueFromPipeline = true
  2. By resource id - involves using a ResourceId parameter that has ValueFromPipelineByPropertyName = true
  3. By command line - involves using a Name and ResourceGroupName parameter with no ability to accept its value from the pipeline; this is your default parameter set

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First two scenario fits for ASR.
Getting the PSObject by Name and ResourceGroupName parameter is not possible in ASR Case we need additional parameter like vault , protection container etc on case to case basis.
Name is mainly server generated Id and hard to remember.

@markcowl
Copy link
Member

@viverm It looks like you haven't committed and pushed the changes you mention in your responses to review comments.

@viverm
Copy link
Contributor Author

viverm commented Nov 1, 2017

Error during build

https://azuresdkci.westus2.cloudapp.azure.com/job/powershell/322/console

Saw similar error with other PR builds/

d:\workspace\powershell\src\ResourceManager\Common\Commands.ScenarioTests.ResourceManager.Common\EnvironmentSetupHelper.cs(427): error : Microsoft.Azure.Commands.Sql.Test.ScenarioTests.VirtualNetworkRuleTest.TestVirtualNetworkRuleRemove [FAIL] [d:\workspace\powershell\build.proj]
04:47:22 d:\workspace\powershell\src\ResourceManager\Common\Commands.ScenarioTests.ResourceManager.Common\EnvironmentSetupHelper.cs(427): error : Microsoft.Azure.Commands.Sql.Test.ScenarioTests.VirtualNetworkRuleTest.TestVirtualNetworkRuleCreateAndUpdate [FAIL] [d:\workspace\powershell\build.proj]
04:47:22 d:\workspace\powershell\src\ResourceManager\Common\Commands.ScenarioTests.ResourceManager.Common\EnvironmentSetupHelper.cs(427): error : Microsoft.Azure.Commands.Sql.Test.ScenarioTests.VirtualNetworkRuleTest.TestVirtualNetworkRuleGet [FAIL] [d:\workspace\powershell\build.proj]

@cormacpayne
Copy link
Member

cormacpayne commented Nov 2, 2017

Copy link
Member

@cormacpayne cormacpayne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm a few additional comments

I kicked off an on-demand job, and I suspect that StaticAnalysis will fail from the breaking change tool and/or signature verifier. If so, please check the Build Artifacts of the job, and look for the severity 0 or 1 exceptions in the BreakingChangeIssues.csv and/or SignatureIssues.csv files

@@ -170,7 +231,7 @@ PrivateData = @{
Tags = 'Azure','ResourceManager','ARM','SiteRecovery'

# A URL to the license for this module.
LicenseUri = 'https://aka.ms/azps-license'
LicenseUri = 'https://raw.githubusercontent.com/Azure/azure-powershell/preview/LICENSE.txt'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm please revert this change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -153,7 +155,7 @@ public static string GetDefaultPath()
throw new Exception("Invalid ARM ID");
}

for (var i = 1; i < armFields.Length; i = i + 2)
for (var i = 0; i < armFields.Length; i = i + 2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm shouldn't this always fail with an IndexOutOfRangeException?

For example, if armFields has five elements, this loop will get the following elements:

i == 0: 1st (idx 0) and 2nd (idx 1)
i == 2: 3rd (idx 2) and 4th (idx 3)
i == 4: 5th (idx 4) and 6th (idx 5 DOESN'T EXIST!)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we were expecting things in pair like 1st will be the 2nd the value .
We are using the other utility method to get the value .this call is not used anymore .
Marked this as part of cleanup activity,

@@ -75,25 +76,28 @@ public override void ExecuteSiteRecoveryCmdlet()
{
using (var powerShell = System.Management.Automation.PowerShell.Create())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm if the powerShell object is not being used anymore, we should remove the using

@@ -148,6 +148,20 @@ public override void ExecuteSiteRecoveryCmdlet()
VmId = ((HyperVReplicaBlueReplicationDetails)item
.Properties.ProviderSpecificDetails).VmId;
}
else if (item.Properties.ProviderSpecificDetails
.GetType() ==
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm nit: for the lines where .GetType() is by itself, can you tab it to be consistent with the other instances of it above

It looks like this is also the case in NewAzureRmRecoveryServicesAsrRecoveryPlan.cs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@viverm viverm assigned cormacpayne and unassigned viverm Nov 2, 2017
Copy link
Member

@cormacpayne cormacpayne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm a few minor questions, otherwise LGTM

[Parameter(ParameterSetName = ASRParameterSets.ByParam)]
[Parameter(ParameterSetName = ASRParameterSets.ByFabricId)]
[ValidateNotNullOrEmpty]
public ASRFabric Fabric { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm raising this again - if a Fabric has a FabricId, why does the user need to provide one? It seems like you're just using it to get the Name of the fabric, but you already receive the name from the mandatory Fabric parameter that a user would pass.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can make is mutually exclusive and break in two paramset. If the user has fabricId or fabricObject he can directly call it.

/// <summary>
/// ProcessRecord of the command.
/// </summary>
public override void ExecuteSiteRecoveryCmdlet()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm can we add a parameter set that allows users to provide a Fabric and Name? This will be the default parameter set that will take care of the command line scenario and is similar to what is done with the Get-AsrVCenter cmdlet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure.

if (this.ShouldProcess(vCenterName, VerbsCommon.Remove))
{
var response = this.RecoveryServicesClient.RemoveAzureRmSiteRecoveryvCenter(
fabricName,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viverm just a general question for cmdlets that have a Fabric parameter (and this might have been discussed already): why don't we make the user provide a FabricName parameter instead of the entire object? That way, they don't have to get the Fabric object each time they want to run these cmdlets and can just provide a string instead. Is the FabricName hard to discover for the user, or difficult to remember?

Copy link
Contributor Author

@viverm viverm Nov 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fabric Name is ASR generated id which is unique . It is Difficult for user to remember and pass it. user will store and pass it so he can fabric object like he is doing in other cmdlets.

@markcowl markcowl changed the base branch from preview to release-5.0.0 November 2, 2017 23:24
@cormacpayne
Copy link
Member

@viverm
Copy link
Contributor Author

viverm commented Nov 6, 2017

@cormacpayne cormacpayne merged commit e82c8a2 into Azure:release-5.0.0 Nov 6, 2017
@viverm viverm deleted the Final_V2A_AAD branch November 19, 2017 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants