Пример #1
0
 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')
Пример #2
0
 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'
                 }
             })
Пример #3
0
# --------------------------------------------------------------------------------------------
# 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')
Пример #4
0
# --------------------------------------------------------------------------------------------
# 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')
Пример #5
0
# --------------------------------------------------------------------------------------------
# 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)
Пример #6
0
# --------------------------------------------------------------------------------------------
# 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')
Пример #7
0
# --------------------------------------------------------------------------------------------
# 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)
Пример #8
0
# --------------------------------------------------------------------------------------------
# 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')
Пример #9
0
# --------------------------------------------------------------------------------------------
# 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')
Пример #10
0
# --------------------------------------------------------------------------------------------
# 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')
Пример #11
0
# --------------------------------------------------------------------------------------------
# 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')
Пример #12
0
# --------------------------------------------------------------------------------------------
# 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')
Пример #13
0
# --------------------------------------------------------------------------------------------
# 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')
Пример #14
0
# --------------------------------------------------------------------------------------------
# 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')
Пример #15
0
# --------------------------------------------------------------------------------------------
# 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)
Пример #16
0
# --------------------------------------------------------------------------------------------
# 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')
Пример #17
0
# --------------------------------------------------------------------------------------------
# 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')
Пример #18
0
# --------------------------------------------------------------------------------------------
# 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