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

[ARM] Add new parameter to support adding managedBy information for az group create #11796

Merged
merged 2 commits into from
Jan 30, 2020
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
1 change: 1 addition & 0 deletions src/azure-cli/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Release History
* Fix issue #11658: `az group export` command does not support `--query` and `--output` parameters
* Fix issue #10279: The exit code of `az group deployment validate` is 0 when the verification fails
* Fix issue #9916: Improve the error message of the conflict between tag and other filter conditions for `az resource list` command
* Add new parameter `--managed-by` to support adding managedBy information for command `az group create`

**Azure Red Hat OpenShift**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ class ResourceCommandsLoader(AzCommandsLoader):
def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azure.cli.core import ModExtensionSuppress
from azure.cli.core.profiles import ResourceType
resource_custom = CliCommandType(operations_tmpl='azure.cli.command_modules.resource.custom#{}')
super(ResourceCommandsLoader, self).__init__(cli_ctx=cli_ctx,
resource_type=ResourceType.MGMT_RESOURCE_RESOURCES,
custom_command_type=resource_custom,
suppress_extension=ModExtensionSuppress(
__name__, 'managementgroups', '0.1.0',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ def load_arguments(self, _):

with self.argument_context('group create') as c:
c.argument('rg_name', options_list=['--name', '--resource-group', '-n', '-g'], help='name of the new resource group', completer=None)
c.argument('managed_by', min_api='2016-09-01', help='The ID of the resource that manages this resource group.')

with self.argument_context('tag') as c:
c.argument('tag_name', options_list=['--name', '-n'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ def list_resource_groups(cmd, tag=None): # pylint: disable=no-self-use
return list(groups)


def create_resource_group(cmd, rg_name, location, tags=None):
def create_resource_group(cmd, rg_name, location, tags=None, managed_by=None):
""" Create a new resource group.
:param str resource_group_name:the desired resource group name
:param str location:the resource group location
Expand All @@ -740,6 +740,10 @@ def create_resource_group(cmd, rg_name, location, tags=None):
location=location,
tags=tags
)

if cmd.supported_api_version(min_api='2016-09-01'):
parameters.managed_by = managed_by

return rcf.resource_groups.create_or_update(rg_name, parameters)


Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ interactions:
ParameterSetName:
- -n --no-wait --yes
User-Agent:
- python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2
azure-mgmt-resource/4.0.0 Azure-SDK-For-Python AZURECLI/2.0.75
- python/3.8.0 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2
azure-mgmt-resource/6.0.0 Azure-SDK-For-Python AZURECLI/2.0.79
accept-language:
- en-US
method: DELETE
Expand All @@ -30,19 +30,19 @@ interactions:
content-length:
- '0'
date:
- Mon, 21 Oct 2019 05:11:56 GMT
- Wed, 08 Jan 2020 02:37:51 GMT
expires:
- '-1'
location:
- https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1DTEk6NUZSRzo1Rk5PV0FJVDo1RlRFU1Q1UlRDS1hMRFNZVVNIQ0hCUDZMTExDSnw1NkE3Qzk0NkM4QzFGRkFGLVdFU1RVUyIsImpvYkxvY2F0aW9uIjoid2VzdHVzIn0?api-version=2019-07-01
- https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1DTEk6NUZSRzo1Rk5PV0FJVDo1RlRFU1RLT1pNRE81REdVNVhXM1hFMlhES0hZQXxENEFGOTlENTNERjhDNjAyLVdFU1RVUyIsImpvYkxvY2F0aW9uIjoid2VzdHVzIn0?api-version=2019-07-01
pragma:
- no-cache
strict-transport-security:
- max-age=31536000; includeSubDomains
x-content-type-options:
- nosniff
x-ms-ratelimit-remaining-subscription-deletes:
- '14999'
- '14998'
status:
code: 202
message: Accepted
Expand All @@ -60,15 +60,15 @@ interactions:
ParameterSetName:
- --deleted -n
User-Agent:
- python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2
azure-mgmt-resource/4.0.0 Azure-SDK-For-Python AZURECLI/2.0.75
- python/3.8.0 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2
azure-mgmt-resource/6.0.0 Azure-SDK-For-Python AZURECLI/2.0.79
accept-language:
- en-US
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_rg_nowait_test000001?api-version=2019-07-01
response:
body:
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_rg_nowait_test000001","name":"cli_rg_nowait_test000001","type":"Microsoft.Resources/resourceGroups","location":"westus","tags":{"product":"azurecli","cause":"automation","date":"2019-10-21T05:11:40Z"},"properties":{"provisioningState":"Deleting"}}'
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_rg_nowait_test000001","name":"cli_rg_nowait_test000001","type":"Microsoft.Resources/resourceGroups","location":"westus","tags":{"product":"azurecli","cause":"automation","date":"2020-01-08T02:37:41Z"},"properties":{"provisioningState":"Deleting"}}'
headers:
cache-control:
- no-cache
Expand All @@ -77,7 +77,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Mon, 21 Oct 2019 05:11:56 GMT
- Wed, 08 Jan 2020 02:37:52 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -105,15 +105,15 @@ interactions:
ParameterSetName:
- --deleted -n
User-Agent:
- python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2
azure-mgmt-resource/4.0.0 Azure-SDK-For-Python AZURECLI/2.0.75
- python/3.8.0 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2
azure-mgmt-resource/6.0.0 Azure-SDK-For-Python AZURECLI/2.0.79
accept-language:
- en-US
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_rg_nowait_test000001?api-version=2019-07-01
response:
body:
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_rg_nowait_test000001","name":"cli_rg_nowait_test000001","type":"Microsoft.Resources/resourceGroups","location":"westus","tags":{"product":"azurecli","cause":"automation","date":"2019-10-21T05:11:40Z"},"properties":{"provisioningState":"Deleting"}}'
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_rg_nowait_test000001","name":"cli_rg_nowait_test000001","type":"Microsoft.Resources/resourceGroups","location":"westus","tags":{"product":"azurecli","cause":"automation","date":"2020-01-08T02:37:41Z"},"properties":{"provisioningState":"Deleting"}}'
headers:
cache-control:
- no-cache
Expand All @@ -122,7 +122,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Mon, 21 Oct 2019 05:12:26 GMT
- Wed, 08 Jan 2020 02:38:22 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -150,53 +150,8 @@ interactions:
ParameterSetName:
- --deleted -n
User-Agent:
- python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2
azure-mgmt-resource/4.0.0 Azure-SDK-For-Python AZURECLI/2.0.75
accept-language:
- en-US
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_rg_nowait_test000001?api-version=2019-07-01
response:
body:
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_rg_nowait_test000001","name":"cli_rg_nowait_test000001","type":"Microsoft.Resources/resourceGroups","location":"westus","tags":{"product":"azurecli","cause":"automation","date":"2019-10-21T05:11:40Z"},"properties":{"provisioningState":"Deleting"}}'
headers:
cache-control:
- no-cache
content-length:
- '427'
content-type:
- application/json; charset=utf-8
date:
- Mon, 21 Oct 2019 05:12:56 GMT
expires:
- '-1'
pragma:
- no-cache
strict-transport-security:
- max-age=31536000; includeSubDomains
vary:
- Accept-Encoding
x-content-type-options:
- nosniff
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
CommandName:
- group wait
Connection:
- keep-alive
ParameterSetName:
- --deleted -n
User-Agent:
- python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2
azure-mgmt-resource/4.0.0 Azure-SDK-For-Python AZURECLI/2.0.75
- python/3.8.0 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2
azure-mgmt-resource/6.0.0 Azure-SDK-For-Python AZURECLI/2.0.79
accept-language:
- en-US
method: GET
Expand All @@ -213,7 +168,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Mon, 21 Oct 2019 05:13:27 GMT
- Wed, 08 Jan 2020 02:38:52 GMT
expires:
- '-1'
pragma:
Expand Down Expand Up @@ -241,8 +196,8 @@ interactions:
ParameterSetName:
- -n
User-Agent:
- python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2
azure-mgmt-resource/4.0.0 Azure-SDK-For-Python AZURECLI/2.0.75
- python/3.8.0 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2
azure-mgmt-resource/6.0.0 Azure-SDK-For-Python AZURECLI/2.0.79
accept-language:
- en-US
method: HEAD
Expand All @@ -258,7 +213,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Mon, 21 Oct 2019 05:13:27 GMT
- Wed, 08 Jan 2020 02:38:53 GMT
expires:
- '-1'
pragma:
Expand All @@ -273,7 +228,7 @@ interactions:
code: 404
message: Not Found
- request:
body: '{"location": "westus"}'
body: '{"location": "westus", "managedBy": "test_admin"}'
headers:
Accept:
- application/json
Expand All @@ -284,30 +239,30 @@ interactions:
Connection:
- keep-alive
Content-Length:
- '22'
- '49'
Content-Type:
- application/json; charset=utf-8
ParameterSetName:
- -n -l
- -n -l --managed-by
User-Agent:
- python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2
azure-mgmt-resource/4.0.0 Azure-SDK-For-Python AZURECLI/2.0.75
- python/3.8.0 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2
azure-mgmt-resource/6.0.0 Azure-SDK-For-Python AZURECLI/2.0.79
accept-language:
- en-US
method: PUT
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_rg_nowait_test000001?api-version=2019-07-01
response:
body:
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_rg_nowait_test000001","name":"cli_rg_nowait_test000001","type":"Microsoft.Resources/resourceGroups","location":"westus","properties":{"provisioningState":"Succeeded"}}'
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_rg_nowait_test000001","name":"cli_rg_nowait_test000001","type":"Microsoft.Resources/resourceGroups","location":"westus","managedBy":"test_admin","properties":{"provisioningState":"Succeeded"}}'
headers:
cache-control:
- no-cache
content-length:
- '347'
- '372'
content-type:
- application/json; charset=utf-8
date:
- Mon, 21 Oct 2019 05:13:30 GMT
- Wed, 08 Jan 2020 02:38:59 GMT
expires:
- '-1'
pragma:
Expand All @@ -317,7 +272,7 @@ interactions:
x-content-type-options:
- nosniff
x-ms-ratelimit-remaining-subscription-writes:
- '1191'
- '1198'
status:
code: 201
message: Created
Expand All @@ -335,8 +290,8 @@ interactions:
ParameterSetName:
- -n
User-Agent:
- python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2
azure-mgmt-resource/4.0.0 Azure-SDK-For-Python AZURECLI/2.0.75
- python/3.8.0 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2
azure-mgmt-resource/6.0.0 Azure-SDK-For-Python AZURECLI/2.0.79
accept-language:
- en-US
method: HEAD
Expand All @@ -350,7 +305,7 @@ interactions:
content-length:
- '0'
date:
- Mon, 21 Oct 2019 05:13:30 GMT
- Wed, 08 Jan 2020 02:39:00 GMT
expires:
- '-1'
pragma:
Expand All @@ -376,24 +331,24 @@ interactions:
ParameterSetName:
- --exists -n
User-Agent:
- python/3.7.4 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2
azure-mgmt-resource/4.0.0 Azure-SDK-For-Python AZURECLI/2.0.75
- python/3.8.0 (Windows-10-10.0.18362-SP0) msrest/0.6.10 msrest_azure/0.6.2
azure-mgmt-resource/6.0.0 Azure-SDK-For-Python AZURECLI/2.0.79
accept-language:
- en-US
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_rg_nowait_test000001?api-version=2019-07-01
response:
body:
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_rg_nowait_test000001","name":"cli_rg_nowait_test000001","type":"Microsoft.Resources/resourceGroups","location":"westus","properties":{"provisioningState":"Succeeded"}}'
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_rg_nowait_test000001","name":"cli_rg_nowait_test000001","type":"Microsoft.Resources/resourceGroups","location":"westus","managedBy":"test_admin","properties":{"provisioningState":"Succeeded"}}'
headers:
cache-control:
- no-cache
content-length:
- '347'
- '372'
content-type:
- application/json; charset=utf-8
date:
- Mon, 21 Oct 2019 05:13:31 GMT
- Wed, 08 Jan 2020 02:39:00 GMT
expires:
- '-1'
pragma:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ def test_resource_group(self, resource_group):
self.cmd('group exists -n {rg}',
checks=self.check('@', False))

self.cmd('group create -n {rg} -l westus --tag a=b c', checks=[
self.cmd('group create -n {rg} -l westus --tag a=b c --managed-by test_admin', checks=[
self.check('name', '{rg}'),
self.check('tags', {'a': 'b', 'c': ''})
self.check('tags', {'a': 'b', 'c': ''}),
self.check('managedBy', 'test_admin')
])
self.cmd('group exists -n {rg}',
checks=self.check('@', True))
Expand Down Expand Up @@ -65,8 +66,10 @@ def test_resource_group_no_wait(self, resource_group):
checks=self.is_empty())
self.cmd('group exists -n {rg}',
checks=self.check('@', False))
self.cmd('group create -n {rg} -l westus',
checks=self.check('name', '{rg}'))
self.cmd('group create -n {rg} -l westus --managed-by test_admin', checks=[
self.check('name', '{rg}'),
self.check('managedBy', 'test_admin')
])
self.cmd('group exists -n {rg}',
checks=self.check('@', True))
self.cmd('group wait --exists -n {rg}',
Expand Down