From c557663b90dc3ac3f0ae7391cb6eac543812a946 Mon Sep 17 00:00:00 2001 From: Tanguy Leroux Date: Fri, 24 Jun 2016 16:51:49 +0200 Subject: [PATCH] Make discovery-azure work again The discovery-plugin has been broken since 2.x because the code was not compliant with the security manager and because plugins have been refactored. closes #18637, #15630 --- docs/plugins/discovery-azure.asciidoc | 4 +- .../management/AzureComputeServiceImpl.java | 46 +++++++++++-------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/docs/plugins/discovery-azure.asciidoc b/docs/plugins/discovery-azure.asciidoc index e3bdc83e470..825c258133b 100644 --- a/docs/plugins/discovery-azure.asciidoc +++ b/docs/plugins/discovery-azure.asciidoc @@ -56,9 +56,11 @@ discovery: .Binding the network host ============================================== +WARNING: The keystore file must be placed in a directory accessible by elasticsearch like the `config` directory. + It's important to define `network.host` as by default it's bound to `localhost`. -You can use {ref}/modules-network.html[core network host settings]. For example `_non_loopback_` or `_en0_`. +You can use {ref}/modules-network.html[core network host settings]. For example `_en0_`. ============================================== diff --git a/plugins/discovery-azure/src/main/java/org/elasticsearch/cloud/azure/management/AzureComputeServiceImpl.java b/plugins/discovery-azure/src/main/java/org/elasticsearch/cloud/azure/management/AzureComputeServiceImpl.java index 0764ec99c12..076ce52ff80 100644 --- a/plugins/discovery-azure/src/main/java/org/elasticsearch/cloud/azure/management/AzureComputeServiceImpl.java +++ b/plugins/discovery-azure/src/main/java/org/elasticsearch/cloud/azure/management/AzureComputeServiceImpl.java @@ -20,19 +20,21 @@ package org.elasticsearch.cloud.azure.management; import com.microsoft.windowsazure.Configuration; +import com.microsoft.windowsazure.core.Builder; +import com.microsoft.windowsazure.core.DefaultBuilder; import com.microsoft.windowsazure.core.utils.KeyStoreType; import com.microsoft.windowsazure.management.compute.ComputeManagementClient; import com.microsoft.windowsazure.management.compute.ComputeManagementService; import com.microsoft.windowsazure.management.compute.models.HostedServiceGetDetailedResponse; import com.microsoft.windowsazure.management.configuration.ManagementConfiguration; import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.cloud.azure.AzureServiceDisableException; import org.elasticsearch.cloud.azure.AzureServiceRemoteException; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import java.io.IOException; +import java.util.ServiceLoader; /** * @@ -40,7 +42,7 @@ import java.io.IOException; public class AzureComputeServiceImpl extends AbstractLifecycleComponent implements AzureComputeService { - private final ComputeManagementClient computeManagementClient; + private final ComputeManagementClient client; private final String serviceName; @Inject @@ -54,28 +56,36 @@ public class AzureComputeServiceImpl extends AbstractLifecycleComponent