diff options
14 files changed, 579 insertions, 54 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java index 7f0f6e4a8b..4dc139f37d 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java @@ -26,14 +26,20 @@ import org.onap.so.openstack.exceptions.MsoException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; import com.woorea.openstack.base.client.OpenStackRequest; import com.woorea.openstack.nova.Nova; import com.woorea.openstack.nova.model.Flavor; import com.woorea.openstack.nova.model.Flavors; import com.woorea.openstack.nova.model.HostAggregate; import com.woorea.openstack.nova.model.HostAggregates; +import com.woorea.openstack.nova.model.Hypervisors; import com.woorea.openstack.nova.model.QuotaSet; import com.woorea.openstack.nova.model.Server; +import com.woorea.openstack.nova.model.VolumeAttachment; @Component @@ -216,4 +222,61 @@ public class NovaClientImpl extends MsoCommonUtils { throw new NovaClientException("Error building Nova Client", e); } } + + public void postActionToServer(String cloudSiteId, String tenantId, String id, String request) + throws NovaClientException { + try { + ObjectMapper mapper = new ObjectMapper(); + JsonNode actualObj = mapper.readTree(request); + Entity<JsonNode> openstackEntity = new Entity<>(actualObj, "application/json"); + CharSequence actionPath = "/servers/" + id + "/action"; + Nova novaClient = getNovaClient(cloudSiteId, tenantId); + OpenStackRequest<Void> OSRequest = + new OpenStackRequest<>(novaClient, HttpMethod.POST, actionPath, openstackEntity, Void.class); + executeAndRecordOpenstackRequest(OSRequest, false); + } catch (Exception e) { + logger.error("Error building Nova Client", e); + throw new NovaClientException("Error building Nova Client", e); + } + } + + public void attachVolume(String cloudSiteId, String tenantId, String serverId, VolumeAttachment volumeAttachment) + throws NovaClientException { + Nova novaClient; + try { + novaClient = getNovaClient(cloudSiteId, tenantId); + OpenStackRequest<Void> request = novaClient.servers().attachVolume(serverId, volumeAttachment.getVolumeId(), + volumeAttachment.getDevice()); + executeAndRecordOpenstackRequest(request, false); + } catch (MsoException e) { + logger.error("Error building Nova Client", e); + throw new NovaClientException("Error building Nova Client", e); + } + } + + public void detachVolume(String cloudSiteId, String tenantId, String serverId, String volumeId) + throws NovaClientException { + Nova novaClient; + try { + novaClient = getNovaClient(cloudSiteId, tenantId); + OpenStackRequest<Void> request = novaClient.servers().detachVolume(serverId, volumeId); + executeAndRecordOpenstackRequest(request, false); + } catch (MsoException e) { + logger.error("Error building Nova Client", e); + throw new NovaClientException("Error building Nova Client", e); + } + } + + public Hypervisors getHypervisorDetails(String cloudSiteId, String tenantId) throws NovaClientException { + Nova novaClient; + try { + novaClient = getNovaClient(cloudSiteId, tenantId); + OpenStackRequest<Hypervisors> request = novaClient.hypervisors().listDetail(); + return executeAndRecordOpenstackRequest(request, false); + } catch (MsoException e) { + logger.error("Error building Nova Client", e); + throw new NovaClientException("Error building Nova Client", e); + } + } + } diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V7.5__AddServiceArtifact.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V7.5__AddServiceArtifact.sql new file mode 100644 index 0000000000..d32c4666c5 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V7.5__AddServiceArtifact.sql @@ -0,0 +1,30 @@ +use catalogdb; + +CREATE TABLE IF NOT EXISTS `service_info` ( + `ID` int (11) AUTO_INCREMENT, + `SERVICE_INPUT` varchar (5000), + `SERVICE_PROPERTIES` varchar (5000), + PRIMARY KEY (`ID`) +)ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE IF NOT EXISTS `service_artifact`( + `ARTIFACT_UUID` varchar (200) NOT NULL, + `TYPE` varchar (200) NOT NULL, + `NAME` varchar (200) NOT NULL, + `VERSION` varchar (200) NOT NULL, + `DESCRIPTION` varchar (200) DEFAULT NULL, + `CONTENT` LONGTEXT DEFAULT NULL, + `CHECKSUM` varchar (200) DEFAULT NULL, + `CREATION_TIMESTAMP` DATETIME DEFAULT CURRENT_TIMESTAMP, + `SERVICE_MODEL_UUID` varchar (200) NOT NULL, + PRIMARY KEY (`ARTIFACT_UUID`), + CONSTRAINT `fk_service_artifact_service_info1` FOREIGN KEY (`SERVICE_MODEL_UUID`) REFERENCES `service` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE +)ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE TABLE IF NOT EXISTS `service_to_service_info` ( + `SERVICE_MODEL_UUID` varchar (200) NOT NULL, + `SERVICE_INFO_ID` INT (11) NOT NULL, + PRIMARY KEY (`SERVICE_MODEL_UUID`,`SERVICE_INFO_ID`), + CONSTRAINT `fk_service_to_service_info__service1` FOREIGN KEY (`SERVICE_MODEL_UUID`) REFERENCES `service` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_service_to_service_info__service_info1` FOREIGN KEY (`SERVICE_INFO_ID`) REFERENCES `service_info` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE +)
\ No newline at end of file diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/AaiConnection.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/AaiConnection.java index a2bd603ae6..9b2a8c3d62 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/AaiConnection.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/AaiConnection.java @@ -20,6 +20,8 @@ package org.onap.so.adapters.vevnfm.aai; +import java.util.Collections; +import java.util.LinkedList; import java.util.List; import java.util.Optional; import org.apache.logging.log4j.util.Strings; @@ -43,27 +45,27 @@ public class AaiConnection { private static final int FIRST_INDEX = 0; - private static void isValid(final EsrSystemInfo info) throws VeVnfmException { - if (info == null || Strings.isBlank(info.getServiceUrl())) { + private static void isValid(final List<EsrSystemInfo> infos) throws VeVnfmException { + if (infos == null || infos.isEmpty() || Strings.isBlank(infos.get(FIRST_INDEX).getServiceUrl())) { throw new VeVnfmException("No 'url' field in VNFM info"); } } - public EsrSystemInfo receiveVnfm() throws VeVnfmException { - EsrSystemInfo info; + public List<EsrSystemInfo> receiveVnfm() throws VeVnfmException { + List<EsrSystemInfo> infos; try { - info = receiveVnfmInternal(); + infos = receiveVnfmInternal(); } catch (Exception e) { throw new VeVnfmException(e); } - isValid(info); + isValid(infos); - return info; + return infos; } - private EsrSystemInfo receiveVnfmInternal() { + private List<EsrSystemInfo> receiveVnfmInternal() { final AAIResourcesClient resourcesClient = new AAIResourcesClient(); final AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VNFM_LIST); final Optional<EsrVnfmList> response = resourcesClient.get(EsrVnfmList.class, resourceUri); @@ -73,33 +75,29 @@ public class AaiConnection { logger.info("The VNFM replied with: {}", esrVnfmList); final List<EsrVnfm> esrVnfm = esrVnfmList.getEsrVnfm(); - if (esrVnfm.isEmpty()) { - return null; + final List<EsrSystemInfo> infos = new LinkedList<>(); + + for (final EsrVnfm vnfm : esrVnfm) { + final String vnfmId = vnfm.getVnfmId(); + infos.addAll(receiveVnfmServiceUrl(resourcesClient, vnfmId)); } - final String vnfmId = esrVnfm.get(FIRST_INDEX).getVnfmId(); - return receiveVnfmServiceUrl(resourcesClient, vnfmId); + return infos; } return null; } - private EsrSystemInfo receiveVnfmServiceUrl(final AAIResourcesClient resourcesClient, final String vnfmId) { + private List<EsrSystemInfo> receiveVnfmServiceUrl(final AAIResourcesClient resourcesClient, final String vnfmId) { final Optional<EsrVnfm> response = resourcesClient.get(EsrVnfm.class, AAIUriFactory.createResourceUri(AAIObjectType.VNFM, vnfmId).depth(Depth.ONE)); if (response.isPresent()) { final EsrVnfm esrVnfm = response.get(); logger.info("The VNFM replied with: {}", esrVnfm); - final List<EsrSystemInfo> esrSystemInfo = esrVnfm.getEsrSystemInfoList().getEsrSystemInfo(); - - if (esrSystemInfo.isEmpty()) { - return null; - } - - return esrSystemInfo.get(FIRST_INDEX); + return esrVnfm.getEsrSystemInfoList().getEsrSystemInfo(); } - return null; + return Collections.emptyList(); } } diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/EsrId.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/EsrId.java new file mode 100644 index 0000000000..13ff2b6397 --- /dev/null +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/EsrId.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * SO + * ================================================================================ + * Copyright (C) 2020 Samsung. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.vevnfm.aai; + +import org.onap.aai.domain.yang.EsrSystemInfo; + +public class EsrId { + + private EsrSystemInfo info; + private String id; + + public EsrSystemInfo getInfo() { + return info; + } + + public void setInfo(final EsrSystemInfo info) { + this.info = info; + } + + public String getId() { + return id; + } + + public void setId(final String id) { + this.id = id; + } +} diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/StartupConfiguration.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/StartupConfiguration.java index ae330f7ed6..c033fc3f96 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/StartupConfiguration.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/StartupConfiguration.java @@ -20,6 +20,7 @@ package org.onap.so.adapters.vevnfm.configuration; +import java.util.List; import org.onap.aai.domain.yang.EsrSystemInfo; import org.onap.so.adapters.vevnfm.service.StartupService; import org.onap.so.adapters.vevnfm.service.SubscriptionScheduler; @@ -47,8 +48,8 @@ public class StartupConfiguration { @EventListener(ApplicationReadyEvent.class) public void onApplicationReadyEvent() throws Exception { if (!environment.acceptsProfiles(Profiles.of(TEST_PROFILE))) { - final EsrSystemInfo info = startupService.receiveVnfm(); - subscriptionScheduler.setInfo(info); + final List<EsrSystemInfo> infos = startupService.receiveVnfm(); + subscriptionScheduler.setInfos(infos); } } } diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java index 59397cead3..36a4c3300d 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java @@ -25,12 +25,15 @@ public class DmaapService { private HttpRestServiceProvider restProvider; public void send(final VnfLcmOperationOccurrenceNotification notification) { - final ResponseEntity<String> response = restProvider.postHttpRequest(notification, getUrl(), String.class); - - final HttpStatus statusCode = response.getStatusCode(); - final String body = response.getBody(); - - logger.info("The DMaaP replied with the code {} and the body {}", statusCode, body); + try { + final ResponseEntity<String> response = restProvider.postHttpRequest(notification, getUrl(), String.class); + final HttpStatus statusCode = response.getStatusCode(); + final String body = response.getBody(); + + logger.info("The DMaaP replied with the code {} and the body {}", statusCode, body); + } catch (Exception e) { + logger.warn("An issue connecting to DMaaP", e); + } } private String getUrl() { diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java index 3d215148f2..92906ef35c 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java @@ -20,6 +20,8 @@ package org.onap.so.adapters.vevnfm.service; +import java.util.Collections; +import java.util.List; import org.onap.aai.domain.yang.EsrSystemInfo; import org.onap.so.adapters.vevnfm.aai.AaiConnection; import org.onap.so.adapters.vevnfm.exception.VeVnfmException; @@ -45,18 +47,17 @@ public class StartupService { @Autowired private AaiConnection aaiConnection; - @Retryable(value = {VeVnfmException.class}, maxAttempts = 5, backoff = @Backoff(delay = 5000, multiplier = 10)) - public EsrSystemInfo receiveVnfm() throws VeVnfmException { + @Retryable(value = {Exception.class}, maxAttempts = 5, backoff = @Backoff(delay = 5000, multiplier = 2)) + public List<EsrSystemInfo> receiveVnfm() throws VeVnfmException { return aaiConnection.receiveVnfm(); } @Recover - public EsrSystemInfo recoverReceiveVnfm(final Throwable e) { + public List<EsrSystemInfo> recoverReceiveVnfm(final Throwable t) { logger.warn("Connection to AAI failed"); final EsrSystemInfo info = new EsrSystemInfo(); info.setServiceUrl(vnfmDefaultEndpoint); logger.warn("This EsrSystemInfo is used by default: {}", info); - - return info; + return Collections.singletonList(info); } } diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriptionScheduler.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriptionScheduler.java index 16427437fc..d9f3acc3df 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriptionScheduler.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriptionScheduler.java @@ -20,7 +20,10 @@ package org.onap.so.adapters.vevnfm.service; +import java.util.LinkedList; +import java.util.List; import org.onap.aai.domain.yang.EsrSystemInfo; +import org.onap.so.adapters.vevnfm.aai.EsrId; import org.onap.so.adapters.vevnfm.exception.VeVnfmException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,33 +41,57 @@ public class SubscriptionScheduler { @Autowired private SubscriberService subscriberService; - private String subscribedId; + private List<EsrId> esrIds; - private EsrSystemInfo info; + public void setInfos(final List<EsrSystemInfo> infos) { + esrIds = new LinkedList<>(); - public void setInfo(final EsrSystemInfo info) { - this.info = info; + for (final EsrSystemInfo info : infos) { + final EsrId esrId = new EsrId(); + esrId.setInfo(info); + esrIds.add(esrId); + } + } + + List<EsrId> getEsrIds() { + return esrIds; } @Scheduled(fixedRate = 5000, initialDelay = 2000) void subscribeTask() throws VeVnfmException { - if (info != null) { - if (subscribedId == null) { - logger.info("Starting subscribe task"); - subscribedId = subscriberService.subscribe(info); + if (isEsrIdsValid()) { + for (final EsrId esrId : esrIds) { + singleSubscribe(esrId); } } } @Scheduled(fixedRate = 20000) void checkSubscribeTask() throws VeVnfmException { - if (info != null) { - if (subscribedId != null) { - logger.info("Checking subscription: {}", subscribedId); - if (!subscriberService.checkSubscription(info, subscribedId)) { - logger.info("Subscription {} not available", subscribedId); - subscribedId = null; - } + if (isEsrIdsValid()) { + for (final EsrId esrId : esrIds) { + singleCheckSubscription(esrId); + } + } + } + + private boolean isEsrIdsValid() { + return esrIds != null && !esrIds.isEmpty(); + } + + private void singleSubscribe(final EsrId esrId) throws VeVnfmException { + if (esrId.getId() == null) { + logger.info("Single subscribe task"); + esrId.setId(subscriberService.subscribe(esrId.getInfo())); + } + } + + private void singleCheckSubscription(final EsrId esrId) throws VeVnfmException { + if (esrId.getId() != null) { + logger.info("Checking subscription: {}", esrId.getId()); + if (!subscriberService.checkSubscription(esrId.getInfo(), esrId.getId())) { + logger.info("Subscription {} not available", esrId.getId()); + esrId.setId(null); } } } diff --git a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java index d1d34a706f..9b18cf96dc 100644 --- a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java +++ b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java @@ -23,6 +23,8 @@ package org.onap.so.adapters.vevnfm.service; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.util.Collections; +import java.util.List; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -52,14 +54,15 @@ public class StartupServiceTest { // given final EsrSystemInfo info = new EsrSystemInfo(); info.setServiceUrl(URL); + final List<EsrSystemInfo> infos = Collections.singletonList(info); - when(aaiConnection.receiveVnfm()).thenReturn(info); + when(aaiConnection.receiveVnfm()).thenReturn(infos); // when - final EsrSystemInfo systemInfo = startupService.receiveVnfm(); + final List<EsrSystemInfo> systemInfo = startupService.receiveVnfm(); // then verify(aaiConnection).receiveVnfm(); - assertEquals(info, systemInfo); + assertEquals(infos, systemInfo); } } diff --git a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/SubscriptionSchedulerTest.java b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/SubscriptionSchedulerTest.java new file mode 100644 index 0000000000..d3da7c86ec --- /dev/null +++ b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/SubscriptionSchedulerTest.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * SO + * ================================================================================ + * Copyright (C) 2020 Samsung. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.vevnfm.service; + +import static org.junit.Assert.assertNull; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import java.util.Collections; +import java.util.List; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.aai.domain.yang.EsrSystemInfo; + +@RunWith(MockitoJUnitRunner.class) +public class SubscriptionSchedulerTest { + + private static final String URL = "url"; + private static final String ID = "id044"; + + @Mock + private SubscriberService subscriberService; + + @InjectMocks + private SubscriptionScheduler subscriptionScheduler; + + @Test + public void testFullScenario() throws Exception { + // given + final EsrSystemInfo info = new EsrSystemInfo(); + info.setServiceUrl(URL); + final List<EsrSystemInfo> infos = Collections.singletonList(info); + + when(subscriberService.subscribe(eq(info))).thenReturn(ID); + when(subscriberService.checkSubscription(eq(info), eq(ID))).thenReturn(false); + + // when + subscriptionScheduler.setInfos(infos); + subscriptionScheduler.subscribeTask(); + subscriptionScheduler.checkSubscribeTask(); + + // then + verify(subscriberService).subscribe(info); + verify(subscriberService).checkSubscription(info, ID); + + assertNull(subscriptionScheduler.getEsrIds().get(0).getId()); + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceArtifact.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceArtifact.java new file mode 100644 index 0000000000..a8884a81bb --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceArtifact.java @@ -0,0 +1,168 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2019, CMCC Technologies Co., Ltd. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.db.catalog.beans; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.openpojo.business.annotation.BusinessKey; +import org.apache.commons.lang3.builder.ToStringBuilder; +import javax.persistence.*; +import java.io.Serializable; +import java.util.Date; +import java.util.Objects; + +@Entity +@Table(name = "service_artifact") +public class ServiceArtifact implements Serializable { + + private static final long serialVersionUID = 768026109321305392L; + + @BusinessKey + @Id + @Column(name = "ARTIFACT_UUID") + private String artifactUUID; + + @Column(name = "TYPE") + private String type; + + @Column(name = "NAME") + private String name; + + @Column(name = "VERSION") + private String version; + + @Column(name = "DESCRIPTION") + private String description; + + @Column(name = "CONTENT", columnDefinition = "LONGTEXT") + private String content; + + @Column(name = "CHECKSUM") + private String checksum; + + @Column(name = "CREATION_TIMESTAMP", updatable = false) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS") + @Temporal(TemporalType.TIMESTAMP) + private Date creationTimestamp; + + @ManyToOne(cascade = CascadeType.ALL) + @JoinColumn(name = "SERVICE_MODEL_UUID") + private Service service; + + @PrePersist + protected void onCreate() { + this.creationTimestamp = new Date(); + } + + public String getArtifactUUID() { + return artifactUUID; + } + + public void setArtifactUUID(String artifactUUID) { + this.artifactUUID = artifactUUID; + } + + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getChecksum() { + return checksum; + } + + public void setChecksum(String checksum) { + this.checksum = checksum; + } + + public Date getCreationTimestamp() { + return creationTimestamp; + } + + public void setCreationTimestamp(Date creationTimestamp) { + this.creationTimestamp = creationTimestamp; + } + + public Service getService() { + return service; + } + + public void setService(Service service) { + this.service = service; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("artifactUUID", artifactUUID).append("type", type).append("name", name) + .append("version", version).append("description", description).append("content", content) + .append("checksum", checksum).append("creationTimestamp", creationTimestamp).toString(); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + ServiceArtifact that = (ServiceArtifact) o; + return artifactUUID.equals(that.artifactUUID); + } + + @Override + public int hashCode() { + return Objects.hash(artifactUUID); + } +} diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceInfo.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceInfo.java new file mode 100644 index 0000000000..f9c95767f6 --- /dev/null +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/ServiceInfo.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2019, CMCC Technologies Co., Ltd. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.db.catalog.beans; + +import com.openpojo.business.annotation.BusinessKey; +import org.apache.commons.lang3.builder.ToStringBuilder; +import uk.co.blackpepper.bowman.annotation.LinkedResource; +import javax.persistence.*; +import java.io.Serializable; +import java.util.Objects; + +@Entity +@Table(name = "service_info") +public class ServiceInfo implements Serializable { + + private static final long serialVersionUID = 768026109321305392L; + + @Id + @BusinessKey + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "ID") + private Integer id; + + @Column(name = "SERVICE_INPUT") + private String serviceInput; + + @Column(name = "SERVICE_PROPERTIES") + private String serviceProperties; + + @OneToOne(cascade = CascadeType.ALL) + @JoinTable(name = "service_to_service_info", joinColumns = @JoinColumn(name = "SERVICE_INFO_ID"), + inverseJoinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID")) + private Service service; + + public Integer getId() { + return id; + } + + public void setId(Integer serviceInfoId) { + this.id = serviceInfoId; + } + + public String getServiceInput() { + return serviceInput; + } + + public void setServiceInput(String serviceInput) { + this.serviceInput = serviceInput; + } + + public String getServiceProperties() { + return serviceProperties; + } + + public void setServiceProperties(String serviceProperties) { + this.serviceProperties = serviceProperties; + } + + @LinkedResource + public Service getService() { + return service; + } + + public void setService(Service service) { + this.service = service; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("id", id).append("serviceProperties", serviceProperties) + .append("serviceInput", serviceInput).toString(); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + ServiceInfo that = (ServiceInfo) o; + return id.equals(that.id); + } + + @Override + public int hashCode() { + return Objects.hash(id); + } +} @@ -49,7 +49,7 @@ <sonar.cpd.exclusions>**/*</sonar.cpd.exclusions> <jacoco.version>0.8.5</jacoco.version> <org.apache.maven.user-settings /> - <openstack.version>1.5.1</openstack.version> + <openstack.version>1.5.2-SNAPSHOT</openstack.version> <maven.build.timestamp.format>yyyyMMdd'T'HHmm</maven.build.timestamp.format> <originalClassifier>original</originalClassifier> <docker.skip>true</docker.skip> diff --git a/so-simulator/pom.xml b/so-simulator/pom.xml index 352a16769b..35964d6de6 100644 --- a/so-simulator/pom.xml +++ b/so-simulator/pom.xml @@ -17,8 +17,19 @@ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <citrus.simulator.version>1.1.0</citrus.simulator.version> + <spring.boot.version>2.0.9.RELEASE</spring.boot.version> </properties> - + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-dependencies</artifactId> + <version>${spring.boot.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> |