Skip to content

Commit 307b1c0

Browse files
Lucas Martinserikbocks
authored andcommitted
Fix message and log error
1 parent c60a59a commit 307b1c0

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

api/src/main/java/org/apache/cloudstack/config/ApiServiceConfiguration.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919
import org.apache.cloudstack.framework.config.ConfigKey;
2020
import org.apache.cloudstack.framework.config.Configurable;
2121
import com.cloud.exception.InvalidParameterValueException;
22+
import org.apache.commons.lang3.StringUtils;
23+
import org.apache.log4j.Logger;
2224

2325
public class ApiServiceConfiguration implements Configurable {
26+
protected static Logger LOGGER = Logger.getLogger(ApiServiceConfiguration.class);
2427
public static final ConfigKey<String> ManagementServerAddresses = new ConfigKey<>(String.class, "host", "Advanced", "localhost", "The ip address of management server. This can also accept comma separated addresses.", true, ConfigKey.Scope.Global, null, null, null, null, null, ConfigKey.Kind.CSV, null);
2528
public static final ConfigKey<String> ApiServletPath = new ConfigKey<String>("Advanced", String.class, "endpoint.url", "http://localhost:8080/client/api",
2629
"API end point. Can be used by CS components/services deployed remotely, for sending CS API requests", true);
@@ -34,8 +37,9 @@ public class ApiServiceConfiguration implements Configurable {
3437

3538
public static void validateEndpointUrl() {
3639
String csUrl = getApiServletPathValue();
37-
if (csUrl == null || csUrl.contains("localhost")) {
38-
throw new InvalidParameterValueException(String.format("Global setting %s cannot be null or localhost", ApiServletPath.key()));
40+
if (StringUtils.isBlank(csUrl) || csUrl.contains("localhost") || csUrl.contains("127.0.0.1")) {
41+
LOGGER.error(String.format("Global setting %s cannot contain localhost or be blank. Current value: %s", ApiServletPath.key(), csUrl));
42+
throw new InvalidParameterValueException("Unable to complete this operation. Contact your cloud admin.");
3943
}
4044
}
4145

0 commit comments

Comments
 (0)