diff --git a/README.md b/README.md index 27b6db0b5f2..25eb515df81 100644 --- a/README.md +++ b/README.md @@ -64,13 +64,13 @@ How to start (short story) Azure credential API settings ----------------------------- -The following are a list of settings (prefixed with `cloud.azure.management`) that can further control the discovery: +The following are a list of settings that can further control the credential API: -* `keystore.path`: /path/to/keystore -* `keystore.type`: `pkcs12`, `jceks` or `jks`. Defaults to `pkcs12`. -* `keystore.password`: your_password for the keystore -* `subscription.id`: your_azure_subscription_id -* `cloud.service.name`: your_azure_cloud_service_name +* `cloud.azure.management.keystore.path`: /path/to/keystore +* `cloud.azure.management.keystore.type`: `pkcs12`, `jceks` or `jks`. Defaults to `pkcs12`. +* `cloud.azure.management.keystore.password`: your_password for the keystore +* `cloud.azure.management.subscription.id`: your_azure_subscription_id +* `cloud.azure.management.cloud.service.name`: your_azure_cloud_service_name Note that in previous versions, it was: @@ -86,16 +86,16 @@ cloud: Advanced settings ----------------- -The following are a list of settings (prefixed with `discovery.azure`) that can further control the discovery: +The following are a list of settings that can further control the discovery: -* `host.type`: either `public_ip` or `private_ip` (default). Azure discovery will use the one you set to ping +* `discovery.azure.host.type`: either `public_ip` or `private_ip` (default). Azure discovery will use the one you set to ping other nodes. This feature was not documented before but was existing under `cloud.azure.host_type`. -* `endpoint.name`: when using `public_ip` this setting is used to identify the endpoint name used to forward requests +* `discovery.azure.endpoint.name`: when using `public_ip` this setting is used to identify the endpoint name used to forward requests to elasticsearch (aka transport port name). Defaults to `elasticsearch`. In Azure management console, you could define an endpoint `elasticsearch` forwarding for example requests on public IP on port 8100 to the virtual machine on port 9300. This feature was not documented before but was existing under `cloud.azure.port_name`. -* `deployment.name`: deployment name if any. Defaults to the value set with `cloud.azure.management.cloud.service.name`. -* `deployment.slot`: either `staging` or `production` (default). +* `discovery.azure.deployment.name`: deployment name if any. Defaults to the value set with `cloud.azure.management.cloud.service.name`. +* `discovery.azure.deployment.slot`: either `staging` or `production` (default). For example: @@ -476,10 +476,10 @@ Example using Java: ```java client.admin().cluster().preparePutRepository("my_backup3") - .setType("azure").setSettings(ImmutableSettings.settingsBuilder() - .put(AzureStorageService.Fields.CONTAINER, "backup_container") - .put(AzureStorageService.Fields.CHUNK_SIZE, new ByteSizeValue(32, ByteSizeUnit.MB)) - ).get(); + .setType("azure").setSettings(ImmutableSettings.settingsBuilder() + .put(Storage.CONTAINER, "backup_container") + .put(Storage.CHUNK_SIZE, new ByteSizeValue(32, ByteSizeUnit.MB)) + ).get(); ``` Repository validation rules diff --git a/src/main/java/org/elasticsearch/cloud/azure/AzureModule.java b/src/main/java/org/elasticsearch/cloud/azure/AzureModule.java index f7ebdc2ca16..d9c21d00b00 100644 --- a/src/main/java/org/elasticsearch/cloud/azure/AzureModule.java +++ b/src/main/java/org/elasticsearch/cloud/azure/AzureModule.java @@ -20,10 +20,13 @@ package org.elasticsearch.cloud.azure; import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.cloud.azure.storage.AzureStorageService; -import org.elasticsearch.cloud.azure.storage.AzureStorageServiceImpl; import org.elasticsearch.cloud.azure.management.AzureComputeService; +import org.elasticsearch.cloud.azure.management.AzureComputeService.Discovery; +import org.elasticsearch.cloud.azure.management.AzureComputeService.Management; import org.elasticsearch.cloud.azure.management.AzureComputeServiceImpl; +import org.elasticsearch.cloud.azure.storage.AzureStorageService; +import org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage; +import org.elasticsearch.cloud.azure.storage.AzureStorageServiceImpl; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Inject; @@ -63,7 +66,7 @@ public class AzureModule extends AbstractModule { if (isDiscoveryReady(settings, logger)) { logger.debug("starting azure discovery service"); bind(AzureComputeService.class) - .to(settings.getAsClass("cloud.azure.api.impl", AzureComputeServiceImpl.class)) + .to(settings.getAsClass(Management.API_IMPLEMENTATION, AzureComputeServiceImpl.class)) .asEagerSingleton(); } @@ -71,7 +74,7 @@ public class AzureModule extends AbstractModule { if (isSnapshotReady(settings, logger)) { logger.debug("starting azure repository service"); bind(AzureStorageService.class) - .to(settings.getAsClass("repositories.azure.api.impl", AzureStorageServiceImpl.class)) + .to(settings.getAsClass(Storage.API_IMPLEMENTATION, AzureStorageServiceImpl.class)) .asEagerSingleton(); } } @@ -102,22 +105,22 @@ public class AzureModule extends AbstractModule { } if ( // We check new parameters - (isPropertyMissing(settings, "cloud.azure.management." + AzureComputeService.Fields.SUBSCRIPTION_ID) || - isPropertyMissing(settings, "cloud.azure.management." + AzureComputeService.Fields.SERVICE_NAME) || - isPropertyMissing(settings, "cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PATH) || - isPropertyMissing(settings, "cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PASSWORD)) + (isPropertyMissing(settings, Management.SUBSCRIPTION_ID) || + isPropertyMissing(settings, Management.SERVICE_NAME) || + isPropertyMissing(settings, Management.KEYSTORE_PATH) || + isPropertyMissing(settings, Management.KEYSTORE_PASSWORD)) // We check deprecated - && (isPropertyMissing(settings, "cloud.azure." + AzureComputeService.Fields.SUBSCRIPTION_ID_DEPRECATED) || - isPropertyMissing(settings, "cloud.azure." + AzureComputeService.Fields.SERVICE_NAME_DEPRECATED) || - isPropertyMissing(settings, "cloud.azure." + AzureComputeService.Fields.KEYSTORE_DEPRECATED) || - isPropertyMissing(settings, "cloud.azure." + AzureComputeService.Fields.PASSWORD_DEPRECATED)) + && (isPropertyMissing(settings, Management.SUBSCRIPTION_ID_DEPRECATED) || + isPropertyMissing(settings, Management.SERVICE_NAME_DEPRECATED) || + isPropertyMissing(settings, Management.KEYSTORE_DEPRECATED) || + isPropertyMissing(settings, Management.PASSWORD_DEPRECATED)) ) { logger.debug("one or more azure discovery settings are missing. " + - "Check elasticsearch.yml file and `cloud.azure.management`. Should have [{}], [{}], [{}] and [{}].", - AzureComputeService.Fields.SUBSCRIPTION_ID, - AzureComputeService.Fields.SERVICE_NAME, - AzureComputeService.Fields.KEYSTORE_PATH, - AzureComputeService.Fields.KEYSTORE_PASSWORD); + "Check elasticsearch.yml file. Should have [{}], [{}], [{}] and [{}].", + Management.SUBSCRIPTION_ID, + Management.SERVICE_NAME, + Management.KEYSTORE_PATH, + Management.KEYSTORE_PASSWORD); return false; } @@ -137,13 +140,13 @@ public class AzureModule extends AbstractModule { return false; } - if ((isPropertyMissing(settings, "cloud.azure.storage." + AzureStorageService.Fields.ACCOUNT) || - isPropertyMissing(settings, "cloud.azure.storage." + AzureStorageService.Fields.KEY)) && - (isPropertyMissing(settings, "cloud.azure." + AzureStorageService.Fields.ACCOUNT_DEPRECATED) || - isPropertyMissing(settings, "cloud.azure." + AzureStorageService.Fields.KEY_DEPRECATED))) { - logger.debug("azure repository is not set [using cloud.azure.storage.{}] and [cloud.azure.storage.{}] properties", - AzureStorageService.Fields.ACCOUNT, - AzureStorageService.Fields.KEY); + if ((isPropertyMissing(settings, Storage.ACCOUNT) || + isPropertyMissing(settings, Storage.KEY)) && + (isPropertyMissing(settings, Storage.ACCOUNT_DEPRECATED) || + isPropertyMissing(settings, Storage.KEY_DEPRECATED))) { + logger.debug("azure repository is not set using [{}] and [{}] properties", + Storage.ACCOUNT, + Storage.KEY); return false; } @@ -171,24 +174,16 @@ public class AzureModule extends AbstractModule { public static void checkDeprecated(Settings settings, ESLogger logger) { // Cloud services are disabled if (isCloudReady(settings)) { - checkDeprecatedSettings(settings, "cloud.azure." + AzureStorageService.Fields.ACCOUNT_DEPRECATED, - "cloud.azure.storage." + AzureStorageService.Fields.ACCOUNT, logger); - checkDeprecatedSettings(settings, "cloud.azure." + AzureStorageService.Fields.KEY_DEPRECATED, - "cloud.azure.storage." + AzureStorageService.Fields.KEY, logger); + checkDeprecatedSettings(settings, Storage.ACCOUNT_DEPRECATED, Storage.ACCOUNT, logger); + checkDeprecatedSettings(settings, Storage.KEY_DEPRECATED, Storage.KEY, logger); // TODO Remove in 3.0.0 - checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.KEYSTORE_DEPRECATED, - "cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PATH, logger); - checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.PASSWORD_DEPRECATED, - "cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PASSWORD, logger); - checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.SERVICE_NAME_DEPRECATED, - "cloud.azure.management." + AzureComputeService.Fields.SERVICE_NAME, logger); - checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.SUBSCRIPTION_ID_DEPRECATED, - "cloud.azure.management." + AzureComputeService.Fields.SUBSCRIPTION_ID, logger); - checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.HOST_TYPE_DEPRECATED, - "discovery.azure." + AzureComputeService.Fields.HOST_TYPE, logger); - checkDeprecatedSettings(settings, "cloud.azure." + AzureComputeService.Fields.PORT_NAME_DEPRECATED, - "discovery.azure." + AzureComputeService.Fields.ENDPOINT_NAME, logger); + checkDeprecatedSettings(settings, Management.KEYSTORE_DEPRECATED, Management.KEYSTORE_PATH, logger); + checkDeprecatedSettings(settings, Management.PASSWORD_DEPRECATED, Management.KEYSTORE_PASSWORD, logger); + checkDeprecatedSettings(settings, Management.SERVICE_NAME_DEPRECATED, Management.SERVICE_NAME, logger); + checkDeprecatedSettings(settings, Management.SUBSCRIPTION_ID_DEPRECATED, Management.SUBSCRIPTION_ID, logger); + checkDeprecatedSettings(settings, Discovery.HOST_TYPE_DEPRECATED, Discovery.HOST_TYPE, logger); + checkDeprecatedSettings(settings, Discovery.PORT_NAME_DEPRECATED, Discovery.ENDPOINT_NAME, logger); } } diff --git a/src/main/java/org/elasticsearch/cloud/azure/AzureSettingsFilter.java b/src/main/java/org/elasticsearch/cloud/azure/AzureSettingsFilter.java deleted file mode 100644 index 313e80f35bc..00000000000 --- a/src/main/java/org/elasticsearch/cloud/azure/AzureSettingsFilter.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.cloud.azure; - -import org.elasticsearch.cloud.azure.management.AzureComputeService; -import org.elasticsearch.cloud.azure.storage.AzureStorageService; -import org.elasticsearch.common.settings.ImmutableSettings; -import org.elasticsearch.common.settings.SettingsFilter; - -/** - * Filtering cloud.azure.* settings - */ -public class AzureSettingsFilter implements SettingsFilter.Filter { - - @Override - public void filter(ImmutableSettings.Builder settings) { - // Cloud global settings - settings.remove("cloud.azure." + AzureComputeService.Fields.REFRESH); - - // Cloud management API settings - settings.remove("cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PATH); - settings.remove("cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_PASSWORD); - settings.remove("cloud.azure.management." + AzureComputeService.Fields.KEYSTORE_TYPE); - settings.remove("cloud.azure.management." + AzureComputeService.Fields.SUBSCRIPTION_ID); - settings.remove("cloud.azure.management." + AzureComputeService.Fields.SERVICE_NAME); - - // Deprecated Cloud management API settings - // TODO Remove in 3.0.0 - settings.remove("cloud.azure." + AzureComputeService.Fields.KEYSTORE_DEPRECATED); - settings.remove("cloud.azure." + AzureComputeService.Fields.PASSWORD_DEPRECATED); - settings.remove("cloud.azure." + AzureComputeService.Fields.SUBSCRIPTION_ID_DEPRECATED); - settings.remove("cloud.azure." + AzureComputeService.Fields.SERVICE_NAME_DEPRECATED); - - // Cloud storage API settings - settings.remove("cloud.azure.storage." + AzureStorageService.Fields.ACCOUNT); - settings.remove("cloud.azure.storage." + AzureStorageService.Fields.KEY); - - // Deprecated Cloud storage API settings - // TODO Remove in 3.0.0 - settings.remove("cloud.azure." + AzureStorageService.Fields.ACCOUNT_DEPRECATED); - settings.remove("cloud.azure." + AzureStorageService.Fields.KEY_DEPRECATED); - } -} diff --git a/src/main/java/org/elasticsearch/cloud/azure/blobstore/AzureBlobStore.java b/src/main/java/org/elasticsearch/cloud/azure/blobstore/AzureBlobStore.java index 75f6dea9adf..6edcae73e07 100644 --- a/src/main/java/org/elasticsearch/cloud/azure/blobstore/AzureBlobStore.java +++ b/src/main/java/org/elasticsearch/cloud/azure/blobstore/AzureBlobStore.java @@ -29,10 +29,12 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.repositories.RepositoryName; import org.elasticsearch.repositories.RepositorySettings; -import org.elasticsearch.repositories.azure.AzureRepository; import java.net.URISyntaxException; +import static org.elasticsearch.cloud.azure.storage.AzureStorageService.Storage.CONTAINER; +import static org.elasticsearch.repositories.azure.AzureRepository.CONTAINER_DEFAULT; + /** * */ @@ -48,8 +50,7 @@ public class AzureBlobStore extends AbstractComponent implements BlobStore { AzureStorageService client) throws URISyntaxException, StorageException { super(settings); this.client = client; - this.container = repositorySettings.settings().get(AzureStorageService.Fields.CONTAINER, - componentSettings.get(AzureStorageService.Fields.CONTAINER, AzureRepository.CONTAINER_DEFAULT)); + this.container = repositorySettings.settings().get("container", settings.get(CONTAINER, CONTAINER_DEFAULT)); this.repositoryName = name.getName(); } diff --git a/src/main/java/org/elasticsearch/cloud/azure/management/AzureComputeService.java b/src/main/java/org/elasticsearch/cloud/azure/management/AzureComputeService.java index 3fd1a5b2532..67f34cd6f23 100644 --- a/src/main/java/org/elasticsearch/cloud/azure/management/AzureComputeService.java +++ b/src/main/java/org/elasticsearch/cloud/azure/management/AzureComputeService.java @@ -26,36 +26,43 @@ import com.microsoft.windowsazure.management.compute.models.HostedServiceGetDeta */ public interface AzureComputeService { - static public final class Fields { + static public final class Management { // Deprecated azure management cloud settings @Deprecated - public static final String SUBSCRIPTION_ID_DEPRECATED = "subscription_id"; + public static final String SUBSCRIPTION_ID_DEPRECATED = "cloud.azure.subscription_id"; @Deprecated - public static final String SERVICE_NAME_DEPRECATED = "service_name"; + public static final String SERVICE_NAME_DEPRECATED = "cloud.azure.service_name"; @Deprecated - public static final String KEYSTORE_DEPRECATED = "keystore"; + public static final String KEYSTORE_DEPRECATED = "cloud.azure.keystore"; @Deprecated - public static final String PASSWORD_DEPRECATED = "password"; - @Deprecated - public static final String PORT_NAME_DEPRECATED = "port_name"; - @Deprecated - public static final String HOST_TYPE_DEPRECATED = "host_type"; + public static final String PASSWORD_DEPRECATED = "cloud.azure.password"; - public static final String SUBSCRIPTION_ID = "subscription.id"; - public static final String SERVICE_NAME = "cloud.service.name"; + public static final String API_IMPLEMENTATION = "cloud.azure.management.api.impl"; + + public static final String SUBSCRIPTION_ID = "cloud.azure.management.subscription.id"; + public static final String SERVICE_NAME = "cloud.azure.management.cloud.service.name"; // Keystore settings - public static final String KEYSTORE_PATH = "keystore.path"; - public static final String KEYSTORE_PASSWORD = "keystore.password"; - public static final String KEYSTORE_TYPE = "keystore.type"; - - public static final String REFRESH = "refresh_interval"; - - public static final String HOST_TYPE = "host.type"; - public static final String ENDPOINT_NAME = "endpoint.name"; - public static final String DEPLOYMENT_NAME = "deployment.name"; - public static final String DEPLOYMENT_SLOT = "deployment.slot"; + public static final String KEYSTORE_PATH = "cloud.azure.management.keystore.path"; + public static final String KEYSTORE_PASSWORD = "cloud.azure.management.keystore.password"; + public static final String KEYSTORE_TYPE = "cloud.azure.management.keystore.type"; } + static public final class Discovery { + // Deprecated azure discovery cloud settings + @Deprecated + public static final String PORT_NAME_DEPRECATED = "cloud.azure.port_name"; + @Deprecated + public static final String HOST_TYPE_DEPRECATED = "cloud.azure.host_type"; + @Deprecated + public static final String REFRESH_DEPRECATED = "cloud.azure.refresh_interval"; + + public static final String REFRESH = "discovery.azure.refresh_interval"; + + public static final String HOST_TYPE = "discovery.azure.host.type"; + public static final String ENDPOINT_NAME = "discovery.azure.endpoint.name"; + public static final String DEPLOYMENT_NAME = "discovery.azure.deployment.name"; + public static final String DEPLOYMENT_SLOT = "discovery.azure.deployment.slot"; + } public HostedServiceGetDetailedResponse getServiceDetails(); } diff --git a/src/main/java/org/elasticsearch/cloud/azure/management/AzureComputeServiceImpl.java b/src/main/java/org/elasticsearch/cloud/azure/management/AzureComputeServiceImpl.java index baad3236259..ac8c28b1f92 100644 --- a/src/main/java/org/elasticsearch/cloud/azure/management/AzureComputeServiceImpl.java +++ b/src/main/java/org/elasticsearch/cloud/azure/management/AzureComputeServiceImpl.java @@ -28,16 +28,16 @@ import com.microsoft.windowsazure.management.configuration.ManagementConfigurati import org.elasticsearch.ElasticsearchException; import org.elasticsearch.cloud.azure.AzureServiceDisableException; import org.elasticsearch.cloud.azure.AzureServiceRemoteException; -import org.elasticsearch.cloud.azure.AzureSettingsFilter; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.settings.SettingsFilter; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import static org.elasticsearch.cloud.azure.management.AzureComputeService.Management.*; + /** * */ @@ -52,21 +52,19 @@ public class AzureComputeServiceImpl extends AbstractLifecycleComponent