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] Migrate resource to track2 SDK #17783

Merged
merged 4 commits into from
May 12, 2021
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
36 changes: 15 additions & 21 deletions src/azure-cli/azure/cli/command_modules/acs/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1032,23 +1032,21 @@ def _invoke_deployment(cmd, resource_group_name, deployment_name, template, para
properties = DeploymentProperties(template=template, parameters=parameters, mode='incremental')
smc = get_mgmt_service_client(cmd.cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES,
subscription_id=subscription_id).deployments

Deployment = cmd.get_models('Deployment', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
deployment = Deployment(properties=properties)

if validate:
logger.info('==== BEGIN TEMPLATE ====')
logger.info(json.dumps(template, indent=2))
logger.info('==== END TEMPLATE ====')

if cmd.supported_api_version(min_api='2019-10-01', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES):
Deployment = cmd.get_models('Deployment', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
deployment = Deployment(properties=properties)

if validate:
validation_poller = smc.validate(resource_group_name, deployment_name, deployment)
if cmd.supported_api_version(min_api='2019-10-01', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES):
validation_poller = smc.begin_validate(resource_group_name, deployment_name, deployment)
return LongRunningOperation(cmd.cli_ctx)(validation_poller)
return sdk_no_wait(no_wait, smc.create_or_update, resource_group_name, deployment_name, deployment)

if validate:
return smc.validate(resource_group_name, deployment_name, properties)
return sdk_no_wait(no_wait, smc.create_or_update, resource_group_name, deployment_name, properties)
return smc.validate(resource_group_name, deployment_name, deployment)
Juliehzl marked this conversation as resolved.
Show resolved Hide resolved

return sdk_no_wait(no_wait, smc.begin_create_or_update, resource_group_name, deployment_name, deployment)


def k8s_get_credentials(cmd, client, name, resource_group_name,
Expand Down Expand Up @@ -3248,16 +3246,12 @@ def _ensure_default_log_analytics_workspace_for_monitoring(cmd, subscription_id,
else:
resource_groups.create_or_update(default_workspace_resource_group, {'location': workspace_region})

default_workspace_params = {
'location': workspace_region,
'properties': {
'sku': {
'name': 'standalone'
}
}
}
async_poller = resources.create_or_update_by_id(default_workspace_resource_id, '2015-11-01-preview',
default_workspace_params)
from azure.cli.core.profiles import ResourceType
GenericResource = cmd.get_models('GenericResource', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
generic_resource = GenericResource(location=workspace_region, properties={'sku': {'name': 'standalone'}})

async_poller = resources.begin_create_or_update_by_id(default_workspace_resource_id, '2015-11-01-preview',
generic_resource)

ws_resource_id = ''
while True:
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,10 @@ def create_domain(cmd, resource_group_name, hostname, contact_info, privacy=True
client = get_mgmt_service_client(cmd.cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES).deployments
DeploymentProperties = cmd.get_models('DeploymentProperties', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
properties = DeploymentProperties(template=template, parameters={}, mode='incremental')

if cmd.supported_api_version(min_api='2019-10-01', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES):
Deployment = cmd.get_models('Deployment', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
deployment = Deployment(properties=properties)

deployment_result = DeploymentOutputLongRunningOperation(cmd.cli_ctx)(
sdk_no_wait(no_wait, client.create_or_update, resource_group_name, deployment_name, deployment))
else:
deployment_result = DeploymentOutputLongRunningOperation(cmd.cli_ctx)(
sdk_no_wait(no_wait, client.create_or_update, resource_group_name, deployment_name, properties))
Deployment = cmd.get_models('Deployment', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
deployment = Deployment(properties=properties)
deployment_result = DeploymentOutputLongRunningOperation(cmd.cli_ctx)(
sdk_no_wait(no_wait, client.begin_create_or_update, resource_group_name, deployment_name, deployment))

return deployment_result

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def create_appserviceenvironment_arm(cmd, resource_group_name, name, subnet, kin
subnet_id=subnet_id, kind='ASEv3')
logger.info('Create App Service Environment...')
deployment_client = _get_resource_client_factory(cmd.cli_ctx).deployments
return sdk_no_wait(no_wait, deployment_client.create_or_update,
return sdk_no_wait(no_wait, deployment_client.begin_create_or_update,
resource_group_name, deployment_name, ase_deployment_properties)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,11 @@ def test_app_service_environment_create(self, ase_client_factory_mock, network_c
ignore_network_security_group=True, ignore_route_table=True,
location='westeurope')

# Assert create_or_update is called with correct rg and deployment name
resource_client_mock.deployments.create_or_update.assert_called_once()
self.assertEqual(resource_client_mock.deployments.create_or_update.call_args[0][0], rg_name)
self.assertEqual(resource_client_mock.deployments.create_or_update.call_args[0][1], deployment_name)
# Assert begin_create_or_update is called with correct rg and deployment name
resource_client_mock.deployments.begin_create_or_update.assert_called_once()
call_args = resource_client_mock.deployments.begin_create_or_update.call_args
self.assertEqual(call_args[0][0], rg_name)
self.assertEqual(call_args[0][1], deployment_name)

@mock.patch('azure.cli.command_modules.appservice.appservice_environment._get_location_from_resource_group', autospec=True)
@mock.patch('azure.cli.command_modules.appservice.appservice_environment._get_ase_client_factory', autospec=True)
Expand Down Expand Up @@ -211,10 +212,11 @@ def test_app_service_environment_v3_create(self, ase_client_factory_mock, networ
subnet=subnet_name, vnet_name=vnet_name, kind='ASEv3',
location='westeurope')

# Assert create_or_update is called with correct rg and deployment name
resource_client_mock.deployments.create_or_update.assert_called_once()
self.assertEqual(resource_client_mock.deployments.create_or_update.call_args[0][0], rg_name)
self.assertEqual(resource_client_mock.deployments.create_or_update.call_args[0][1], deployment_name)
# Assert begin_create_or_update is called with correct rg and deployment name
resource_client_mock.deployments.begin_create_or_update.assert_called_once()
call_args = resource_client_mock.deployments.begin_create_or_update.call_args
self.assertEqual(call_args[0][0], rg_name)
self.assertEqual(call_args[0][1], deployment_name)


if __name__ == '__main__':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,12 @@ def deploy_arm_template(cmd, resource_group_name, # pylint: disable=too-many-ar

properties = DeploymentProperties(template=template, template_link=None,
parameters=parameters, mode=mode)
Deployment = cmd.get_models('Deployment', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
deployment = Deployment(properties=properties)

resource_mgmt_client = get_mgmt_service_client(cmd.cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES).deployments

if cmd.supported_api_version(min_api='2019-10-01', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES):
Deployment = cmd.get_models('Deployment', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
deployment = Deployment(properties=properties)
deployment_poller = resource_mgmt_client.create_or_update(resource_group_name, deployment_name, deployment)
else:
deployment_poller = resource_mgmt_client.create_or_update(resource_group_name, deployment_name, properties)
deployment_poller = resource_mgmt_client.begin_create_or_update(resource_group_name, deployment_name,
deployment)

return LongRunningOperation(cmd.cli_ctx, 'Deploying ARM Tempalte')(deployment_poller)

Expand Down
4 changes: 2 additions & 2 deletions src/azure-cli/azure/cli/command_modules/container/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,8 @@ def container_export(cmd, resource_group_name, name, file):
'',
"containerGroups",
name,
container_group_client.api_version,
False).__dict__
container_group_client.api_version).__dict__

# Remove unwanted properites
resource['properties'].pop('instanceView', None)
resource.pop('sku', None)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
|Scenario|Result|ErrorMessage|ErrorStack|ErrorNormalized|StartDt|EndDt|
|step_device_create|successed||||2020-12-08 08:53:08.187377|2020-12-08 08:53:15.694106|
|step_device_show|successed||||2020-12-08 08:53:24.625022|2020-12-08 08:53:27.072164|
|step_device_list|successed||||2020-12-08 08:53:35.316539|2020-12-08 08:53:35.803951|
|step_device_list2|successed||||2020-12-08 08:53:18.661886|2020-12-08 08:53:19.430990|
|step_device_update|successed||||2020-12-08 08:53:19.430990|2020-12-08 08:53:24.624053|
|step_device_delete|successed||||2020-12-08 08:53:27.072164|2020-12-08 08:53:35.316539|
|step_device_create|successed||||2021-04-14 08:27:17.186809|2021-04-14 08:27:18.959151|
|step_device_show|successed||||2021-04-14 08:27:19.477764|2021-04-14 08:27:19.610764|
|step_device_list|successed||||2021-04-14 08:27:19.724763|2021-04-14 08:27:19.856764|
|step_device_list2|successed||||2021-04-14 08:27:19.221150|2021-04-14 08:27:19.339763|
|step_device_update|successed||||2021-04-14 08:27:19.339763|2021-04-14 08:27:19.476763|
|step_device_delete|successed||||2021-04-14 08:27:19.613764|2021-04-14 08:27:19.723764|
Coverage: 6/6
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
|Scenario|Result|ErrorMessage|ErrorStack|ErrorNormalized|StartDt|EndDt|
|step_list_sku|successed||||2020-12-08 08:53:08.229344|2020-12-08 08:53:08.585716|
|step_list_sku|successed||||2021-04-14 08:27:17.167296|2021-04-14 08:27:18.966150|
Coverage: 1/1
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
|Scenario|Result|ErrorMessage|ErrorStack|ErrorNormalized|StartDt|EndDt|
|step_device_create|successed||||2020-12-08 08:53:08.185376|2020-12-08 08:53:14.434966|
|step_order_create|successed||||2020-12-08 08:53:14.443005|2020-12-08 08:54:18.003579|
|step_order_show|successed||||2020-12-08 08:54:18.004577|2020-12-08 08:54:19.514589|
|step_order_list|successed||||2020-12-08 08:54:55.166716|2020-12-08 08:54:56.677546|
|step_order_delete|successed||||2020-12-08 08:54:20.993150|2020-12-08 08:54:55.165713|
|step_device_delete|successed||||2020-12-08 08:54:56.677546|2020-12-08 08:55:03.651581|
|step_device_create|successed||||2021-04-14 08:27:17.207808|2021-04-14 08:27:18.962149|
|step_order_create|successed||||2021-04-14 08:27:18.962149|2021-04-14 08:27:20.372280|
|step_order_show|successed||||2021-04-14 08:27:20.372280|2021-04-14 08:27:20.501315|
|step_order_list|successed||||2021-04-14 08:27:20.798342|2021-04-14 08:27:20.957341|
|step_order_delete|successed||||2021-04-14 08:27:20.631342|2021-04-14 08:27:20.798342|
|step_device_delete|successed||||2021-04-14 08:27:20.958341|2021-04-14 08:27:21.117341|
Coverage: 6/6
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
|Scenario|Result|ErrorMessage|ErrorStack|ErrorNormalized|StartDt|EndDt|
|step_device_create|successed||||2021-04-20 08:09:08.608349|2021-04-20 08:09:08.670648|
|step_device_show|successed||||2021-04-20 08:09:08.821395|2021-04-20 08:09:08.851546|
|step_device_list|successed||||2021-04-20 08:09:08.891952|2021-04-20 08:09:08.930348|
|step_device_list2|successed||||2021-04-20 08:09:08.740943|2021-04-20 08:09:08.781153|
|step_device_update|successed||||2021-04-20 08:09:08.781153|2021-04-20 08:09:08.821395|
|step_device_delete|successed||||2021-04-20 08:09:08.851546|2021-04-20 08:09:08.891952|
|step_device_create|successed||||2021-04-20 04:35:29.869012|2021-04-20 04:35:30.443009|
|step_device_show|successed||||2021-04-20 04:35:31.949064|2021-04-20 04:35:32.266062|
|step_device_list|successed||||2021-04-20 04:35:32.704571|2021-04-20 04:35:33.109077|
|step_device_list2|successed||||2021-04-20 04:35:31.208025|2021-04-20 04:35:31.615043|
|step_device_update|successed||||2021-04-20 04:35:31.616044|2021-04-20 04:35:31.949064|
|step_device_delete|successed||||2021-04-20 04:35:32.267061|2021-04-20 04:35:32.704571|
Coverage: 6/6
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
|Scenario|Result|ErrorMessage|ErrorStack|ErrorNormalized|StartDt|EndDt|
|step_device_create|successed||||2021-04-20 08:09:08.608349|2021-04-20 08:09:08.670648|
|step_device_show|successed||||2021-04-20 08:09:08.821395|2021-04-20 08:09:08.851546|
|step_device_list|successed||||2021-04-20 08:09:08.891952|2021-04-20 08:09:08.930348|
|step_device_list2|successed||||2021-04-20 08:09:08.740943|2021-04-20 08:09:08.781153|
|step_device_update|successed||||2021-04-20 08:09:08.781153|2021-04-20 08:09:08.821395|
|step_device_delete|successed||||2021-04-20 08:09:08.851546|2021-04-20 08:09:08.891952|
|step_list_sku|successed||||2021-04-20 08:09:08.952524|2021-04-20 08:09:08.992749|
|step_device_create|successed||||2021-04-20 04:35:29.869012|2021-04-20 04:35:30.443009|
|step_device_show|successed||||2021-04-20 04:35:31.949064|2021-04-20 04:35:32.266062|
|step_device_list|successed||||2021-04-20 04:35:32.704571|2021-04-20 04:35:33.109077|
|step_device_list2|successed||||2021-04-20 04:35:31.208025|2021-04-20 04:35:31.615043|
|step_device_update|successed||||2021-04-20 04:35:31.616044|2021-04-20 04:35:31.949064|
|step_device_delete|successed||||2021-04-20 04:35:32.267061|2021-04-20 04:35:32.704571|
|step_list_sku|successed||||2021-04-20 04:35:33.453611|2021-04-20 04:35:33.798611|
Coverage: 7/7
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
|Scenario|Result|ErrorMessage|ErrorStack|ErrorNormalized|StartDt|EndDt|
|step_device_create|successed||||2021-04-20 08:09:09.030949|2021-04-20 08:09:09.063238|
|step_device_show|successed||||2021-04-20 08:09:08.821395|2021-04-20 08:09:08.851546|
|step_device_list|successed||||2021-04-20 08:09:08.891952|2021-04-20 08:09:08.930348|
|step_device_list2|successed||||2021-04-20 08:09:08.740943|2021-04-20 08:09:08.781153|
|step_device_update|successed||||2021-04-20 08:09:08.781153|2021-04-20 08:09:08.821395|
|step_device_delete|successed||||2021-04-20 08:09:12.298288|2021-04-20 08:09:12.338485|
|step_list_sku|successed||||2021-04-20 08:09:08.952524|2021-04-20 08:09:08.992749|
|step_order_create|successed||||2021-04-20 08:09:09.063238|2021-04-20 08:09:10.419631|
|step_order_show|successed||||2021-04-20 08:09:10.419631|2021-04-20 08:09:10.459870|
|step_order_list|successed||||2021-04-20 08:09:12.268177|2021-04-20 08:09:12.298288|
|step_order_delete|successed||||2021-04-20 08:09:10.490003|2021-04-20 08:09:12.268177|
|step_device_create|successed||||2021-04-20 04:35:34.158635|2021-04-20 04:35:34.554633|
|step_device_show|successed||||2021-04-20 04:35:31.949064|2021-04-20 04:35:32.266062|
|step_device_list|successed||||2021-04-20 04:35:32.704571|2021-04-20 04:35:33.109077|
|step_device_list2|successed||||2021-04-20 04:35:31.208025|2021-04-20 04:35:31.615043|
|step_device_update|successed||||2021-04-20 04:35:31.616044|2021-04-20 04:35:31.949064|
|step_device_delete|successed||||2021-04-20 04:36:04.142692|2021-04-20 04:36:04.495718|
|step_list_sku|successed||||2021-04-20 04:35:33.453611|2021-04-20 04:35:33.798611|
|step_order_create|successed||||2021-04-20 04:35:34.555632|2021-04-20 04:35:46.652334|
|step_order_show|successed||||2021-04-20 04:35:46.653334|2021-04-20 04:35:47.001843|
|step_order_list|successed||||2021-04-20 04:36:03.764159|2021-04-20 04:36:04.141691|
|step_order_delete|successed||||2021-04-20 04:35:47.428399|2021-04-20 04:36:03.764159|
Coverage: 11/11
Loading