def test_register_resource_type_bad_profile(self): test_profile = {'latest': {ResourceType.MGMT_STORAGE: '2020-10-10'}} with mock.patch('azure.cli.core.profiles.API_PROFILES', test_profile): custom_rt = CustomResourceType('mysdkpath', 'myClient') with self.assertRaises(ValueError): register_resource_type('doesnotexist', custom_rt, '2020-12-12-preview')
def test_register_resource_type_valid(self): test_profile = {'latest': {ResourceType.MGMT_STORAGE: '2020-10-10'}} with mock.patch('azure.cli.core.profiles.API_PROFILES', test_profile): custom_rt = CustomResourceType('mysdkpath', 'myClient') register_resource_type('latest', custom_rt, '2020-12-12-preview') from azure.cli.core.profiles import API_PROFILES self.assertDictEqual( API_PROFILES, { 'latest': { ResourceType.MGMT_STORAGE: '2020-10-10', custom_rt: '2020-12-12-preview' } })
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- from azure.cli.core.profiles import CustomResourceType CUSTOM_DATA_STORAGE = CustomResourceType( 'azext_storage_preview.vendored_sdks.azure_storage', None) CUSTOM_DATA_STORAGE_ADLS = CustomResourceType( 'azext_storage_preview.vendored_sdks.azure_adls_storage_preview', None) CUSTOM_MGMT_STORAGE = CustomResourceType( 'azext_storage_preview.vendored_sdks.azure_mgmt_storage', 'StorageManagementClient') CUSTOM_MGMT_PREVIEW_STORAGE = CustomResourceType( 'azext_storage_preview.vendored_sdks.azure_mgmt_preview_storage', 'StorageManagementClient')
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- from azure.cli.core.profiles import CustomResourceType CUSTOM_NW_CONNECTION_MONITOR = CustomResourceType( 'azext_connection_monitor_preview.vendored_sdks.v2019_11_01', 'NetworkManagementClient') CUSTOM_NW_CONNECTION_MONITOR_V1 = CustomResourceType( 'azext_connection_monitor_preview.vendored_sdks.v2019_06_01', 'NetworkManagementClient')
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- from azure.cli.core.profiles import CustomResourceType CUSTOM_DATA_STORAGE = CustomResourceType('azext_storage_preview.vendored_sdks.azure_storage', None)
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- from azure.cli.core.profiles import CustomResourceType CUSTOM_MGMT_STORAGE_ORS = CustomResourceType('azext_storage_ors_preview.vendored_sdks.azure_mgmt_storage', 'StorageManagementClient')
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- from azure.cli.core.profiles import CustomResourceType CUSTOM_DATA_STORAGE = CustomResourceType( 'azext_storage_preview.vendored_sdks.azure_storage', None) CUSTOM_DATA_STORAGE_ADLS = CustomResourceType( 'azext_storage_preview.vendored_sdks.azure_adls_storage_preview', None) CUSTOM_MGMT_STORAGE = CustomResourceType( 'azext_storage_preview.vendored_sdks.azure_mgmt_storage', 'StorageManagementClient') CUSTOM_DATA_STORAGE_FILESHARE = CustomResourceType( 'azext_storage_preview.vendored_sdks.azure_storagev2.fileshare', None) CUSTOM_DATA_STORAGE_FILEDATALAKE = CustomResourceType( 'azext_storage_preview.vendored_sdks.azure_storage_filedatalake', None)
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- from azure.cli.core.profiles import CustomResourceType CUSTOM_ER_CC = CustomResourceType('azext_expressroutecrossconnection.vendored_sdks', 'NetworkManagementClient')
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- from azure.cli.core.profiles import CustomResourceType CUSTOM_DATA_STORAGE_BLOB = CustomResourceType('azext_storage_blob_preview.vendored_sdks.azure_storage_blob', 'BlobClient')
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- from azure.cli.core.profiles import CustomResourceType CUSTOM_DATA_STORAGE_BLOB = CustomResourceType( 'azext_storage_blob_preview.vendored_sdks.azure_storage_blob', 'BlobClient') CUSTOM_MGMT_STORAGE = CustomResourceType( 'azext_storage_blob_preview.vendored_sdks.azure_mgmt_storage', 'StorageManagementClient')
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- from azure.cli.core.profiles import CustomResourceType CUSTOM_FIREWALL = CustomResourceType( 'azext_firewall.vendored_sdks.v2020_07_01', 'NetworkManagementClient')
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- from azure.cli.core.profiles import CustomResourceType CUSTOM_IP_GROUPS = CustomResourceType('azext_ip_group.vendored_sdks', 'NetworkManagementClient')
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- from azure.cli.core.profiles import CustomResourceType CUSTOM_ER = CustomResourceType('azext_express_route.vendored_sdks', 'NetworkManagementClient')
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- from azure.cli.core.profiles import CustomResourceType CUSTOM_VNET_TAP = CustomResourceType('azext_vnettap.vendored_sdks', 'NetworkManagementClient')
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- from azure.cli.core.commands.client_factory import get_mgmt_service_client from azure.cli.core.commands.parameters import get_resources_in_subscription from azure.cli.core.profiles import ResourceType from azure.cli.core.profiles import CustomResourceType from knack.util import CLIError CUSTOM_MGMT_AKS_PREVIEW = CustomResourceType('azext_aks_preview.vendored_sdks.azure_mgmt_preview_aks', 'ContainerServiceClient') CUSTOM_MGMT_AKS = CustomResourceType('azext_aks_preview.vendored_sdks.azure_mgmt_aks', 'ContainerServiceClient') def cf_storage(cli_ctx, subscription_id=None): return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_STORAGE, subscription_id=subscription_id) def cf_compute_service(cli_ctx, *_): return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_COMPUTE) def cf_container_services(cli_ctx, *_): return get_container_service_client(cli_ctx).container_services def get_container_service_client(cli_ctx, **_): return get_mgmt_service_client(cli_ctx, CUSTOM_MGMT_AKS_PREVIEW)
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- from azure.cli.core.profiles import CustomResourceType CUSTOM_VWAN = CustomResourceType('azext_vwan.vendored_sdks.v2018_08_01', 'NetworkManagementClient') CUSTOM_VHUB_ROUTE_TABLE = CustomResourceType( 'azext_vwan.vendored_sdks.v2020_04_01', 'NetworkManagementClient')
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- from azure.cli.core.profiles import CustomResourceType CUSTOM_VWAN = CustomResourceType('azext_vwan.vendored_sdks.v2020_05_01', 'NetworkManagementClient')
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- from azure.cli.core.commands.client_factory import get_mgmt_service_client from azure.cli.core.profiles import ResourceType, CustomResourceType CUSTOM_MGMT_APPSERVICE = CustomResourceType('azext_appservice_kube.vendored_sdks.azure_mgmt_web', 'WebSiteManagementClient') # pylint: disable=inconsistent-return-statements def ex_handler_factory(creating_plan=False, no_throw=False): def _polish_bad_errors(ex): import json from knack.util import CLIError try: detail = json.loads(ex.response.text)['Message'] if creating_plan: if 'Requested features are not supported in region' in detail: detail = ("Plan with linux worker is not supported in current region. For " + "supported regions, please refer to https://docs.microsoft.com/" "azure/app-service-web/app-service-linux-intro") elif 'Not enough available reserved instance servers to satisfy' in detail: detail = ("Plan with Linux worker can only be created in a group " + "which has never contained a Windows worker, and vice versa. " + "Please use a new resource group. Original error:" + detail) ex = CLIError(detail) except Exception: # pylint: disable=broad-except pass