use of com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_CORE_MANAGEMENT_URI in project photon-model by vmware.
the class AzureComputeHostStorageStatsGatherer method getStorageAccounts.
private void getStorageAccounts(AzureStorageStatsDataHolder statsData, StorageMetricsStages next) {
String uriStr = AdapterUriUtil.expandUriPathTemplate(LIST_STORAGE_ACCOUNTS, statsData.parentAuth.userLink);
URI uri = UriUtils.extendUriWithQuery(UriUtils.buildUri(uriStr), QUERY_PARAM_API_VERSION, STORAGE_ACCOUNT_REST_API_VERSION);
Operation operation = Operation.createGet(uri);
operation.addRequestHeader(Operation.ACCEPT_HEADER, Operation.MEDIA_TYPE_APPLICATION_JSON);
operation.addRequestHeader(Operation.CONTENT_TYPE_HEADER, Operation.MEDIA_TYPE_APPLICATION_JSON);
try {
operation.addRequestHeader(Operation.AUTHORIZATION_HEADER, AUTH_HEADER_BEARER_PREFIX + statsData.azureClients.credentials.getToken(AZURE_CORE_MANAGEMENT_URI));
} catch (Exception ex) {
this.handleError(statsData, ex);
return;
}
operation.setCompletion((op, er) -> {
if (er != null) {
handleError(statsData, er);
return;
}
StorageAccountResultList results = op.getBody(StorageAccountResultList.class);
List<StorageAccount> storageAccounts = results.value;
// If there are no storage accounts in Azure, the are no bytes being used/billed
if (storageAccounts == null || storageAccounts.size() == 0) {
statsData.stage = StorageMetricsStages.FINISHED;
handleStorageMetricDiscovery(statsData);
return;
}
logFine(() -> String.format("Retrieved %d storage accounts from Azure", storageAccounts.size()));
for (StorageAccount storageAccount : storageAccounts) {
statsData.storageAccounts.put(storageAccount.id, storageAccount);
}
logFine(() -> String.format("Processing %d storage accounts", statsData.storageAccounts.size()));
statsData.stage = next;
handleStorageMetricDiscovery(statsData);
});
sendRequest(operation);
}
Aggregations