diff options
15 files changed, 206 insertions, 76 deletions
diff --git a/adapters/etsi-sol002-adapter/pom.xml b/adapters/etsi-sol002-adapter/pom.xml index 81e35d896d..5dee8fe8e6 100644 --- a/adapters/etsi-sol002-adapter/pom.xml +++ b/adapters/etsi-sol002-adapter/pom.xml @@ -82,6 +82,18 @@ </executions> </plugin> </plugins> + <resources> + <resource> + <directory>${basedir}/src/main/resources</directory> + <excludes> + <exclude>certs/*</exclude> + </excludes> + </resource> + <resource> + <directory>${basedir}/src/main/resources/certs</directory> + <filtering>false</filtering> + </resource> + </resources> </build> </project> diff --git a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ApplicationConfiguration.java b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ApplicationConfiguration.java index 411572ff5b..38f7a0cd3f 100644 --- a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ApplicationConfiguration.java +++ b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ApplicationConfiguration.java @@ -20,17 +20,44 @@ package org.onap.so.adapters.vevnfm.configuration; +import java.io.IOException; +import java.security.*; +import java.security.cert.CertificateException; +import javax.net.ssl.SSLContext; +import org.apache.http.client.HttpClient; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.ssl.SSLContextBuilder; import org.onap.so.adapters.vevnfm.provider.AuthorizationHeadersProvider; import org.onap.so.configuration.rest.HttpHeadersProvider; import org.onap.so.rest.service.HttpRestServiceProvider; import org.onap.so.rest.service.HttpRestServiceProviderImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.Resource; +import org.springframework.http.client.BufferingClientHttpRequestFactory; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; @Configuration public class ApplicationConfiguration { + private static final Logger logger = LoggerFactory.getLogger(ApplicationConfiguration.class); + + private final Resource clientKeyStore; + private final String clientKeyStorePassword; + private final Resource clientTrustStore; + private final String clientTrustStorePassword; + + public ApplicationConfiguration(final ConfigProperties configProperties) { + clientKeyStore = configProperties.getClientKeyStore(); + clientKeyStorePassword = configProperties.getClientKeyStorePassword(); + clientTrustStore = configProperties.getClientTrustStore(); + clientTrustStorePassword = configProperties.getClientTrustStorePassword(); + } + @Bean public AuthorizationHeadersProvider headersProvider() { return new AuthorizationHeadersProvider(); @@ -39,6 +66,35 @@ public class ApplicationConfiguration { @Bean public HttpRestServiceProvider restProvider(final RestTemplate restTemplate, final HttpHeadersProvider headersProvider) { + modify(restTemplate); return new HttpRestServiceProviderImpl(restTemplate, headersProvider); } + + private void modify(final RestTemplate restTemplate) { + + if (clientKeyStore == null || clientTrustStore == null) { + return; + } + + try { + final KeyStore keystore = KeyStore.getInstance("PKCS12"); + keystore.load(clientKeyStore.getInputStream(), clientKeyStorePassword.toCharArray()); + + final SSLContext sslContext = new SSLContextBuilder() + .loadTrustMaterial(clientTrustStore.getURL(), clientTrustStorePassword.toCharArray()) + .loadKeyMaterial(keystore, clientKeyStorePassword.toCharArray()).build(); + + logger.info("Setting truststore: {}", clientTrustStore.getURL()); + + final SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(sslContext); + final HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build(); + final HttpComponentsClientHttpRequestFactory factory = + new HttpComponentsClientHttpRequestFactory(httpClient); + + restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(factory)); + } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException | CertificateException + | IOException | UnrecoverableKeyException e) { + logger.error("Error reading truststore, TLS connection to VNFM will fail.", e); + } + } } diff --git a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ConfigProperties.java b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ConfigProperties.java index d4ca5af0f2..a8a436ddc6 100644 --- a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ConfigProperties.java +++ b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ConfigProperties.java @@ -23,6 +23,7 @@ package org.onap.so.adapters.vevnfm.configuration; import org.onap.so.adapters.vevnfm.constant.NotificationVnfFilterType; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.Resource; @Configuration public class ConfigProperties { @@ -72,6 +73,18 @@ public class ConfigProperties { @Value("${spring.security.usercredentials[0].openpass}") private String springSecurityOpenpass; + @Value("${client.key-store:#{null}}") + private Resource clientKeyStore; + + @Value("${client.key-store-password:#{null}}") + private String clientKeyStorePassword; + + @Value("${client.trust-store:#{null}}") + private Resource clientTrustStore; + + @Value("${client.trust-store-password:#{null}}") + private String clientTrustStorePassword; + public String getVevnfmadapterVnfFilterJson() { return vevnfmadapterVnfFilterJson; } @@ -131,4 +144,20 @@ public class ConfigProperties { public String getSpringSecurityOpenpass() { return springSecurityOpenpass; } + + public Resource getClientKeyStore() { + return clientKeyStore; + } + + public String getClientKeyStorePassword() { + return clientKeyStorePassword; + } + + public Resource getClientTrustStore() { + return clientTrustStore; + } + + public String getClientTrustStorePassword() { + return clientTrustStorePassword; + } } diff --git a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java index c128275e43..eba1d087c6 100644 --- a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java +++ b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java @@ -28,7 +28,6 @@ import org.onap.so.adapters.vevnfm.configuration.ConfigProperties; import org.onap.so.adapters.vevnfm.exception.VeVnfmException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.retry.annotation.Backoff; import org.springframework.retry.annotation.EnableRetry; import org.springframework.retry.annotation.Recover; @@ -44,7 +43,6 @@ public class StartupService { private final String vnfmDefaultEndpoint; private final AaiConnection aaiConnection; - @Autowired public StartupService(final ConfigProperties configProperties, final AaiConnection aaiConnection) { this.vnfmDefaultEndpoint = configProperties.getVnfmDefaultEndpoint(); this.aaiConnection = aaiConnection; diff --git a/adapters/etsi-sol002-adapter/src/main/resources/application.yaml b/adapters/etsi-sol002-adapter/src/main/resources/application.yaml index c69c95187a..f5b6bc3158 100644 --- a/adapters/etsi-sol002-adapter/src/main/resources/application.yaml +++ b/adapters/etsi-sol002-adapter/src/main/resources/application.yaml @@ -19,17 +19,23 @@ server: vevnfmadapter: vnf-filter-json: '{notificationTypes:[VnfLcmOperationOccurrenceNotification],operationStates:[COMPLETED]}' - endpoint: http://so-ve-vnfm-adapter.onap:9098 + endpoint: http://so-ve-vnfm-adapter:9098 + +client: + key-store: classpath:ve-vnfm-adapter.p12 + key-store-password: 'ywsqCy:EEo#j}HJHM7z^Rk[L' + trust-store: classpath:org.onap.so.trust.jks + trust-store-password: ',sx#.C*W)]wVgJC6ccFHI#:H' mso: key: 07a7159d3bf51a0e53be7a8f89699be7 aai: - endpoint: https://aai.onap:30233 + endpoint: https://aai:30233 auth: 75C4483F9C05E2C33A8602635FA532397EC44AB667A2B64DED4FEE08DD932F2E3C1FEE vnfm: - default-endpoint: https://so-vnfm-simulator.onap:9093 + default-endpoint: https://so-vnfm-simulator:9093 subscription: /vnflcm/v1/subscriptions notification: /lcm/v1/vnf/instances/notifications @@ -37,7 +43,7 @@ notification: vnf-filter-type: NONE dmaap: - endpoint: http://message-router.onap:30227 + endpoint: http://message-router:30227 topic: /events/unauthenticated.DCAE_CL_OUTPUT closed-loop: control: diff --git a/adapters/etsi-sol002-adapter/src/main/resources/certs/org.onap.so.trust.jks b/adapters/etsi-sol002-adapter/src/main/resources/certs/org.onap.so.trust.jks Binary files differnew file mode 100644 index 0000000000..1f0d8a550a --- /dev/null +++ b/adapters/etsi-sol002-adapter/src/main/resources/certs/org.onap.so.trust.jks diff --git a/adapters/etsi-sol002-adapter/src/main/resources/certs/ve-vnfm-adapter.p12 b/adapters/etsi-sol002-adapter/src/main/resources/certs/ve-vnfm-adapter.p12 Binary files differnew file mode 100644 index 0000000000..ae4fddc684 --- /dev/null +++ b/adapters/etsi-sol002-adapter/src/main/resources/certs/ve-vnfm-adapter.p12 diff --git a/adapters/mso-openstack-adapters/pom.xml b/adapters/mso-openstack-adapters/pom.xml index 893f50c458..d78178f5ba 100644 --- a/adapters/mso-openstack-adapters/pom.xml +++ b/adapters/mso-openstack-adapters/pom.xml @@ -353,5 +353,10 @@ <artifactId>camunda-external-task-client</artifactId> <version>1.1.1</version> </dependency> + <dependency> + <groupId>com.github.seancfoley</groupId> + <artifactId>ipaddress</artifactId> + <version>2.0.0</version> + </dependency> </dependencies> </project> diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java index f37555392a..3224f4b4f1 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java @@ -86,12 +86,14 @@ import org.openstack4j.model.network.IP; import org.openstack4j.model.network.Network; import org.openstack4j.model.network.NetworkType; import org.openstack4j.model.network.Port; +import org.openstack4j.model.network.Subnet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.core.env.Environment; import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; +import inet.ipaddr.IPAddressString; /** * This class provides an implementation of {@link HeatBridgeApi} @@ -266,13 +268,12 @@ public class HeatBridgeImpl implements HeatBridgeApi { extractStackResourceIdsByResourceType(stackResources, HeatBridgeConstants.OS_PORT_RESOURCE_TYPE); for (String portId : portIds) { Port port = osClient.getPortById(portId); + Network network = osClient.getNetworkById(port.getNetworkId()); LInterface lIf = new LInterface(); lIf.setInterfaceId(port.getId()); lIf.setInterfaceName(port.getName()); lIf.setMacaddr(port.getMacAddress()); - if (port.getProfile() != null && port.getProfile().get("physical_network") != null) { - lIf.setNetworkName((String) port.getProfile().get("physical_network")); - } + lIf.setNetworkName(network.getName()); lIf.setIsPortMirrored(false); lIf.setIsIpUnnumbered(false); lIf.setInMaint(false); @@ -297,6 +298,8 @@ public class HeatBridgeImpl implements HeatBridgeApi { // Update l-interface to the vserver transaction.create(AAIUriFactory.createResourceUri(AAIObjectType.L_INTERFACE, cloudOwner, cloudRegionId, tenantId, port.getDeviceId(), lIf.getInterfaceName()), lIf); + + updateSriovPfToPserver(port, lIf); } } @@ -350,8 +353,7 @@ public class HeatBridgeImpl implements HeatBridgeApi { Vlan vlan = new Vlan(); Network network = osClient.getNetworkById(port.getNetworkId()); if (network.getNetworkType() != null && network.getNetworkType().equals(NetworkType.VLAN)) { - vlan.setVlanInterface(network.getName() + network.getProviderSegID()); - + vlan.setVlanInterface(port.getName() + network.getProviderSegID()); vlan.setVlanIdOuter(Long.parseLong(network.getProviderSegID())); vlan.setVlanIdInner(0L); vlan.setInMaint(false); @@ -371,17 +373,12 @@ public class HeatBridgeImpl implements HeatBridgeApi { SriovVf sriovVf = new SriovVf(); sriovVf.setPciId(port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString()); sriovVf.setNeutronNetworkId(port.getNetworkId()); - if (port.getVifDetails() != null) { - sriovVf.setVfVlanFilter((String) port.getVifDetails().get(HeatBridgeConstants.OS_VLAN_NETWORK_KEY)); - } + sriovVf.setVfVlanFilter("0"); sriovVf.setVfVlanAntiSpoofCheck(false); sriovVf.setVfMacAntiSpoofCheck(false); sriovVfList.add(sriovVf); lIf.setSriovVfs(sriovVfs); - - // For the given port create sriov-pf for host pserver/p-interface if absent - updateSriovPfToPserver(port, lIf); } } @@ -395,48 +392,59 @@ public class HeatBridgeImpl implements HeatBridgeApi { * @param lIf AAI l-interface object */ private void updateSriovPfToPserver(final Port port, final LInterface lIf) { - if (port.getProfile() == null || Strings - .isNullOrEmpty(port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString())) { - logger.debug("The SRIOV port:" + port.getName() + " is missing physical-network-id, cannot update " - + "sriov-pf object for host pserver: " + port.getHostId()); - return; - } - Optional<String> matchingPifName = HeatBridgeUtils.getMatchingPserverPifName( - port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString()); - if (matchingPifName.isPresent()) { - // Update l-interface description - String pserverHostName = port.getHostId(); - lIf.setInterfaceDescription("Attached to SR-IOV port: " + pserverHostName + "::" + matchingPifName.get()); - try { - Optional<PInterface> matchingPIf = resourcesClient.get(PInterface.class, - AAIUriFactory - .createResourceUri(AAIObjectType.P_INTERFACE, pserverHostName, matchingPifName.get()) - .depth(Depth.ONE)); - if (matchingPIf.isPresent()) { - SriovPfs pIfSriovPfs = matchingPIf.get().getSriovPfs(); - if (pIfSriovPfs == null) { - pIfSriovPfs = new SriovPfs(); - } - // Extract PCI-ID from OS port object - String pfPciId = port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString(); - - List<SriovPf> existingSriovPfs = pIfSriovPfs.getSriovPf(); - if (CollectionUtils.isEmpty(existingSriovPfs) || existingSriovPfs.stream() - .noneMatch(existingSriovPf -> existingSriovPf.getPfPciId().equals(pfPciId))) { - // Add sriov-pf object with PCI-ID to AAI - SriovPf sriovPf = new SriovPf(); - sriovPf.setPfPciId(pfPciId); - logger.debug("Queuing AAI command to update sriov-pf object to pserver: " + pserverHostName - + "/" + matchingPifName.get()); - transaction.create(AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF, pserverHostName, - matchingPifName.get(), sriovPf.getPfPciId()), sriovPf); + if (port.getvNicType().equalsIgnoreCase(HeatBridgeConstants.OS_SRIOV_PORT_TYPE)) { + if (port.getProfile() == null || Strings + .isNullOrEmpty(port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString())) { + logger.debug("The SRIOV port:" + port.getName() + " is missing physical-network-id, cannot update " + + "sriov-pf object for host pserver: " + port.getHostId()); + return; + } + Optional<String> matchingPifName = HeatBridgeUtils.getMatchingPserverPifName( + port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString()); + if (matchingPifName.isPresent()) { + // Update l-interface description + String pserverHostName = port.getHostId(); + lIf.setInterfaceDescription( + "Attached to SR-IOV port: " + pserverHostName + "::" + matchingPifName.get()); + try { + Optional<PInterface> matchingPIf = resourcesClient.get(PInterface.class, AAIUriFactory + .createResourceUri(AAIObjectType.P_INTERFACE, pserverHostName, matchingPifName.get()) + .depth(Depth.ONE)); + if (matchingPIf.isPresent()) { + SriovPfs pIfSriovPfs = matchingPIf.get().getSriovPfs(); + if (pIfSriovPfs == null) { + pIfSriovPfs = new SriovPfs(); + } + // Extract PCI-ID from OS port object + String pfPciId = port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString(); + + List<SriovPf> existingSriovPfs = pIfSriovPfs.getSriovPf(); + if (CollectionUtils.isEmpty(existingSriovPfs) || existingSriovPfs.stream() + .noneMatch(existingSriovPf -> existingSriovPf.getPfPciId().equals(pfPciId))) { + // Add sriov-pf object with PCI-ID to AAI + SriovPf sriovPf = new SriovPf(); + sriovPf.setPfPciId(pfPciId); + logger.debug("Queuing AAI command to update sriov-pf object to pserver: " + pserverHostName + + "/" + matchingPifName.get()); + + AAIResourceUri sriovPfUri = AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF, + pserverHostName, matchingPifName.get(), sriovPf.getPfPciId()); + + transaction.create(sriovPfUri, sriovPf); + + AAIResourceUri sriovVfUri = AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_VF, + cloudOwner, cloudRegionId, tenantId, port.getDeviceId(), lIf.getInterfaceName(), + port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString()); + + transaction.connect(sriovPfUri, sriovVfUri); + } } + } catch (WebApplicationException e) { + // Silently log that we failed to update the Pserver p-interface with PCI-ID + logger.error(LoggingAnchor.NINE, MessageEnum.GENERAL_EXCEPTION, pserverHostName, + matchingPifName.get(), cloudOwner, tenantId, "OpenStack", "Heatbridge", + ErrorCode.DataError.getValue(), "Exception - Failed to add sriov-pf object to pserver", e); } - } catch (WebApplicationException e) { - // Silently log that we failed to update the Pserver p-interface with PCI-ID - logger.error(LoggingAnchor.NINE, MessageEnum.GENERAL_EXCEPTION, pserverHostName, matchingPifName.get(), - cloudOwner, tenantId, "OpenStack", "Heatbridge", ErrorCode.DataError.getValue(), - "Exception - Failed to add sriov-pf object to pserver", e); } } } @@ -446,11 +454,13 @@ public class HeatBridgeImpl implements HeatBridgeApi { for (IP ip : port.getFixedIps()) { String ipAddress = ip.getIpAddress(); if (InetAddressValidator.getInstance().isValidInet4Address(ipAddress)) { + Subnet subnet = osClient.getSubnetById(ip.getSubnetId()); + IPAddressString cidr = new IPAddressString(subnet.getCidr()); L3InterfaceIpv4AddressList lInterfaceIp = new L3InterfaceIpv4AddressList(); lInterfaceIp.setL3InterfaceIpv4Address(ipAddress); lInterfaceIp.setNeutronNetworkId(port.getNetworkId()); lInterfaceIp.setNeutronSubnetId(ip.getSubnetId()); - lInterfaceIp.setL3InterfaceIpv4PrefixLength(32L); + lInterfaceIp.setL3InterfaceIpv4PrefixLength(Long.parseLong(cidr.getNetworkPrefixLength().toString())); lInterfaceIps.add(lInterfaceIp); } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java index 6817be8c49..c4d9cbe871 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java @@ -145,7 +145,6 @@ public class AaiHelper { vserver.setVserverId(serverId); vserver.setVserverName(server.getName()); vserver.setVserverName2(server.getName()); - vserver.setProvStatus(server.getStatus().value()); server.getLinks().stream().filter(link -> link.getRel().equals(HeatBridgeConstants.OS_RESOURCES_SELF_LINK_KEY)) .findFirst().ifPresent(link -> vserver.setVserverSelflink(link.getHref())); return vserver; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClient.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClient.java index 7184ec1e93..8d47ff4ceb 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClient.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClient.java @@ -42,6 +42,7 @@ import org.openstack4j.model.compute.Server; import org.openstack4j.model.heat.Resource; import org.openstack4j.model.network.Network; import org.openstack4j.model.network.Port; +import org.openstack4j.model.network.Subnet; public interface OpenstackClient { @@ -92,4 +93,12 @@ public interface OpenstackClient { * @return List of filtered Network objects */ List<Network> listNetworksByFilter(Map<String, String> filterParams); + + /** + * Get a subnet object by subnet ID + * + * @param subnetId Unique UUID of the subnet. + * @return Subnet object. + */ + Subnet getSubnetById(String subnetId); } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientImpl.java index 5a2b0732dc..1505203d7c 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientImpl.java @@ -45,6 +45,7 @@ import org.openstack4j.model.compute.Server; import org.openstack4j.model.heat.Resource; import org.openstack4j.model.network.Network; import org.openstack4j.model.network.Port; +import org.openstack4j.model.network.Subnet; abstract class OpenstackClientImpl implements OpenstackClient { @Override @@ -78,6 +79,11 @@ abstract class OpenstackClientImpl implements OpenstackClient { return (List<Network>) getClient().networking().network().list(filterParams); } + @Override + public Subnet getSubnetById(String subnetId) { + return getClient().networking().subnet().get(subnetId); + } + /** * Retrieves the specific client to utilize. * diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java index de40f1e6ba..091edefe5a 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java @@ -49,9 +49,11 @@ import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Objects; import java.util.Optional; +import java.util.Set; import org.apache.commons.io.FileUtils; import org.junit.Assert; import org.junit.Before; @@ -83,6 +85,7 @@ import org.openstack4j.model.compute.Image; import org.openstack4j.model.compute.Server; import org.openstack4j.model.compute.Server.Status; import org.openstack4j.model.heat.Resource; +import org.openstack4j.model.network.IP; import org.openstack4j.model.network.Network; import org.openstack4j.model.network.NetworkType; import org.openstack4j.model.network.Port; @@ -415,7 +418,6 @@ public class HeatBridgeImplTest { when(port.getMacAddress()).thenReturn("78:4f:43:68:e2:78"); when(port.getNetworkId()).thenReturn("890a203a-23gg-56jh-df67-731656a8f13a"); when(port.getDeviceId()).thenReturn("test-device-id"); - when(port.getVifDetails()).thenReturn(ImmutableMap.of(HeatBridgeConstants.OS_VLAN_NETWORK_KEY, "2345")); String pfPciId = "0000:08:00.0"; when(port.getProfile()).thenReturn(ImmutableMap.of(HeatBridgeConstants.OS_PCI_SLOT_KEY, pfPciId, HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY, "physical_network_id")); @@ -445,7 +447,7 @@ public class HeatBridgeImplTest { // Assert verify(transaction, times(5)).create(any(AAIResourceUri.class), any(LInterface.class)); verify(osClient, times(5)).getPortById(anyString()); - verify(osClient, times(5)).getNetworkById(anyString()); + verify(osClient, times(10)).getNetworkById(anyString()); } @Test @@ -459,7 +461,6 @@ public class HeatBridgeImplTest { when(port.getMacAddress()).thenReturn("78:4f:43:68:e2:78"); when(port.getNetworkId()).thenReturn("890a203a-23gg-56jh-df67-731656a8f13a"); when(port.getDeviceId()).thenReturn("test-device-id"); - when(port.getVifDetails()).thenReturn(ImmutableMap.of(HeatBridgeConstants.OS_VLAN_NETWORK_KEY, "2345")); String pfPciId = "0000:08:00.0"; when(port.getProfile()).thenReturn(ImmutableMap.of(HeatBridgeConstants.OS_PCI_SLOT_KEY, pfPciId, HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY, "physical_network_id")); @@ -474,6 +475,7 @@ public class HeatBridgeImplTest { when(osClient.getPortById("70a09dfd-f1c5-4bc8-bd8f-dc539b8d662a")).thenReturn(port); when(osClient.getPortById("12f88b4d-c8a4-4fbd-bcb4-7e36af02430b")).thenReturn(port); when(osClient.getPortById("c54b9f45-b413-4937-bbe4-3c8a5689cfc9")).thenReturn(port); + when(osClient.getNetworkById(anyString())).thenReturn(network); SriovPf sriovPf = new SriovPf(); sriovPf.setPfPciId(pfPciId); @@ -487,7 +489,7 @@ public class HeatBridgeImplTest { // Assert verify(transaction, times(5)).create(any(AAIResourceUri.class), any(LInterface.class)); verify(osClient, times(5)).getPortById(anyString()); - verify(osClient, times(0)).getNetworkById(anyString()); + verify(osClient, times(5)).getNetworkById(anyString()); } private List<? extends Resource> extractTestStackResources() { diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java index 4fb63651eb..2d41eb4e26 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java @@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.core.env.Environment; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -68,6 +69,7 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { private static final WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance(); long workflowPollInterval = 1000; + private static final String ASYNC_WAIT_TIME = "mso.workflow.async.waitTime"; @Autowired private WorkflowProcessor processor; @@ -75,6 +77,9 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { @Autowired private WorkflowContextHolder workflowContext; + @Autowired + private Environment env; + public void setProcessor(WorkflowProcessor processor) { this.processor = processor; } @@ -119,7 +124,7 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { protected WorkflowResponse waitForResponse(Map<String, Object> inputVariables) throws Exception { String requestId = getRequestId(inputVariables); long currentWaitTime = 0; - long waitTime = getWaitTime(inputVariables); + long waitTime = getWaitTime(); logger.debug("WorkflowAsyncResource.waitForResponse using timeout: " + waitTime); while (waitTime > currentWaitTime) { Thread.sleep(workflowPollInterval); @@ -185,18 +190,8 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { * @param inputVariables * @return */ - private long getWaitTime(Map<String, Object> inputVariables) { - String timeout = inputVariables.get("mso-service-request-timeout") == null ? null - : inputVariables.get("mso-service-request-timeout").toString(); - - if (timeout != null) { - try { - return Long.parseLong(timeout) * 1000; - } catch (NumberFormatException nex) { - logger.debug("Invalid input for mso-service-request-timeout"); - } - } - return DEFAULT_WAIT_TIME; + private long getWaitTime() { + return env.getProperty(ASYNC_WAIT_TIME, Long.class, new Long(DEFAULT_WAIT_TIME)); } } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java index b3402fa221..2335a48d43 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java @@ -63,6 +63,7 @@ import org.onap.aai.domain.yang.ServiceSubscription; import org.onap.aai.domain.yang.SliceProfile; import org.onap.aai.domain.yang.SpPartner; import org.onap.aai.domain.yang.SriovPf; +import org.onap.aai.domain.yang.SriovVf; import org.onap.aai.domain.yang.Subnet; import org.onap.aai.domain.yang.Tenant; import org.onap.aai.domain.yang.TunnelXconnect; @@ -184,6 +185,8 @@ public class AAIObjectType implements AAIObjectBase, GraphInventoryObjectType, S new AAIObjectType(AAINamespaceConstants.NETWORK, AggregateRoute.class); public static final AAIObjectType L_INTERFACE = new AAIObjectType(AAIObjectType.VSERVER.uriTemplate(), LInterface.class); + public static final AAIObjectType SRIOV_VF = + new AAIObjectType(AAIObjectType.L_INTERFACE.uriTemplate(), SriovVf.class); public static final AAIObjectType SUB_L_INTERFACE = new AAIObjectType(AAIObjectType.L_INTERFACE.uriTemplate(), "/l-interfaces/l-interface/{sub-interface-name}", "sub-l-interface"); public static final AAIObjectType IMAGE = new AAIObjectType(AAIObjectType.CLOUD_REGION.uriTemplate(), Image.class); |