Skip to content
Closed
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
28 changes: 12 additions & 16 deletions diworker/diworker/importers/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import tools.optscale_time as opttime
from diworker.diworker.utils import retry_backoff
from tools.cloud_adapter.clouds.azure import (
AzureConsumptionException, ExpenseImportScheme,
AzureErrorResponseException, AzureAuthenticationError,
AzureResourceNotFoundError)
AzureConsumptionException,
ExpenseImportScheme,
AzureAuthenticationError,
AzureResourceNotFoundError,
)

from diworker.diworker.importers.base import BaseReportImporter

Expand Down Expand Up @@ -449,13 +451,10 @@ def load_raw_data(self):
LOG.info('Downloading PayAsYouGo prices')
try:
prices = self.cloud_adapter.get_public_prices()
except AzureErrorResponseException as exc:
code = getattr(exc.error, 'additional_properties', {}).get(
'error', {}).get('code')
except AzureConsumptionException as exc:
code = getattr(exc.error, 'code', None)
if code == 'SubscriptionNotFound':
msg = exc.error.additional_properties['error'].get(
'message')
raise AzureResourceNotFoundError(msg)
raise AzureResourceNotFoundError(getattr(exc.error, 'message', str(exc)))
else:
raise exc
LOG.info('Fetched %s price entries', len(prices))
Expand Down Expand Up @@ -554,14 +553,11 @@ def _load_raw_usage_data(self, prices):
if len(chunk) == CHUNK_SIZE:
self.update_raw_records(chunk)
chunk = []
except AzureErrorResponseException as ex:
code = getattr(ex.error, 'additional_properties', {}).get(
'error', {}).get('code')
except AzureConsumptionException as exc:
code = getattr(exc.error, 'code', None)
if code == 'SubscriptionNotFound':
msg = ex.error.additional_properties['error'].get(
'message')
raise AzureResourceNotFoundError(msg)
error_message = str(ex)
raise AzureResourceNotFoundError(getattr(exc.error, 'message', str(exc)))
error_message = str(exc)
if 'Unknown error' in error_message:
LOG.error('No ready reports yet in cloud for %s. Will '
'skip the remaining report import days and try '
Expand Down
Loading
Loading