summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcus G K Williams <marcus.williams@intel.com>2018-09-24 16:22:51 -0700
committerMarcus G K Williams <marcus.williams@intel.com>2018-09-24 16:30:57 -0700
commit105bdfc688df2b0443517c47b7449dcb5a0e9853 (patch)
tree3d04bddece68f331a133e9327d6343b11a908071
parentd3bbcec732486df9375c238594c81a5d526c48f0 (diff)
Add cloudSite Post to catalogDbClient
Issue-ID: SO-1081 Change-Id: I5808292c4b11413dfef07216d2b933b3358e4fae Signed-off-by: Marcus G K Williams <marcus.williams@intel.com>
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientPortChanger.java9
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java42
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml6
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudSite.java21
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java51
5 files changed, 121 insertions, 8 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientPortChanger.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientPortChanger.java
index bf69686a76..e38bd02069 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientPortChanger.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientPortChanger.java
@@ -29,6 +29,15 @@ public class CatalogDbClientPortChanger extends CatalogDbClient {
public String wiremockPort;
+ CatalogDbClientPortChanger(){
+
+ }
+
+ CatalogDbClientPortChanger(String baseUri, String auth, String wiremockPort) {
+ super(baseUri, auth);
+ this.wiremockPort = wiremockPort;
+ }
+
protected URI getUri(String template) {
URI uri = URI.create(template);
String path = uri.getPath();
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
index 3783a51689..5c7b64d054 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
@@ -26,10 +26,13 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.so.adapters.catalogdb.CatalogDBApplication;
+import org.onap.so.db.catalog.beans.AuthenticationType;
+import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.db.catalog.beans.CloudifyManager;
import org.onap.so.db.catalog.beans.InstanceGroup;
import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
+import org.onap.so.db.catalog.beans.ServerType;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.ServiceRecipe;
import org.onap.so.db.catalog.beans.VfModule;
@@ -40,11 +43,13 @@ import org.onap.so.db.catalog.beans.VnfResource;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
+import java.net.URI;
import java.util.List;
import java.util.UUID;
@@ -55,12 +60,16 @@ public class CatalogDbClientTest {
public static final String MTN13 = "mtn13";
@LocalServerPort
private int port;
+
+ @Value("${mso.db.auth}")
+ private String msoAdaptersAuth;
+
@Autowired
CatalogDbClientPortChanger client;
@Before
- public void initialize() {
- client.wiremockPort = String.valueOf(port);
+ public void initialize(){
+ client.wiremockPort= String.valueOf(port);
}
@Test
@@ -376,4 +385,33 @@ public class CatalogDbClientTest {
VfModule module = moduleList.get(0);
Assert.assertEquals("vSAMP10a DEV Base",module.getDescription());
}
+
+ @Test
+ public void testPostCloudSite() {
+ CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger("http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort);
+ CloudSite cloudSite = new CloudSite();
+ cloudSite.setId("MTN6");
+ cloudSite.setClli("TESTCLLI");
+ cloudSite.setRegionId("regionId");
+ cloudSite.setCloudVersion("VERSION");
+ cloudSite.setPlatform("PLATFORM");
+
+ CloudIdentity cloudIdentity = new CloudIdentity();
+ cloudIdentity.setId("RANDOMID");
+ cloudIdentity.setIdentityUrl("URL");
+ cloudIdentity.setMsoId("MSO_ID");
+ cloudIdentity.setMsoPass("MSO_PASS");
+ cloudIdentity.setAdminTenant("ADMIN_TENANT");
+ cloudIdentity.setMemberRole("ROLE");
+ cloudIdentity.setIdentityServerType(ServerType.KEYSTONE);
+ cloudIdentity.setIdentityAuthenticationType(AuthenticationType.RACKSPACE_APIKEY);
+ cloudSite.setIdentityService(cloudIdentity);
+ localClient.postCloudSite(cloudSite);
+ CloudSite getCloudSite = this.client.getCloudSite("MTN6");
+ Assert.assertNotNull(getCloudSite);
+ Assert.assertNotNull(getCloudSite.getIdentityService());
+ Assert.assertEquals("TESTCLLI", getCloudSite.getClli());
+ Assert.assertEquals("regionId", getCloudSite.getRegionId());
+ Assert.assertEquals("RANDOMID", getCloudSite.getIdentityServiceId());
+ }
}
diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml b/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml
index a1e62f5e85..a59ea0ef65 100644
--- a/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml
+++ b/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml
@@ -1,5 +1,5 @@
# TEST FILE
-catalog.db.endpoint: "http://localhost:"
+catalog.db.endpoint: http://localhost:${wiremock.server.port}
ssl-enable: false
mso:
@@ -8,7 +8,7 @@ mso:
catalog:
db:
spring:
- endpoint: "http://localhost:"
+ endpoint: http://localhost:${wiremock.server.port}
db:
auth: Basic YnBlbDptc28tZGItMTUwNyE=
@@ -50,7 +50,7 @@ mariaDB4j:
databaseName: catalogdb
server:
- port: 8080
+ port: ${wiremock.server.port}
tomcat:
max-threads: 50
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudSite.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudSite.java
index 9cce212c36..a56abff927 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudSite.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/CloudSite.java
@@ -21,14 +21,19 @@
package org.onap.so.db.catalog.beans;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.openpojo.business.annotation.BusinessKey;
+import com.openpojo.reflection.java.packageloader.impl.URLToFileSystemAdapter;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
+import uk.co.blackpepper.bowman.annotation.RemoteResource;
+import uk.co.blackpepper.bowman.annotation.ResourceId;
import javax.persistence.CascadeType;
import javax.persistence.Column;
@@ -40,6 +45,7 @@ import javax.persistence.OneToOne;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import javax.persistence.Temporal;
+import javax.persistence.Transient;
import javax.persistence.TemporalType;
/**
@@ -48,6 +54,7 @@ import javax.persistence.TemporalType;
* object, of which it is a component
*
*/
+@RemoteResource("/cloudSite")
@Entity
@Table(name = "cloud_sites")
public class CloudSite {
@@ -115,6 +122,9 @@ public class CloudSite {
@Temporal(TemporalType.TIMESTAMP)
private Date updated;
+ @Transient
+ private URI uri;
+
public CloudSite() {
}
@@ -135,8 +145,8 @@ public class CloudSite {
this.regionId = site.getRegionId();
this.identityServiceId = site.getIdentityServiceId();
}
-
-
+
+
public String getId() {
return this.id;
}
@@ -145,6 +155,13 @@ public class CloudSite {
this.id = id;
}
+ @ResourceId
+ public URI getUri() {return this.uri;}
+
+ public void setUri(URI uri) {
+ this.uri = uri;
+ }
+
public String getRegionId() {
return regionId;
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
index 9a03f8fb07..9742a0c85b 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
@@ -27,7 +27,6 @@ import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
import org.onap.so.db.catalog.beans.ControllerSelectionReference;
import org.onap.so.db.catalog.beans.CvnfcCustomization;
-import org.onap.so.db.catalog.beans.ExternalServiceToInternalService;
import org.onap.so.db.catalog.beans.InstanceGroup;
import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
import org.onap.so.db.catalog.beans.NetworkRecipe;
@@ -291,6 +290,47 @@ public class CatalogDbClient {
controllerSelectionReferenceClient = clientFactory.create(ControllerSelectionReference.class);
}
+ public CatalogDbClient(String baseUri, String auth) {
+ ClientHttpRequestFactory factory = new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory());
+
+ ClientFactory clientFactory = Configuration.builder().setBaseUri(baseUri).setClientHttpRequestFactory(factory).setRestTemplateConfigurer(restTemplate -> {
+ restTemplate.getInterceptors().add((new SpringClientFilter()));
+
+ restTemplate.getInterceptors().add((request, body, execution) -> {
+
+ request.getHeaders().add(HttpHeaders.AUTHORIZATION, auth);
+ request.getHeaders().add(LogConstants.TARGET_ENTITY_HEADER,TARGET_ENTITY);
+ return execution.execute(request, body);
+ });
+ }).build().buildClientFactory();
+ serviceClient = clientFactory.create(Service.class);
+ networkRecipeClient = clientFactory.create(NetworkRecipe.class);
+ networkResourceCustomizationClient = clientFactory.create(NetworkResourceCustomization.class);
+ vnfResourceClient = clientFactory.create(VnfResource.class);
+ vnfResourceCustomizationClient = clientFactory.create(VnfResourceCustomization.class);
+ vnfRecipeClient = clientFactory.create(VnfRecipe.class);
+ orchestrationClient = clientFactory.create(OrchestrationFlow.class);
+ vfModuleCustomizationClient = clientFactory.create(VfModuleCustomization.class);
+ vfModuleClient = clientFactory.create(VfModule.class);
+ vnfComponentsRecipeClient = clientFactory.create(VnfComponentsRecipe.class);
+ northBoundRequestClient = clientFactory.create(NorthBoundRequest.class);
+ rainyDayHandlerStatusClient = clientFactory.create(RainyDayHandlerStatus.class);
+ buildingBlockDetailClient = clientFactory.create(BuildingBlockDetail.class);
+ orchestrationStatusStateTransitionDirectiveClient = clientFactory
+ .create(OrchestrationStatusStateTransitionDirective.class);
+ vnfcInstanceGroupCustomizationClient = clientFactory.create(VnfcInstanceGroupCustomization.class);
+ collectionResourceInstanceGroupCustomizationClient = clientFactory
+ .create(CollectionResourceInstanceGroupCustomization.class);
+ instanceGroupClient = clientFactory.create(InstanceGroup.class);
+ networkCollectionResourceCustomizationClient = clientFactory.create(NetworkCollectionResourceCustomization.class);
+ collectionNetworkResourceCustomizationClient = clientFactory.create(CollectionNetworkResourceCustomization.class);
+ cloudSiteClient = clientFactory.create(CloudSite.class);
+ cloudifyManagerClient = clientFactory.create(CloudifyManager.class);
+ serviceRecipeClient = clientFactory.create(ServiceRecipe.class);
+ cvnfcCustomizationClient = clientFactory.create(CvnfcCustomization.class);
+ controllerSelectionReferenceClient = clientFactory.create(ControllerSelectionReference.class);
+ }
+
public NetworkCollectionResourceCustomization getNetworkCollectionResourceCustomizationByID(String modelCustomizationUUID) {
NetworkCollectionResourceCustomization networkCollectionResourceCustomization =
this.getSingleResource(networkCollectionResourceCustomizationClient, getUri(networkCollectionResourceCustomizationURI + modelCustomizationUUID));
@@ -504,6 +544,11 @@ public class CatalogDbClient {
return this.getSingleResource(cloudSiteClient, getUri(cloudSiteURI + id));
}
+ public void postCloudSite(CloudSite cloudSite){
+ this.postSingleResource(cloudSiteClient, cloudSite);
+ }
+
+
public CloudSite getCloudSiteByClliAndAicVersion (String clli, String cloudVersion){
return this.getSingleResource(cloudSiteClient, getUri(UriBuilder
.fromUri(findByClliAndCloudVersion)
@@ -547,6 +592,10 @@ public class CatalogDbClient {
it.forEachRemaining(list::add);
return list;
}
+
+ private <T> URI postSingleResource(Client<T> client, T type){
+ return client.post(type);
+ }
public List<CvnfcCustomization> getCvnfcCustomizationByVnfCustomizationUUIDAndVfModuleCustomizationUUID(String vnfCustomizationUUID, String vfModuleCustomizationUUID){
return this.getMultipleVnfcCustomizations(