diff options
author | Denes Nemeth <denes.nemeth@nokia.com> | 2018-03-24 14:00:54 +0100 |
---|---|---|
committer | Denes Nemeth <denes.nemeth@nokia.com> | 2018-03-25 21:32:03 +0200 |
commit | c82c886215ed34953a51dff0710c6bd15cb80ee4 (patch) | |
tree | 783f928ba8e033bbf55b6cffa343c7ea47c40b59 /nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap | |
parent | 1489e4215e075ab3ffe8f7158559a38778cd0b34 (diff) |
Removing jackson to mitigate cve-2017-4995
Signed-off-by: Denes Nemeth <denes.nemeth@nokia.com>
Issue-ID: VFC-728
Change-Id: Ib495d4706361cc39527dfe86463aa505d9564afa
Diffstat (limited to 'nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap')
18 files changed, 295 insertions, 278 deletions
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/GenericExternalSystemInfoProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/GenericExternalSystemInfoProvider.java index 13b070a7..38665877 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/GenericExternalSystemInfoProvider.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/GenericExternalSystemInfoProvider.java @@ -17,6 +17,7 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; +import java.util.concurrent.TimeUnit; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.VimInfoProvider; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.VnfmInfoProvider; import org.onap.vnfmdriver.model.VnfmInfo; @@ -24,10 +25,9 @@ import org.slf4j.Logger; import org.springframework.beans.factory.InitializingBean; import org.springframework.core.env.Environment; -import java.util.concurrent.TimeUnit; +import static java.lang.Long.valueOf; import static com.google.common.cache.CacheBuilder.newBuilder; -import static java.lang.Long.valueOf; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure; import static org.slf4j.LoggerFactory.getLogger; diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/IpMappingProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/IpMappingProvider.java index ec6db5e4..99fe615d 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/IpMappingProvider.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/IpMappingProvider.java @@ -15,15 +15,14 @@ */ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - import static com.google.common.base.Splitter.on; import static com.google.common.collect.Lists.newArrayList; diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/MsbApiProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/MsbApiProvider.java index 64a418de..c9edf895 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/MsbApiProvider.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/MsbApiProvider.java @@ -15,17 +15,17 @@ */ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core; -import org.onap.msb.sdk.discovery.common.RouteException; -import org.onap.msb.sdk.discovery.entity.MicroServiceFullInfo; -import org.onap.msb.sdk.discovery.entity.NodeInfo; -import org.onap.msb.sdk.httpclient.msb.MSBServiceClient; +import com.google.common.annotations.VisibleForTesting; +import org.onap.msb.ApiClient; +import org.onap.msb.api.ServiceResourceApi; +import org.onap.msb.model.MicroServiceFullInfo; +import org.onap.msb.model.NodeInfo; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; -import static java.lang.Integer.valueOf; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure; import static org.slf4j.LoggerFactory.getLogger; @@ -48,8 +48,15 @@ public class MsbApiProvider extends IpMappingProvider { /** * @return API to access ONAP MSB */ - public MSBServiceClient getMsbClient() { - return new MSBServiceClient(messageBusIp, valueOf(messageBusPort)); + public ServiceResourceApi getMsbApi() { + return buildApiClient().createService(ServiceResourceApi.class); + } + + @VisibleForTesting + ApiClient buildApiClient() { + ApiClient apiClient = new ApiClient(); + apiClient.setAdapterBuilder(apiClient.getAdapterBuilder().baseUrl("http://" + messageBusIp + ":" + messageBusPort + "/api/msdiscover/v1/")); + return apiClient; } /** @@ -60,15 +67,15 @@ public class MsbApiProvider extends IpMappingProvider { public String getMicroServiceUrl(String name, String version) { MicroServiceFullInfo microServiceFullInfo = getMicroServiceInfo(name, version); String ipAnPort = getNodeIpAnPort(microServiceFullInfo); - String protocol = microServiceFullInfo.isEnable_ssl() ? "https://" : "http://"; + String protocol = microServiceFullInfo.isEnableSsl() ? "https://" : "http://"; //the field name in A&AI is misleading the URL is relative path postfixed to http(s)://ip:port return protocol + ipAnPort + microServiceFullInfo.getUrl(); } private MicroServiceFullInfo getMicroServiceInfo(String name, String version) { try { - return getMsbClient().queryMicroServiceInfo(name, version); - } catch (RouteException e) { + return getMsbApi().getMicroService_0(name, version, null, null, null, null, null).blockingFirst(); + } catch (Exception e) { throw buildFatalFailure(logger, "Unable to get micro service URL for " + name + " with version " + version, e); } } diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java index 92064b16..0c57c376 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/SelfRegistrationManager.java @@ -18,11 +18,10 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core; import com.nokia.cbam.lcn.v32.api.SubscriptionsApi; import com.nokia.cbam.lcn.v32.model.*; -import org.onap.msb.sdk.discovery.common.RouteException; -import org.onap.msb.sdk.discovery.entity.MicroServiceFullInfo; -import org.onap.msb.sdk.discovery.entity.MicroServiceInfo; -import org.onap.msb.sdk.discovery.entity.Node; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions; +import java.util.ArrayList; +import org.onap.msb.model.MicroServiceFullInfo; +import org.onap.msb.model.MicroServiceInfo; +import org.onap.msb.model.Node; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties; import org.slf4j.Logger; @@ -30,11 +29,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; -import java.util.ArrayList; -import java.util.HashSet; - import static com.nokia.cbam.lcn.v32.model.SubscriptionAuthentication.TypeEnum.NONE; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure; +import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions.systemFunctions; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider.NOKIA_LCN_API_VERSION; import static org.slf4j.LoggerFactory.getLogger; @@ -89,17 +86,20 @@ public class SelfRegistrationManager { public void deRegister() { try { logger.info("Cancelling micro service registration"); - msbApiProvider.getMsbClient().cancelMicroServiceInfo(SERVICE_NAME, DRIVER_VERSION); - } catch (RouteException e) { + systemFunctions().blockingFirst(msbApiProvider.getMsbApi().deleteMicroService(SERVICE_NAME, DRIVER_VERSION, null, null)); + } catch (Exception e) { //ONAP throws 500 internal server error, but deletes the micro service + boolean serviceFoundAfterDelete = false; try { - msbApiProvider.getMsbClient().queryMicroServiceInfo(SERVICE_NAME, DRIVER_VERSION); - //the micro service still exists - throw buildFatalFailure(logger, "Unable to deRegister Nokia VNFM driver", e); - } catch (RouteException e1) { + msbApiProvider.getMsbApi().getMicroService_0(SERVICE_NAME, DRIVER_VERSION, null, null, null, null, null); + serviceFoundAfterDelete = true; + } catch (Exception e1) { logger.info("Unable to query " + SERVICE_NAME + " from MSB (so the service was successfully deleted)", e1); // the micro service was deleted (even though 500 HTTP code was reported) } + if (serviceFoundAfterDelete) { + throw buildFatalFailure(logger, "Unable to deRegister Nokia VNFM driver", e); + } } deleteSubscription(driverProperties.getVnfmId()); } @@ -108,7 +108,7 @@ public class SelfRegistrationManager { * @return the swagger API definition */ public byte[] getSwaggerApiDefinition() { - return SystemFunctions.systemFunctions().loadFile(SWAGGER_API_DEFINITION); + return systemFunctions().loadFile(SWAGGER_API_DEFINITION); } private String getDriverVnfmUrl() { @@ -122,7 +122,8 @@ public class SelfRegistrationManager { String callbackUrl = getDriverVnfmUrl() + DriverProperties.LCN_URL; for (Subscription subscription : lcnApi.subscriptionsGet(NOKIA_LCN_API_VERSION).blockingFirst()) { if (subscription.getCallbackUrl().equals(callbackUrl)) { - lcnApi.subscriptionsSubscriptionIdDelete(subscription.getId(), NOKIA_LCN_API_VERSION); + logger.info("Deleting subscription with {} identifier", subscription.getId()); + systemFunctions().blockingFirst(lcnApi.subscriptionsSubscriptionIdDelete(subscription.getId(), NOKIA_LCN_API_VERSION)); } } } catch (Exception e) { @@ -135,20 +136,20 @@ public class SelfRegistrationManager { MicroServiceInfo microServiceInfo = new MicroServiceInfo(); microServiceInfo.setUrl(DriverProperties.BASE_URL); //the PATH should not be set - microServiceInfo.setProtocol("REST"); - microServiceInfo.setVisualRange(INTERNAL_SERVICE); + microServiceInfo.setProtocol(MicroServiceInfo.ProtocolEnum.REST); + microServiceInfo.setVisualRange(MicroServiceInfo.VisualRangeEnum._1); microServiceInfo.setServiceName(SERVICE_NAME); microServiceInfo.setVersion(DRIVER_VERSION); - microServiceInfo.setEnable_ssl(false); + microServiceInfo.setEnableSsl(false); Node node = new Node(); - microServiceInfo.setNodes(new HashSet<>()); + microServiceInfo.setNodes(new ArrayList<>()); microServiceInfo.getNodes().add(node); node.setIp(driverMsbExternalIp); node.setPort(driverPort); node.setTtl("0"); try { - return msbApiProvider.getMsbClient().registerMicroServiceInfo(microServiceInfo); - } catch (RouteException e) { + return msbApiProvider.getMsbApi().addMicroService(microServiceInfo, true, false).blockingFirst(); + } catch (Exception e) { throw buildFatalFailure(logger, "Unable to register Nokia VNFM driver", e); } } @@ -160,6 +161,7 @@ public class SelfRegistrationManager { try { for (Subscription subscription : lcnApi.subscriptionsGet(NOKIA_LCN_API_VERSION).blockingFirst()) { if (subscription.getCallbackUrl().equals(callbackUrl)) { + logger.warn("The subscription with {} identifier has the same callback URL", subscription.getId()); return; } } @@ -175,7 +177,8 @@ public class SelfRegistrationManager { SubscriptionAuthentication subscriptionAuthentication = new SubscriptionAuthentication(); subscriptionAuthentication.setType(NONE); request.setAuthentication(subscriptionAuthentication); - lcnApi.subscriptionsPost(request, NOKIA_LCN_API_VERSION); + Subscription createdSubscription = lcnApi.subscriptionsPost(request, NOKIA_LCN_API_VERSION).blockingFirst(); + logger.info("Subscribed to LCN with {} identifier", createdSubscription.getId()); } catch (Exception e) { throw buildFatalFailure(logger, "Unable to subscribe to CBAM LCN", e); } diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AAIExternalSystemInfoProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AAIExternalSystemInfoProvider.java index f5656f75..81834bcb 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AAIExternalSystemInfoProvider.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AAIExternalSystemInfoProvider.java @@ -15,9 +15,8 @@ */ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct; -import org.onap.aai.domain.yang.v11.EsrSystemInfo; -import org.onap.aai.domain.yang.v11.EsrSystemInfoList; -import org.onap.aai.domain.yang.v11.EsrVnfm; +import org.onap.aai.model.EsrSystemInfo; +import org.onap.aai.model.EsrVnfm; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.GenericExternalSystemInfoProvider; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions; import org.onap.vnfmdriver.model.VimInfo; @@ -28,9 +27,6 @@ import org.springframework.context.annotation.Conditional; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; -import static java.lang.String.format; -import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider.AAIService.CLOUD; -import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider.AAIService.ESR; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.getCloudOwner; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.getRegionName; @@ -42,8 +38,6 @@ import static org.slf4j.LoggerFactory.getLogger; @Component @Conditional(value = Conditions.UseForDirect.class) public class AAIExternalSystemInfoProvider extends GenericExternalSystemInfoProvider { - private static final String VNFM_URL = "/esr-vnfm-list/esr-vnfm/%s?depth=all"; - private static final String VIM_URL = "/cloud-regions/cloud-region/%s/%s/esr-system-info-list"; private static Logger logger = getLogger(AAIExternalSystemInfoProvider.class); private final AAIRestApiProvider aaiRestApiProvider; @@ -55,20 +49,20 @@ public class AAIExternalSystemInfoProvider extends GenericExternalSystemInfoProv @Override public VnfmInfo queryVnfmInfoFromSource(String vnfmId) { + return convertEsrToVnfmInfo(getEsrVnfm(vnfmId)); + } + + private EsrVnfm getEsrVnfm(String vnfmId) { try { - return convertEsrToVnfmInfo(aaiRestApiProvider.get(logger, ESR, format(VNFM_URL, vnfmId), EsrVnfm.class)); - } catch (RuntimeException e) { + return aaiRestApiProvider.getExternalSystemApi().getExternalSystemEsrVnfmListEsrVnfm(vnfmId).blockingFirst(); + } catch (Exception e) { throw buildFatalFailure(logger, "Unable to query VNFM with " + vnfmId + " identifier from AAI", e); } } @Override public VimInfo getVimInfo(String vimId) { - try { - return convertEsrToVim(getEsrSystemInfo(vimId), vimId); - } catch (RuntimeException e) { - throw buildFatalFailure(logger, "Unable to query VIM with " + vimId + " identifier from AAI", e); - } + return convertEsrToVim(getEsrSystemInfo(vimId), vimId); } /** @@ -76,8 +70,11 @@ public class AAIExternalSystemInfoProvider extends GenericExternalSystemInfoProv * @return the VIM details */ public EsrSystemInfo getEsrSystemInfo(String vimId) { - String url = format(VIM_URL, getCloudOwner(vimId), getRegionName(vimId)); - return aaiRestApiProvider.get(logger, CLOUD, url, EsrSystemInfoList.class).getEsrSystemInfo().get(0); + try { + return aaiRestApiProvider.getCloudInfrastructureApi().getCloudInfrastructureCloudRegionsCloudRegion(getCloudOwner(vimId), getRegionName(vimId), null, null).blockingFirst().getEsrSystemInfoList().get(0); + } catch (Exception e) { + throw buildFatalFailure(logger, "Unable to query VIM with " + vimId + " identifier from AAI", e); + } } private VimInfo convertEsrToVim(EsrSystemInfo esrSystemInfo, String vimId) { @@ -103,7 +100,7 @@ public class AAIExternalSystemInfoProvider extends GenericExternalSystemInfoProv private VnfmInfo convertEsrToVnfmInfo(EsrVnfm vnfmInAai) { - EsrSystemInfo esrSystemInfo = vnfmInAai.getEsrSystemInfoList().getEsrSystemInfo().get(0); + EsrSystemInfo esrSystemInfo = vnfmInAai.getEsrSystemInfoList().get(0); VnfmInfo vnfmInfo = new VnfmInfo(); vnfmInfo.setPassword(esrSystemInfo.getPassword()); vnfmInfo.setDescription(esrSystemInfo.getEsrSystemInfoId()); diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AAIRestApiProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AAIRestApiProvider.java index 141ba847..14bdea11 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AAIRestApiProvider.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AAIRestApiProvider.java @@ -16,32 +16,20 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct; import com.google.common.annotations.VisibleForTesting; -import org.onap.aai.restclient.client.Headers; -import org.onap.aai.restclient.client.OperationResult; -import org.onap.aai.restclient.client.RestClient; -import org.onap.aai.restclient.enums.RestAuthenticationMode; +import okhttp3.Credentials; +import okhttp3.Request; +import org.onap.aai.ApiClient; +import org.onap.aai.api.CloudInfrastructureApi; +import org.onap.aai.api.ExternalSystemApi; +import org.onap.aai.api.NetworkApi; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.MsbApiProvider; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions; -import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Conditional; -import org.springframework.http.MediaType; import org.springframework.stereotype.Component; -import javax.xml.bind.JAXBContext; -import java.io.ByteArrayOutputStream; -import java.io.StringReader; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; - -import static com.google.common.collect.Lists.newArrayList; -import static javax.ws.rs.core.MediaType.APPLICATION_XML_TYPE; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager.SERVICE_NAME; -import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure; -import static org.slf4j.LoggerFactory.getLogger; /** * Responsible for providing access to AAI APIs. @@ -50,118 +38,63 @@ import static org.slf4j.LoggerFactory.getLogger; @Component @Conditional(value = Conditions.UseForDirect.class) public class AAIRestApiProvider { - private static final String AAI_VERSION = "v11"; - private static Logger logger = getLogger(AAIRestApiProvider.class); private final MsbApiProvider msbApiProvider; + private final AaiSecurityProvider aaiSecurityProvider; @Value("${aaiUsername}") private String aaiUsername; @Value("${aaiPassword}") private String aaiPassword; @Autowired - AAIRestApiProvider(MsbApiProvider msbApiProvider) { + AAIRestApiProvider(MsbApiProvider msbApiProvider, AaiSecurityProvider aaiSecurityProvider) { this.msbApiProvider = msbApiProvider; + this.aaiSecurityProvider = aaiSecurityProvider; } /** - * @param logger the logger of the class that requests unmarshalling - * @param service the AAI service of the request - * @param url the URL of the request after the base URL (ex. /cloud-infrastructure/...) - * @param clazz the class of the result - * @param <T> the type of the result - * @return the result of the GET request - */ - public <T> T get(Logger logger, AAIService service, String url, Class<T> clazz) { - return expectSuccess(logger, buildClient().get(getBaseUrl(service.getServiceName()) + url, buildCommonHeaders(), APPLICATION_XML_TYPE), clazz, url); - } - - /** - * @param logger the logger of the class that requests unmarshalling - * @param service the AAI service of the request - * @param url the URL of the request after the base URL (ex. /cloud-infrastructure/...) - * @param payload the payload of the request (non serialized) - * @param clazz the class of the result - * @param <T> the type of the result - * @return the result of the PUT request + * @return API to access the cloud infrastructure */ - public <T, S> T put(Logger logger, AAIService service, String url, S payload, Class<T> clazz) { - String marshalledContent = marshall(payload); - OperationResult result = buildClient().put(getBaseUrl(service.getServiceName()) + url, marshalledContent, buildCommonHeaders(), APPLICATION_XML_TYPE, APPLICATION_XML_TYPE); - return expectSuccess(logger, result, clazz, url); + public CloudInfrastructureApi getCloudInfrastructureApi() { + return buildApiClient(AAIService.CLOUD).createService(CloudInfrastructureApi.class); } /** - * Execute a delete request on the given URL - * - * @param logger the logger of the class that requests unmarshalling - * @param service the AAI service of the request - * @param url the URL of the request after the base URL (ex. /cloud-infrastructure/...) + * @return API to access the external systems */ - public void delete(Logger logger, AAIService service, String url) { - buildClient().delete(getBaseUrl(service.getServiceName()) + url, buildCommonHeaders(), APPLICATION_XML_TYPE); + public ExternalSystemApi getExternalSystemApi() { + return buildApiClient(AAIService.ESR).createService(ExternalSystemApi.class); } /** - * @param serviceName the name of the AAI service on MSB - * @return the base URL of the service + * @return API to access the networking */ - private String getBaseUrl(String serviceName) { - return msbApiProvider.getMicroServiceUrl(serviceName, AAI_VERSION); - } + public NetworkApi getNetworkApi() { + return buildApiClient(AAIService.NETWORK).createService(NetworkApi.class); - private <T> T expectSuccess(Logger logger, OperationResult result, Class<T> clazz, String url) { - if (!result.wasSuccessful()) { - if (result.getResultCode() == 404) { - logger.debug("The resource at " + url + " does not exists"); - throw new NoSuchElementException("The resource at " + url + " does not exists"); - } - throw buildFatalFailure(logger, "Bad response. Code: " + result.getResultCode() + " cause: " + result.getFailureCause()); - } - if (clazz.isAssignableFrom(Void.class)) { - return null; - } - return unmarshal(result.getResult(), clazz); - } - - private <T> T unmarshal(String content, Class<T> clazz) { - try { - return (T) JAXBContext.newInstance(clazz).createUnmarshaller().unmarshal(new StringReader(content)); - } catch (Exception e) { - throw buildFatalFailure(logger, "Unable to unmarshal content", e); - } - } - - private String marshall(Object object) { - try { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - JAXBContext.newInstance(object.getClass()).createMarshaller().marshal(object, bos); - return bos.toString(); - } catch (Exception e) { - throw buildFatalFailure(logger, "Unable to marshal content", e); - } - } - - /** - * @return the common mandatory headers for AAI requests - */ - private Map<String, List<String>> buildCommonHeaders() { - Map<String, List<String>> headers = new HashMap<>(); - headers.put(Headers.ACCEPT, newArrayList(MediaType.APPLICATION_XML_VALUE)); - headers.put(Headers.FROM_APP_ID, newArrayList(SERVICE_NAME)); - return headers; - } - - - private RestClient buildClient() { - return buildRawClient().basicAuthUsername(aaiUsername).basicAuthPassword(aaiPassword).authenticationMode(RestAuthenticationMode.SSL_BASIC); } @VisibleForTesting - RestClient buildRawClient() { - return new RestClient(); + ApiClient buildApiClient(AAIService service) { + ApiClient apiClient = new ApiClient(); + apiClient.getOkBuilder().sslSocketFactory(aaiSecurityProvider.buildSSLSocketFactory(), aaiSecurityProvider.buildTrustManager()); + apiClient.getOkBuilder().hostnameVerifier(aaiSecurityProvider.buildHostnameVerifier()); + apiClient.getOkBuilder().addInterceptor(chain -> { + Request request = chain.request().newBuilder().addHeader("X-FromAppId", SERVICE_NAME).build(); + return chain.proceed(request); + }); + apiClient.getOkBuilder().authenticator((route, response) -> { + String credential = Credentials.basic(aaiUsername, aaiPassword); + return response.request().newBuilder().header("Authorization", credential).build(); + }); + String url = msbApiProvider.getMicroServiceUrl(service.getServiceName(), "v11"); + if (!url.endsWith("/")) { + url = url + "/"; + } + apiClient.getAdapterBuilder().baseUrl(url); + return apiClient; } - public enum AAIService { + enum AAIService { NETWORK { String getServiceName() { return "aai-network"; diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AaiSecurityProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AaiSecurityProvider.java new file mode 100644 index 00000000..688a82fd --- /dev/null +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AaiSecurityProvider.java @@ -0,0 +1,48 @@ +/* + * Copyright 2016-2017, Nokia Corporation + * + * 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. + */ +package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct; + +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.GenericSecurityProvider; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +/** + * Responsible for providing SSL factories for AAI + */ +@Component +public class AaiSecurityProvider extends GenericSecurityProvider { + @Value("${trustedCertificatesForAai}") + private String trustedCertificates; + @Value("${skipCertificateVerificationForAai}") + private boolean skipCertificateVerification; + @Value("${skipHostnameVerificationForAai}") + private boolean skipHostnameVerification; + + @Override + protected boolean skipHostnameVerification() { + return skipHostnameVerification; + } + + @Override + protected boolean skipCertificateVerification() { + return skipCertificateVerification; + } + + @Override + protected String trustedCertificates() { + return trustedCertificates; + } +} diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/SdcPackageProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/SdcPackageProvider.java index 8a165478..a7e6e404 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/SdcPackageProvider.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/SdcPackageProvider.java @@ -17,6 +17,8 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct; import com.google.gson.Gson; import com.google.gson.JsonObject; +import java.io.ByteArrayInputStream; +import java.io.InputStream; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; @@ -32,11 +34,9 @@ import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Component; import org.yaml.snakeyaml.Yaml; -import java.io.ByteArrayInputStream; -import java.io.InputStream; +import static java.lang.String.format; import static com.google.common.io.ByteStreams.toByteArray; -import static java.lang.String.format; import static org.apache.http.HttpHeaders.ACCEPT; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager.SERVICE_NAME; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.*; diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AAINotificationProcessor.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AAINotificationProcessor.java index aad90eac..86517435 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AAINotificationProcessor.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AAINotificationProcessor.java @@ -18,6 +18,10 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification; import com.nokia.cbam.lcm.v32.model.AffectedVirtualLink; import com.nokia.cbam.lcm.v32.model.OperationExecution; import com.nokia.cbam.lcm.v32.model.VnfLifecycleChangeNotification; +import java.util.Collection; +import java.util.HashSet; +import java.util.Optional; +import java.util.Set; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.INotificationSender; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.ReportedAffectedConnectionPoints; @@ -27,11 +31,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Component; -import java.util.Collection; -import java.util.HashSet; -import java.util.Optional; -import java.util.Set; - import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.tryFind; import static com.nokia.cbam.lcm.v32.model.ChangeType.*; diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AbstractManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AbstractManager.java index c8008f38..ee7a3feb 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AbstractManager.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/AbstractManager.java @@ -16,20 +16,17 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification; import com.google.gson.Gson; -import org.onap.aai.domain.yang.v11.ObjectFactory; -import org.onap.aai.domain.yang.v11.Relationship; -import org.onap.aai.domain.yang.v11.RelationshipData; -import org.onap.aai.domain.yang.v11.RelationshipList; +import io.reactivex.Observable; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import org.onap.aai.model.Relationship; +import org.onap.aai.model.RelationshipData; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties; import org.slf4j.Logger; -import java.util.HashSet; -import java.util.List; -import java.util.NoSuchElementException; -import java.util.Set; - import static com.google.common.collect.Iterables.find; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.SEPARATOR; @@ -37,7 +34,6 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.SEPARATOR * Handles the common management of changing entities in AAI */ abstract class AbstractManager { - protected static final ObjectFactory OBJECT_FACTORY = new ObjectFactory(); protected final AAIRestApiProvider aaiRestApiProvider; protected final CbamRestApiProvider cbamRestApiProvider; protected final DriverProperties driverProperties; @@ -78,17 +74,17 @@ abstract class AbstractManager { * @param relationships the list of relationships * @param relationship the expected relationship */ - protected static void addSingletonRelation(RelationshipList relationships, Relationship relationship) { + protected static void addSingletonRelation(List<Relationship> relationships, Relationship relationship) { boolean found = false; - for (Relationship currentRelationShip : relationships.getRelationship()) { + for (Relationship currentRelationShip : relationships) { if (relationship.getRelatedTo().equals(currentRelationShip.getRelatedTo())) { found = true; } } if (!found) { - relationships.getRelationship().add(relationship); + relationships.add(relationship); } else { - Relationship existingRelationShip = find(relationships.getRelationship(), currentRelationShip -> currentRelationShip.getRelatedTo().equals(relationship.getRelatedTo())); + Relationship existingRelationShip = find(relationships, currentRelationShip -> currentRelationShip.getRelatedTo().equals(relationship.getRelatedTo())); existingRelationShip.getRelationshipData().clear(); existingRelationShip.getRelationshipData().addAll(relationship.getRelationshipData()); } @@ -100,14 +96,14 @@ abstract class AbstractManager { * @param relationships the relationships * @param relationship the relationship to be added */ - protected static void addMissingRelation(RelationshipList relationships, Relationship relationship) { - for (Relationship currentRelationShip : relationships.getRelationship()) { + protected static void addMissingRelation(List<Relationship> relationships, Relationship relationship) { + for (Relationship currentRelationShip : relationships) { if (currentRelationShip.getRelatedTo().equals(relationship.getRelatedTo()) && compositeKeys(currentRelationShip.getRelationshipData()).equals(compositeKeys(relationship.getRelationshipData()))) { return; } } - relationships.getRelationship().add(relationship); + relationships.add(relationship); } private static Set<String> compositeKeys(List<RelationshipData> data) { @@ -126,17 +122,16 @@ abstract class AbstractManager { /** * Creates or returns a REST resource instance * - * @param service the type of the service - * @param url the URL of the resource without the service prefix + * @param get provides an existing instance * @param newInstance the empty instance if the resource does not exists * @param <T> the type of the resource * @return the created or queried resource */ - protected <T> T createOrGet(AAIRestApiProvider.AAIService service, String url, T newInstance) { + protected <T> T createOrGet(Observable<T> get, T newInstance) { try { - return (T) aaiRestApiProvider.get(getLogger(), service, url, newInstance.getClass()); - } catch (NoSuchElementException e) { - getLogger().debug("The resource on " + url + " URL was not found in AAI", e); + return get.blockingFirst(); + } catch (Exception e) { + getLogger().debug("The resource was not found in AAI", e); return newInstance; } } diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java index 2b9b3882..130004e4 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java @@ -16,10 +16,13 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification; import com.nokia.cbam.lcm.v32.model.VnfInfo; -import org.onap.aai.domain.yang.v11.GenericVnf; -import org.onap.aai.domain.yang.v11.Relationship; +import java.util.ArrayList; +import java.util.NoSuchElementException; +import org.onap.aai.model.GenericVnf; +import org.onap.aai.model.Relationship; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties; import org.slf4j.Logger; @@ -27,10 +30,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Component; -import java.util.NoSuchElementException; - -import static java.lang.String.format; -import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider.AAIService.NETWORK; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions.systemFunctions; @@ -40,7 +39,6 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions.sys @Component @Conditional(value = Conditions.UseForDirect.class) class GenericVnfManager extends AbstractManager { - private static final String VNF_URL = "/generic-vnfs/generic-vnf/%s"; private static final long MAX_MS_TO_WAIT_FOR_VNF_TO_APPEAR = 30 * 1000L; private static Logger logger = org.slf4j.LoggerFactory.getLogger(GenericVnfManager.class); @@ -52,6 +50,7 @@ class GenericVnfManager extends AbstractManager { static Relationship linkTo(String vnfId) { Relationship relationship = new Relationship(); relationship.setRelatedTo("generic-vnf"); + relationship.setRelationshipData(new ArrayList<>()); relationship.getRelationshipData().add(buildRelationshipData("generic-vnf.vnf-id", vnfId)); return relationship; } @@ -68,7 +67,7 @@ class GenericVnfManager extends AbstractManager { } catch (NoSuchElementException e) { try { logger.warn("The VNF with " + vnfId + " identifier did not appear in time", e); - updateFields(OBJECT_FACTORY.createGenericVnf(), vnfId, inMaintenance); + updateFields(new GenericVnf(), vnfId, inMaintenance); } catch (Exception e2) { logger.warn("The VNF with " + vnfId + " identifier has been created since after the maximal wait for VNF to appear timeout", e2); //the VNF might have been created since the last poll @@ -77,8 +76,8 @@ class GenericVnfManager extends AbstractManager { } } - GenericVnf getExistingVnf(String vnfId) { - return aaiRestApiProvider.get(logger, NETWORK, format(VNF_URL, vnfId), GenericVnf.class); + private GenericVnf getExistingVnf(String vnfId) { + return aaiRestApiProvider.getNetworkApi().getNetworkGenericVnfsGenericVnf(vnfId, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null).blockingFirst(); } private void updateFields(GenericVnf vnf, String vnfId, boolean inMaintenance) { @@ -90,18 +89,17 @@ class GenericVnfManager extends AbstractManager { } vnf.setVnfId(vnfId); vnf.setInMaint(inMaintenance); - vnf.setVnfInstanceId(vnfId); //FIXME whould be good to know if this parameter is relevant or not? (mandatory) vnf.setVnfType("NokiaVNF"); vnf.setIsClosedLoopDisabled(inMaintenance); - aaiRestApiProvider.put(logger, NETWORK, format(VNF_URL, vnf.getVnfId()), vnf, Void.class); + SystemFunctions.systemFunctions().blockingFirst(aaiRestApiProvider.getNetworkApi().createOrUpdateNetworkGenericVnfsGenericVnf(vnf.getVnfId(), vnf)); } private GenericVnf waitForVnfToAppearInAai(String vnfId) { long timeoutInMs = systemFunctions().currentTimeMillis() + MAX_MS_TO_WAIT_FOR_VNF_TO_APPEAR; while (timeoutInMs - systemFunctions().currentTimeMillis() > 0) { try { - return aaiRestApiProvider.get(logger, NETWORK, format(VNF_URL, vnfId), GenericVnf.class); + return getExistingVnf(vnfId); } catch (NoSuchElementException e) { logger.debug("Unable to get VNF with " + vnfId + " identifier", e); } diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/L3NetworkManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/L3NetworkManager.java index 6d2b42bc..1d641cff 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/L3NetworkManager.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/L3NetworkManager.java @@ -16,9 +16,10 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification; import com.nokia.cbam.lcm.v32.model.AffectedVirtualLink; -import org.onap.aai.domain.yang.v11.L3Network; -import org.onap.aai.domain.yang.v11.Relationship; -import org.onap.aai.domain.yang.v11.RelationshipList; +import io.reactivex.Observable; +import java.util.ArrayList; +import org.onap.aai.model.L3Network; +import org.onap.aai.model.Relationship; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider; @@ -28,9 +29,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Component; -import static java.lang.String.format; -import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider.AAIService.NETWORK; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.SEPARATOR; +import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions.systemFunctions; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.getCloudOwner; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.getRegionName; @@ -40,7 +40,6 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.ge @Component @Conditional(value = Conditions.UseForDirect.class) class L3NetworkManager extends AbstractManager { - private static final String NETWORK_URL = "/l3-networks/l3-network/%s"; private static Logger logger = org.slf4j.LoggerFactory.getLogger(L3NetworkManager.class); @Autowired @@ -54,12 +53,17 @@ class L3NetworkManager extends AbstractManager { } void update(String vimId, String vnfId, AffectedVirtualLink affectedVirtualLink) { - L3Network l3Network = createOrGet(NETWORK, format(NETWORK_URL, buildNetworkId(vnfId, affectedVirtualLink)), OBJECT_FACTORY.createL3Network()); + L3Network l3Network = createOrGet(getNetwork(vnfId, affectedVirtualLink), new L3Network()); updateNetworkFields(vimId, vnfId, affectedVirtualLink, l3Network); } + private Observable<L3Network> getNetwork(String vnfId, AffectedVirtualLink affectedVirtualLink) { + return aaiRestApiProvider.getNetworkApi().getNetworkL3NetworksL3Network(buildNetworkId(vnfId, affectedVirtualLink), null, null, null, null, null, null, null, null, null); + } + void delete(String vnfId, AffectedVirtualLink removedVl) { - aaiRestApiProvider.delete(logger, NETWORK, format(NETWORK_URL, buildNetworkId(vnfId, removedVl))); + L3Network l3Network = getNetwork(vnfId, removedVl).blockingFirst(); + systemFunctions().blockingFirst(aaiRestApiProvider.getNetworkApi().deleteNetworkL3NetworksL3Network(l3Network.getNetworkId(), l3Network.getResourceVersion())); } private void updateNetworkFields(String vimId, String vnfId, AffectedVirtualLink affectedVirtualLink, L3Network network) { @@ -73,12 +77,12 @@ class L3NetworkManager extends AbstractManager { network.setOperationalStatus("active"); network.setOrchestrationStatus("active"); if (network.getRelationshipList() == null) { - network.setRelationshipList(new RelationshipList()); + network.setRelationshipList(new ArrayList<>()); } addMissingRelation(network.getRelationshipList(), GenericVnfManager.linkTo(vnfId)); addSingletonRelation(network.getRelationshipList(), getRegionLink(vimId)); addSingletonRelation(network.getRelationshipList(), getTenantLink(vimId, extractMandatoryValue(affectedVirtualLink.getResource().getAdditionalData(), "tenantId"))); - aaiRestApiProvider.put(logger, NETWORK, format(NETWORK_URL, network.getNetworkId()), network, Void.class); + systemFunctions().blockingFirst(aaiRestApiProvider.getNetworkApi().createOrUpdateNetworkL3NetworksL3Network(network.getNetworkId(), network)); } private String buildNetworkId(String vnfId, AffectedVirtualLink affectedVirtualLink) { @@ -88,6 +92,7 @@ class L3NetworkManager extends AbstractManager { private Relationship getRegionLink(String vimId) { Relationship relationship = new Relationship(); relationship.setRelatedTo("cloud-region"); + relationship.setRelationshipData(new ArrayList<>()); relationship.getRelationshipData().add(buildRelationshipData("cloud-region.cloud-owner", getCloudOwner(vimId))); relationship.getRelationshipData().add(buildRelationshipData("cloud-region.cloud-region-id", getRegionName(vimId))); return relationship; @@ -96,6 +101,7 @@ class L3NetworkManager extends AbstractManager { private Relationship getTenantLink(String vimId, String tenantId) { Relationship relationship = new Relationship(); relationship.setRelatedTo("tenant"); + relationship.setRelationshipData(new ArrayList<>()); relationship.getRelationshipData().add(buildRelationshipData("cloud-region.cloud-owner", getCloudOwner(vimId))); relationship.getRelationshipData().add(buildRelationshipData("cloud-region.cloud-region-id", getRegionName(vimId))); relationship.getRelationshipData().add(buildRelationshipData("tenant.tenant-id", tenantId)); diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/LInterfaceManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/LInterfaceManager.java index 229fe679..78da503e 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/LInterfaceManager.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/LInterfaceManager.java @@ -15,10 +15,11 @@ */ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification; -import org.onap.aai.domain.yang.v11.L3InterfaceIpv4AddressList; -import org.onap.aai.domain.yang.v11.L3InterfaceIpv6AddressList; -import org.onap.aai.domain.yang.v11.LInterface; -import org.onap.aai.domain.yang.v11.RelationshipList; +import io.reactivex.Observable; +import java.util.ArrayList; +import org.onap.aai.model.L3InterfaceIpv4AddressList; +import org.onap.aai.model.L3InterfaceIpv6AddressList; +import org.onap.aai.model.LInterface; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider; @@ -30,7 +31,8 @@ import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Component; import static java.lang.String.format; -import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider.AAIService.CLOUD; + +import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions.systemFunctions; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.getCloudOwner; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.getRegionName; @@ -62,15 +64,30 @@ class LInterfaceManager extends AbstractManager { } void update(String vnfId, String vimId, ReportedAffectedCp affectedCp, boolean inMaintenance) { - LInterface lInterface = createOrGet(CLOUD, buildUrl(vimId, affectedCp), OBJECT_FACTORY.createLInterface()); - updateFields(lInterface, affectedCp, vnfId, buildUrl(vimId, affectedCp), inMaintenance); + LInterface lInterface = createOrGet(getLinterface(vimId, affectedCp), new LInterface()); + updateFields(vimId, lInterface, affectedCp, vnfId, inMaintenance); } void delete(String vimId, ReportedAffectedCp removedCp) { - aaiRestApiProvider.delete(logger, AAIRestApiProvider.AAIService.CLOUD, buildUrl(vimId, removedCp)); + LInterface linterface = getLinterface(vimId, removedCp).blockingFirst(); + String cloudOwner = getCloudOwner(vimId); + String regionName = getRegionName(vimId); + String tenantId = removedCp.getTenantId(); + String vServerId = removedCp.getServerProviderId(); + String cpId = removedCp.getCpId(); + aaiRestApiProvider.getCloudInfrastructureApi().deleteCloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserverLInterfacesLInterface(cloudOwner, regionName, tenantId, vServerId, cpId, linterface.getResourceVersion()); + } + + private Observable<LInterface> getLinterface(String vimId, ReportedAffectedCp cp) { + String cloudOwner = getCloudOwner(vimId); + String regionName = getRegionName(vimId); + String tenantId = cp.getTenantId(); + String vServerId = cp.getServerProviderId(); + String cpId = cp.getCpId(); + return aaiRestApiProvider.getCloudInfrastructureApi().getCloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserverLInterfacesLInterface(cloudOwner, regionName, tenantId, vServerId, cpId, null, null, null, null, null, null, null, null, null, null, null, null); } - private void updateFields(LInterface logicalInterface, ReportedAffectedCp affectedCp, String vnfId, String url, boolean inMaintenance) { + private void updateFields(String vimId, LInterface logicalInterface, ReportedAffectedCp affectedCp, String vnfId, boolean inMaintenance) { logicalInterface.setInMaint(inMaintenance); logicalInterface.setIsIpUnnumbered(false); logicalInterface.setIsPortMirrored(false); @@ -81,21 +98,32 @@ class LInterfaceManager extends AbstractManager { logicalInterface.setProvStatus("active"); if (affectedCp.getIpAddress() != null) { if (affectedCp.getIpAddress().contains(":")) { - L3InterfaceIpv6AddressList ipv6Address = OBJECT_FACTORY.createL3InterfaceIpv6AddressList(); + L3InterfaceIpv6AddressList ipv6Address = new L3InterfaceIpv6AddressList(); ipv6Address.setL3InterfaceIpv6Address(affectedCp.getIpAddress()); ipv6Address.setNeutronNetworkId(affectedCp.getNetworkProviderId()); + if (logicalInterface.getL3InterfaceIpv6AddressList() == null) { + logicalInterface.setL3InterfaceIpv6AddressList(new ArrayList<>()); + } logicalInterface.getL3InterfaceIpv6AddressList().add(ipv6Address); } else { - L3InterfaceIpv4AddressList ipv4Address = OBJECT_FACTORY.createL3InterfaceIpv4AddressList(); + L3InterfaceIpv4AddressList ipv4Address = new L3InterfaceIpv4AddressList(); ipv4Address.setL3InterfaceIpv4Address(affectedCp.getIpAddress()); ipv4Address.setNeutronNetworkId(affectedCp.getNetworkProviderId()); + if (logicalInterface.getL3InterfaceIpv4AddressList() == null) { + logicalInterface.setL3InterfaceIpv4AddressList(new ArrayList<>()); + } logicalInterface.getL3InterfaceIpv4AddressList().add(ipv4Address); } } if (logicalInterface.getRelationshipList() == null) { - logicalInterface.setRelationshipList(new RelationshipList()); + logicalInterface.setRelationshipList(new ArrayList<>()); } addSingletonRelation(logicalInterface.getRelationshipList(), GenericVnfManager.linkTo(vnfId)); - aaiRestApiProvider.put(logger, CLOUD, url, logicalInterface, Void.class); + String cloudOwner = getCloudOwner(vimId); + String regionName = getRegionName(vimId); + String tenantId = affectedCp.getTenantId(); + String vServerId = affectedCp.getServerProviderId(); + String cpId = affectedCp.getCpId(); + systemFunctions().blockingFirst(aaiRestApiProvider.getCloudInfrastructureApi().createOrUpdateCloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserverLInterfacesLInterface(cloudOwner, regionName, tenantId, vServerId, cpId, logicalInterface)); } } diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VnfcManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VnfcManager.java index e1d1197b..9528e1a7 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VnfcManager.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VnfcManager.java @@ -15,8 +15,9 @@ */ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification; -import org.onap.aai.domain.yang.v11.RelationshipList; -import org.onap.aai.domain.yang.v11.Vnfc; +import io.reactivex.Observable; +import java.util.ArrayList; +import org.onap.aai.model.Vnfc; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider; @@ -26,9 +27,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Component; -import static java.lang.String.format; -import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider.AAIService.NETWORK; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.SEPARATOR; +import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions.systemFunctions; /** * Responsible for managing {@link Vnfc} in AAI @@ -43,15 +43,6 @@ public class VnfcManager extends AbstractManager { super(aaiRestApiProvider, cbamRestApiProvider, driverProperties); } - /** - * @param vnfId the identifier of the VNF - * @param cbamVnfcId the identifier of the VNFC in CBAM - * @return the URL of the VNFC - */ - public static String buildUrl(String vnfId, String cbamVnfcId) { - return format("/vnfcs/vnfc/%s", buildId(vnfId, cbamVnfcId)); - } - private static String buildId(String vnfId, String cbamVnfcId) { return vnfId + SEPARATOR + cbamVnfcId; } @@ -62,16 +53,20 @@ public class VnfcManager extends AbstractManager { } void delete(String vnfId, com.nokia.cbam.lcm.v32.model.AffectedVnfc cbamVnfc) { - aaiRestApiProvider.delete(logger, NETWORK, buildUrl(vnfId, cbamVnfc.getId())); + Vnfc vnfc = getVnfc(buildId(vnfId, cbamVnfc.getId())).blockingFirst(); + systemFunctions().blockingFirst(aaiRestApiProvider.getNetworkApi().deleteNetworkVnfcsVnfc(vnfc.getVnfcName(), vnfc.getResourceVersion())); + } + + private Observable<Vnfc> getVnfc(String vnfcId) { + return aaiRestApiProvider.getNetworkApi().getNetworkVnfcsVnfc(vnfcId, null, null, null, null, null, null, null, null, null); } void update(String vimId, String tenantId, String vnfId, com.nokia.cbam.lcm.v32.model.AffectedVnfc cbamVnfc, boolean inMaintenance) { - String url = buildUrl(vnfId, cbamVnfc.getId()); - Vnfc vnfc = createOrGet(NETWORK, url, OBJECT_FACTORY.createVnfc()); - updateFields(vimId, tenantId, vnfc, cbamVnfc, vnfId, url, inMaintenance); + Vnfc vnfc = createOrGet(getVnfc(buildId(vnfId, cbamVnfc.getId())), new Vnfc()); + updateFields(vimId, tenantId, vnfc, cbamVnfc, vnfId, inMaintenance); } - private void updateFields(String vimId, String tenantId, Vnfc aaiVnfc, com.nokia.cbam.lcm.v32.model.AffectedVnfc cbamVnfc, String vnfId, String url, boolean inMaintenance) { + private void updateFields(String vimId, String tenantId, Vnfc aaiVnfc, com.nokia.cbam.lcm.v32.model.AffectedVnfc cbamVnfc, String vnfId, boolean inMaintenance) { aaiVnfc.setInMaint(inMaintenance); aaiVnfc.setIsClosedLoopDisabled(inMaintenance); //FIXME would be good to know what is this mandatory parameter @@ -79,9 +74,11 @@ public class VnfcManager extends AbstractManager { //FIXME would be good to know what is this mandatory parameter aaiVnfc.setNfcNamingCode(cbamVnfc.getId()); aaiVnfc.setVnfcName(buildId(vnfId, cbamVnfc.getId())); - aaiVnfc.setRelationshipList(new RelationshipList()); + if (aaiVnfc.getRelationshipList() == null) { + aaiVnfc.setRelationshipList(new ArrayList<>()); + } addSingletonRelation(aaiVnfc.getRelationshipList(), VserverManager.linkTo(vimId, tenantId, cbamVnfc.getComputeResource().getResourceId())); addSingletonRelation(aaiVnfc.getRelationshipList(), GenericVnfManager.linkTo(vnfId)); - aaiRestApiProvider.put(logger, NETWORK, url, aaiVnfc, Void.class); + systemFunctions().blockingFirst(aaiRestApiProvider.getNetworkApi().createOrUpdateNetworkVnfcsVnfc(aaiVnfc.getVnfcName(), aaiVnfc)); } }
\ No newline at end of file diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VserverManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VserverManager.java index cec779a4..3eba8b21 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VserverManager.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/VserverManager.java @@ -20,7 +20,12 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.nokia.cbam.lcm.v32.model.AffectedVirtualStorage; import com.nokia.cbam.lcm.v32.model.AffectedVnfc; -import org.onap.aai.domain.yang.v11.*; +import io.reactivex.Observable; +import java.util.ArrayList; +import java.util.List; +import org.onap.aai.model.Relationship; +import org.onap.aai.model.Volume; +import org.onap.aai.model.Vserver; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider; @@ -30,12 +35,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Component; -import java.util.List; - import static com.google.common.collect.Iterables.find; -import static java.lang.String.format; -import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIRestApiProvider.AAIService.CLOUD; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.childElement; +import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions.systemFunctions; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.getCloudOwner; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.getRegionName; @@ -45,7 +47,7 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.ge @Component @Conditional(value = Conditions.UseForDirect.class) class VserverManager extends AbstractManager { - private static Logger logger = org.slf4j.LoggerFactory.getLogger(VserverManager.class); + private static Logger logger = org.slf4j.LoggerFactory.getLogger(AbstractManager.class); @Autowired VserverManager(AAIRestApiProvider aaiRestApiProvider, CbamRestApiProvider cbamRestApiProvider, DriverProperties driverProperties) { @@ -55,6 +57,7 @@ class VserverManager extends AbstractManager { static Relationship linkTo(String vimId, String tenantId, String serverProviderId) { Relationship relationship = new Relationship(); relationship.setRelatedTo("vserver"); + relationship.setRelationshipData(new ArrayList<>()); relationship.getRelationshipData().add(buildRelationshipData("cloud-region.cloud-owner", getCloudOwner(vimId))); relationship.getRelationshipData().add(buildRelationshipData("cloud-region.cloud-region-id", getRegionName(vimId))); relationship.getRelationshipData().add(buildRelationshipData("tenant.tenant-id", tenantId)); @@ -72,47 +75,53 @@ class VserverManager extends AbstractManager { } void update(String vimId, String vnfId, AffectedVnfc cbamVnfc, List<AffectedVirtualStorage> affectedVirtualStorages, boolean inMaintenance) { - String url = buildUrl(vimId, cbamVnfc); - Vserver vserver = createOrGet(CLOUD, url, OBJECT_FACTORY.createVserver()); - updateFields(vserver, cbamVnfc, vnfId, affectedVirtualStorages, url, inMaintenance); + Vserver vserver = createOrGet(getVserver(vimId, cbamVnfc), new Vserver()); + updateFields(vimId, vserver, cbamVnfc, vnfId, affectedVirtualStorages, inMaintenance); } - void delete(String vimId, com.nokia.cbam.lcm.v32.model.AffectedVnfc deletedVnfc) { - aaiRestApiProvider.delete(logger, CLOUD, buildUrl(vimId, deletedVnfc)); + void delete(String vimId, AffectedVnfc deletedVnfc) { + String tenantId = getTenantId(deletedVnfc); + String cloudOwner = getCloudOwner(vimId); + String regionName = getRegionName(vimId); + Vserver vserver = getVserver(vimId, deletedVnfc).blockingFirst(); + aaiRestApiProvider.getCloudInfrastructureApi().deleteCloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserver(cloudOwner, regionName, tenantId, vserver.getVserverId(), vserver.getResourceVersion()); } - private String buildUrl(String vimId, AffectedVnfc cbamVnfc) { + private Observable<Vserver> getVserver(String vimId, AffectedVnfc cbamVnfc) { String tenantId = getTenantId(cbamVnfc); String cloudOwner = getCloudOwner(vimId); String regionName = getRegionName(vimId); - return format("/cloud-regions/cloud-region/%s/%s/tenants/tenant/%s/vservers/vserver/%s", cloudOwner, regionName, tenantId, cbamVnfc.getComputeResource().getResourceId()); + return aaiRestApiProvider.getCloudInfrastructureApi().getCloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserver(cloudOwner, regionName, tenantId, cbamVnfc.getComputeResource().getResourceId(), null, null, null, null, null, null, null, null, null); } - private void updateFields(Vserver server, AffectedVnfc cbamVnfc, String vnfId, List<AffectedVirtualStorage> affectedVirtualStorages, String url, boolean inMaintenance) { + private void updateFields(String vimId, Vserver server, AffectedVnfc cbamVnfc, String vnfId, List<AffectedVirtualStorage> affectedVirtualStorages, boolean inMaintenance) { server.setInMaint(inMaintenance); server.setIsClosedLoopDisabled(inMaintenance); JsonElement additionalData = new Gson().toJsonTree(cbamVnfc.getComputeResource().getAdditionalData()); server.setVserverName(additionalData.getAsJsonObject().get("name").getAsString()); server.setVserverId(cbamVnfc.getComputeResource().getResourceId()); server.setProvStatus("active"); - server.setRelationshipList(new RelationshipList()); + server.setRelationshipList(new ArrayList<>()); server.setVserverId(cbamVnfc.getComputeResource().getResourceId()); server.setVserverSelflink(extractSelfLink(cbamVnfc.getComputeResource().getAdditionalData())); addSingletonRelation(server.getRelationshipList(), GenericVnfManager.linkTo(vnfId)); - if (server.getVolumes() == null) { - server.setVolumes(new Volumes()); - } if (cbamVnfc.getStorageResourceIds() != null) { + if (server.getVolumes() == null) { + server.setVolumes(new ArrayList<>()); + } for (String virtualStorageId : cbamVnfc.getStorageResourceIds()) { Volume volume = new Volume(); AffectedVirtualStorage affectedStorage = find(affectedVirtualStorages, storage -> virtualStorageId.equals(storage.getId())); volume.setVolumeId(affectedStorage.getResource().getResourceId()); - server.getVolumes().getVolume().add(volume); + server.getVolumes().add(volume); } } else { - server.setVolumes(OBJECT_FACTORY.createVolumes()); + server.setVolumes(new ArrayList<>()); } - aaiRestApiProvider.put(logger, CLOUD, url, server, Void.class); + String tenantId = getTenantId(cbamVnfc); + String cloudOwner = getCloudOwner(vimId); + String regionName = getRegionName(vimId); + systemFunctions().blockingFirst(aaiRestApiProvider.getCloudInfrastructureApi().createOrUpdateCloudInfrastructureCloudRegionsCloudRegionTenantsTenantVserversVserver(cloudOwner, regionName, tenantId, server.getVserverId(), server)); } private String extractSelfLink(Object additionalData) { diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcGrantManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcGrantManager.java index 03169612..01b75027 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcGrantManager.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcGrantManager.java @@ -23,6 +23,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.nokia.cbam.lcm.v32.model.VnfInfo; import com.nokia.cbam.lcm.v32.model.VnfcResourceInfo; +import java.util.*; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.IGrantManager; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CatalogManager; @@ -34,8 +35,6 @@ import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Component; import org.yaml.snakeyaml.Yaml; -import java.util.*; - import static com.nokia.cbam.lcm.v32.model.InstantiationState.INSTANTIATED; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.child; diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcNotificationSender.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcNotificationSender.java index 50f6221b..65cef408 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcNotificationSender.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcNotificationSender.java @@ -19,6 +19,8 @@ import com.google.gson.Gson; import com.nokia.cbam.lcm.v32.model.OperationExecution; import com.nokia.cbam.lcm.v32.model.ScaleVnfRequest; import com.nokia.cbam.lcm.v32.model.VnfLifecycleChangeNotification; +import java.util.ArrayList; +import java.util.Optional; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.INotificationSender; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.Conditions; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties; @@ -31,12 +33,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Component; -import java.util.ArrayList; -import java.util.Optional; +import static java.util.Optional.of; import static com.google.common.collect.Iterables.tryFind; import static com.nokia.cbam.lcm.v32.model.ScaleDirection.IN; -import static java.util.Optional.of; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.SEPARATOR; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.JobManager.extractOnapJobId; diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcPackageProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcPackageProvider.java index 5a3e960f..9ade5f4a 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcPackageProvider.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/VfcPackageProvider.java @@ -18,6 +18,9 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc; import com.google.common.io.ByteStreams; import com.google.gson.JsonElement; import com.google.gson.JsonParser; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; import org.apache.http.HttpEntity; import org.apache.http.HttpHeaders; import org.apache.http.client.methods.CloseableHttpResponse; @@ -33,10 +36,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Conditional; import org.springframework.stereotype.Component; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; - import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.buildFatalFailure; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions.systemFunctions; import static org.slf4j.LoggerFactory.getLogger; |