diff --git a/plugins/integrations/cloudian/src/org/apache/cloudstack/cloudian/CloudianConnectorImpl.java b/plugins/integrations/cloudian/src/org/apache/cloudstack/cloudian/CloudianConnectorImpl.java index 49a2e3e7f48..b588b3077a8 100644 --- a/plugins/integrations/cloudian/src/org/apache/cloudstack/cloudian/CloudianConnectorImpl.java +++ b/plugins/integrations/cloudian/src/org/apache/cloudstack/cloudian/CloudianConnectorImpl.java @@ -216,6 +216,10 @@ public class CloudianConnectorImpl extends ComponentLifecycleBase implements Clo return true; } + LOG.debug(String.format("Cloudian connector is enabled, completed configuration, integration is ready. " + + "Cloudian admin host:%s, port:%s, user:%s", + CloudianAdminHost.value(), CloudianAdminPort.value(), CloudianAdminUser.value())); + messageBus.subscribe(AccountManager.MESSAGE_ADD_ACCOUNT_EVENT, new MessageSubscriber() { @Override public void onPublishMessage(String senderAddress, String subject, Object args) { @@ -276,9 +280,6 @@ public class CloudianConnectorImpl extends ComponentLifecycleBase implements Clo } }); - LOG.debug(String.format("Cloudian connector is enabled, completed configuration, integration is ready. " + - "Cloudian admin host:%s, port:%s", CloudianAdminHost.value(), CloudianAdminPort.value())); - return true; } diff --git a/plugins/integrations/cloudian/src/org/apache/cloudstack/cloudian/client/CloudianClient.java b/plugins/integrations/cloudian/src/org/apache/cloudstack/cloudian/client/CloudianClient.java index 58dcbec5f1e..9464e6fcd19 100644 --- a/plugins/integrations/cloudian/src/org/apache/cloudstack/cloudian/client/CloudianClient.java +++ b/plugins/integrations/cloudian/src/org/apache/cloudstack/cloudian/client/CloudianClient.java @@ -171,10 +171,11 @@ public class CloudianClient { if (Strings.isNullOrEmpty(userId) || Strings.isNullOrEmpty(groupId)) { return null; } + LOG.debug("Trying to find Cloudian user with id=" + userId + " and group id=" + groupId); try { final HttpResponse response = get(String.format("/user?userId=%s&groupId=%s", userId, groupId)); if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Cloudian API call unauthorized, failed to list user"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Cloudian admin API call unauthorized, please ask your administrator to fix integration issues."); } if (response.getEntity() == null || response.getEntity().getContent() == null) { return null; @@ -194,10 +195,11 @@ public class CloudianClient { if (Strings.isNullOrEmpty(groupId)) { return new ArrayList<>(); } + LOG.debug("Trying to list Cloudian users in group id=" + groupId); try { final HttpResponse response = get(String.format("/user/list?groupId=%s&userType=all&userStatus=active", groupId)); if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { - return new ArrayList<>(); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Cloudian admin API call unauthorized, please ask your administrator to fix integration issues."); } final ObjectMapper mapper = new ObjectMapper(); if (response.getEntity() == null || response.getEntity().getContent() == null) { @@ -272,10 +274,11 @@ public class CloudianClient { if (Strings.isNullOrEmpty(groupId)) { return null; } + LOG.debug("Trying to find Cloudian group with id=" + groupId); try { final HttpResponse response = get(String.format("/group?groupId=%s", groupId)); if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Cloudian API call unauthorized, failed to list group"); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Cloudian admin API call unauthorized, please ask your administrator to fix integration issues."); } if (response.getEntity() == null || response.getEntity().getContent() == null){ return null; @@ -292,9 +295,13 @@ public class CloudianClient { } public List listGroups() { + LOG.debug("Trying to list Cloudian groups"); try { final HttpResponse response = get("/group/list"); - if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK || response.getEntity() == null || response.getEntity().getContent() == null) { + if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Cloudian admin API call unauthorized, please ask your administrator to fix integration issues."); + } + if (response.getEntity() == null || response.getEntity().getContent() == null) { return new ArrayList<>(); } final ObjectMapper mapper = new ObjectMapper();