Update query vnfm from ESR interface 73/20773/1
authoryufei_zhou <yufei.zhou@nokia-sbell.com>
Thu, 26 Oct 2017 10:56:31 +0000 (18:56 +0800)
committeryufei_zhou <yufei.zhou@nokia-sbell.com>
Thu, 26 Oct 2017 10:56:31 +0000 (18:56 +0800)
Change-Id: I536f901f91fe5d290b5b97fa7e0365f7378fa59b
Issue-Id:VFC-552
Signed-off-by: yufei_zhou <yufei.zhou@nokia-sbell.com>
nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/pom.xml
nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/bo/AaiVnfmInfo.java
nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/bo/entity/EsrSystemInfo.java
nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/impl/AaiMgmrInfImpl.java
nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImpl.java
nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/constant/CommonConstants.java
nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/impl/AaiMgmrInfImplTest.java
nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImplTest.java

index b12c681..4f08fa0 100644 (file)
                        <artifactId>dropwizard-core</artifactId>
                        <version>0.8.0</version>
                </dependency>
+               
+               <dependency>
+          <groupId>com.jcraft</groupId>
+          <artifactId>jsch</artifactId>
+          <version>0.1.54</version>
+        </dependency>
+        
+        <dependency>
+          <groupId>commons-net</groupId>
+          <artifactId>commons-net</artifactId>
+          <version>3.6</version>
+        </dependency>
+
        </dependencies>
     <build>
  <!-- 
index e405f86..5727674 100644 (file)
@@ -40,8 +40,8 @@ public class AaiVnfmInfo {
        @JsonProperty("resource-version")
        private String resourceVersion;
        
-       @SerializedName("esr-system-info-list")
-       @JsonProperty("esr-system-info-list")
+       @SerializedName("esr-system-info")
+       @JsonProperty("esr-system-info")
        private List<EsrSystemInfo> esrSystemInfoList;
 
        public String getVnfmId() {
index 9e750ea..f5a0b8c 100644 (file)
 
 package org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.bo.entity;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
 import com.google.gson.annotations.SerializedName;
 
 public class EsrSystemInfo {
+       @JsonProperty("esr-system-info-id")
        @SerializedName("esr-system-info-id")
        private String esrSystemId;
        
+       @JsonProperty("system-name")
        @SerializedName("system-name")
        private String esrSystemName;
        
+       @JsonProperty("type")
        @SerializedName("type")
        private String type;
        
+       @JsonProperty("vendor")
        @SerializedName("vendor")
        private String vendor;
        
+       @JsonProperty("version")
        @SerializedName("version")
        private String version;
        
+       @JsonProperty("service-url")
        @SerializedName("service-url")
        private String serviceUrl;
        
+       @JsonProperty("user-name")
        @SerializedName("user-name")
        private String userName;
        
+       @JsonProperty("password")
        @SerializedName("password")
        private String password;
        
-       @SerializedName("protocal")
-       private String protocal;
+       @JsonProperty("system-type")
+       @SerializedName("system-type")
+       private String systemType;
        
-       @SerializedName("ssl-cacert")
-       private String sslCacert;
+       @JsonProperty("resource-version")
+       @SerializedName("resource-version")
+       private String resourceVersion;
        
-       @SerializedName("ssl-insecure")
-       private String sslInsecure;
-       
-       @SerializedName("ip-address")
-       private String ip;
-       
-       @SerializedName("port")
-       private String port;
-       
-       @SerializedName("cloud-domain")
-       private String cloudDomain;
-       
-       @SerializedName("default-tenant")
-       private String defaultTenant;
-
        public String getEsrSystemId() {
                return esrSystemId;
        }
@@ -128,60 +124,19 @@ public class EsrSystemInfo {
                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 String getSystemType() {
+               return systemType;
        }
 
-       public void setSslInsecure(String sslInsecure) {
-               this.sslInsecure = sslInsecure;
+       public void setSystemType(String systemType) {
+               this.systemType = systemType;
        }
 
-       public String getIp() {
-               return ip;
+       public String getResourceVersion() {
+               return resourceVersion;
        }
 
-       public void setIp(String ip) {
-               this.ip = ip;
+       public void setResourceVersion(String resourceVersion) {
+               this.resourceVersion = resourceVersion;
        }
-
-       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;
-       }
-       
 }
index a8286f8..ddc78eb 100644 (file)
@@ -19,6 +19,7 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.impl;
 import java.io.IOException;
 import java.util.HashMap;
 
+import org.apache.commons.codec.binary.Base64;
 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.inf.AaiMgmrInf;
@@ -28,7 +29,6 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpClientProcessorInf;
 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;
 
@@ -62,10 +62,19 @@ public class AaiMgmrInfImpl implements AaiMgmrInf{
        private String operateHttpTask(Object httpBodyObj, String httpPath, RequestMethod method) throws ClientProtocolException, IOException {
                String url=adaptorEnv.getAaiApiUriFront() + httpPath;
                
-               HashMap<String, String> map = new HashMap<>();
-               map.put(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);
+               HashMap<String, String> headerMap = new HashMap<>();
+               headerMap.put("Content-Type", "application/json");
+        headerMap.put("Accept", "application/json");
+        headerMap.put("X-TransactionId", "9999");
+        headerMap.put("X-FromAppId", "esr-server");
+
+        Base64 token = new Base64();
+        String authen = new String(token.encode(("AAI:AAI").getBytes()));
+        headerMap.put("Authorization", "Basic " + authen);
+        logger.info("getVimById headerMap: {}", headerMap.toString());
+        
                
-               String responseStr = httpClientProcessor.process(url, method, map, gson.toJson(httpBodyObj)).getContent();
+               String responseStr = httpClientProcessor.process(url, method, headerMap, gson.toJson(httpBodyObj)).getContent();
                
                return responseStr;
        }
index 29d2fc2..3e7457c 100644 (file)
@@ -229,7 +229,7 @@ public class VnfmDriverMgmrImpl implements VnfmDriverMgmrInf{
                
                EsrSystemInfo systemInfo = vnfmInfo.getEsrSystemInfoList().get(0);
                
-               String urlHead = systemInfo.getProtocal() + "://" + systemInfo.getIp() + ":" + systemInfo.getPort();
+               String urlHead = systemInfo.getServiceUrl();
                adaptorEnv.setCbamApiUriFront(urlHead);
                return urlHead;
        }
index 052f6ee..8115e76 100644 (file)
@@ -31,7 +31,7 @@ public class CommonConstants {
        
        //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";
+       public static final String RetrieveVnfmListPath = "/external-system/esr-vnfm-list/esr-vnfm/%s/esr-system-info-list";
        
        //Nslcm path
        public static final String NslcmGrantPath = "/ns/grantvnf";
@@ -43,7 +43,7 @@ public class CommonConstants {
        //CBAM -- Nokia VNFM path
        public static final String CBAM_TOKEN_KEY = "access_token";
        public static final String RetrieveCbamTokenPath="/auth/realms/cbam/protocol/openid-connect/token";
-       public static final String RetrieveCbamTokenPostStr="grant_type=%s&client_id=%s&client_secret=%s";
+       public static final String RetrieveCbamTokenPostStr="grant_type=%s&client_id=%s&client_secret=%s&usernmae=%s&password=%s";
        public static final String CbamCreateVnfPath="/vnfs";
        public static final String CbamInstantiateVnfPath="/vnfs/%s/instantiate";
        public static final String CbamQueryVnfPath="/vnfs/%s";
index 3a2ca76..01c256b 100644 (file)
@@ -56,7 +56,7 @@ public class AaiMgmrInfImplTest {
                                + "\"vim-id\":\"vim-id_001\","
                                + "\"certificate-url\":\"certificate-url_001\","
                                + "\"resource-version\":\"resource-version_001\","
-                               + "\"esr-system-info-list\":[{\"ip-address\" : \"1.3.5.6\"}]"
+                               + "\"esr-system-info\":[{\"type\" : \"vnfm\"}]"
                                + "}"
                                + "";
                HttpResult httpResult = new HttpResult();
@@ -69,6 +69,6 @@ public class AaiMgmrInfImplTest {
        public void testQueryVnfPackage() throws ClientProtocolException, IOException
        {
                AaiVnfmInfo vnfmInfo = aaiMgmr.queryVnfm(vnfmId);
-               Assert.assertEquals("1.3.5.6", vnfmInfo.getEsrSystemInfoList().get(0).getIp());
+               Assert.assertEquals("vnfm", vnfmInfo.getEsrSystemInfoList().get(0).getType());
        }
 }
index 3948638..d783446 100644 (file)
@@ -105,16 +105,9 @@ public class VnfmDriverMgmrImplTest {
                cbamHttpHead = protocol + "://" + ip + ":" + port;
                
                EsrSystemInfo esrSystemInfo = new EsrSystemInfo();
-               esrSystemInfo.setProtocal(protocol);
-               esrSystemInfo.setIp(ip);
-               esrSystemInfo.setPort(port);
-               esrSystemInfo.setCloudDomain("cloudDomain");
-               esrSystemInfo.setDefaultTenant("defaultTenant");
                esrSystemInfo.setEsrSystemId("esrSystemId");
                esrSystemInfo.setPassword("password");
-               esrSystemInfo.setServiceUrl("serviceUrl");
-               esrSystemInfo.setSslCacert("sslCacert");
-               esrSystemInfo.setSslInsecure("sslInsecure");
+               esrSystemInfo.setServiceUrl(cbamHttpHead);
                esrSystemInfo.setType("type");
                esrSystemInfo.setUserName("userName");
                esrSystemInfo.setVendor("vendor");