Skip to content
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

Add management groups commands to azure-cli-resource #6426

Merged
merged 13 commits into from
May 31, 2018

Conversation

rajshah11
Copy link
Contributor


This checklist is used to make sure that common guidelines for a pull request are followed.

  • The PR has modified HISTORY.rst describing any customer-facing, functional changes. Note that this does not include changes only to help content. (see Modifying change log).

  • I adhere to the Command Guidelines.

@promptws
Copy link

View a preview at https://prompt.ws/r/Azure/azure-cli/6426
This is an experimental preview for @microsoft users.

@rajshah11
Copy link
Contributor Author

The SDK is in PR Azure/azure-sdk-for-python#2520. I have tested by downloading the wheel into the "privates" folder. The SDK will be merged and release once this PR is given a thumbs up. Adding @lmazuel

Copy link
Member

@tjprescott tjprescott left a comment

Choose a reason for hiding this comment

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

To transition from an extension to being in the CLI, a command review is required. Please reach out to schedule.

@@ -3,6 +3,10 @@
Release History
===============

2.0.30
++++++
* Add management-group commands
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be more explicit especially since these commands live in the command tree that is predominantly in a different module.
"* add account management-group commands."

Copy link
Contributor Author

@rajshah11 rajshah11 May 24, 2018

Choose a reason for hiding this comment

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

Ok will make this change. Also, just checked the travis build. Will make the changes.

@@ -33,7 +33,8 @@
DEPENDENCIES = [
'azure-mgmt-resource==1.2.1',
'azure-cli-core',
'azure-mgmt-authorization==0.40.0'
'azure-mgmt-authorization==0.40.0',
'azure-mgmt-managementgroups==2018-03-01-preview'
Copy link
Member

Choose a reason for hiding this comment

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

Just to be sure we're on the same page 2018-03-01-preview is a temporary version picked by the SDK CI, actual final version will be 0.1.0.
So once we're done here, final step will be:

  • I release the SDK as 0.1.0 on PyPI
  • You do a last commit here that removes the "privates" folder, and change this line to 0.1.0

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. That's right.

Copy link
Member

@tjprescott tjprescott left a comment

Choose a reason for hiding this comment

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

Summary of changes we discussed during the review:

  • all examples need to be updated
  • remove --group-name and just use --name
  • --parent-id should be just --parent and accept the name or ID of another management group

@tjprescott tjprescott added this to the Sprint 38 milestone May 30, 2018
Copy link
Member

@tjprescott tjprescott left a comment

Choose a reason for hiding this comment

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

Some feedback on certain implementation details. Didn't see anything obvious that would be not working about parent.

@@ -1077,8 +1077,119 @@ def update_policy_setdefinition(cmd, policy_set_definition_name, definitions=Non
return policy_client.policy_set_definitions.create_or_update(policy_set_definition_name, parameters)


def _register_rp(cli_ctx, subscription_id=None):
Copy link
Member

Choose a reason for hiding this comment

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

Why is this in here? @yugangw-msft @lmazuel correct me if I'm wrong but msrest will automatically handle this, correct?

Copy link
Contributor Author

@rajshah11 rajshah11 May 30, 2018

Choose a reason for hiding this comment

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

You can look at the discussion here - Azure/azure-cli-extensions#62. Not sure if the issue has been resolved.


def cli_managementgroups_group_update_get():
update_parameters = {'display_name': None, 'parent': None}
return update_parameters
Copy link
Member

Choose a reason for hiding this comment

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

Instead of creating a dictionary, you could just create the PatchManagementGroupRequest object here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do. Thanks!

parent=None):
instance["display_name"] = display_name
instance["parent"] = parent
return instance
Copy link
Member

Choose a reason for hiding this comment

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

If the instance is the object, these simply become instance.foo = foo. A little cleaner.

parent_id=_get_parent_id_from_parent(parameters["parent"])
from azure.mgmt.managementgroups.models import PatchManagementGroupRequest
patch_mgmt_grp_request = PatchManagementGroupRequest(display_name=parameters["display_name"], parent_id=parent_id)
return client.update(group_name, patch_mgmt_grp_request)
Copy link
Member

Choose a reason for hiding this comment

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

This could be made cleaner:

def cli_managmentgroups_group_update_set(…):
   return client.update(group_name, parameters)

@troydai
Copy link
Contributor

troydai commented May 30, 2018

@rajshah11 the sprint 38 will close by the end of tomorrow. Please make sure this PR is merged by then.

@rajshah11 rajshah11 force-pushed the cli-mgmt-grp branch 3 times, most recently from ebee1a0 to 385ff5d Compare May 31, 2018 00:17
@rajshah11
Copy link
Contributor Author

rajshah11 commented May 31, 2018

I have made all the suggested changes and fixed some of the build errors. However, there are still a few errors. Can someone please look into this build and assist me in removing those errors - https://travis-ci.org/Azure/azure-cli/builds/385959671?utm_source=github_status&utm_medium=notification?

Firstly, I am getting an error saying
FAIL: unrecognized_help_parameter_rule
Help-Entry: account management-group subscription add - The following parameter help names are invalid: --subscription
Help-Entry: account management-group subscription remove - The following parameter help names are invalid: --subscription

However, account management-group subscription add -h does show the parameter and command works as well.

Also, the automation tests are failing but the tests run properly on my machine.

Copy link
Member

@tjprescott tjprescott left a comment

Choose a reason for hiding this comment

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

@codecov-io
Copy link

codecov-io commented May 31, 2018

Codecov Report

Merging #6426 into dev will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@         Coverage Diff         @@
##           dev   #6426   +/-   ##
===================================
  Coverage    0%      0%           
===================================
  Files       11      11           
  Lines      133     133           
  Branches     9       9           
===================================
  Misses     133     133

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2cd0ed3...e73a0a6. Read the comment docs.

@tjprescott
Copy link
Member

Also please make sure you are running azdev style before pushing your changes. That way you'll find out quickly if there are pylint/pep8 errors instead of waiting for the CI to tell you.

helps['account management-group create'] = """
type: command
short-summary: Create a new management group.
long-summary: Create a new management group.
Copy link
Member

Choose a reason for hiding this comment

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

long-summary should provide additional information, instead of being a duplicate of short-summary.

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.

8 participants