use of com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_STORAGE_ACCOUNT_KEY1 in project photon-model by vmware.
the class AzureStorageEnumerationAdapterService method createStorageDescription.
private DeferredResult<StorageDescription> createStorageDescription(StorageEnumContext context, StorageAccount storageAccount, StorageAccountsInner stOps) {
String resourceGroupName = getResourceGroupName(storageAccount.id);
AzureDeferredResultServiceCallback<StorageAccountListKeysResultInner> handler = new Default<>(this, "Load account keys for storage: " + storageAccount.name);
PhotonModelUtils.runInExecutor(this.executorService, () -> {
stOps.listKeysAsync(resourceGroupName, storageAccount.name, handler);
}, handler::failure);
return handler.toDeferredResult().thenCompose(keys -> AzureUtils.storeKeys(getHost(), keys, context.request.endpointLink, context.parentCompute.tenantLinks)).thenApply(auth -> {
String connectionString = String.format(STORAGE_CONNECTION_STRING, storageAccount.name, auth.customProperties.get(AZURE_STORAGE_ACCOUNT_KEY1));
context.storageConnectionStrings.put(storageAccount.id, connectionString);
return auth;
}).thenApply(auth -> {
StorageDescription storageDesc = AzureUtils.constructStorageDescription(context.parentCompute, context.request, storageAccount, auth.documentSelfLink);
return storageDesc;
}).thenCompose(sd -> sendWithDeferredResult(Operation.createPost(context.request.buildUri(StorageDescriptionService.FACTORY_LINK)).setBody(sd).setCompletion((o, e) -> {
if (e != null) {
logWarning("Unable to store storage description for storage account:[%s], reason: %s", storageAccount.name, Utils.toJsonHtml(e));
} else {
StorageDescription storageDescription = o.getBody(StorageDescription.class);
context.storageDescriptionsForPatching.put(storageDescription.id, storageDescription);
}
}), StorageDescription.class));
}
Aggregations