diff options
15 files changed, 231 insertions, 104 deletions
diff --git a/nokia/vnfmdriver/vfcadaptorservice/docker/instance-init.sh b/nokia/vnfmdriver/vfcadaptorservice/docker/instance-init.sh index a0595456..69e2b25d 100755 --- a/nokia/vnfmdriver/vfcadaptorservice/docker/instance-init.sh +++ b/nokia/vnfmdriver/vfcadaptorservice/docker/instance-init.sh @@ -17,6 +17,7 @@ # Config mysql credentials function start_mysql { + echo "start mysql ... " service mysql start sleep 1 } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Driver2CbamRequestConverter.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Driver2CbamRequestConverter.java index 42c91058..28400ed0 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Driver2CbamRequestConverter.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Driver2CbamRequestConverter.java @@ -32,7 +32,10 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.VimInfo; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.VnfExtCpData; import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonEnum; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmGrantVnfResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.AccessInfo; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.GrantInfo; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.NslcmVimInfo; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.VimAssets; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.VimComputeResourceFlavour; import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.HealVnfRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.InstantiateVnfRequest; @@ -59,15 +62,21 @@ public class Driver2CbamRequestConverter { VimInfo vim = new VimInfo(); EndpointInfo inter = new EndpointInfo(); OpenstackV3Info openstackV3 = new OpenstackV3Info(); - - vim.setId(nslc.getVim().getVimId()); - openstackV3.setId(nslc.getVim().getVimId()); - inter.setEndpoint(nslc.getVim().getInterfaceEndpoint()); + List<NslcmVimInfo> nslcmVim=nslc.getVim(); + for(int i=0;i<=nslcmVim.size();i++) { + vim.setId(nslcmVim.get(i).getVimInfoId()); + openstackV3.setId(nslcmVim.get(i).getVimId()); + inter.setEndpoint(nslcmVim.get(i).getInterfaceEndpoint()); openstackV3.setInterfaceInfo(inter); OpenStackAccessInfoV3 v3 = new OpenStackAccessInfoV3(); - v3.setUsername(nslc.getVim().getAccessInfo().getUsername()); - v3.setPassword(nslc.getVim().getAccessInfo().getPassword()); + List<AccessInfo> accessInfo=nslcmVim.get(i).getAccessInfo(); + for(int j=0;j<=accessInfo.size();j++) { + v3.setUsername(accessInfo.get(j).getUsername()); + v3.setPassword(accessInfo.get(j).getPassword()); + } openstackV3.setAccessInfo(v3); + } + vims.add(vim); List<ExtVirtualLinkData> list = new ArrayList<ExtVirtualLinkData>(); ExtVirtualLinkData ext = new ExtVirtualLinkData(); diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/impl/CatalogMgmrImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/impl/CatalogMgmrImpl.java index e8bb6be4..a3fb8e57 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/impl/CatalogMgmrImpl.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/impl/CatalogMgmrImpl.java @@ -20,18 +20,15 @@ import java.io.IOException; import java.util.HashMap; import org.apache.http.client.ClientProtocolException; -import org.apache.http.impl.client.HttpClientBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.bo.CatalogQueryVnfResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.inf.CatalogMgmrInf; import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv; import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonConstants; import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpClientProcessorInf; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpRequestProcessor; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.VnfPackageInfo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.RequestMethod; diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/common/bo/AdaptorEnv.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/common/bo/AdaptorEnv.java index 4a9570b5..e9a706c5 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/common/bo/AdaptorEnv.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/common/bo/AdaptorEnv.java @@ -56,6 +56,8 @@ public class AdaptorEnv { //cbamApiFront is from aai query private String cbamApiUriFront; + + private String msbApiUriFront; // for retrieving token from CBAM, configured in application.properties @Value("${grantType}") @@ -211,5 +213,13 @@ public class AdaptorEnv { this.lcmApiUriFront = lcmApiUriFront; } + public String getMsbApiUriFront() { + return msbApiUriFront; + } + + public void setMsbApiUriFront(String msbApiUriFront) { + this.msbApiUriFront = msbApiUriFront; + } + } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/constant/CommonConstants.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/constant/CommonConstants.java index aefd996a..052f6ee5 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/constant/CommonConstants.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/constant/CommonConstants.java @@ -68,4 +68,5 @@ public class CommonConstants { public static final String MSB_REGISTER_SERVICE_PATH = "/api/microservices/v1/services"; // public static final String MSB_REGISTER_SERVICE_PATH = "/api/microservices/v1/services/{serviceName}/version/{version}/nodes/{ip}/{port}"; public static final String MSB_UNREGISTER_SERVICE_PATH = "/api/microservices/v1/services/%s/version/%s/nodes/%s/%s"; + public static final String MSB_QUERY_SERVICE_PATH = "/api/microservices/v1/services/%s/version/%s"; } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/init/EnvVariablesInitialization.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/init/EnvVariablesInitialization.java index 30da37e3..7e756219 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/init/EnvVariablesInitialization.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/init/EnvVariablesInitialization.java @@ -18,6 +18,7 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.init; import java.io.IOException; +import org.apache.http.client.ClientProtocolException; import org.json.JSONException; import org.json.JSONObject; import org.onap.msb.sdk.discovery.common.RouteException; @@ -53,42 +54,47 @@ public class EnvVariablesInitialization implements ApplicationRunner { try { handleAaiMsbServiceInfo(); - } catch (RouteException e) { + } catch (Exception e) { logger.error("handleAaiMsbServiceInfo error", e); } try { handLcmMsbServiceInfo(); - } catch (RouteException e) { + } catch (Exception e) { logger.error("handLcmMsbServiceInfo error", e); } try { handCatalogMsbServiceInfo(); - } catch (RouteException e) { + } catch (Exception e) { logger.error("handCatalogMsbServiceInfo error", e); } } - private void handleAaiMsbServiceInfo() throws RouteException { - String urlInMsb = msbMgmr.getServiceUrlInMsbBySeriveNameAndPort(adaptorEnv.getAaiServiceNameInMsb(), adaptorEnv.getAaiVersionInMsb()); + private void handleAaiMsbServiceInfo() throws RouteException, ClientProtocolException, IOException { + String urlInMsb = msbMgmr.getServiceUrlInMsbBySeriveNameAndVersion(adaptorEnv.getAaiServiceNameInMsb(), adaptorEnv.getAaiVersionInMsb()); adaptorEnv.setAaiUrlInMsb(urlInMsb); adaptorEnv.setAaiApiUriFront(generateApiUriFront(urlInMsb)); } private String generateApiUriFront(String urlInMsb) { - return CommonConstants.SCHEMA_HTTP + "://" + adaptorEnv.getMsbIp() + ":" + adaptorEnv.getMsbPort() + urlInMsb; + return generateMsbApiUriFront() + urlInMsb; + } + + private String generateMsbApiUriFront() + { + return CommonConstants.SCHEMA_HTTP + "://" + adaptorEnv.getMsbIp() + ":" + adaptorEnv.getMsbPort(); } - private void handLcmMsbServiceInfo() throws RouteException { - String urlInMsb = msbMgmr.getServiceUrlInMsbBySeriveNameAndPort(adaptorEnv.getLcmServiceNameInMsb(), adaptorEnv.getLcmVersionInMsb()); + private void handLcmMsbServiceInfo() throws RouteException, ClientProtocolException, IOException { + String urlInMsb = msbMgmr.getServiceUrlInMsbBySeriveNameAndVersion(adaptorEnv.getLcmServiceNameInMsb(), adaptorEnv.getLcmVersionInMsb()); adaptorEnv.setLcmUrlInMsb(urlInMsb); adaptorEnv.setLcmApiUriFront(generateApiUriFront(urlInMsb)); } - private void handCatalogMsbServiceInfo() throws RouteException { - String urlInMsb = msbMgmr.getServiceUrlInMsbBySeriveNameAndPort(adaptorEnv.getCatalogServiceNameInMsb(), adaptorEnv.getCatalogVersionInMsb()); + private void handCatalogMsbServiceInfo() throws RouteException, ClientProtocolException, IOException { + String urlInMsb = msbMgmr.getServiceUrlInMsbBySeriveNameAndVersion(adaptorEnv.getCatalogServiceNameInMsb(), adaptorEnv.getCatalogVersionInMsb()); adaptorEnv.setCatalogUrlInMsb(urlInMsb); adaptorEnv.setCatalogApiUriFront(generateApiUriFront(urlInMsb)); } @@ -102,6 +108,7 @@ public class EnvVariablesInitialization implements ApplicationRunner { adaptorEnv.setMsbIp(msb_ip); adaptorEnv.setMsbPort(msb_port); + adaptorEnv.setMsbApiUriFront(generateMsbApiUriFront()); } private String readMsbInfoFromJsonFile() throws IOException { diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/bo/MsbServiceInfo.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/bo/MsbServiceInfo.java new file mode 100644 index 00000000..0ca55017 --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/bo/MsbServiceInfo.java @@ -0,0 +1,66 @@ +/* + * 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.msb.bo; + +public class MsbServiceInfo { + private String serviceName; + private String version; + private String protocol; + private String visualRange; + private String url; + + public String getServiceName() { + return serviceName; + } + + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getVisualRange() { + return visualRange; + } + + public void setVisualRange(String visualRange) { + this.visualRange = visualRange; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImpl.java index 7738b2f2..f2b1a32e 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImpl.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImpl.java @@ -16,22 +16,24 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.msb.impl; +import java.io.FileNotFoundException; import java.io.IOException; +import java.util.HashMap; -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.RouteResult; -import org.onap.msb.sdk.httpclient.msb.MSBServiceClient; +import org.apache.http.client.ClientProtocolException; import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv; import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.util.CommonUtil; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonConstants; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpClientProcessorInf; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.msb.bo.MsbServiceInfo; import org.onap.vfc.nfvo.driver.vnfm.svnfm.msb.inf.IMsbMgmr; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestMethod; -import com.alibaba.fastjson.JSON; import com.google.gson.Gson; @Component @@ -41,25 +43,28 @@ public class MsbMgmrImpl implements IMsbMgmr { @Autowired AdaptorEnv adaptorEnv; + @Autowired + HttpClientProcessorInf httpClientProcessor; + private Gson gson = new Gson(); @Override public void register() { + try { - String vfcAdaptorInfoJsonStr = readVfcAdaptorInfoFromJsonFile(); + String url = adaptorEnv.getMsbApiUriFront() + CommonConstants.MSB_REGISTER_SERVICE_PATH; + HashMap<String, String> map = new HashMap<>(); + map.put(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); - JSON json = com.alibaba.fastjson.JSON.parseObject(vfcAdaptorInfoJsonStr); - MicroServiceInfo msinfo = com.alibaba.fastjson.JSON.toJavaObject(json , MicroServiceInfo.class); + String bodyPostStr = readVfcAdaptorInfoFromJsonFile();; - MSBServiceClient msbClient = new MSBServiceClient(adaptorEnv.getMsbIp(), adaptorEnv.getMsbPort()); - MicroServiceFullInfo microServiceInfo = msbClient.registerMicroServiceInfo(msinfo); - logger.info("Registered service response info is " + microServiceInfo.toString()); + String responseStr = httpClientProcessor.process(url, RequestMethod.POST, map, bodyPostStr).getContent(); - } catch (RouteException e) { - logger.error("RouteException Failed to register nokia vnfm driver! ", e); - } catch (IOException e) { + logger.info("MsbMgmrImpl -> register, responseStr is " + responseStr); + + } catch (IOException e) { logger.error("IOException Failed to register nokia vnfm driver! ", e); - } + } } @@ -73,36 +78,35 @@ public class MsbMgmrImpl implements IMsbMgmr { @Override public void unregister() { try { - String jsonStr = readVfcAdaptorInfoFromJsonFile(); - MicroServiceInfo msinfo = gson.fromJson(jsonStr, MicroServiceInfo.class); + String url = adaptorEnv.getMsbApiUriFront() + String.format(CommonConstants.MSB_UNREGISTER_SERVICE_PATH); + + String responseStr = httpClientProcessor.process(url, RequestMethod.DELETE, null, null).getContent(); - MSBServiceClient msbClient = new MSBServiceClient(adaptorEnv.getMsbIp(), adaptorEnv.getMsbPort()); - RouteResult routeResult = msbClient.cancelMicroServiceInfo(msinfo.getServiceName(), msinfo.getVersion()); - logger.info("unregistered service response info is " + routeResult.toString()); + logger.info("MsbMgmrImpl -> unregister, responseStr is " + responseStr); - } catch (IOException e) { - logger.error("Failed to read vfcadaptor info! ", e); - } catch (RouteException e) { - logger.error("Failed to register nokia vnfm driver! ", e); + } catch (Exception e) { + logger.error("IOException Failed to unregister nokia vnfm driver! ", e); } + } - public String getServiceUrlInMsbBySeriveNameAndPort(String serviceName, String version) throws RouteException + public String getServiceUrlInMsbBySeriveNameAndVersion(String serviceName, String version) throws ClientProtocolException, IOException { - String serviceUrl = null; - MSBServiceClient msbClient = new MSBServiceClient(adaptorEnv.getMsbIp(), adaptorEnv.getMsbPort()); - MicroServiceFullInfo microServiceInfo = msbClient.queryMicroServiceInfo(serviceName, version); - if(null == microServiceInfo) - { - logger.error("There is no service in MSB for serviceName = {} and version = {}", serviceName, version); - } - else - { - serviceUrl = microServiceInfo.getUrl(); - logger.info("Service Url in MSB for serviceName = {} and version = {} is {}", serviceName, version, serviceUrl); - } - return serviceUrl; + String url=adaptorEnv.getMsbApiUriFront() + String.format(CommonConstants.MSB_QUERY_SERVICE_PATH, serviceName, version); + + String responseStr = httpClientProcessor.process(url, RequestMethod.GET, null, null).getContent(); + logger.info("MsbMgmrImpl -> getServiceUrlInMsbBySeriveNameAndVersion, responseStr is " + responseStr); + + MsbServiceInfo serviceInfo = gson.fromJson(responseStr, MsbServiceInfo.class); + if(null == serviceInfo) + { + logger.error("There is no service in MSB for serviceName = {} and version = {}", serviceName, version); + } + + String serviceUrl = serviceInfo.getUrl(); + logger.info("Service Url in MSB for serviceName = {} and version = {} is {}", serviceName, version, serviceUrl); + return serviceUrl; } public void setAdaptorEnv(AdaptorEnv env) { diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/inf/IMsbMgmr.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/inf/IMsbMgmr.java index f63b5a56..d860e398 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/inf/IMsbMgmr.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/inf/IMsbMgmr.java @@ -16,10 +16,13 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.msb.inf; +import java.io.IOException; + +import org.apache.http.client.ClientProtocolException; import org.onap.msb.sdk.discovery.common.RouteException; public interface IMsbMgmr { public void register(); public void unregister(); - public String getServiceUrlInMsbBySeriveNameAndPort(String serviceName, String version) throws RouteException; + public String getServiceUrlInMsbBySeriveNameAndVersion(String serviceName, String version) throws RouteException, ClientProtocolException, IOException; } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/NslcmGrantVnfResponse.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/NslcmGrantVnfResponse.java index b5f0fec1..8a0dd538 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/NslcmGrantVnfResponse.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/NslcmGrantVnfResponse.java @@ -19,25 +19,27 @@ import java.util.List; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.ResourceDefinition; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.VimAssets; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.VimInfo; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.NslcmVimInfo; import com.fasterxml.jackson.annotation.JsonProperty; public class NslcmGrantVnfResponse { @JsonProperty("vim") - private VimInfo vim; + private List<NslcmVimInfo> vim; @JsonProperty("vimAssets") private VimAssets vimAssets; @JsonProperty("additionalParam") private List<ResourceDefinition> additionalParam; - public VimInfo getVim() { + + + public List<NslcmVimInfo> getVim() { return vim; } - public void setVim(VimInfo vim) { + public void setVim(List<NslcmVimInfo> vim) { this.vim = vim; } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/NslcmNotifyLCMEventsRequest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/NslcmNotifyLCMEventsRequest.java index bdfdf848..ccfe8f25 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/NslcmNotifyLCMEventsRequest.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/NslcmNotifyLCMEventsRequest.java @@ -15,6 +15,8 @@ */ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo; +import java.util.List; + import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonEnum; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.AffectedVirtualLink; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.AffectedVirtualStorage; @@ -34,11 +36,11 @@ public class NslcmNotifyLCMEventsRequest { @JsonProperty("jobId") private String jobId; @JsonProperty("affectedVnfc") - private AffectedVnfc affectedVnfc; + private List<AffectedVnfc> affectedVnfc; @JsonProperty("affectedVl") - private AffectedVirtualLink affectedVl; + private List<AffectedVirtualLink> affectedVl; @JsonProperty("affectedVirtualStorage") - private AffectedVirtualStorage affectedVirtualStorage; + private List<AffectedVirtualStorage> affectedVirtualStorage; public CommonEnum.status getStatus() { return status; } @@ -63,27 +65,26 @@ public class NslcmNotifyLCMEventsRequest { public void setJobId(String jobId) { this.jobId = jobId; } - public AffectedVnfc getAffectedVnfc() { + public List<AffectedVnfc> getAffectedVnfc() { return affectedVnfc; } - public void setAffectedVnfc(AffectedVnfc affectedVnfc) { + public void setAffectedVnfc(List<AffectedVnfc> affectedVnfc) { this.affectedVnfc = affectedVnfc; } - public AffectedVirtualLink getAffectedVl() { + public List<AffectedVirtualLink> getAffectedVl() { return affectedVl; } - public void setAffectedVl(AffectedVirtualLink affectedVl) { + public void setAffectedVl(List<AffectedVirtualLink> affectedVl) { this.affectedVl = affectedVl; } - public AffectedVirtualStorage getAffectedVirtualStorage() { + public List<AffectedVirtualStorage> getAffectedVirtualStorage() { return affectedVirtualStorage; } - public void setAffectedVirtualStorage(AffectedVirtualStorage affectedVirtualStorage) { + public void setAffectedVirtualStorage(List<AffectedVirtualStorage> affectedVirtualStorage) { this.affectedVirtualStorage = affectedVirtualStorage; } - } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/VimInfo.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/NslcmVimInfo.java index 8bb63490..268840f7 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/VimInfo.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/NslcmVimInfo.java @@ -15,9 +15,11 @@ */ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity; +import java.util.List; + import com.fasterxml.jackson.annotation.JsonProperty; -public class VimInfo { +public class NslcmVimInfo { @JsonProperty("vimInfoId") private String vimInfoId; @@ -25,9 +27,9 @@ public class VimInfo { @JsonProperty("vimId") private String vimId; @JsonProperty("interfaceInfo") - private InterfaceInfo interfaceInfo; + private List<InterfaceInfo> interfaceInfo; @JsonProperty("accessInfo") - private AccessInfo accessInfo; + private List<AccessInfo> accessInfo; @JsonProperty("interfaceEndpoint") private String interfaceEndpoint; @@ -47,20 +49,23 @@ public class VimInfo { public void setVimId(String vimId) { this.vimId = vimId; } - - public InterfaceInfo getInterfaceInfo() { + + + + + public List<InterfaceInfo> getInterfaceInfo() { return interfaceInfo; } - public void setInterfaceInfo(InterfaceInfo interfaceInfo) { + public void setInterfaceInfo(List<InterfaceInfo> interfaceInfo) { this.interfaceInfo = interfaceInfo; } - public AccessInfo getAccessInfo() { + public List<AccessInfo> getAccessInfo() { return accessInfo; } - public void setAccessInfo(AccessInfo accessInfo) { + public void setAccessInfo(List<AccessInfo> accessInfo) { this.accessInfo = accessInfo; } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/VimAssets.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/VimAssets.java index 041e6413..a2199436 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/VimAssets.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/VimAssets.java @@ -15,20 +15,24 @@ */ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity; +import java.util.List; + import com.fasterxml.jackson.annotation.JsonProperty; public class VimAssets { @JsonProperty("softwareImage") - private VimSoftwareImage softwareImage; + private List<VimSoftwareImage> softwareImage; - public VimSoftwareImage getSoftwareImage() { + public List<VimSoftwareImage> getSoftwareImage() { return softwareImage; } - public void setSoftwareImage(VimSoftwareImage softwareImage) { + public void setSoftwareImage(List<VimSoftwareImage> softwareImage) { this.softwareImage = softwareImage; - } + } + + diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImplTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImplTest.java index 8e175e63..aa1a0217 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImplTest.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImplTest.java @@ -16,14 +16,22 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.msb.impl; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.util.HashMap; + +import org.apache.http.client.ClientProtocolException; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.onap.msb.sdk.discovery.common.RouteException; import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv; import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpClientProcessorInf; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpResult; +import org.springframework.web.bind.annotation.RequestMethod; public class MsbMgmrImplTest { @InjectMocks @@ -40,23 +48,29 @@ public class MsbMgmrImplTest { env.setMsbPort(80); msbMgmr.setAdaptorEnv(env); MockitoAnnotations.initMocks(this); + + String json = "{\"serviceName\":\"catalog\", \"url\":\"/api/catalog/v1\"}"; + HttpResult httpResult = new HttpResult(); + httpResult.setContent(json); + + when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(httpResult); } - @Test(expected = RuntimeException.class) + @Test public void testRegister() { msbMgmr.register(); } - @Test(expected = RuntimeException.class) + @Test public void testunRegister() { msbMgmr.unregister(); } - @Test(expected = RouteException.class) - public void testGetServiceUrlInMsbBySeriveNameAndPort() throws RouteException + @Test + public void testGetServiceUrlInMsbBySeriveNameAndPort() throws ClientProtocolException, IOException { - msbMgmr.getServiceUrlInMsbBySeriveNameAndPort("serviceName", "88"); + msbMgmr.getServiceUrlInMsbBySeriveNameAndVersion("serviceName", "88"); } } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImplTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImplTest.java index ddff4ca2..47c33bf1 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImplTest.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImplTest.java @@ -45,7 +45,7 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.AffectedVnfc; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.InterfaceInfo; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.ResourceDefinition; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.VimAssets; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.VimInfo; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.NslcmVimInfo; import org.springframework.web.bind.annotation.RequestMethod; import com.google.gson.Gson; @@ -87,18 +87,21 @@ public class NslcmMgmrImplTest { additionalParam2.add(resource); gresponse.setAdditionalParam(additionalParam2); - VimInfo vim = new VimInfo(); - vim.setInterfaceEndpoint("interfaceEndpoint"); - vim.setVimId("vimId"); - AccessInfo accessInfo = null; - vim.setAccessInfo(accessInfo ); - InterfaceInfo interfaceInfo = null; - vim.setInterfaceInfo(interfaceInfo); + List<NslcmVimInfo> vim = new ArrayList<NslcmVimInfo>(); + NslcmVimInfo vims=new NslcmVimInfo(); + vims.setInterfaceEndpoint("interfaceEndpoint"); + vims.setVimId("vimId"); + List<AccessInfo> accessInfo = null; + vims.setAccessInfo(accessInfo); + List<InterfaceInfo> interfaceInfo = null; + vims.setInterfaceInfo(interfaceInfo); + + vim.add(vims); VimAssets vimAssets = null; gresponse.setVimAssets(vimAssets); - gresponse.setVim(vim ); + gresponse.setVim(vim); String json = gson.toJson(gresponse); HttpResult httpResult = new HttpResult(); httpResult.setContent(json); @@ -139,9 +142,9 @@ public class NslcmMgmrImplTest { cbamRequest.setJobId("jobId"); cbamRequest.setOperation("operation"); cbamRequest.setVnfInstanceId(vnfInstanceId); - AffectedVirtualStorage affectedVirtualStorage = new AffectedVirtualStorage(); + List<AffectedVirtualStorage> affectedVirtualStorage = new ArrayList<AffectedVirtualStorage>(); cbamRequest.setAffectedVirtualStorage(affectedVirtualStorage ); - AffectedVnfc affectedVnfc = new AffectedVnfc(); + List<AffectedVnfc> affectedVnfc = new ArrayList<AffectedVnfc>(); cbamRequest.setAffectedVnfc(affectedVnfc ); nslcmMgmr.notifyVnf(cbamRequest, vnfInstanceId); } |