diff options
author | 2017-10-06 19:33:54 +0800 | |
---|---|---|
committer | 2017-10-06 19:33:54 +0800 | |
commit | c0134003468a9331c1efb70872d0324bbe89ee88 (patch) | |
tree | 9b9e639711b1f8e51317242d3495b5903343a391 /nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java | |
parent | 358611bc1303a4e114ea862a3437947fc2f5caf6 (diff) |
Add Unit Tests.
Change-Id: Ic4cde859dea0f93958de908b091bfa1dbe61fc70
Issue-ID: VFC-53
Signed-off-by: yufei_zhou <yufei.zhou@nokia-sbell.com>
Diffstat (limited to 'nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java')
19 files changed, 1027 insertions, 219 deletions
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/bo/AaiVnfmInfo.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/bo/AaiVnfmInfo.java new file mode 100644 index 00000000..0d75003b --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/bo/AaiVnfmInfo.java @@ -0,0 +1,80 @@ +/* + * 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.aai.bo; + +import java.util.List; + +import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.bo.entity.EsrSystemInfo; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class AaiVnfmInfo { + @JsonProperty("vnfm-id") + private String vnfmId; + + @JsonProperty("vim-id") + private String vimId; + + @JsonProperty("certificate-url") + private String certificateUrl; + + @JsonProperty("resource-version") + private String resourceVersion; + + @JsonProperty("esr-system-info-list") + private List<EsrSystemInfo> esrSystemInfoList; + + public String getVnfmId() { + return vnfmId; + } + + public void setVnfmId(String vnfmId) { + this.vnfmId = vnfmId; + } + + public String getVimId() { + return vimId; + } + + public void setVimId(String vimId) { + this.vimId = vimId; + } + + public String getCertificateUrl() { + return certificateUrl; + } + + public void setCertificateUrl(String certificateUrl) { + this.certificateUrl = certificateUrl; + } + + public String getResourceVersion() { + return resourceVersion; + } + + public void setResourceVersion(String resourceVersion) { + this.resourceVersion = resourceVersion; + } + + public List<EsrSystemInfo> getEsrSystemInfoList() { + return esrSystemInfoList; + } + + public void setEsrSystemInfoList(List<EsrSystemInfo> esrSystemInfoList) { + this.esrSystemInfoList = esrSystemInfoList; + } +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/bo/entity/EsrSystemInfo.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/bo/entity/EsrSystemInfo.java new file mode 100644 index 00000000..75e0e7fa --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/bo/entity/EsrSystemInfo.java @@ -0,0 +1,187 @@ +/* + * 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.aai.bo.entity; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class EsrSystemInfo { + @JsonProperty("esr-system-info-id") + private String esrSystemId; + + @JsonProperty("system-name") + private String esrSystemName; + + @JsonProperty("type") + private String type; + + @JsonProperty("vendor") + private String vendor; + + @JsonProperty("version") + private String version; + + @JsonProperty("service-url") + private String serviceUrl; + + @JsonProperty("user-name") + private String userName; + + @JsonProperty("password") + private String password; + + @JsonProperty("protocal") + private String protocal; + + @JsonProperty("ssl-cacert") + private String sslCacert; + + @JsonProperty("ssl-insecure") + private String sslInsecure; + + @JsonProperty("ip-address") + private String ip; + + @JsonProperty("port") + private String port; + + @JsonProperty("cloud-domain") + private String cloudDomain; + + @JsonProperty("default-tenant") + private String defaultTenant; + + public String getEsrSystemId() { + return esrSystemId; + } + + public void setEsrSystemId(String esrSystemId) { + this.esrSystemId = esrSystemId; + } + + public String getEsrSystemName() { + return esrSystemName; + } + + public void setEsrSystemName(String esrSystemName) { + this.esrSystemName = esrSystemName; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getVendor() { + return vendor; + } + + public void setVendor(String vendor) { + this.vendor = vendor; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getServiceUrl() { + return serviceUrl; + } + + public void setServiceUrl(String serviceUrl) { + this.serviceUrl = serviceUrl; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getProtocal() { + return protocal; + } + + public void setProtocal(String protocal) { + this.protocal = protocal; + } + + public String getSslCacert() { + return sslCacert; + } + + public void setSslCacert(String sslCacert) { + this.sslCacert = sslCacert; + } + + public String getSslInsecure() { + return sslInsecure; + } + + public void setSslInsecure(String sslInsecure) { + this.sslInsecure = sslInsecure; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public String getPort() { + return port; + } + + public void setPort(String port) { + this.port = port; + } + + public String getCloudDomain() { + return cloudDomain; + } + + public void setCloudDomain(String cloudDomain) { + this.cloudDomain = cloudDomain; + } + + public String getDefaultTenant() { + return defaultTenant; + } + + public void setDefaultTenant(String defaultTenant) { + this.defaultTenant = defaultTenant; + } + +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/impl/AaiMgmrInfImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/impl/AaiMgmrInfImpl.java new file mode 100644 index 00000000..caec85da --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/impl/AaiMgmrInfImpl.java @@ -0,0 +1,74 @@ +/* + * 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.aai.impl; + +import java.io.IOException; + +import org.apache.http.client.ClientProtocolException; +import org.apache.http.impl.client.HttpClientBuilder; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.bo.AaiVnfmInfo; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.inf.AaiMgmrInf; +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.HttpRequestProcessor; +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.google.gson.Gson; + +@Component +public class AaiMgmrInfImpl implements AaiMgmrInf{ + private static final Logger logger = LoggerFactory.getLogger(AaiMgmrInfImpl.class); + + @Autowired + private AdaptorEnv adaptorEnv; + + @Autowired + private HttpClientBuilder httpClientBuilder; + + private Gson gson = new Gson(); + @Override + public AaiVnfmInfo queryVnfm(String vnfmId) throws ClientProtocolException, IOException { + String httpPath = String.format(CommonConstants.RetrieveVnfmListPath, vnfmId); + RequestMethod method = RequestMethod.GET; + + String responseStr = operateHttpTask(null, httpPath, method); + + logger.info("AaiMgmrInfImpl->queryVnfm, the vnfmInfo is {}", responseStr); + + AaiVnfmInfo response = gson.fromJson(responseStr, AaiVnfmInfo.class); + + return response; + } + + private String operateHttpTask(Object httpBodyObj, String httpPath, RequestMethod method) throws ClientProtocolException, IOException { + String url=adaptorEnv.getAaiApiUriFront() + httpPath; + HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, method); + processor.addHdeader(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); + + processor.addPostEntity(gson.toJson(httpBodyObj)); + + String responseStr = processor.process(url); + + return responseStr; + } + +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/inf/AaiMgmrInf.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/inf/AaiMgmrInf.java new file mode 100644 index 00000000..c81496dc --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/inf/AaiMgmrInf.java @@ -0,0 +1,26 @@ +/* + * 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.aai.inf; + +import java.io.IOException; + +import org.apache.http.client.ClientProtocolException; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.bo.AaiVnfmInfo; + +public interface AaiMgmrInf { + public AaiVnfmInfo queryVnfm(String vnfmId) throws ClientProtocolException, IOException; +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Cbam2DriverResponseConverter.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Cbam2DriverResponseConverter.java index 33d34d0f..b79104f9 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Cbam2DriverResponseConverter.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Cbam2DriverResponseConverter.java @@ -46,15 +46,7 @@ public class Cbam2DriverResponseConverter { @Autowired private VnfmJobExecutionRepository jobDbManager; - public InstantiateVnfResponse createRspConvert(CBAMCreateVnfResponse cbamResponse) { - - VnfmJobExecutionInfo jobInfo = new VnfmJobExecutionInfo(); - jobInfo.setVnfInstanceId(cbamResponse.getId()); - jobInfo.setVnfmInterfceName(CommonConstants.NSLCM_OPERATION_INSTANTIATE); - jobInfo.setStatus(CommonConstants.CBAM_OPERATION_STATUS_START); - - VnfmJobExecutionInfo jobInfo1 = (VnfmJobExecutionInfo) jobDbManager.save(jobInfo); - Long jobId = jobInfo1.getJobId(); + public InstantiateVnfResponse createRspConvert(CBAMCreateVnfResponse cbamResponse, Long jobId) { InstantiateVnfResponse response = new InstantiateVnfResponse(); response.setJobId(jobId.longValue() + ""); diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImpl.java index 59fad026..10802c87 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImpl.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImpl.java @@ -16,9 +16,13 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.adaptor; +import java.io.IOException; + import org.apache.http.HttpStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.http.client.ClientProtocolException; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.bo.AaiVnfmInfo; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.bo.entity.EsrSystemInfo; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.inf.AaiMgmrInf; import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.inf.CatalogMgmrInf; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateVnfRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateVnfResponse; @@ -29,11 +33,11 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMQueryVnfResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.inf.CbamMgmrInf; +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.db.bean.VnfmJobExecutionInfo; import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.repository.VnfmJobExecutionRepository; import org.onap.vfc.nfvo.driver.vnfm.svnfm.exception.VnfmDriverException; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.VnfmInfo; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.inf.NslcmMgmrInf; import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.HealVnfRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.HealVnfResponse; @@ -45,10 +49,15 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.ScaleVnfRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.ScaleVnfResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.TerminateVnfRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.TerminateVnfResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.inf.VnfContinueProcessorInf; import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.inf.VnfmDriverMgmrInf; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import com.google.gson.Gson; + @Component public class VnfmDriverMgmrImpl implements VnfmDriverMgmrInf{ @@ -70,28 +79,32 @@ public class VnfmDriverMgmrImpl implements VnfmDriverMgmrInf{ private NslcmMgmrInf nslcmMgmr; @Autowired + private AaiMgmrInf aaiMgmr; + + @Autowired private VnfmJobExecutionRepository jobDbManager; + @Autowired + AdaptorEnv adaptorEnv; + + @Autowired + private VnfContinueProcessorInf vnfContinueProcessorInf; + + private Gson gson = new Gson(); + public InstantiateVnfResponse instantiateVnf(InstantiateVnfRequest driverRequest, String vnfmId) throws VnfmDriverException { InstantiateVnfResponse driverResponse; try { - //step 1: query vnfm info - VnfmInfo vnfmInfo = nslcmMgmr.queryVnfm(vnfmId); - - if(vnfmInfo == null || vnfmId.equalsIgnoreCase(vnfmInfo.getVnfmId())) - { - throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500); - } + buildVnfmHttpPathById(vnfmId); //step 3: create vnf CBAMCreateVnfRequest cbamRequest = requestConverter.createReqConvert(driverRequest); CBAMCreateVnfResponse cbamResponse = cbamMgmr.createVnf(cbamRequest); - driverResponse = responseConverter.createRspConvert(cbamResponse); - - String vnfInstanceId = driverResponse.getVnfInstanceId(); - String jobId = driverResponse.getJobId(); - continueInstantiateVnf(driverRequest, vnfInstanceId, jobId); + String vnfInstanceId = cbamResponse.getId(); + Long jobId = saveCreateVnfJob(vnfInstanceId); + driverResponse = responseConverter.createRspConvert(cbamResponse, jobId); + vnfContinueProcessorInf.continueInstantiateVnf(driverRequest, vnfInstanceId, jobId.toString(), nslcmMgmr, catalogMgmr, cbamMgmr, requestConverter, jobDbManager); } catch (Exception e) { throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500); @@ -99,28 +112,25 @@ public class VnfmDriverMgmrImpl implements VnfmDriverMgmrInf{ return driverResponse; } + + private Long saveCreateVnfJob(String vnfInstanceId) { + VnfmJobExecutionInfo jobInfo = new VnfmJobExecutionInfo(); + jobInfo.setVnfInstanceId(vnfInstanceId); + jobInfo.setVnfmInterfceName(CommonConstants.NSLCM_OPERATION_INSTANTIATE); + jobInfo.setStatus(CommonConstants.CBAM_OPERATION_STATUS_START); - public void continueInstantiateVnf(InstantiateVnfRequest driverRequest, String vnfInstanceId, String jobId) { - InstantiateVnfContinueRunnable runnable = new InstantiateVnfContinueRunnable(driverRequest, vnfInstanceId, jobId, - nslcmMgmr, catalogMgmr, cbamMgmr, requestConverter, jobDbManager); - - Thread thread = new Thread(runnable); - - thread.run(); + VnfmJobExecutionInfo jobInfo1 = (VnfmJobExecutionInfo) jobDbManager.save(jobInfo); + Long jobId = jobInfo1.getJobId(); + return jobId; } public TerminateVnfResponse terminateVnf(TerminateVnfRequest driverRequest, String vnfmId, String vnfInstanceId) { TerminateVnfResponse driverResponse; try { - VnfmInfo vnfmInfo = nslcmMgmr.queryVnfm(vnfmId); - - if(vnfmInfo == null || vnfmId.equalsIgnoreCase(vnfmInfo.getVnfmId())) - { - throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500); - } + buildVnfmHttpPathById(vnfmId); driverResponse = generateTerminateVnfResponse(vnfInstanceId); String jobId = driverResponse.getJobId(); - continueTerminateVnf(driverRequest, vnfInstanceId, jobId); + vnfContinueProcessorInf.continueTerminateVnf(driverRequest, vnfInstanceId, jobId, nslcmMgmr, cbamMgmr, requestConverter, jobDbManager); } catch (Exception e) { throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500); @@ -143,26 +153,10 @@ public class VnfmDriverMgmrImpl implements VnfmDriverMgmrInf{ return response; } - public void continueTerminateVnf(TerminateVnfRequest driverRequest, String vnfInstanceId, String jobId) { - TerminateVnfContinueRunnable runnable = new TerminateVnfContinueRunnable(driverRequest, vnfInstanceId, jobId, - nslcmMgmr, cbamMgmr, requestConverter, jobDbManager); - - Thread thread = new Thread(runnable); - - thread.run(); - } - - public QueryVnfResponse queryVnf(String vnfmId, String vnfInstanceId) { QueryVnfResponse driverResponse; try { - nslcmMgmr.queryVnfm(vnfmId); - VnfmInfo vnfmInfo = nslcmMgmr.queryVnfm(vnfmId); - - if(vnfmInfo == null || vnfmId.equalsIgnoreCase(vnfmInfo.getVnfmId())) - { - throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500); - } + buildVnfmHttpPathById(vnfmId); CBAMQueryVnfResponse cbamResponse = cbamMgmr.queryVnf(vnfInstanceId); driverResponse = responseConverter.queryRspConvert(cbamResponse); } catch (Exception e) { @@ -173,24 +167,14 @@ public class VnfmDriverMgmrImpl implements VnfmDriverMgmrInf{ } public OperStatusVnfResponse getOperStatus(String vnfmId, String jobId) throws VnfmDriverException { - VnfmInfo vnfmInfo; - try { - vnfmInfo = nslcmMgmr.queryVnfm(vnfmId); - } catch (Exception e) { - throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500); - } - - if(vnfmInfo == null || vnfmId.equalsIgnoreCase(vnfmInfo.getVnfmId())) - { - throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500); - } - - VnfmJobExecutionInfo jobInfo = jobDbManager.findOne(Long.getLong(jobId)); - String execId = jobInfo.getVnfmExecutionId(); CBAMQueryOperExecutionResponse cbamResponse; try { + buildVnfmHttpPathById(vnfmId); + + VnfmJobExecutionInfo jobInfo = jobDbManager.findOne(Long.getLong(jobId)); + String execId = jobInfo.getVnfmExecutionId(); cbamResponse = cbamMgmr.queryOperExecution(execId); } catch (Exception e) { throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500); @@ -204,12 +188,7 @@ public class VnfmDriverMgmrImpl implements VnfmDriverMgmrInf{ public ScaleVnfResponse scaleVnf(ScaleVnfRequest driverRequest, String vnfmId, String vnfInstanceId) throws VnfmDriverException { ScaleVnfResponse driverResponse; try { - VnfmInfo vnfmInfo = nslcmMgmr.queryVnfm(vnfmId); - - if(vnfmInfo == null || vnfmId.equalsIgnoreCase(vnfmInfo.getVnfmId())) - { - throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500); - } + buildVnfmHttpPathById(vnfmId); CBAMScaleVnfRequest cbamRequest = requestConverter.scaleReqconvert(driverRequest); CBAMScaleVnfResponse cbamResponse = cbamMgmr.scaleVnf(cbamRequest, vnfInstanceId); driverResponse = responseConverter.scaleRspConvert(cbamResponse); @@ -223,12 +202,7 @@ public class VnfmDriverMgmrImpl implements VnfmDriverMgmrInf{ public HealVnfResponse healVnf(HealVnfRequest driverRequest, String vnfmId, String vnfInstanceId) throws VnfmDriverException { HealVnfResponse driverResponse; try { - VnfmInfo vnfmInfo = nslcmMgmr.queryVnfm(vnfmId); - - if(vnfmInfo == null || vnfmId.equalsIgnoreCase(vnfmInfo.getVnfmId())) - { - throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500); - } + buildVnfmHttpPathById(vnfmId); CBAMHealVnfRequest cbamRequest = requestConverter.healReqConvert(driverRequest); CBAMHealVnfResponse cbamResponse = cbamMgmr.healVnf(cbamRequest, vnfInstanceId); driverResponse = responseConverter.healRspConvert(cbamResponse); @@ -239,4 +213,31 @@ public class VnfmDriverMgmrImpl implements VnfmDriverMgmrInf{ return driverResponse; } + public String buildVnfmHttpPathById(String vnfmId) throws ClientProtocolException, IOException, VnfmDriverException { + AaiVnfmInfo vnfmInfo = aaiMgmr.queryVnfm(vnfmId); + logger.info("vnfmInfo in AAI is {}", gson.toJson(vnfmInfo)); + if(isVnfmInfoValid(vnfmId, vnfmInfo)) + { + throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500); + } + + EsrSystemInfo systemInfo = vnfmInfo.getEsrSystemInfoList().get(0); + + String urlHead = systemInfo.getProtocal() + "://" + systemInfo.getIp() + ":" + systemInfo.getPort(); + adaptorEnv.setCbamApiUriFront(urlHead); + return urlHead; + } + + private boolean isVnfmInfoValid(String vnfmId, AaiVnfmInfo vnfmInfo) { + return vnfmInfo == null || !vnfmId.equalsIgnoreCase(vnfmInfo.getVnfmId()) || vnfmInfo.getEsrSystemInfoList() == null || vnfmInfo.getEsrSystemInfoList().isEmpty(); + } + + public void setRequestConverter(Driver2CbamRequestConverter requestConverter) { + this.requestConverter = requestConverter; + } + + public void setResponseConverter(Cbam2DriverResponseConverter responseConverter) { + this.responseConverter = responseConverter; + } + } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImpl.java index 1e2cecf7..2c88320e 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImpl.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImpl.java @@ -17,6 +17,7 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.impl; import java.io.IOException; +import java.util.HashMap; import org.apache.http.client.ClientProtocolException; import org.apache.http.impl.client.HttpClientBuilder; @@ -38,6 +39,7 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMTerminateVnfResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.inf.CbamMgmrInf; 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.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; @@ -55,19 +57,18 @@ public class CbamMgmrImpl implements CbamMgmrInf { private AdaptorEnv adaptorEnv; @Autowired - private HttpClientBuilder httpClientBuilder;// = HttpClientUtils.createHttpClientBuilder(); + HttpClientProcessorInf httpClientProcessor; private String retrieveToken() throws ClientProtocolException, IOException, JSONException { String result = null; String url= adaptorEnv.getCbamApiUriFront() + CommonConstants.RetrieveCbamTokenPath; - HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, RequestMethod.POST); - processor.addHdeader(CommonConstants.ACCEPT, "*/*"); - processor.addHdeader(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE); + HashMap<String, String> map = new HashMap<String, String>(); + map.put(CommonConstants.ACCEPT, "*/*"); + map.put(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE); String bodyPostStr = String.format(CommonConstants.RetrieveCbamTokenPostStr, adaptorEnv.getGrantType(), adaptorEnv.getClientId(), adaptorEnv.getClientSecret()); - processor.addPostEntity(bodyPostStr); - String responseStr = processor.process(url); + String responseStr = httpClientProcessor.process(url, RequestMethod.GET, map, bodyPostStr); logger.info("CbamMgmrImpl -> retrieveToken, responseStr is " + responseStr); @@ -175,13 +176,12 @@ public class CbamMgmrImpl implements CbamMgmrInf { } String url= adaptorEnv.getCbamApiUriFront() + httpPath; - HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, method); - processor.addHdeader(CommonConstants.AUTHORIZATION, "bearer " + token); - processor.addHdeader(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); - processor.addPostEntity(gson.toJson(httpBodyObj)); + HashMap<String, String> map = new HashMap<String, String>(); + map.put(CommonConstants.AUTHORIZATION, "bearer " + token); + map.put(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); - String responseStr = processor.process(url); + String responseStr = httpClientProcessor.process(url, method, map, gson.toJson(httpBodyObj)); return responseStr; } @@ -198,5 +198,9 @@ public class CbamMgmrImpl implements CbamMgmrInf { return response; } + + public void setAdaptorEnv(AdaptorEnv adaptorEnv) { + this.adaptorEnv = adaptorEnv; + } } 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 343e517e..4a9570b5 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 @@ -21,69 +21,195 @@ import org.springframework.stereotype.Component; @Component public class AdaptorEnv { - @Value("${nslcmApiUriFront}") - private String nslcmApiUriFront; + private String msbIp; + private int msbPort; - @Value("${catalogApiUriFront}") - private String catalogApiUriFront; + // service name and version of MSB services AAI/LCM/Catalog configured in application.properties + @Value("${aaiServiceNameInMsb}") + private String aaiServiceNameInMsb; + + @Value("${aaiVersionInMsb}") + private String aaiVersionInMsb; + + @Value("${lcmServiceNameInMsb}") + private String lcmServiceNameInMsb; + + @Value("${lcmVersionInMsb}") + private String lcmVersionInMsb; + + @Value("${catalogServiceNameInMsb}") + private String catalogServiceNameInMsb; + + @Value("${catalogVersionInMsb}") + private String catalogVersionInMsb; + + //Following uriFront is from msb query - @Value("${cbamApiUriFront}") - private String cbamApiUriFront; + private String aaiUrlInMsb; + private String aaiApiUriFront; - @Value("${msbApiUriFront}") - private String msbApiUriFront; + private String lcmUrlInMsb; + private String lcmApiUriFront; + + private String catalogUrlInMsb; + private String catalogApiUriFront; - //for retrieving token from CBAM + //cbamApiFront is from aai query + private String cbamApiUriFront; + + // for retrieving token from CBAM, configured in application.properties @Value("${grantType}") private String grantType; - + @Value("${clientId}") private String clientId; - + @Value("${clientSecret}") private String clientSecret; - - public String getNslcmApiUriFront() { - return nslcmApiUriFront; + + public String getAaiServiceNameInMsb() { + return aaiServiceNameInMsb; + } + + public void setAaiServiceNameInMsb(String aaiServiceNameInMsb) { + this.aaiServiceNameInMsb = aaiServiceNameInMsb; + } + + public String getAaiVersionInMsb() { + return aaiVersionInMsb; + } + + public void setAaiVersionInMsb(String aaiVersionInMsb) { + this.aaiVersionInMsb = aaiVersionInMsb; + } + + public String getLcmServiceNameInMsb() { + return lcmServiceNameInMsb; + } + + public void setLcmServiceNameInMsb(String lcmServiceNameInMsb) { + this.lcmServiceNameInMsb = lcmServiceNameInMsb; + } + + public String getLcmVersionInMsb() { + return lcmVersionInMsb; + } + + public void setLcmVersionInMsb(String lcmVersionInMsb) { + this.lcmVersionInMsb = lcmVersionInMsb; + } + + public String getCatalogServiceNameInMsb() { + return catalogServiceNameInMsb; + } + + public void setCatalogServiceNameInMsb(String catalogServiceNameInMsb) { + this.catalogServiceNameInMsb = catalogServiceNameInMsb; + } + + public String getCatalogVersionInMsb() { + return catalogVersionInMsb; + } + + public void setCatalogVersionInMsb(String catalogVersionInMsb) { + this.catalogVersionInMsb = catalogVersionInMsb; } - public void setNslcmApiUriFront(String nslcmApiUriFront) { - this.nslcmApiUriFront = nslcmApiUriFront; + + public String getAaiApiUriFront() { + return aaiApiUriFront; } + + public void setAaiApiUriFront(String aaiApiUriFront) { + this.aaiApiUriFront = aaiApiUriFront; + } + public String getCatalogApiUriFront() { return catalogApiUriFront; } + public void setCatalogApiUriFront(String catalogApiUriFront) { this.catalogApiUriFront = catalogApiUriFront; } + public String getCbamApiUriFront() { return cbamApiUriFront; } + public void setCbamApiUriFront(String cbamApiUriFront) { this.cbamApiUriFront = cbamApiUriFront; } + public String getGrantType() { return grantType; } + public void setGrantType(String grantType) { this.grantType = grantType; } + public String getClientId() { return clientId; } + public void setClientId(String clientId) { this.clientId = clientId; } + public String getClientSecret() { return clientSecret; } + public void setClientSecret(String clientSecret) { this.clientSecret = clientSecret; } - public String getMsbApiUriFront() { - return msbApiUriFront; + + public String getMsbIp() { + return msbIp; + } + + public void setMsbIp(String msbIp) { + this.msbIp = msbIp; } - public void setMsbApiUriFront(String msbApiUriFront) { - this.msbApiUriFront = msbApiUriFront; + + public int getMsbPort() { + return msbPort; } - + + public void setMsbPort(int msbPort) { + this.msbPort = msbPort; + } + + public String getAaiUrlInMsb() { + return aaiUrlInMsb; + } + + public void setAaiUrlInMsb(String aaiUrlInMsb) { + this.aaiUrlInMsb = aaiUrlInMsb; + } + + public String getCatalogUrlInMsb() { + return catalogUrlInMsb; + } + + public void setCatalogUrlInMsb(String catalogUrlInMsb) { + this.catalogUrlInMsb = catalogUrlInMsb; + } + + public String getLcmUrlInMsb() { + return lcmUrlInMsb; + } + + public void setLcmUrlInMsb(String lcmUrlInMsb) { + this.lcmUrlInMsb = lcmUrlInMsb; + } + + public String getLcmApiUriFront() { + return lcmApiUriFront; + } + + public void setLcmApiUriFront(String lcmApiUriFront) { + this.lcmApiUriFront = lcmApiUriFront; + } + + } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/common/util/CommonUtil.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/common/util/CommonUtil.java new file mode 100644 index 00000000..34530b51 --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/common/util/CommonUtil.java @@ -0,0 +1,81 @@ +/* + * 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.common.util; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public final class CommonUtil { + private static final Logger logger = LoggerFactory.getLogger(CommonUtil.class); + + public static String getJsonStrFromFile(String filePath) throws IOException { + InputStream ins = null; + BufferedInputStream bins = null; + String fileContent = ""; + String fileName = getAppRoot() + filePath; + + try { + ins = new FileInputStream(fileName); + bins = new BufferedInputStream(ins); + + byte[] contentByte = new byte[ins.available()]; + int num = bins.read(contentByte); + + if(num > 0) { + fileContent = new String(contentByte); + } + } catch(FileNotFoundException e) { + logger.error(fileName + "is not found!", e); + } finally { + if(ins != null) { + ins.close(); + } + if(bins != null) { + bins.close(); + } + } + return fileContent; + } + + private static String getAppRoot() { + String appRoot = System.getProperty("catalina.base"); + if(appRoot != null) { + appRoot = getCanonicalPath(appRoot); + } + return appRoot; + } + + private static String getCanonicalPath(final String inPath) { + String path = null; + try { + if(inPath != null) { + final File file = new File(inPath); + path = file.getCanonicalPath(); + } + } catch(final IOException e) { + logger.error("file.getCanonicalPath() IOException:", e); + } + return path; + } +} 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 22c06ef0..368e8a4e 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 @@ -17,6 +17,8 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.constant; public class CommonConstants { + public static final String SCHEMA_HTTP = "http"; + public static final String HTTP_ERROR_DESC_500 = "Internal Server Error"; @@ -27,13 +29,16 @@ public class CommonConstants { public static final String AUTHORIZATION = "Authorization"; public static final String UTF_8 = "utf-8"; + //AAI path get vnfm + // /external-system/esr-vnfm-list/esr-vnfm/{vnfm-id} + public static final String RetrieveVnfmListPath = "/external-system/esr-vnfm-list/esr-vnfm/%s"; + //Nslcm path - public static final String RetrieveNvfmListPath = "/nslcm/vl/vnfms/%s"; - public static final String NslcmGrantPath = "/nslcm/v1/ns/grantvnf"; - public static final String NslcmNotifyPath = "/nslcm/v1/vnfs/%s/Notify"; + public static final String NslcmGrantPath = "/ns/grantvnf"; + public static final String NslcmNotifyPath = "/vnfs/%s/Notify"; //Catalog path - public static final String RetrieveVnfPackagePath = "/catalog/v1/vnfpackages/%s"; + public static final String RetrieveVnfPackagePath = "/vnfpackages/%s"; //CBAM -- Nokia VNFM path public static final String CBAM_TOKEN_KEY = "access_token"; diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorImpl.java new file mode 100644 index 00000000..9bebb1c9 --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorImpl.java @@ -0,0 +1,52 @@ +/* + * 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.http.client; + +import java.io.IOException; +import java.util.HashMap; + +import org.apache.http.client.ClientProtocolException; +import org.apache.http.impl.client.HttpClientBuilder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestMethod; + +@Component +public class HttpClientProcessorImpl implements HttpClientProcessorInf{ + + @Autowired + private HttpClientBuilder httpClientBuilder; + + public String process(String url, RequestMethod methodType, HashMap<String, String> headerMap, String bodyString) throws ClientProtocolException, IOException + { + HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, methodType); + if(headerMap != null && !headerMap.isEmpty()) + { + for(String key : headerMap.keySet()) + { + processor.addHdeader(key, headerMap.get(key)); + } + + if(null != bodyString && bodyString.length() > 0) + { + processor.addPostEntity(bodyString); + } + + } + return processor.process(url); + } +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorInf.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorInf.java new file mode 100644 index 00000000..41b84d9b --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorInf.java @@ -0,0 +1,28 @@ +/* + * 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.http.client; + +import java.io.IOException; +import java.util.HashMap; + +import org.apache.http.client.ClientProtocolException; +import org.springframework.web.bind.annotation.RequestMethod; + +public interface HttpClientProcessorInf { + public String process(String url, RequestMethod methodType, HashMap<String, String> headerMap, String bodyString) throws ClientProtocolException, IOException; + +} 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 new file mode 100644 index 00000000..30da37e3 --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/init/EnvVariablesInitialization.java @@ -0,0 +1,113 @@ +/* + * 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.init; + +import java.io.IOException; + +import org.json.JSONException; +import org.json.JSONObject; +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.common.util.CommonUtil; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonConstants; +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.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.stereotype.Component; + +@Component +public class EnvVariablesInitialization implements ApplicationRunner { + private static final Logger logger = LoggerFactory.getLogger(EnvVariablesInitialization.class); + + @Autowired + AdaptorEnv adaptorEnv; + + @Autowired + private IMsbMgmr msbMgmr; + + @Override + public void run(ApplicationArguments args){ + try { + getMsbIpAndPort(); + } catch (Exception e) { + logger.error("getMsbIpAndPort error", e); + return; + } + + try { + handleAaiMsbServiceInfo(); + } catch (RouteException e) { + logger.error("handleAaiMsbServiceInfo error", e); + } + + try { + handLcmMsbServiceInfo(); + } catch (RouteException e) { + logger.error("handLcmMsbServiceInfo error", e); + } + + try { + handCatalogMsbServiceInfo(); + } catch (RouteException e) { + logger.error("handCatalogMsbServiceInfo error", e); + } + + } + + private void handleAaiMsbServiceInfo() throws RouteException { + String urlInMsb = msbMgmr.getServiceUrlInMsbBySeriveNameAndPort(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; + } + + private void handLcmMsbServiceInfo() throws RouteException { + String urlInMsb = msbMgmr.getServiceUrlInMsbBySeriveNameAndPort(adaptorEnv.getLcmServiceNameInMsb(), adaptorEnv.getLcmVersionInMsb()); + adaptorEnv.setLcmUrlInMsb(urlInMsb); + adaptorEnv.setLcmApiUriFront(generateApiUriFront(urlInMsb)); + } + + private void handCatalogMsbServiceInfo() throws RouteException { + String urlInMsb = msbMgmr.getServiceUrlInMsbBySeriveNameAndPort(adaptorEnv.getCatalogServiceNameInMsb(), adaptorEnv.getCatalogVersionInMsb()); + adaptorEnv.setCatalogUrlInMsb(urlInMsb); + adaptorEnv.setCatalogApiUriFront(generateApiUriFront(urlInMsb)); + } + + private void getMsbIpAndPort() throws IOException, JSONException { + String msbInfoJsonStr = readMsbInfoFromJsonFile(); + JSONObject totalJsonObj = new JSONObject(msbInfoJsonStr); + JSONObject serverJsonObj = totalJsonObj.getJSONObject("defaultServer"); + String msb_ip = serverJsonObj.getString("host"); + int msb_port = serverJsonObj.getInt("port"); + + adaptorEnv.setMsbIp(msb_ip); + adaptorEnv.setMsbPort(msb_port); + } + + private String readMsbInfoFromJsonFile() throws IOException { + String filePath = "/etc/conf/restclient.json"; + String fileContent = CommonUtil.getJsonStrFromFile(filePath); + + return fileContent; + } +} 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 cb93b0be..8f668c2f 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,23 +16,19 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.msb.impl; -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; -import java.io.InputStream; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.json.JSONException; -import org.json.JSONObject; 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.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.msb.inf.IMsbMgmr; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.google.gson.Gson; @@ -41,25 +37,18 @@ import com.google.gson.Gson; public class MsbMgmrImpl implements IMsbMgmr { private static final Logger logger = LoggerFactory.getLogger(MsbMgmrImpl.class); - private Gson gson = new Gson(); - - private String msb_ip; + @Autowired + AdaptorEnv adaptorEnv; - private int msb_port; + private Gson gson = new Gson(); @Override public void register() { try { - String msbInfoJsonStr = readMsbInfoFromJsonFile(); - JSONObject totalJsonObj = new JSONObject(msbInfoJsonStr); - JSONObject serverJsonObj = totalJsonObj.getJSONObject("defaultServer"); - msb_ip = serverJsonObj.getString("host"); - msb_port = serverJsonObj.getInt("port"); - String vfcAdaptorInfoJsonStr = readVfcAdaptorInfoFromJsonFile(); MicroServiceInfo msinfo = gson.fromJson(vfcAdaptorInfoJsonStr, MicroServiceInfo.class); - MSBServiceClient msbClient = new MSBServiceClient(msb_ip, msb_port); + MSBServiceClient msbClient = new MSBServiceClient(adaptorEnv.getMsbIp(), adaptorEnv.getMsbPort()); MicroServiceFullInfo microServiceInfo = msbClient.registerMicroServiceInfo(msinfo); logger.info("Registered service response info is " + microServiceInfo.toString()); @@ -67,62 +56,24 @@ public class MsbMgmrImpl implements IMsbMgmr { logger.error("Failed to read vfcadaptor info! ", e); } catch (RouteException e) { logger.error("Failed to register nokia vnfm driver! ", e); - } catch (JSONException e) { - logger.error("Failed to retrieve json info! ", e); } } - private String readMsbInfoFromJsonFile() throws IOException { - String filePath = "/etc/conf/restclient.json"; - String fileContent = getJsonStrFromFile(filePath); - - return fileContent; - } - private String readVfcAdaptorInfoFromJsonFile() throws IOException { String filePath = "/etc/adapterInfo/vnfmadapterinfo.json"; - String fileContent = getJsonStrFromFile(filePath); + String fileContent = CommonUtil.getJsonStrFromFile(filePath); return fileContent; } - public String getJsonStrFromFile(String filePath) throws IOException { - InputStream ins = null; - BufferedInputStream bins = null; - String fileContent = ""; - String fileName = getAppRoot() + filePath; - - try { - ins = new FileInputStream(fileName); - bins = new BufferedInputStream(ins); - - byte[] contentByte = new byte[ins.available()]; - int num = bins.read(contentByte); - - if(num > 0) { - fileContent = new String(contentByte); - } - } catch(FileNotFoundException e) { - logger.error(fileName + "is not found!", e); - } finally { - if(ins != null) { - ins.close(); - } - if(bins != null) { - bins.close(); - } - } - return fileContent; - } - @Override public void unregister() { try { String jsonStr = readVfcAdaptorInfoFromJsonFile(); MicroServiceInfo msinfo = gson.fromJson(jsonStr, MicroServiceInfo.class); - MSBServiceClient msbClient = new MSBServiceClient(msb_ip, msb_port); + 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()); @@ -133,26 +84,24 @@ public class MsbMgmrImpl implements IMsbMgmr { } } - public String getAppRoot() { - String appRoot = null; - appRoot = System.getProperty("catalina.base"); - if(appRoot != null) { - appRoot = getCanonicalPath(appRoot); - } - return appRoot; - } + public String getServiceUrlInMsbBySeriveNameAndPort(String serviceName, String version) throws RouteException + { + 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); + } + + String serviceUrl = microServiceInfo.getUrl(); + logger.info("Service Url in MSB for serviceName = {} and version = {} is {}", serviceName, version, serviceUrl); + + return serviceUrl; + + } - private String getCanonicalPath(final String inPath) { - String path = null; - try { - if(inPath != null) { - final File file = new File(inPath); - path = file.getCanonicalPath(); - } - } catch(final IOException e) { - logger.error("file.getCanonicalPath() IOException:", e); - } - return path; - } + public void setAdaptorEnv(AdaptorEnv env) { + this.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 aaabc3f2..f63b5a56 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,7 +16,10 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.msb.inf; +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; } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImpl.java index eb14023c..405c7365 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImpl.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImpl.java @@ -17,6 +17,7 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.impl; import java.io.IOException; +import java.util.HashMap; import org.apache.http.client.ClientProtocolException; import org.apache.http.impl.client.HttpClientBuilder; @@ -24,6 +25,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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.NslcmGrantVnfRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmGrantVnfResponse; @@ -44,24 +46,25 @@ public class NslcmMgmrImpl implements NslcmMgmrInf{ @Autowired private AdaptorEnv adaptorEnv; - @Autowired - private HttpClientBuilder httpClientBuilder; + @Autowired + HttpClientProcessorInf httpClientProcessor; private Gson gson = new Gson(); - public VnfmInfo queryVnfm(String vnfmId) throws ClientProtocolException, IOException - { - String httpPath = String.format(CommonConstants.RetrieveNvfmListPath, vnfmId); - RequestMethod method = RequestMethod.GET; - - String responseStr = operateNslcmHttpTask(null, httpPath, method); - - logger.info("NslcmMgmrImpl->queryVnfm, the vnfmInfo is {}", responseStr); - - VnfmInfo response = gson.fromJson(responseStr, VnfmInfo.class); - - return response; - } +// @Deprecated +// public VnfmInfo queryVnfm(String vnfmId) throws ClientProtocolException, IOException +// { +// String httpPath = String.format(CommonConstants.RetrieveVnfmListPath, vnfmId); +// RequestMethod method = RequestMethod.GET; +// +// String responseStr = operateNslcmHttpTask(null, httpPath, method); +// +// logger.info("NslcmMgmrImpl->queryVnfm, the vnfmInfo is {}", responseStr); +// +// VnfmInfo response = gson.fromJson(responseStr, VnfmInfo.class); +// +// return response; +// } public NslcmGrantVnfResponse grantVnf(NslcmGrantVnfRequest driverRequest) throws ClientProtocolException, IOException { String httpPath = CommonConstants.NslcmGrantPath; @@ -83,16 +86,19 @@ public class NslcmMgmrImpl implements NslcmMgmrInf{ operateNslcmHttpTask(driverRequest, httpPath, method); } - public String operateNslcmHttpTask(Object httpBodyObj, String httpPath, RequestMethod method) throws ClientProtocolException, IOException { - String url=adaptorEnv.getNslcmApiUriFront() + httpPath; - HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, method); - processor.addHdeader(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); + private String operateNslcmHttpTask(Object httpBodyObj, String httpPath, RequestMethod method) throws ClientProtocolException, IOException { + String url=adaptorEnv.getLcmApiUriFront() + httpPath; - processor.addPostEntity(gson.toJson(httpBodyObj)); + HashMap<String, String> map = new HashMap<String, String>(); + map.put(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); - String responseStr = processor.process(url); + String responseStr = httpClientProcessor.process(url, method, map, gson.toJson(httpBodyObj)); return responseStr; } + public void setAdaptorEnv(AdaptorEnv env) { + this.adaptorEnv = env; + } + } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/inf/NslcmMgmrInf.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/inf/NslcmMgmrInf.java index ca7fa449..d9c39dff 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/inf/NslcmMgmrInf.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/inf/NslcmMgmrInf.java @@ -25,7 +25,7 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmNotifyLCMEventsRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.VnfmInfo; public interface NslcmMgmrInf { - public VnfmInfo queryVnfm(String vnfmId) throws ClientProtocolException, IOException; +// public VnfmInfo queryVnfm(String vnfmId) throws ClientProtocolException, IOException; public NslcmGrantVnfResponse grantVnf(NslcmGrantVnfRequest driverRequest) throws ClientProtocolException, IOException; diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/impl/VnfContinueProcessorImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/impl/VnfContinueProcessorImpl.java new file mode 100644 index 00000000..d5130893 --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/impl/VnfContinueProcessorImpl.java @@ -0,0 +1,51 @@ +/* + * 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.vnfmdriver.impl; + +import java.util.concurrent.Executors; + +import org.onap.vfc.nfvo.driver.vnfm.svnfm.adaptor.Cbam2DriverResponseConverter; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.adaptor.Driver2CbamRequestConverter; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.adaptor.InstantiateVnfContinueRunnable; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.adaptor.TerminateVnfContinueRunnable; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.inf.CatalogMgmrInf; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.inf.CbamMgmrInf; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.repository.VnfmJobExecutionRepository; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.inf.NslcmMgmrInf; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.InstantiateVnfRequest; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.TerminateVnfRequest; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.inf.VnfContinueProcessorInf; + +public class VnfContinueProcessorImpl implements VnfContinueProcessorInf{ + + @Override + public void continueInstantiateVnf(InstantiateVnfRequest driverRequest, String vnfInstanceId, String jobId, NslcmMgmrInf nslcmMgmr, CatalogMgmrInf catalogMgmr, CbamMgmrInf cbamMgmr, Driver2CbamRequestConverter requestConverter, VnfmJobExecutionRepository jobDbManager) { + InstantiateVnfContinueRunnable task = new InstantiateVnfContinueRunnable(driverRequest, vnfInstanceId, jobId, + nslcmMgmr, catalogMgmr, cbamMgmr, requestConverter, jobDbManager); + + Executors.newSingleThreadExecutor().submit(task); + } + + @Override + public void continueTerminateVnf(TerminateVnfRequest driverRequest, String vnfInstanceId, String jobId, NslcmMgmrInf nslcmMgmr, CbamMgmrInf cbamMgmr, Driver2CbamRequestConverter requestConverter, VnfmJobExecutionRepository jobDbManager) { + TerminateVnfContinueRunnable task = new TerminateVnfContinueRunnable(driverRequest, vnfInstanceId, jobId, + nslcmMgmr, cbamMgmr, requestConverter, jobDbManager); + + Executors.newSingleThreadExecutor().submit(task); + } + +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/inf/VnfContinueProcessorInf.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/inf/VnfContinueProcessorInf.java new file mode 100644 index 00000000..3898a477 --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/inf/VnfContinueProcessorInf.java @@ -0,0 +1,30 @@ +/* +* 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.vnfmdriver.inf; + +import org.onap.vfc.nfvo.driver.vnfm.svnfm.adaptor.Driver2CbamRequestConverter; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.inf.CatalogMgmrInf; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.inf.CbamMgmrInf; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.repository.VnfmJobExecutionRepository; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.inf.NslcmMgmrInf; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.InstantiateVnfRequest; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.TerminateVnfRequest; + +public interface VnfContinueProcessorInf { + public void continueInstantiateVnf(InstantiateVnfRequest driverRequest, String vnfInstanceId, String jobId, NslcmMgmrInf nslcmMgmr, CatalogMgmrInf catalogMgmr, CbamMgmrInf cbamMgmr, Driver2CbamRequestConverter requestConverter, VnfmJobExecutionRepository jobDbManager); + public void continueTerminateVnf(TerminateVnfRequest driverRequest, String vnfInstanceId, String jobId, NslcmMgmrInf nslcmMgmr, CbamMgmrInf cbamMgmr, Driver2CbamRequestConverter requestConverter, VnfmJobExecutionRepository jobDbManager); +} |