summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwangguirong <wangguirong@boco.com.cn>2017-10-24 15:44:53 +0800
committerwangguirong <wangguirong@boco.com.cn>2017-10-24 15:45:17 +0800
commitc586a5fbf3598a83abd57f030088a356838ed7ce (patch)
tree0f2cd64d0691b5c0574adfc8e55919568d72e907
parent2b8910da098521f16edf751f6f792be32b1e10be (diff)
Modify esr Request
Change-Id: Ie10ddb0f13709acd42aa7011a9a503513bd43af3 Issue-Id: VFC-548 Signed-off-by: wangguirong <wangguirong@boco.com.cn>
-rw-r--r--ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/EMSDriverApp.java76
-rw-r--r--ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/TaskThread.java7
-rw-r--r--ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/configmgr/ConfigurationManager.java5
-rw-r--r--ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/HttpClientUtil.java36
-rw-r--r--ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/NorthMessageMgr.java1
-rw-r--r--ems/microservice-standalone/src/main/assembly/conf/emsdriver.yml2
6 files changed, 45 insertions, 82 deletions
diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/EMSDriverApp.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/EMSDriverApp.java
deleted file mode 100644
index 72d10cf..0000000
--- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/EMSDriverApp.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * Copyright 2017 BOCO Corporation. CMCC Technologies Co., Ltd
- *
- * 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.emsdriver;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.onap.vfc.nfvo.emsdriver.commons.constant.Constant;
-import org.onap.vfc.nfvo.emsdriver.commons.utils.DriverThread;
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.FileSystemXmlApplicationContext;
-
-
-
-public class EMSDriverApp {
-
- private static Log log = LogFactory.getLog(DriverThread.class);
- private static ApplicationContext context = null;
- static {
- try {
- /** spring bean applicationContext **/
- context = new FileSystemXmlApplicationContext("file:" + Constant.SYS_CFG+ "spring.xml");
-
- } catch (BeansException e) {
- log.error("spring.xml is fail ", e);
- System.exit(1);
- } catch (Exception e) {
- log.error("spring.xml is fail", e);
- System.exit(1);
- }
- }
-
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- String[] allThreadName = context.getBeanNamesForType(DriverThread.class);
-
- log.info("worker num :" + allThreadName.length);
-
- for (String threadName : allThreadName) {
- DriverThread thread = (DriverThread) context.getBean(threadName);
- if (thread == null) {
- log.error(threadName + "Thread start error,system exit");
- System.exit(1);
- }else{
- thread.setName(threadName);
- thread.start();
- }
-
- }
-
- try {
- new EmsDriverApplication().run(args);
- } catch (Exception e) {
- log.error("EmsDriverApplication.run is fail", e);
- System.exit(1);
- }
- log.info("the workerThreads start sucess" );
- }
-
-}
diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/TaskThread.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/TaskThread.java
index 1d0b6bb..fdbf3ba 100644
--- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/TaskThread.java
+++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/TaskThread.java
@@ -132,8 +132,11 @@ public class TaskThread implements Runnable{
if("ems-resource".equalsIgnoreCase(collectVo.getType())){
parseResult = processCMXml(tempfile, nename,"CM");
}else{
- parseResult = processPMCsv(tempfile);
-
+ if(unfileName.indexOf(".csv") > 0){
+ parseResult = processPMCsv(tempfile);
+ }else{
+ parseResult = processPMCsv(tempfile);
+ }
}
if (parseResult){
diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/configmgr/ConfigurationManager.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/configmgr/ConfigurationManager.java
index b7346b5..923d2ed 100644
--- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/configmgr/ConfigurationManager.java
+++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/configmgr/ConfigurationManager.java
@@ -312,6 +312,11 @@ public class ConfigurationManager extends DriverThread{
Thread.sleep(60*1000);
}
} catch (Exception e) {
+ try {
+ Thread.sleep(60*1000);
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
log.error("ReceiveSource exception",e);
}
}
diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/HttpClientUtil.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/HttpClientUtil.java
index 2924b50..f9484f8 100644
--- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/HttpClientUtil.java
+++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/HttpClientUtil.java
@@ -20,14 +20,22 @@ import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpEntity;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
+import org.apache.commons.codec.binary.Base64;
+
/*
* HttpClient post request
*/
@@ -119,11 +127,14 @@ public class HttpClientUtil {
HttpGet httpGet = null;
String result = null;
try{
- httpClient = HttpClientFactory.getSSLClientFactory();
+ httpClient = HttpClients.createDefault();
httpGet = new HttpGet(url);
-
+ Base64 token = new Base64();
+ String authenticationEncoding = new String(token.encode(("AAI:AAI").getBytes()));
+
+ httpGet.setHeader("Authorization", "Basic " + authenticationEncoding);
CloseableHttpResponse response = httpClient.execute(httpGet);
-
+ log.info("doGet sucess url ="+url);
try {
if(response != null){
HttpEntity resEntity = response.getEntity();
@@ -151,4 +162,23 @@ public class HttpClientUtil {
return result;
}
+ public static CloseableHttpClient createCloseableHttpClientWithBasicAuth(){
+ // 创建HttpClientBuilder
+ HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
+ // 设置BasicAuth
+ CredentialsProvider provider = new BasicCredentialsProvider();
+ // Create the authentication scope
+ AuthScope scope = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM);
+ // Create credential pair,username and password
+ UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("AAI", "AAI");
+ // Inject the credentials
+ provider.setCredentials(scope, credentials);
+ // Set the default credentials provider
+ httpClientBuilder.setDefaultCredentialsProvider(provider);
+ // HttpClient
+ CloseableHttpClient closeableHttpClient = httpClientBuilder.build();
+
+ return closeableHttpClient;
+ }
+
} \ No newline at end of file
diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/NorthMessageMgr.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/NorthMessageMgr.java
index c752a29..22dbe69 100644
--- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/NorthMessageMgr.java
+++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/NorthMessageMgr.java
@@ -72,6 +72,7 @@ public class NorthMessageMgr extends DriverThread{
username,
password,
level);
+ log.info("AgentMain.evel_initialize sucess ");
} catch( Exception e ){
log.error("AgentMain.evel_initialize fail ",e);
}
diff --git a/ems/microservice-standalone/src/main/assembly/conf/emsdriver.yml b/ems/microservice-standalone/src/main/assembly/conf/emsdriver.yml
index 1319656..5b82754 100644
--- a/ems/microservice-standalone/src/main/assembly/conf/emsdriver.yml
+++ b/ems/microservice-standalone/src/main/assembly/conf/emsdriver.yml
@@ -19,7 +19,7 @@ defaultName: EmsDriver-Stranger
#microservice Bus address
msbAddress: 10.74.205.123:80
-autoServiceRegister: true
+autoServiceRegister: false
server:
type: simple
rootPath: '/api/emsdriver/v1/*'