From 029a1743a0e3e5c81a232c2153ea9d1b808ba7b6 Mon Sep 17 00:00:00 2001 From: yufei_zhou Date: Sun, 5 Nov 2017 23:17:21 +0800 Subject: Update db process part Change-Id: Ie66c98744f3b27c9abf4e6bb24d1be84580ccb91 Issue-ID: VFC-544 Signed-off-by: yufei_zhou --- .../vfcadaptorservice/deployment/pom.xml | 6 +- .../deployment/src/main/release/conf/server.xml | 3 +- .../src/main/release/db/mysql/db-schema.sql | 18 +- .../vfcadaptorservice/vfcadaptor/pom.xml | 5 + .../svnfm/adaptor/Driver2CbamRequestConverter.java | 133 ++++++++-- .../vnfm/svnfm/adaptor/VnfmDriverMgmrImpl.java | 8 +- .../vnfm/svnfm/catalog/impl/CatalogMgmrImpl.java | 2 +- .../driver/vnfm/svnfm/cbam/bo/SslConfInfo.java | 74 ++++++ .../driver/vnfm/svnfm/cbam/impl/CbamMgmrImpl.java | 98 ++++++- .../vnfm/svnfm/cbam/impl/MultipartUtility.java | 291 +++++++++++++++++++++ .../driver/vnfm/svnfm/common/bo/AdaptorEnv.java | 52 +++- .../driver/vnfm/svnfm/common/util/CommonUtil.java | 2 +- .../vnfm/svnfm/constant/CommonConstants.java | 24 +- .../vnfm/svnfm/db/bean/VnfmJobExecutionInfo.java | 15 +- .../vnfm/svnfm/db/bean/VnfmResourceInfo.java | 11 +- .../vnfm/svnfm/http/client/HttpClientUtils.java | 81 +++--- .../svnfm/http/client/HttpRequestProcessor.java | 5 + .../svnfm/init/EnvVariablesInitialization.java | 36 +-- .../nslcm/bo/NslcmNotifyLCMEventsRequest.java | 6 +- .../vnfm/svnfm/nslcm/bo/entity/AddResource.java | 62 +++++ .../svnfm/nslcm/bo/entity/AdditionalParam.java | 52 ++++ .../vnfm/svnfm/nslcm/bo/entity/AffectedCp.java | 86 ++++++ .../nslcm/bo/entity/AffectedVirtualStorage.java | 20 +- .../vnfm/svnfm/nslcm/bo/entity/PortResource.java | 81 ++++++ .../svnfm/nslcm/bo/entity/ResourceDefinition.java | 51 +++- .../svnfm/nslcm/bo/entity/ResourceTemplate.java | 50 ++++ .../nslcm/bo/entity/VirtualComputeDescriptor.java | 40 +++ .../vnfm/svnfm/nslcm/bo/entity/VirtualCpu.java | 34 +++ .../vnfm/svnfm/nslcm/bo/entity/VirtualMemory.java | 35 +++ .../nslcm/bo/entity/VirtualStorageDescriptor.java | 52 ++++ .../vnfm/svnfm/vnfmdriver/bo/entity/VimInfo.java | 16 +- .../controller/VnfmDriverController.java | 17 +- .../src/main/resources/application.properties | 22 +- .../src/main/resources/register.properties | 2 +- .../vnfm/svnfm/adaptor/VnfmDriverMgmrImplTest.java | 4 +- .../vnfm/svnfm/nslcm/impl/NslcmMgmrImplTest.java | 38 ++- 36 files changed, 1373 insertions(+), 159 deletions(-) create mode 100644 nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/SslConfInfo.java create mode 100644 nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/MultipartUtility.java create mode 100644 nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/AddResource.java create mode 100644 nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/AdditionalParam.java create mode 100644 nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/AffectedCp.java create mode 100644 nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/PortResource.java create mode 100644 nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/ResourceTemplate.java create mode 100644 nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/VirtualComputeDescriptor.java create mode 100644 nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/VirtualCpu.java create mode 100644 nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/VirtualMemory.java create mode 100644 nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/VirtualStorageDescriptor.java diff --git a/nokia/vnfmdriver/vfcadaptorservice/deployment/pom.xml b/nokia/vnfmdriver/vfcadaptorservice/deployment/pom.xml index f0c4df7f..d1f943c3 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/deployment/pom.xml +++ b/nokia/vnfmdriver/vfcadaptorservice/deployment/pom.xml @@ -74,7 +74,11 @@ fileset(dir: "${basedir}/src/main/release"){ exclude(name: "**/.gitignore") } - + } + ant.copy(todir: "${deployUnzip}/docker") { + fileset(dir: "${basedir}/../docker"){ + exclude(name: "**/.gitignore") + } } System.out.println("******** start copying from ${project.build.directory}/../../vfcadaptor/target/${package.name}-${project.version} to ${deployUnzip}/webapps/ROOT. ************") diff --git a/nokia/vnfmdriver/vfcadaptorservice/deployment/src/main/release/conf/server.xml b/nokia/vnfmdriver/vfcadaptorservice/deployment/src/main/release/conf/server.xml index 825cbc01..4c503eb2 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/deployment/src/main/release/conf/server.xml +++ b/nokia/vnfmdriver/vfcadaptorservice/deployment/src/main/release/conf/server.xml @@ -32,13 +32,14 @@ + diff --git a/nokia/vnfmdriver/vfcadaptorservice/deployment/src/main/release/db/mysql/db-schema.sql b/nokia/vnfmdriver/vfcadaptorservice/deployment/src/main/release/db/mysql/db-schema.sql index 2f2c8913..8a3b2a28 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/deployment/src/main/release/db/mysql/db-schema.sql +++ b/nokia/vnfmdriver/vfcadaptorservice/deployment/src/main/release/db/mysql/db-schema.sql @@ -36,21 +36,21 @@ set Names 'utf8'; /******************drop old table and create new***************************/ -DROP TABLE IF EXISTS vnfm_job_execution_record; -CREATE TABLE `vnfm_job_execution_record` ( - `jobId` int(11) auto_increment primary key, - `vnfInstanceId` varchar(60) DEFAULT NULL, - `vnfmExecutionId` varchar(60) DEFAULT NULL, - `vnfmInterfceName` varchar(60) DEFAULT NULL, +DROP TABLE IF EXISTS vnfm_job_execution_info; +CREATE TABLE `vnfm_job_execution_info` ( + `job_id` int(11) auto_increment primary key, + `vnf_instance_id` varchar(60) DEFAULT NULL, + `vnfm_execution_id` varchar(60) DEFAULT NULL, + `vnfm_interface_name` varchar(60) DEFAULT NULL, `status` varchar(24) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -DROP TABLE IF EXISTS vnfm_resource_record; -CREATE TABLE `vnfm_resource_record` ( +DROP TABLE IF EXISTS vnfm_resource_info; +CREATE TABLE `vnfm_resource_info` ( `id` int(11) auto_increment primary key, `type` enum ('VDU','VL','CP','Storage') DEFAULT NULL, - `resourceDefinitionId` varchar(60) DEFAULT NULL, + `resource_definition_id` varchar(60) DEFAULT NULL, `vdu` varchar(60) DEFAULT NULL, `status` varchar(24) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8; \ No newline at end of file diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/pom.xml b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/pom.xml index 0a159f91..ec7ed2b2 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/pom.xml +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/pom.xml @@ -138,6 +138,11 @@ 1.12 + + ca.juliusdavies + not-yet-commons-ssl + 0.3.9 + finish " + httpConn.getResponseMessage()); + if (status == HttpsURLConnection.HTTP_OK) { + BufferedReader reader = new BufferedReader(new InputStreamReader( + httpConn.getInputStream())); + String line = null; + while ((line = reader.readLine()) != null) { + response.add(line); + } + reader.close(); + httpConn.disconnect(); + } else { + throw new IOException("Server returned non-OK status: " + status); + } + + return response; + } +} \ No newline at end of file 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 1a41765f..1fed73f3 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 @@ -55,13 +55,18 @@ public class AdaptorEnv { private String catalogApiUriFront; //cbamApiFront is from aai query + @Value("${cbamApiUriFront}") private String cbamApiUriFront; + + @Value("${cbamUserName}") private String cbamUserName; + + @Value("${cbamPassword}") private String cbamPassword; private String msbApiUriFront; - + // for retrieving token from CBAM, configured in application.properties @Value("${grantType}") private String grantType; @@ -71,6 +76,19 @@ public class AdaptorEnv { @Value("${clientSecret}") private String clientSecret; + + // for granting + @Value("${type}") + private String type; + + @Value("${sizeOfStorage}") + private String sizeOfStorage; + + @Value("${virtualMemSize}") + private String virtualMemSize; + + @Value("${numVirtualCpu}") + private String numVirtualCpu; public String getAaiServiceNameInMsb() { return aaiServiceNameInMsb; @@ -240,5 +258,37 @@ public class AdaptorEnv { this.cbamPassword = cbamPassword; } + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getSizeOfStorage() { + return sizeOfStorage; + } + + public void setSizeOfStorage(String sizeOfStorage) { + this.sizeOfStorage = sizeOfStorage; + } + + public String getVirtualMemSize() { + return virtualMemSize; + } + + public void setVirtualMemSize(String virtualMemSize) { + this.virtualMemSize = virtualMemSize; + } + + public String getNumVirtualCpu() { + return numVirtualCpu; + } + + public void setNumVirtualCpu(String numVirtualCpu) { + this.numVirtualCpu = numVirtualCpu; + } + } 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 index c49d1f04..e59a301a 100644 --- 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 @@ -59,7 +59,7 @@ public final class CommonUtil { return fileContent; } - private static String getAppRoot() { + public static String getAppRoot() { String appRoot = System.getProperty("catalina.base"); if(appRoot != null) { appRoot = getCanonicalPath(appRoot); 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 a2be9f12..fd1864eb 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 @@ -31,27 +31,27 @@ public class CommonConstants { //AAI path get vnfm // /external-system/esr-vnfm-list/esr-vnfm/{vnfm-id}/esr-system-info-list - public static final String RetrieveVnfmListPath = "/external-system/esr-vnfm-list/esr-vnfm/%s/esr-system-info-list"; + public static final String RetrieveVnfmListPath = "/aai/v11/external-system/esr-vnfm-list/esr-vnfm/%s/esr-system-info-list"; //Nslcm path - public static final String NslcmGrantPath = "/ns/grantvnf"; - public static final String NslcmNotifyPath = "/vnfs/%s/Notify"; + public static final String NslcmGrantPath = "/api/vnflcm/v1//ns/grantvnf"; + public static final String NslcmNotifyPath = "/api/vnflcm/v1/vnfs/%s/Notify"; //Catalog path - public static final String RetrieveVnfPackagePath = "/catalog/v1/vnfpackages/%s"; + public static final String RetrieveVnfPackagePath = "/api/catalog/v1/vnfpackages/%s"; //CBAM -- Nokia VNFM path public static final String CBAM_TOKEN_KEY = "access_token"; public static final String CbamRetrieveTokenPath="/auth/realms/cbam/protocol/openid-connect/token"; public static final String CbamRetrieveTokenPostStr="grant_type=password&client_id=%s&client_secret=%s&username=%s&password=%s"; - public static final String CbamCreateVnfPath="/vnfs"; - public static final String CbamInstantiateVnfPath="/vnfs/%s/instantiate"; - public static final String CbamQueryVnfPath="/vnfs/%s"; - public static final String CbamDeleteVnfPath="/vnfs/%s"; - public static final String CbamTerminateVnfPath="/vnfs/%s/terminate"; - public static final String CbamGetOperStatusPath="/operation_executions/%s"; - public static final String CbamScaleVnfPath = "/vnfs/%s/scale"; - public static final String CbamHealVnfPath="/vnfs/%s/heal"; + public static final String CbamCreateVnfPath="/vnfm/lcm/v3/vnfs"; + public static final String CbamInstantiateVnfPath="/vnfm/lcm/v3/vnfs/%s/instantiate"; + public static final String CbamQueryVnfPath="/vnfm/lcm/v3/vnfs/%s"; + public static final String CbamDeleteVnfPath="/vnfm/lcm/v3/vnfs/%s"; + public static final String CbamTerminateVnfPath="/vnfm/lcm/v3/vnfs/%s/terminate"; + public static final String CbamGetOperStatusPath="/vnfm/lcm/v3/operation_executions/%s"; + public static final String CbamScaleVnfPath = "/vnfm/lcm/v3/vnfs/%s/scale"; + public static final String CbamHealVnfPath="/vnfm/lcm/v3/vnfs/%s/heal"; public static final String CbamUploadVnfPackagePath="/api/catalog/adapter/vnfpackages"; diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/bean/VnfmJobExecutionInfo.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/bean/VnfmJobExecutionInfo.java index 9c53c516..cf79b052 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/bean/VnfmJobExecutionInfo.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/bean/VnfmJobExecutionInfo.java @@ -16,6 +16,8 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.db.bean; +import java.io.Serializable; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -25,21 +27,22 @@ import javax.persistence.Table; @Entity -@Table(name = "vnfm_job_execution_record") -public class VnfmJobExecutionInfo{ - private static final long serialVersionUID = -2880159539002942812L; +@Table(name = "vnfm_job_execution_info") +public class VnfmJobExecutionInfo implements Serializable { + private static final long serialVersionUID = -288015953900428312L; @Id @GeneratedValue(strategy=GenerationType.AUTO) + @Column(name = "job_id") private long jobId; - @Column(name = "vnfmExecutionId") + @Column(name = "vnfm_execution_id") private String vnfmExecutionId; - @Column(name = "vnfInstanceId") + @Column(name = "vnf_instance_id") private String vnfInstanceId; - @Column(name = "vnfmInterfceName") + @Column(name = "vnfm_interface_name") private String vnfmInterfceName; @Column(name = "status") diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/bean/VnfmResourceInfo.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/bean/VnfmResourceInfo.java index b245f2b8..dadb2b9f 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/bean/VnfmResourceInfo.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/bean/VnfmResourceInfo.java @@ -16,16 +16,19 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.db.bean; -import javax.persistence.Entity; +import java.io.Serializable; + import javax.persistence.Column; +import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; @Entity -@Table(name = "vnfm_resource_record") -public class VnfmResourceInfo { +@Table(name="vnfm_resource_info") +public class VnfmResourceInfo implements Serializable { + private static final long serialVersionUID = -288015953900428312L; @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; @@ -33,7 +36,7 @@ public class VnfmResourceInfo { @Column(name = "type") private ResourceType type; - @Column(name = "resourceDefinitionId") + @Column(name = "resource_definition_id") private String resourceDefinitionId; @Column(name = "vdu") 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 e5a77f7b..13f1014f 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 @@ -16,12 +16,15 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; @@ -30,12 +33,10 @@ import org.apache.http.config.Registry; import org.apache.http.config.RegistryBuilder; import org.apache.http.conn.socket.ConnectionSocketFactory; import org.apache.http.conn.socket.PlainConnectionSocketFactory; -import org.apache.http.conn.ssl.NoopHostnameVerifier; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; -import org.apache.http.ssl.SSLContextBuilder; -import org.apache.http.ssl.TrustStrategy; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -50,36 +51,54 @@ public class HttpClientUtils { @Bean public static HttpClientBuilder createHttpClientBuilder() { - HttpClientBuilder httpClientBuilder = HttpClientBuilder.create(); - - SSLContext sslContext = null; + org.apache.commons.httpclient.protocol.Protocol.unregisterProtocol("https"); + SSLContext sslcontext = null; try { - sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() { - public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { - return true; - } - }).build(); - } catch (Exception e) { - logger.error("Error to createHttpClientBuilder", e); - } - httpClientBuilder.setSSLContext(sslContext); - - HostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE; - - SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(sslContext, hostnameVerifier); - Registry socketFactoryRegistry = RegistryBuilder.create() - .register("http", PlainConnectionSocketFactory.getSocketFactory()) - .register("https", sslSocketFactory) - .build(); - - PoolingHttpClientConnectionManager connMgr = new PoolingHttpClientConnectionManager(socketFactoryRegistry); - connMgr.setMaxTotal(200); - connMgr.setDefaultMaxPerRoute(50); - httpClientBuilder.setConnectionManager(connMgr); + sslcontext = createIgnoreVerifySSL(); + } catch (KeyManagementException | NoSuchAlgorithmException e) { + logger.error("HttpRequestProcessor -> generateHttpClient exception. ", e); + } + + Registry socketFactoryRegistry = RegistryBuilder.create() + .register("http", PlainConnectionSocketFactory.INSTANCE) + .register("https", new SSLConnectionSocketFactory(sslcontext)) + .build(); + + PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry); + connManager.setMaxTotal(200); + connManager.setDefaultMaxPerRoute(50); + + HttpClientBuilder httpClientBuilder = HttpClients.custom().setConnectionManager(connManager); return httpClientBuilder; } + private static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException { + SSLContext sc = SSLContext.getInstance("TLSv1.2"); + + X509TrustManager trustManager = new X509TrustManager() { + @Override + public void checkClientTrusted( + java.security.cert.X509Certificate[] paramArrayOfX509Certificate, + String paramString) throws CertificateException { + } + + @Override + public void checkServerTrusted( + java.security.cert.X509Certificate[] paramArrayOfX509Certificate, + String paramString) throws CertificateException { + } + + @Override + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return null; + } + }; + + sc.init(null, new TrustManager[] { trustManager }, null); + return sc; + } + public static HttpRequestBase getHttpRequest(RequestMethod requestMethod) { HttpRequestBase base = null; switch(requestMethod) { @@ -93,6 +112,8 @@ public class HttpClientUtils { base = new HttpPost(); break; } + RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(20000).setConnectTimeout(20000).setConnectionRequestTimeout(20000).build(); + base.setConfig(requestConfig); return base; } } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpRequestProcessor.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpRequestProcessor.java index 8963dd49..2681be3f 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpRequestProcessor.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpRequestProcessor.java @@ -30,9 +30,12 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonConstants; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.RequestMethod; public class HttpRequestProcessor { + private static final Logger logger = LoggerFactory.getLogger(HttpRequestProcessor.class); private CloseableHttpClient httpClient; private HttpRequestBase httpRequest; @@ -47,6 +50,8 @@ public class HttpRequestProcessor { httpRequest.setURI(URI.create(url)); HttpResponse response = httpClient.execute(httpRequest); + httpRequest.releaseConnection(); +// httpClient.close(); HttpResult httpResult = buildHttpResult(response); return httpResult; diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/init/EnvVariablesInitialization.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/init/EnvVariablesInitialization.java index 1fb7138a..81cc281d 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/init/EnvVariablesInitialization.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/init/EnvVariablesInitialization.java @@ -51,23 +51,27 @@ public class EnvVariablesInitialization implements ApplicationRunner { return; } - try { - handleAaiMsbServiceInfo(); - } catch (Exception e) { - logger.error("handleAaiMsbServiceInfo error", e); - } - - try { - handleLcmMsbServiceInfo(); - } catch (Exception e) { - logger.error("handleLcmMsbServiceInfo error", e); - } + adaptorEnv.setAaiApiUriFront(adaptorEnv.getMsbApiUriFront()); + adaptorEnv.setLcmApiUriFront(adaptorEnv.getMsbApiUriFront()); + adaptorEnv.setCatalogApiUriFront(adaptorEnv.getMsbApiUriFront()); - try { - handleCatalogMsbServiceInfo(); - } catch (Exception e) { - logger.error("handleCatalogMsbServiceInfo error", e); - } +// try { +// handleAaiMsbServiceInfo(); +// } catch (Exception e) { +// logger.error("handleAaiMsbServiceInfo error", e); +// } +// +// try { +// handleLcmMsbServiceInfo(); +// } catch (Exception e) { +// logger.error("handleLcmMsbServiceInfo error", e); +// } +// +// try { +// handleCatalogMsbServiceInfo(); +// } catch (Exception e) { +// logger.error("handleCatalogMsbServiceInfo error", e); +// } } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/NslcmNotifyLCMEventsRequest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/NslcmNotifyLCMEventsRequest.java index ccfe8f25..a30cf50b 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/NslcmNotifyLCMEventsRequest.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/NslcmNotifyLCMEventsRequest.java @@ -18,6 +18,7 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo; import java.util.List; import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonEnum; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.AffectedCp; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.AffectedVirtualLink; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.AffectedVirtualStorage; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.AffectedVnfc; @@ -28,7 +29,6 @@ public class NslcmNotifyLCMEventsRequest { @JsonProperty("status") private CommonEnum.status status; - @JsonProperty("vnfInstanceId") private String vnfInstanceId; @JsonProperty("operation") @@ -37,10 +37,14 @@ public class NslcmNotifyLCMEventsRequest { private String jobId; @JsonProperty("affectedVnfc") private List affectedVnfc; + @JsonProperty("affectedCp") + private List affectedCp; @JsonProperty("affectedVl") private List affectedVl; @JsonProperty("affectedVirtualStorage") private List affectedVirtualStorage; + + public CommonEnum.status getStatus() { return status; } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/AddResource.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/AddResource.java new file mode 100644 index 00000000..0bb58ec4 --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/AddResource.java @@ -0,0 +1,62 @@ +/* + * 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.nslcm.bo.entity; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class AddResource { + @JsonProperty("type") + private String type; + + @JsonProperty("resourceTemplate") + private ResourceTemplate resourceTemplate; + + @JsonProperty("resourceDefinitionId") + private int resourceDefinitionId; + + @JsonProperty("vdu") + private String vdu; + + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + public ResourceTemplate getResourceTemplate() { + return resourceTemplate; + } + public void setResourceTemplate(ResourceTemplate resourceTemplate) { + this.resourceTemplate = resourceTemplate; + } + public int getResourceDefinitionId() { + return resourceDefinitionId; + } + public void setResourceDefinitionId(int resourceDefinitionId) { + this.resourceDefinitionId = resourceDefinitionId; + } + public String getVdu() { + return vdu; + } + public void setVdu(String vdu) { + this.vdu = vdu; + } + + + + + +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/AdditionalParam.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/AdditionalParam.java new file mode 100644 index 00000000..513e9df4 --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/AdditionalParam.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.nslcm.bo.entity; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class AdditionalParam { + @JsonProperty("vnfmid") + private String vnfmid; + @JsonProperty("vimid") + private String vimid; + @JsonProperty("tenant") + private String tenant; + + 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 getTenant() { + return tenant; + } + + public void setTenant(String tenant) { + this.tenant = tenant; + } + +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/AffectedCp.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/AffectedCp.java new file mode 100644 index 00000000..299e6f57 --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/AffectedCp.java @@ -0,0 +1,86 @@ +/* + * 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.nslcm.bo.entity; + +import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonEnum; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class AffectedCp { + + @JsonProperty("virtualLinkInstanceId") + private String virtualLinkInstanceId; + @JsonProperty("cpinstanceid") + private String cpinstanceid; + @JsonProperty("cpdid") + private String cpdid; + @JsonProperty("ownerType") + private String ownerType; + @JsonProperty("ownerId") + private String ownerId; + @JsonProperty("changeType") + private CommonEnum.changeType changeType; + @JsonProperty("portResource") + private PortResource portResource; + + public String getVirtualLinkInstanceId() { + return virtualLinkInstanceId; + } + public void setVirtualLinkInstanceId(String virtualLinkInstanceId) { + this.virtualLinkInstanceId = virtualLinkInstanceId; + } + public String getCpinstanceid() { + return cpinstanceid; + } + public void setCpinstanceid(String cpinstanceid) { + this.cpinstanceid = cpinstanceid; + } + public String getCpdid() { + return cpdid; + } + public void setCpdid(String cpdid) { + this.cpdid = cpdid; + } + public String getOwnerType() { + return ownerType; + } + public void setOwnerType(String ownerType) { + this.ownerType = ownerType; + } + public String getOwnerId() { + return ownerId; + } + public void setOwnerId(String ownerId) { + this.ownerId = ownerId; + } + public CommonEnum.changeType getChangeType() { + return changeType; + } + public void setChangeType(CommonEnum.changeType changeType) { + this.changeType = changeType; + } + public PortResource getPortResource() { + return portResource; + } + public void setPortResource(PortResource portResource) { + this.portResource = portResource; + } + + + + + +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/AffectedVirtualStorage.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/AffectedVirtualStorage.java index 6139adb8..c16c5399 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/AffectedVirtualStorage.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/AffectedVirtualStorage.java @@ -19,38 +19,44 @@ import com.fasterxml.jackson.annotation.JsonProperty; public class AffectedVirtualStorage { @JsonProperty("vsInstanceId") - private String vsInstanceId; + private String vsInstanceId; @JsonProperty("vsdId") - private String vsdId; - + private String vsdId; @JsonProperty("changeType") - private String changeType; + private String changeType; @JsonProperty("storageResource") - private String storageResource; + private String storageResource; + public String getVsInstanceId() { return vsInstanceId; } + public void setVsInstanceId(String vsInstanceId) { this.vsInstanceId = vsInstanceId; } + public String getVsdId() { return vsdId; } + public void setVsdId(String vsdId) { this.vsdId = vsdId; } + public String getChangeType() { return changeType; } + public void setChangeType(String changeType) { this.changeType = changeType; } + public String getStorageResource() { return storageResource; } + public void setStorageResource(String storageResource) { this.storageResource = storageResource; } - - + } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/PortResource.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/PortResource.java new file mode 100644 index 00000000..e39edf82 --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/PortResource.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.nslcm.bo.entity; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class PortResource { + + @JsonProperty("vimid") + private String vimid; + @JsonProperty("resourceid") + private String resourceid; + @JsonProperty("resourceName") + private String resourceName; + @JsonProperty("tenant") + private String tenant; + @JsonProperty("ipAddress") + private String ipAddress; + @JsonProperty("macAddress") + private String macAddress; + @JsonProperty("instId") + private String instId; + + public String getVimid() { + return vimid; + } + public void setVimid(String vimid) { + this.vimid = vimid; + } + public String getResourceid() { + return resourceid; + } + public void setResourceid(String resourceid) { + this.resourceid = resourceid; + } + public String getResourceName() { + return resourceName; + } + public void setResourceName(String resourceName) { + this.resourceName = resourceName; + } + public String getTenant() { + return tenant; + } + public void setTenant(String tenant) { + this.tenant = tenant; + } + public String getIpAddress() { + return ipAddress; + } + public void setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + } + public String getMacAddress() { + return macAddress; + } + public void setMacAddress(String macAddress) { + this.macAddress = macAddress; + } + public String getInstId() { + return instId; + } + public void setInstId(String instId) { + this.instId = instId; + } + + +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/ResourceDefinition.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/ResourceDefinition.java index 4a10ae99..0439f606 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/ResourceDefinition.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/ResourceDefinition.java @@ -15,22 +15,63 @@ */ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonEnum; +import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; public class ResourceDefinition { - @JsonProperty("type") + @JsonProperty("vnfInstanceId") + private String vnfInstanceId; + @JsonProperty("addResource") + private List addResource; + @JsonProperty("vimId") + private String vimId; + @JsonProperty("additionalParam") + private AdditionalParam additionalParam; + + public String getVnfInstanceId() { + return vnfInstanceId; + } + + public void setVnfInstanceId(String vnfInstanceId) { + this.vnfInstanceId = vnfInstanceId; + } + + public List getAddResource() { + return addResource; + } + + public void setAddResource(List addResource) { + this.addResource = addResource; + } + + public String getVimId() { + return vimId; + } + + public void setVimId(String vimId) { + this.vimId = vimId; + } + + public AdditionalParam getAdditionalParam() { + return additionalParam; + } + + public void setAdditionalParam(AdditionalParam additionalParam) { + this.additionalParam = additionalParam; + } + + /*@JsonProperty("type") private CommonEnum.type type; @JsonProperty("resourceDefinitionId") private String resourceDefinitionId; @JsonProperty("vdu") - private String vdu; + private String vdu;*/ - public CommonEnum.type getType() { + /*public CommonEnum.type getType() { return type; } @@ -53,7 +94,7 @@ public class ResourceDefinition { public void setVdu(String vdu) { this.vdu = vdu; } - + */ diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/ResourceTemplate.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/ResourceTemplate.java new file mode 100644 index 00000000..35ad4054 --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/ResourceTemplate.java @@ -0,0 +1,50 @@ +/* + * 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.nslcm.bo.entity; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class ResourceTemplate { + @JsonProperty("virtualStorageDescriptor") + private VirtualStorageDescriptor virtualStorageDescriptor; + @JsonProperty("virtualComputeDescriptor") + private VirtualComputeDescriptor virtualComputeDescriptor; + + + public VirtualStorageDescriptor getVirtualStorageDescriptor() { + return virtualStorageDescriptor; + } + public void setVirtualStorageDescriptor(VirtualStorageDescriptor virtualStorageDescriptor) { + this.virtualStorageDescriptor = virtualStorageDescriptor; + } + public VirtualComputeDescriptor getVirtualComputeDescriptor() { + return virtualComputeDescriptor; + } + public void setVirtualComputeDescriptor(VirtualComputeDescriptor virtualComputeDescriptor) { + this.virtualComputeDescriptor = virtualComputeDescriptor; + } + + + + + + + + + + + +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/VirtualComputeDescriptor.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/VirtualComputeDescriptor.java new file mode 100644 index 00000000..ec937e83 --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/VirtualComputeDescriptor.java @@ -0,0 +1,40 @@ +/* + * 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.nslcm.bo.entity; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class VirtualComputeDescriptor { + @JsonProperty("virtualMemory") + private VirtualMemory virtualMemory; + @JsonProperty("virtualCpu") + private VirtualCpu virtualCpu; + public VirtualMemory getVirtualMemory() { + return virtualMemory; + } + public void setVirtualMemory(VirtualMemory virtualMemory) { + this.virtualMemory = virtualMemory; + } + public VirtualCpu getVirtualCpu() { + return virtualCpu; + } + public void setVirtualCpu(VirtualCpu virtualCpu) { + this.virtualCpu = virtualCpu; + } + + + +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/VirtualCpu.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/VirtualCpu.java new file mode 100644 index 00000000..38e57151 --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/VirtualCpu.java @@ -0,0 +1,34 @@ +/* + * 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.nslcm.bo.entity; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class VirtualCpu { + @JsonProperty("numVirtualCpu") + private int numVirtualCpu; + + public int getNumVirtualCpu() { + return numVirtualCpu; + } + + public void setNumVirtualCpu(int numVirtualCpu) { + this.numVirtualCpu = numVirtualCpu; + } + + + +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/VirtualMemory.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/VirtualMemory.java new file mode 100644 index 00000000..95df117c --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/VirtualMemory.java @@ -0,0 +1,35 @@ +/* + * 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.nslcm.bo.entity; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class VirtualMemory { + @JsonProperty("virtualMemSize") + private int virtualMemSize; + + public int getVirtualMemSize() { + return virtualMemSize; + } + + public void setVirtualMemSize(int virtualMemSize) { + this.virtualMemSize = virtualMemSize; + } + + + + +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/VirtualStorageDescriptor.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/VirtualStorageDescriptor.java new file mode 100644 index 00000000..6e5247c9 --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/bo/entity/VirtualStorageDescriptor.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.nslcm.bo.entity; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class VirtualStorageDescriptor { + @JsonProperty("sizeOfStorage") + private int sizeOfStorage; + @JsonProperty("typeOfStorage") + private String typeOfStorage; + @JsonProperty("swImageDescriptor") + private String swImageDescriptor; + + public int getSizeOfStorage() { + return sizeOfStorage; + } + + public void setSizeOfStorage(int sizeOfStorage) { + this.sizeOfStorage = sizeOfStorage; + } + + public String getTypeOfStorage() { + return typeOfStorage; + } + + public void setTypeOfStorage(String typeOfStorage) { + this.typeOfStorage = typeOfStorage; + } + + public String getSwImageDescriptor() { + return swImageDescriptor; + } + + public void setSwImageDescriptor(String swImageDescriptor) { + this.swImageDescriptor = swImageDescriptor; + } + +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/bo/entity/VimInfo.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/bo/entity/VimInfo.java index bd4e9d7a..ed226775 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/bo/entity/VimInfo.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/bo/entity/VimInfo.java @@ -16,6 +16,8 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.entity; +import java.util.List; + import com.fasterxml.jackson.annotation.JsonProperty; public class VimInfo { @@ -26,10 +28,10 @@ public class VimInfo { private String vimId; @JsonProperty("interfaceInfo") - private InterfaceInfo interfaceInfo; + private List interfaceInfo; @JsonProperty("accessInfo") - private AccessInfo accessInfo; + private List accessInfo; @JsonProperty("interfaceEndpoint") private String interfaceEndpoint; @@ -50,19 +52,21 @@ public class VimInfo { this.vimId = vimId; } - public InterfaceInfo getInterfaceInfo() { + + + public List getInterfaceInfo() { return interfaceInfo; } - public void setInterfaceInfo(InterfaceInfo interfaceInfo) { + public void setInterfaceInfo(List interfaceInfo) { this.interfaceInfo = interfaceInfo; } - public AccessInfo getAccessInfo() { + public List getAccessInfo() { return accessInfo; } - public void setAccessInfo(AccessInfo accessInfo) { + public void setAccessInfo(List accessInfo) { this.accessInfo = accessInfo; } 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 e55c8677..8dd68323 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 @@ -20,8 +20,8 @@ import java.io.IOException; import javax.servlet.http.HttpServletResponse; -import org.apache.http.HttpStatus; import org.apache.commons.io.IOUtils; +import org.apache.http.HttpStatus; 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; @@ -31,7 +31,6 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.OperStatusVnfResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.QueryVnfResponse; 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.SwaggerInfo; 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; @@ -60,17 +59,9 @@ public class VnfmDriverController { @RequestMapping(value = "/swagger.json", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody - public SwaggerInfo apidoc() { + public String apidoc() throws IOException { ClassLoader classLoader = getClass().getClassLoader(); - SwaggerInfo info = null; - try { - String json = IOUtils.toString(classLoader.getResourceAsStream("swagger.json")); - info = gson.fromJson(json, SwaggerInfo.class); - } catch (IOException e) { - logger.error("", e); - } - - return info; + return IOUtils.toString(classLoader.getResourceAsStream("swagger.json")); } @RequestMapping(value = "/{vnfmId}/vnfs", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @@ -82,6 +73,8 @@ public class VnfmDriverController { InstantiateVnfResponse response = vnfmDriverMgmr.instantiateVnf(request, vnfmId); + logger.info("InstantiateVnfResponse is " + gson.toJson(response)); + httpResponse.setStatus(HttpStatus.SC_CREATED); return response; diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/resources/application.properties b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/resources/application.properties index 850e6cad..5b7f742d 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/resources/application.properties +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/resources/application.properties @@ -16,6 +16,13 @@ server.error.whitelabel.enabled=false ## for MySql Database begin ## +spring.jpa.show-sql=true +spring.jpa.generate-ddl=true +spring.jpa.hibernate.ddl-auto=update +spring.jpa.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect +spring.jackson.serialization.indent_output=false + + spring.datasource.username=vnfm spring.datasource.password=vnfmpass spring.datasource.url=jdbc:mysql://127.0.0.1:3306/vnfm_db?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=round&useSSL=false @@ -43,7 +50,16 @@ catalogVersionInMsb=v1 ## configure service name and version of MSB services AAI/LCM/Catalog end ## ## for retrieving token from CBAM begin ## -grantType=grantType1 -clientId=clientId1 -clientSecret=clientSecret1 +grantType=password +clientId=Orchestrator +clientSecret=.1.qtcePQQ3.BqxiGBeyWUjREnGooRr6x1 +cbamApiUriFront=https://172.30.24.3 +cbamUserName=cbam +cbamPassword=Nokia@123 ## for retrieving token from CBAM end ## + +## Granting part +type=vdu +sizeOfStorage=40 +virtualMemSize=8192 +numVirtualCpu=4 diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/resources/register.properties b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/resources/register.properties index 04929955..59babb8c 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/resources/register.properties +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/resources/register.properties @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### -serviceName=nokia-vnfm-driver +serviceName=nokiavnfmdriver version=v1 url=/api/nokiavnfmdriver/v1 protocol=HTTP diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImplTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImplTest.java index d7834465..d5a0e100 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImplTest.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImplTest.java @@ -139,13 +139,13 @@ public class VnfmDriverMgmrImplTest { @Test public void testBuildVnfmHttpPathById() throws ClientProtocolException, IOException { - String vnfmHttpPathHead = vnfmDriverMgmr.buildVnfmHttpPathById(vnfmId); + String vnfmHttpPathHead = vnfmDriverMgmr.buildVnfmHttpPathByRealId(vnfmId); Assert.assertEquals("result is ", cbamHttpHead, vnfmHttpPathHead); } @Test(expected = VnfmDriverException.class) public void testBuildVnfmHttpPathByIdException() throws ClientProtocolException, IOException{ - vnfmDriverMgmr.buildVnfmHttpPathById(vnfmId + "001"); + vnfmDriverMgmr.buildVnfmHttpPathByRealId(vnfmId + "001"); } @Test diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImplTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImplTest.java index 47c33bf1..c55b39d9 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImplTest.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImplTest.java @@ -40,11 +40,18 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmGrantVnfRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmGrantVnfResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmNotifyLCMEventsRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.AccessInfo; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.AddResource; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.AdditionalParam; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.AffectedVirtualStorage; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.AffectedVnfc; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.InterfaceInfo; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.ResourceDefinition; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.ResourceTemplate; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.VimAssets; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.VirtualComputeDescriptor; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.VirtualCpu; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.VirtualMemory; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.VirtualStorageDescriptor; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.NslcmVimInfo; import org.springframework.web.bind.annotation.RequestMethod; @@ -73,8 +80,35 @@ public class NslcmMgmrImplTest { public void testGrantVnf() throws ClientProtocolException, IOException { ResourceDefinition resource = new ResourceDefinition(); - resource.setResourceDefinitionId("resourceDefinitionId"); - resource.setVdu("vdu"); + resource.setVimId("vimId"); + resource.setVnfInstanceId("vnfInstanceId"); + + List addresources=new ArrayList(); + AddResource addresource=new AddResource(); + addresource.setResourceDefinitionId(1); + addresource.setType("type"); + addresource.setVdu("vdu"); + ResourceTemplate temp=new ResourceTemplate(); + VirtualComputeDescriptor compute=new VirtualComputeDescriptor(); + VirtualCpu cpu=new VirtualCpu(); + cpu.setNumVirtualCpu(1); + VirtualMemory memory=new VirtualMemory(); + compute.setVirtualCpu(cpu); + compute.setVirtualMemory(memory); + VirtualStorageDescriptor storage=new VirtualStorageDescriptor(); + storage.setSizeOfStorage(1); + storage.setSwImageDescriptor("swImageDescriptor"); + storage.setSizeOfStorage(1); + temp.setVirtualComputeDescriptor(compute); + temp.setVirtualStorageDescriptor(storage); + addresources.add(addresource); + AdditionalParam param=new AdditionalParam(); + param.setTenant("tenant"); + param.setVimid("vimid"); + param.setVnfmid("vnfmid"); + + resource.setAdditionalParam(param); + resource.setAddResource(addresources); NslcmGrantVnfResponse gresponse = new NslcmGrantVnfResponse(); List additionalParam1 = new ArrayList(); -- cgit 1.2.3-korg