diff --git a/core-test/src/main/java/org/openstack4j/api/tacker/v1/TackerVimTests.java b/core-test/src/main/java/org/openstack4j/api/tacker/v1/TackerVimTests.java index 145fb4793..1086ef33b 100644 --- a/core-test/src/main/java/org/openstack4j/api/tacker/v1/TackerVimTests.java +++ b/core-test/src/main/java/org/openstack4j/api/tacker/v1/TackerVimTests.java @@ -10,10 +10,12 @@ import org.openstack4j.api.AbstractTest; import org.openstack4j.api.Builders; +import org.openstack4j.api.exceptions.ServerResponseException; import org.openstack4j.model.common.ActionResponse; import org.openstack4j.model.tacker.Vim; import org.openstack4j.openstack.tacker.domain.AuthCredentials; import org.openstack4j.openstack.tacker.domain.VimProject; +import org.testng.Assert; import org.testng.annotations.Test; import com.google.common.base.Preconditions; @@ -80,6 +82,36 @@ public void testRegisterVim() throws IOException { assertEquals("test-vim", vim.getName()); } + @Test(expectedExceptions = ServerResponseException.class) + public void testRegisterVimWithTackerError() throws IOException { + String jsonResponse = "{\"TackerError\": {" + + "\"message\": \"'project_domain_name' is missing.\", " + + "\"code\": 500}}"; + + respondWith(500, jsonResponse); + + VimProject vimProject = VimProject.create().name("admin"); + + AuthCredentials authCredentials = AuthCredentials.create() + .username("admin") + .password("password") + .userDomainName("default"); + + Vim vim = Builders.tacker().vim() + .name("test-vim") + .description("test-vim-description") + .authUrl("http://openstack.os4j.com:35357/v3") + .isDefault(Boolean.TRUE) + .type("openstack") + .vimProject(vimProject) + .authCredentials(authCredentials) + .build(); + + vim = osv3().tacker().vim().register(vim); + System.out.println("THROWING EXCEPTIONNNNNNNNN"); + Assert.fail("Exception should have been thrown."); + } + public void testDeleteVim() throws IOException { respondWith(200); ActionResponse result = osv3().tacker().vim().delete("bad2f397-7436-4fc7-8043-726e173c5d30"); diff --git a/core/src/main/java/org/openstack4j/core/transport/functions/ParseActionResponseFromJsonMap.java b/core/src/main/java/org/openstack4j/core/transport/functions/ParseActionResponseFromJsonMap.java index 47697c58a..f5f895ba1 100644 --- a/core/src/main/java/org/openstack4j/core/transport/functions/ParseActionResponseFromJsonMap.java +++ b/core/src/main/java/org/openstack4j/core/transport/functions/ParseActionResponseFromJsonMap.java @@ -17,6 +17,7 @@ public class ParseActionResponseFromJsonMap implements Function map) { String msg = String.valueOf(map.get(COMPUTE_FAULT)); return ActionResponse.actionFailed(msg, response.getStatus()); } + if (inner.containsKey(TACKER_ERROR)) { + /** For 'TackerError' Error Message Propagation.. */ + String msg = String.valueOf(inner.get(TACKER_ERROR)); + return ActionResponse.actionFailed(msg, response.getStatus()); + } } } diff --git a/core/src/main/java/org/openstack4j/openstack/tacker/domain/VnfAttributes.java b/core/src/main/java/org/openstack4j/openstack/tacker/domain/VnfAttributes.java index 1693b8278..c5db5776b 100644 --- a/core/src/main/java/org/openstack4j/openstack/tacker/domain/VnfAttributes.java +++ b/core/src/main/java/org/openstack4j/openstack/tacker/domain/VnfAttributes.java @@ -29,6 +29,65 @@ public class VnfAttributes { @JsonProperty("failure_policy") private String failurePolicy; + public static VnfAttributes create() { + return new VnfAttributes(); + } + + /** + * serviceType to Set.. + * + * @param serviceType the serviceType to set + * @return VnfAttributes + */ + public VnfAttributes serviceType(String serviceType) { + this.serviceType = serviceType; + return this; + } + + /** + * paramValues to Set.. + * + * @param paramValues the paramValues to set + * @return VnfAttributes + */ + public VnfAttributes paramValues(String paramValues) { + this.paramValues = paramValues; + return this; + } + + /** + * heatTemplate to Set.. + * + * @param heatTemplate the heatTemplate to set + * @return VnfAttributes + */ + public VnfAttributes heatTemplate(String heatTemplate) { + this.heatTemplate = heatTemplate; + return this; + } + + /** + * monitoringPolicy to Set.. + * + * @param monitoringPolicy the monitoringPolicy to set + * @return VnfAttributes + */ + public VnfAttributes monitoringPolicy(String monitoringPolicy) { + this.monitoringPolicy = monitoringPolicy; + return this; + } + + /** + * failurePolicy to Set.. + * + * @param failurePolicy the failurePolicy to set + * @return VnfAttributes + */ + public VnfAttributes failurePolicy(String failurePolicy) { + this.failurePolicy = failurePolicy; + return this; + } + @Override public String toString() { return Objects.toStringHelper(this).omitNullValues() @@ -47,13 +106,6 @@ public String getServiceType() { return serviceType; } - /** - * @param serviceType the serviceType to set - */ - public void setServiceType(String serviceType) { - this.serviceType = serviceType; - } - /** * @return the paramValues */ @@ -61,13 +113,6 @@ public String getParamValues() { return paramValues; } - /** - * @param paramValues the paramValues to set - */ - public void setParamValues(String paramValues) { - this.paramValues = paramValues; - } - /** * @return the heatTemplate */ @@ -75,13 +120,6 @@ public String getHeatTemplate() { return heatTemplate; } - /** - * @param heatTemplate the heatTemplate to set - */ - public void setHeatTemplate(String heatTemplate) { - this.heatTemplate = heatTemplate; - } - /** * @return the monitoringPolicy */ @@ -89,24 +127,10 @@ public String getMonitoringPolicy() { return monitoringPolicy; } - /** - * @param monitoringPolicy the monitoringPolicy to set - */ - public void setMonitoringPolicy(String monitoringPolicy) { - this.monitoringPolicy = monitoringPolicy; - } - /** * @return the failurePolicy */ public String getFailurePolicy() { return failurePolicy; } - - /** - * @param failurePolicy the failurePolicy to set - */ - public void setFailurePolicy(String failurePolicy) { - this.failurePolicy = failurePolicy; - } } diff --git a/core/src/main/java/org/openstack4j/openstack/tacker/internal/VimServiceImpl.java b/core/src/main/java/org/openstack4j/openstack/tacker/internal/VimServiceImpl.java index eb4c1adf2..788cf748a 100644 --- a/core/src/main/java/org/openstack4j/openstack/tacker/internal/VimServiceImpl.java +++ b/core/src/main/java/org/openstack4j/openstack/tacker/internal/VimServiceImpl.java @@ -66,7 +66,7 @@ public ActionResponse delete(String vimId) { */ @Override public Vim register(Vim vim) { - return post(TackerVim.class, uri("/vims")).entity(vim).execute(ExecutionOptions.create(PropagateOnStatus.on(404))); + return post(TackerVim.class, uri("/vims")).entity(vim).execute(ExecutionOptions.create(PropagateOnStatus.on(500))); } /** diff --git a/core/src/main/java/org/openstack4j/openstack/tacker/internal/VnfServiceImpl.java b/core/src/main/java/org/openstack4j/openstack/tacker/internal/VnfServiceImpl.java index 3bae66dcf..aa1b662aa 100644 --- a/core/src/main/java/org/openstack4j/openstack/tacker/internal/VnfServiceImpl.java +++ b/core/src/main/java/org/openstack4j/openstack/tacker/internal/VnfServiceImpl.java @@ -67,7 +67,7 @@ public ActionResponse delete(String vnfId) { */ @Override public Vnf create(Vnf vnf) { - return post(TackerVnf.class, uri("/vnfs")).entity(vnf).execute(ExecutionOptions.create(PropagateOnStatus.on(404))); + return post(TackerVnf.class, uri("/vnfs")).entity(vnf).execute(ExecutionOptions.create(PropagateOnStatus.on(500))); } /** diff --git a/core/src/main/java/org/openstack4j/openstack/tacker/internal/VnfdServiceImpl.java b/core/src/main/java/org/openstack4j/openstack/tacker/internal/VnfdServiceImpl.java index 5989d4d16..9e6afd63e 100644 --- a/core/src/main/java/org/openstack4j/openstack/tacker/internal/VnfdServiceImpl.java +++ b/core/src/main/java/org/openstack4j/openstack/tacker/internal/VnfdServiceImpl.java @@ -63,6 +63,6 @@ public ActionResponse delete(String vnfdId) { @Override public Vnfd create(Vnfd vnfd) { - return post(TackerVnfd.class, uri("/vnfds")).entity(vnfd).execute(ExecutionOptions.create(PropagateOnStatus.on(404))); + return post(TackerVnfd.class, uri("/vnfds")).entity(vnfd).execute(ExecutionOptions.create(PropagateOnStatus.on(500))); } }