当前位置: 首页>>代码示例>>Python>>正文


Python azure_exceptions.CloudError方法代码示例

本文整理汇总了Python中msrestazure.azure_exceptions.CloudError方法的典型用法代码示例。如果您正苦于以下问题:Python azure_exceptions.CloudError方法的具体用法?Python azure_exceptions.CloudError怎么用?Python azure_exceptions.CloudError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在msrestazure.azure_exceptions的用法示例。


在下文中一共展示了azure_exceptions.CloudError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _classic_vm_exists

# 需要导入模块: from msrestazure import azure_exceptions [as 别名]
# 或者: from msrestazure.azure_exceptions import CloudError [as 别名]
def _classic_vm_exists(cmd, resource_group_name, vm_name):
    classic_vm_provider = 'Microsoft.ClassicCompute'
    vm_resource_type = 'virtualMachines'

    try:
        rcf = _resource_client_factory(cmd.cli_ctx)
        api_version = _resolve_api_version(rcf, classic_vm_provider, None, vm_resource_type)
        resource_client = rcf.resources
        resource_client.get(resource_group_name, classic_vm_provider, '', vm_resource_type, vm_name, api_version)
    except CloudError as cloudError:
        # Resource does not exist or the API failed
        logger.debug(cloudError)
        return False
    except Exception as exception:
        # Unknown error, so return false for default resource not found error message
        logger.debug(exception)
        return False
    return True 
开发者ID:Azure,项目名称:azure-cli-extensions,代码行数:20,代码来源:_validators.py

示例2: get_rg

# 需要导入模块: from msrestazure import azure_exceptions [as 别名]
# 或者: from msrestazure.azure_exceptions import CloudError [as 别名]
def get_rg(group_name, credentials, subscription_id):
        """
        Get the RG named group_name, if it not exists return None
        """
        try:
            resource_client = ResourceManagementClient(credentials, subscription_id)
            return resource_client.resource_groups.get(group_name)
        except CloudError as cex:
            if cex.status_code == 404:
                return None
            else:
                raise cex 
开发者ID:grycap,项目名称:im,代码行数:14,代码来源:Azure.py

示例3: get_storage_account

# 需要导入模块: from msrestazure import azure_exceptions [as 别名]
# 或者: from msrestazure.azure_exceptions import CloudError [as 别名]
def get_storage_account(group_name, storage_name, credentials, subscription_id):
        """
        Get the Storage Account named storage_name in group_name, if it not exists return None
        """
        try:
            storage_client = StorageManagementClient(credentials, subscription_id)
            return storage_client.storage_accounts.get_properties(group_name, storage_name)
        except CloudError as cex:
            if cex.status_code == 404:
                return None
            else:
                raise cex 
开发者ID:grycap,项目名称:im,代码行数:14,代码来源:Azure.py

示例4: get_server_azure_ad_administrators

# 需要导入模块: from msrestazure import azure_exceptions [as 别名]
# 或者: from msrestazure.azure_exceptions import CloudError [as 别名]
def get_server_azure_ad_administrators(self, resource_group_name, server_name, subscription_id: str):
        try:
            client = self.get_client(subscription_id)
            return await run_concurrently(
                lambda: client.server_azure_ad_administrators.get(resource_group_name, server_name)
            )
        except CloudError as e:
            # No AD admin configured returns a 404 error:
            if e.status_code != 404:
                print_exception('Failed to retrieve server azure ad administrators: {}'.format(e))
            return None
        except Exception as e:
            print_exception('Failed to retrieve server azure ad administrators: {}'.format(e))
            return None 
开发者ID:nccgroup,项目名称:ScoutSuite,代码行数:16,代码来源:sqldatabase.py

示例5: _failover_initial

# 需要导入模块: from msrestazure import azure_exceptions [as 别名]
# 或者: from msrestazure.azure_exceptions import CloudError [as 别名]
def _failover_initial(
            self, resource_group_name, account_name, custom_headers=None, raw=False, **operation_config):
        # Construct URL
        url = self.failover.metadata['url']
        path_format_arguments = {
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'),
            'accountName': self._serialize.url("account_name", account_name, 'str', max_length=24, min_length=3),
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1)
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1)

        # Construct headers
        header_parameters = {}
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct and send request
        request = self._client.post(url, query_parameters, header_parameters)
        response = self._client.send(request, stream=False, **operation_config)

        if response.status_code not in [200, 202]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        if raw:
            client_raw_response = ClientRawResponse(None, response)
            return client_raw_response 
开发者ID:Azure,项目名称:azure-cli-extensions,代码行数:38,代码来源:_storage_accounts_operations.py

示例6: _delete_initial

# 需要导入模块: from msrestazure import azure_exceptions [as 别名]
# 或者: from msrestazure.azure_exceptions import CloudError [as 别名]
def _delete_initial(
            self, resource_group_name, name, extension_name, custom_headers=None, raw=False, **operation_config):
        # Construct URL
        url = self.delete.metadata['url']
        path_format_arguments = {
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
            'name': self._serialize.url("name", name, 'str'),
            'extensionName': self._serialize.url("extension_name", extension_name, 'str'),
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

        # Construct headers
        header_parameters = {}
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct and send request
        request = self._client.delete(url, query_parameters, header_parameters)
        response = self._client.send(request, stream=False, **operation_config)

        if response.status_code not in [200, 202, 204]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        if raw:
            client_raw_response = ClientRawResponse(None, response)
            return client_raw_response 
开发者ID:Azure,项目名称:azure-cli-extensions,代码行数:39,代码来源:_machine_extensions_operations.py

示例7: _delete_initial

# 需要导入模块: from msrestazure import azure_exceptions [as 别名]
# 或者: from msrestazure.azure_exceptions import CloudError [as 别名]
def _delete_initial(
            self, resource_group_name, dedicated_capacity_name, custom_headers=None, raw=False, **operation_config):
        # Construct URL
        url = self.delete.metadata['url']
        path_format_arguments = {
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'),
            'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'),
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

        # Construct headers
        header_parameters = {}
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct and send request
        request = self._client.delete(url, query_parameters, header_parameters)
        response = self._client.send(request, stream=False, **operation_config)

        if response.status_code not in [200, 202, 204]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        if raw:
            client_raw_response = ClientRawResponse(None, response)
            return client_raw_response 
开发者ID:Azure,项目名称:azure-cli-extensions,代码行数:38,代码来源:_capacities_operations.py

示例8: _suspend_initial

# 需要导入模块: from msrestazure import azure_exceptions [as 别名]
# 或者: from msrestazure.azure_exceptions import CloudError [as 别名]
def _suspend_initial(
            self, resource_group_name, dedicated_capacity_name, custom_headers=None, raw=False, **operation_config):
        # Construct URL
        url = self.suspend.metadata['url']
        path_format_arguments = {
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'),
            'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'),
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

        # Construct headers
        header_parameters = {}
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct and send request
        request = self._client.post(url, query_parameters, header_parameters)
        response = self._client.send(request, stream=False, **operation_config)

        if response.status_code not in [200, 202]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        if raw:
            client_raw_response = ClientRawResponse(None, response)
            return client_raw_response 
开发者ID:Azure,项目名称:azure-cli-extensions,代码行数:38,代码来源:_capacities_operations.py

示例9: _resume_initial

# 需要导入模块: from msrestazure import azure_exceptions [as 别名]
# 或者: from msrestazure.azure_exceptions import CloudError [as 别名]
def _resume_initial(
            self, resource_group_name, dedicated_capacity_name, custom_headers=None, raw=False, **operation_config):
        # Construct URL
        url = self.resume.metadata['url']
        path_format_arguments = {
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'),
            'dedicatedCapacityName': self._serialize.url("dedicated_capacity_name", dedicated_capacity_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z][a-z0-9]*$'),
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

        # Construct headers
        header_parameters = {}
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct and send request
        request = self._client.post(url, query_parameters, header_parameters)
        response = self._client.send(request, stream=False, **operation_config)

        if response.status_code not in [200, 202]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        if raw:
            client_raw_response = ClientRawResponse(None, response)
            return client_raw_response 
开发者ID:Azure,项目名称:azure-cli-extensions,代码行数:38,代码来源:_capacities_operations.py

示例10: _validate_and_get_vm

# 需要导入模块: from msrestazure import azure_exceptions [as 别名]
# 或者: from msrestazure.azure_exceptions import CloudError [as 别名]
def _validate_and_get_vm(cmd, resource_group_name, vm_name):
    # Check if target VM exists
    resource_not_found_error = 'ResourceNotFound'
    source_vm = None
    try:
        source_vm = get_vm(cmd, resource_group_name, vm_name)
    except CloudError as cloudError:
        logger.debug(cloudError)
        if cloudError.error.error == resource_not_found_error and _classic_vm_exists(cmd, resource_group_name, vm_name):
            # Given VM is classic VM (RDFE)
            raise CLIError('The given VM \'{}\' is a classic VM. VM repair commands do not support classic VMs.'.format(vm_name))
        # Unknown Error
        raise CLIError(cloudError.message)

    return source_vm 
开发者ID:Azure,项目名称:azure-cli-extensions,代码行数:17,代码来源:_validators.py

示例11: delete

# 需要导入模块: from msrestazure import azure_exceptions [as 别名]
# 或者: from msrestazure.azure_exceptions import CloudError [as 别名]
def delete(
            self, resource_group_name, load_balancer_name, custom_headers=None, raw=False, polling=True, **operation_config):
        """Deletes the specified load balancer.

        :param resource_group_name: The name of the resource group.
        :type resource_group_name: str
        :param load_balancer_name: The name of the load balancer.
        :type load_balancer_name: str
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: The poller return type is ClientRawResponse, the
         direct response alongside the deserialized response
        :param polling: True for ARMPolling, False for no polling, or a
         polling object for personal polling strategy
        :return: An instance of LROPoller that returns None or
         ClientRawResponse<None> if raw==True
        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        raw_result = self._delete_initial(
            resource_group_name=resource_group_name,
            load_balancer_name=load_balancer_name,
            custom_headers=custom_headers,
            raw=True,
            **operation_config
        )

        def get_long_running_output(response):
            if raw:
                client_raw_response = ClientRawResponse(None, response)
                return client_raw_response

        lro_delay = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
        elif polling is False: polling_method = NoPolling()
        else: polling_method = polling
        return LROPoller(self._client, raw_result, get_long_running_output, polling_method) 
开发者ID:Azure,项目名称:azure-cli-extensions,代码行数:41,代码来源:load_balancers_operations.py

示例12: _delete_initial

# 需要导入模块: from msrestazure import azure_exceptions [as 别名]
# 或者: from msrestazure.azure_exceptions import CloudError [as 别名]
def _delete_initial(
            self, resource_group_name, ddos_protection_plan_name, custom_headers=None, raw=False, **operation_config):
        # Construct URL
        url = self.delete.metadata['url']
        path_format_arguments = {
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
            'ddosProtectionPlanName': self._serialize.url("ddos_protection_plan_name", ddos_protection_plan_name, 'str'),
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

        # Construct headers
        header_parameters = {}
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct and send request
        request = self._client.delete(url, query_parameters, header_parameters)
        response = self._client.send(request, stream=False, **operation_config)

        if response.status_code not in [200, 202, 204]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        if raw:
            client_raw_response = ClientRawResponse(None, response)
            return client_raw_response 
开发者ID:Azure,项目名称:azure-cli-extensions,代码行数:38,代码来源:ddos_protection_plans_operations.py

示例13: delete

# 需要导入模块: from msrestazure import azure_exceptions [as 别名]
# 或者: from msrestazure.azure_exceptions import CloudError [as 别名]
def delete(
            self, resource_group_name, ddos_protection_plan_name, custom_headers=None, raw=False, polling=True, **operation_config):
        """Deletes the specified DDoS protection plan.

        :param resource_group_name: The name of the resource group.
        :type resource_group_name: str
        :param ddos_protection_plan_name: The name of the DDoS protection
         plan.
        :type ddos_protection_plan_name: str
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: The poller return type is ClientRawResponse, the
         direct response alongside the deserialized response
        :param polling: True for ARMPolling, False for no polling, or a
         polling object for personal polling strategy
        :return: An instance of LROPoller that returns None or
         ClientRawResponse<None> if raw==True
        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        raw_result = self._delete_initial(
            resource_group_name=resource_group_name,
            ddos_protection_plan_name=ddos_protection_plan_name,
            custom_headers=custom_headers,
            raw=True,
            **operation_config
        )

        def get_long_running_output(response):
            if raw:
                client_raw_response = ClientRawResponse(None, response)
                return client_raw_response

        lro_delay = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
        elif polling is False: polling_method = NoPolling()
        else: polling_method = polling
        return LROPoller(self._client, raw_result, get_long_running_output, polling_method) 
开发者ID:Azure,项目名称:azure-cli-extensions,代码行数:42,代码来源:ddos_protection_plans_operations.py

示例14: _delete_initial

# 需要导入模块: from msrestazure import azure_exceptions [as 别名]
# 或者: from msrestazure.azure_exceptions import CloudError [as 别名]
def _delete_initial(
            self, resource_group_name, service_endpoint_policy_name, custom_headers=None, raw=False, **operation_config):
        # Construct URL
        url = self.delete.metadata['url']
        path_format_arguments = {
            'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
            'serviceEndpointPolicyName': self._serialize.url("service_endpoint_policy_name", service_endpoint_policy_name, 'str'),
            'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str')
        }
        url = self._client.format_url(url, **path_format_arguments)

        # Construct parameters
        query_parameters = {}
        query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

        # Construct headers
        header_parameters = {}
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if self.config.accept_language is not None:
            header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

        # Construct and send request
        request = self._client.delete(url, query_parameters, header_parameters)
        response = self._client.send(request, stream=False, **operation_config)

        if response.status_code not in [200, 202, 204]:
            exp = CloudError(response)
            exp.request_id = response.headers.get('x-ms-request-id')
            raise exp

        if raw:
            client_raw_response = ClientRawResponse(None, response)
            return client_raw_response 
开发者ID:Azure,项目名称:azure-cli-extensions,代码行数:38,代码来源:service_endpoint_policies_operations.py

示例15: delete

# 需要导入模块: from msrestazure import azure_exceptions [as 别名]
# 或者: from msrestazure.azure_exceptions import CloudError [as 别名]
def delete(
            self, resource_group_name, service_endpoint_policy_name, custom_headers=None, raw=False, polling=True, **operation_config):
        """Deletes the specified service endpoint policy.

        :param resource_group_name: The name of the resource group.
        :type resource_group_name: str
        :param service_endpoint_policy_name: The name of the service endpoint
         policy.
        :type service_endpoint_policy_name: str
        :param dict custom_headers: headers that will be added to the request
        :param bool raw: The poller return type is ClientRawResponse, the
         direct response alongside the deserialized response
        :param polling: True for ARMPolling, False for no polling, or a
         polling object for personal polling strategy
        :return: An instance of LROPoller that returns None or
         ClientRawResponse<None> if raw==True
        :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or
         ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]]
        :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
        """
        raw_result = self._delete_initial(
            resource_group_name=resource_group_name,
            service_endpoint_policy_name=service_endpoint_policy_name,
            custom_headers=custom_headers,
            raw=True,
            **operation_config
        )

        def get_long_running_output(response):
            if raw:
                client_raw_response = ClientRawResponse(None, response)
                return client_raw_response

        lro_delay = operation_config.get(
            'long_running_operation_timeout',
            self.config.long_running_operation_timeout)
        if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
        elif polling is False: polling_method = NoPolling()
        else: polling_method = polling
        return LROPoller(self._client, raw_result, get_long_running_output, polling_method) 
开发者ID:Azure,项目名称:azure-cli-extensions,代码行数:42,代码来源:service_endpoint_policies_operations.py


注:本文中的msrestazure.azure_exceptions.CloudError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。