diff options
author | 2017-09-30 16:54:00 +0800 | |
---|---|---|
committer | 2017-09-30 16:54:00 +0800 | |
commit | 358611bc1303a4e114ea862a3437947fc2f5caf6 (patch) | |
tree | 879ff1a8a33df542c75415c697aebe94d71b9a12 /nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java | |
parent | 47fd33356d8ae5d709fdb1759a3fcfdb3a8c06a2 (diff) |
Modify database part in the deployment
Change-Id: I9a058bdfb76b293b740107cb2c11a39fe2387533
Issue-ID: VFC-53
Signed-off-by: yufei_zhou <yufei.zhou@nokia-sbell.com>
Diffstat (limited to 'nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java')
13 files changed, 145 insertions, 119 deletions
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/VfcadaptorApplication.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/VfcadaptorApplication.java index 09aa8193..eeac57bd 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/VfcadaptorApplication.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/VfcadaptorApplication.java @@ -18,8 +18,10 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; @Configuration @SpringBootApplication @@ -27,7 +29,14 @@ import org.springframework.context.annotation.Configuration; @ComponentScan public class VfcadaptorApplication { - public static void main(String[] args) { + public final static void main(String[] args) { SpringApplication.run(VfcadaptorApplication.class, args); } + + @Bean + public static PropertySourcesPlaceholderConfigurer placeholderConfigurer() { + PropertySourcesPlaceholderConfigurer c = new PropertySourcesPlaceholderConfigurer(); + c.setIgnoreUnresolvablePlaceholders(true); + return c; + } } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/InstantiateVnfContinueRunnable.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/InstantiateVnfContinueRunnable.java index 954ab6b1..76a97d71 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/InstantiateVnfContinueRunnable.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/InstantiateVnfContinueRunnable.java @@ -21,8 +21,8 @@ import java.util.ArrayList; import java.util.List; import org.apache.http.client.ClientProtocolException; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.inf.CatalogMgmrInf; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMInstantiateVnfRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMInstantiateVnfResponse; @@ -42,7 +42,7 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.InstantiateVnfRequest; public class InstantiateVnfContinueRunnable implements Runnable { - private static final Logger logger = LogManager.getLogger("InstantiateVnfContinueRunnable"); + private static final Logger logger = LoggerFactory.getLogger(InstantiateVnfContinueRunnable.class); private CbamMgmrInf cbamMgmr; private CatalogMgmrInf catalogMgmr; private NslcmMgmrInf nslcmMgmr; diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/TerminateVnfContinueRunnable.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/TerminateVnfContinueRunnable.java index ba7663d9..4485ad18 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/TerminateVnfContinueRunnable.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/TerminateVnfContinueRunnable.java @@ -21,14 +21,15 @@ import java.util.ArrayList; import java.util.List; import org.apache.http.client.ClientProtocolException; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMTerminateVnfRequest; 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.constant.CommonConstants; import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonEnum; import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonEnum.LifecycleOperation; +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.nslcm.bo.NslcmGrantVnfRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmGrantVnfResponse; @@ -40,7 +41,7 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.TerminateVnfRequest; public class TerminateVnfContinueRunnable implements Runnable { - private static final Logger logger = LogManager.getLogger("TerminateVnfContinueRunnable"); + private static final Logger logger = LoggerFactory.getLogger(TerminateVnfContinueRunnable.class); private CbamMgmrInf cbamMgmr; private NslcmMgmrInf nslcmMgmr; @@ -48,7 +49,7 @@ public class TerminateVnfContinueRunnable implements Runnable { private TerminateVnfRequest driverRequest; private String vnfInstanceId; private String jobId; - private VnfmJobExecutionRepository jobDbManager; + private VnfmJobExecutionRepository jobDbMgmr; private Driver2CbamRequestConverter requestConverter; @@ -61,7 +62,7 @@ public class TerminateVnfContinueRunnable implements Runnable { this.cbamMgmr = cbamMgmr; this.requestConverter = requestConverter; this.jobId = jobId; - this.jobDbManager = dbManager; + this.jobDbMgmr = dbManager; } public void run() { @@ -72,6 +73,7 @@ public class TerminateVnfContinueRunnable implements Runnable { CBAMTerminateVnfRequest cbamRequest = requestConverter.terminateReqConvert(driverRequest); CBAMTerminateVnfResponse cbamResponse = cbamMgmr.terminateVnf(cbamRequest, vnfInstanceId); + handleCbamInstantiateResponse(cbamResponse, jobId); cbamMgmr.deleteVnf(vnfInstanceId); @@ -86,6 +88,13 @@ public class TerminateVnfContinueRunnable implements Runnable { } + private void handleCbamInstantiateResponse(CBAMTerminateVnfResponse cbamResponse, String jobId) { + VnfmJobExecutionInfo jobInfo = jobDbMgmr.findOne(Long.getLong(jobId)); + + jobInfo.setVnfmExecutionId(cbamResponse.getId()); + jobDbMgmr.save(jobInfo); + } + private NslcmGrantVnfRequest buildNslcmGrantVnfRequest() { NslcmGrantVnfRequest request = new NslcmGrantVnfRequest(); diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrIml.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImpl.java index fa274fee..59fad026 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrIml.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImpl.java @@ -16,19 +16,14 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.adaptor; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - import org.apache.http.HttpStatus; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; 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; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfResponse; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMOperExecutVnfRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMQueryOperExecutionResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMQueryVnfResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfRequest; @@ -50,16 +45,14 @@ 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.bo.entity.ResponseDescriptor; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.entity.ResponseHistoryList; import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.inf.VnfmDriverMgmrInf; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component -public class VnfmDriverMgmrIml implements VnfmDriverMgmrInf{ - private static final Logger logger = LogManager.getLogger("VnfmDriverMgmrIml"); +public class VnfmDriverMgmrImpl implements VnfmDriverMgmrInf{ + private static final Logger logger = LoggerFactory.getLogger(VnfmDriverMgmrImpl.class); @Autowired Driver2CbamRequestConverter requestConverter; 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 186a1720..b00f61c7 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,8 +20,8 @@ import java.io.IOException; import org.apache.http.client.ClientProtocolException; import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +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; @@ -36,7 +36,7 @@ import com.google.gson.Gson; @Component public class CatalogMgmrImpl implements CatalogMgmrInf{ - private static final Logger logger = LogManager.getLogger("CatalogMgmrImpl"); + private static final Logger logger = LoggerFactory.getLogger(CatalogMgmrImpl.class); private Gson gson = new Gson(); diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/inf/ICatalogServiceClient.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/inf/ICatalogServiceClient.java new file mode 100644 index 00000000..d58eb7df --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/inf/ICatalogServiceClient.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.catalog.inf; + +//import org.onap.msb.sdk.httpclient.annotaion.ServiceHttpEndPoint; +// +//@ServiceHttpEndPoint(serviceName = "catalog", serviceVersion = "v1") +public interface ICatalogServiceClient { + //TODO +// @GET("vnfpackages/{vnfPkgId}") +// Call<Animal> queryAnimal(@Path("vnfPkgId") String vnfPkgId); +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/controller/CbamController.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/controller/CbamController.java index 9578e75f..0e772a4b 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/controller/CbamController.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/controller/CbamController.java @@ -20,24 +20,19 @@ import java.io.IOException; import org.apache.http.client.ClientProtocolException; import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.apache.log4j.Logger; import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.bo.CatalogQueryVnfResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateVnfResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMInstantiateVnfRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMInstantiateVnfResponse; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMOperExecutVnfRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMOperExecutVnfResponse; 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.bo.CBAMTerminateVnfRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMTerminateVnfResponse; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.OperationExecution; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.ProblemDetails; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.VnfInfo; 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; @@ -54,7 +49,7 @@ import com.google.gson.Gson; @Controller @RequestMapping(value = "/vnfm/lcm/v3") public class CbamController { - private static final Logger logger = LogManager.getLogger("CbamController"); + private static final Logger logger = Logger.getLogger(CbamController.class); @Autowired private AdaptorEnv adaptorEnv; 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 bb56fc18..1e2cecf7 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 @@ -20,8 +20,7 @@ import java.io.IOException; import org.apache.http.client.ClientProtocolException; import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.apache.log4j.Logger; import org.json.JSONException; import org.json.JSONObject; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateVnfRequest; @@ -49,14 +48,14 @@ import com.google.gson.Gson; @Component public class CbamMgmrImpl implements CbamMgmrInf { - private static final Logger logger = LogManager.getLogger("CbamMgmrImpl"); + private static final Logger logger = Logger.getLogger(CbamMgmrImpl.class); private Gson gson = new Gson(); @Autowired private AdaptorEnv adaptorEnv; @Autowired - private HttpClientBuilder httpClientBuilder; + private HttpClientBuilder httpClientBuilder;// = HttpClientUtils.createHttpClientBuilder(); private String retrieveToken() throws ClientProtocolException, IOException, JSONException { String result = null; diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientUtils.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientUtils.java index e3ed0c82..7f6a0006 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientUtils.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientUtils.java @@ -36,13 +36,17 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.ssl.SSLContextBuilder; import org.apache.http.ssl.TrustStrategy; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Service; import org.springframework.web.bind.annotation.RequestMethod; +@EnableAutoConfiguration +@Service public class HttpClientUtils { - private static final Logger logger = LogManager.getLogger("HttpClientUtils"); + private static final Logger logger = LoggerFactory.getLogger(HttpClientUtils.class); @Bean public static HttpClientBuilder createHttpClientBuilder() { 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 ed85fcfc..cb93b0be 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 @@ -23,74 +23,75 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -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.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.msb.inf.IMsbMgmr; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.MediaType; import org.springframework.stereotype.Component; -import org.springframework.util.ResourceUtils; -import org.springframework.web.bind.annotation.RequestMethod; + +import com.google.gson.Gson; @Component public class MsbMgmrImpl implements IMsbMgmr { - private static final Logger logger = LogManager.getLogger("MsbMgmrImpl"); - @Autowired - private HttpClientBuilder httpClientBuilder; - - @Autowired - private AdaptorEnv adaptorEnv; - - @Value("${serviceName}") - private String serviceName; - - @Value("${version}") - private String version; + private static final Logger logger = LoggerFactory.getLogger(MsbMgmrImpl.class); - @Value("${url}") - private String url; + private Gson gson = new Gson(); - @Value("${protocol}") - private String protocol; + private String msb_ip; - @Value("${visualRange}") - private String visualRange; + private int msb_port; - @Value("${ip}") - private String ip; - - @Value("${port}") - private String port; - - @Value("${ttl}") - private String ttl; - @Override public void register() { - String httpPath = CommonConstants.MSB_REGISTER_SERVICE_PATH; - RequestMethod method = RequestMethod.POST; - try { - String jsonStr = readVfcAdaptorInfoFromJsonFile(); - String registerResponse = operateHttpTask(jsonStr, httpPath, method); - logger.info("registerResponse is ", registerResponse); + 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); + MicroServiceFullInfo microServiceInfo = msbClient.registerMicroServiceInfo(msinfo); + logger.info("Registered service response info is " + microServiceInfo.toString()); + } catch (IOException e) { 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); } } - public String readVfcAdaptorInfoFromJsonFile() throws IOException { - InputStream ins = null; + 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); + + return fileContent; + } + + public String getJsonStrFromFile(String filePath) throws IOException { + InputStream ins = null; BufferedInputStream bins = null; String fileContent = ""; - String fileName = getAppRoot() + "/etc/adapterInfo/vnfmadapterinfo.json"; + String fileName = getAppRoot() + filePath; try { ins = new FileInputStream(fileName); @@ -112,35 +113,24 @@ public class MsbMgmrImpl implements IMsbMgmr { bins.close(); } } - - return fileContent; - } + return fileContent; + } @Override public void unregister() { - String httpPath = String.format(CommonConstants.MSB_UNREGISTER_SERVICE_PATH, serviceName, version, ip, port); - RequestMethod method = RequestMethod.DELETE; - try { String jsonStr = readVfcAdaptorInfoFromJsonFile(); - String registerResponse = operateHttpTask(jsonStr, httpPath, method); - logger.info("unregisterResponse is ", registerResponse); + MicroServiceInfo msinfo = gson.fromJson(jsonStr, MicroServiceInfo.class); + + MSBServiceClient msbClient = new MSBServiceClient(msb_ip, msb_port); + RouteResult routeResult = msbClient.cancelMicroServiceInfo(msinfo.getServiceName(), msinfo.getVersion()); + logger.info("unregistered service response info is " + routeResult.toString()); + } catch (IOException e) { - logger.error("Failed to unregister! ", e); + logger.error("Failed to read vfcadaptor info! ", e); + } catch (RouteException e) { + logger.error("Failed to register nokia vnfm driver! ", e); } - - } - - public String operateHttpTask(String httpBodyObj, String httpPath, RequestMethod method) throws ClientProtocolException, IOException { - String url=adaptorEnv.getMsbApiUriFront() + httpPath; - HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, method); - processor.addHdeader(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); - - processor.addPostEntity(httpBodyObj); - - String responseStr = processor.process(url); - - return responseStr; } public String getAppRoot() { diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/service/MsgServiceRegister.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/service/MsbServiceRegister.java index 5f52297d..d9a36e08 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/service/MsgServiceRegister.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/service/MsbServiceRegister.java @@ -16,8 +16,8 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.msb.service; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.onap.vfc.nfvo.driver.vnfm.svnfm.msb.inf.IMsbMgmr; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.ApplicationArguments; @@ -25,14 +25,15 @@ import org.springframework.boot.ApplicationRunner; import org.springframework.stereotype.Component; @Component -public class MsgServiceRegister implements ApplicationRunner{ - private static final Logger logger = LogManager.getLogger("MsgServiceRegister"); +public class MsbServiceRegister implements ApplicationRunner{ + private static final Logger logger = LoggerFactory.getLogger(MsbServiceRegister.class); @Autowired private IMsbMgmr msbMgmr; @Override public void run(ApplicationArguments arg0) { + logger.info("Start to register nokia vnfm driver service."); msbMgmr.register(); logger.info("nokia vnfm driver successfully registered on the MSB"); } 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 94be8d21..eb14023c 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 @@ -20,8 +20,8 @@ import java.io.IOException; import org.apache.http.client.ClientProtocolException; import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +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.HttpRequestProcessor; @@ -39,7 +39,7 @@ import com.google.gson.Gson; @Component public class NslcmMgmrImpl implements NslcmMgmrInf{ - private static final Logger logger = LogManager.getLogger("NslcmMgmrImpl"); + private static final Logger logger = LoggerFactory.getLogger(NslcmMgmrImpl.class); @Autowired private AdaptorEnv adaptorEnv; @@ -56,7 +56,7 @@ public class NslcmMgmrImpl implements NslcmMgmrInf{ String responseStr = operateNslcmHttpTask(null, httpPath, method); - logger.info("NslcmMgmrImpl->queryVnfm, the vnfmInfo is " + responseStr); + logger.info("NslcmMgmrImpl->queryVnfm, the vnfmInfo is {}", responseStr); VnfmInfo response = gson.fromJson(responseStr, VnfmInfo.class); @@ -69,7 +69,7 @@ public class NslcmMgmrImpl implements NslcmMgmrInf{ String responseStr = operateNslcmHttpTask(driverRequest, httpPath, method); - logger.info("NslcmMgmrImpl->grantVnf, the NslcmGrantVnfResponse is " + responseStr); + logger.info("NslcmMgmrImpl->grantVnf, the NslcmGrantVnfResponse is {}", responseStr); NslcmGrantVnfResponse response = gson.fromJson(responseStr, NslcmGrantVnfResponse.class); diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/controller/VnfmDriverController.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/controller/VnfmDriverController.java index 39b6b3f6..2336c941 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/controller/VnfmDriverController.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/controller/VnfmDriverController.java @@ -21,8 +21,6 @@ import java.io.IOException; import javax.servlet.http.HttpServletResponse; import org.apache.http.HttpStatus; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.onap.vfc.nfvo.driver.vnfm.svnfm.exception.VnfmDriverException; import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.HealVnfRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.HealVnfResponse; @@ -35,6 +33,8 @@ 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.VnfmDriverMgmrInf; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; @@ -49,7 +49,7 @@ import com.google.gson.Gson; @Controller @RequestMapping(value = "/api/nokiavnfmdriver/v1") public class VnfmDriverController { - private static final Logger logger = LogManager.getLogger("VnfmDriverController"); + private static final Logger logger = LoggerFactory.getLogger(VnfmDriverController.class); @Autowired private VnfmDriverMgmrInf vnfmDriverMgmr; |