From 6346805afd9fcf4c56966751e41ee959391e8788 Mon Sep 17 00:00:00 2001 From: fujinhua Date: Fri, 30 Jun 2017 14:14:29 +0800 Subject: [PATCH] Create seed codes of nfvo Change-Id: I72a426c6be55f8a6a0200f6dedd2486bee067062 Issue-Id: VFC-52 Signed-off-by: fujinhua --- .../plugin-standalone/plugin-standalone.iml | 122 ++++++++++++ zte/sfc-driver/plugin-standalone/pom.xml | 160 +++++++++++++++ .../src/main/assembly/conf/console.yml | 63 ++++++ .../plugin-standalone/src/main/assembly/run.bat | 21 ++ .../plugin-standalone/src/main/assembly/run.sh | 48 +++++ .../plugin-standalone/src/main/assembly/stop.sh | 47 +++++ zte/sfc-driver/pom.xml | 37 ++++ zte/sfc-driver/sfc-driver-parent.iml | 34 ++++ .../sfc-driver/dependency-reduced-pom.xml | 159 +++++++++++++++ zte/sfc-driver/sfc-driver/pom.xml | 194 +++++++++++++++++++ zte/sfc-driver/sfc-driver/sfc-driver.iml | 125 ++++++++++++ .../src/main/java/org/openo/sfc/SfcDriver.java | 94 +++++++++ .../main/java/org/openo/sfc/SfcDriverConfig.java | 61 ++++++ .../java/org/openo/sfc/entity/ChainParameter.java | 43 +++++ .../main/java/org/openo/sfc/entity/DelReqInfo.java | 46 +++++ .../org/openo/sfc/entity/FlowClassfierReq.java | 110 +++++++++++ .../org/openo/sfc/entity/FlowClassfierReq4N.java | 109 +++++++++++ .../org/openo/sfc/entity/FlowClassifierReq4S.java | 35 ++++ .../org/openo/sfc/entity/MsbRegisterEntity.java | 78 ++++++++ .../main/java/org/openo/sfc/entity/NodeEntity.java | 49 +++++ .../java/org/openo/sfc/entity/PortChainReq.java | 67 +++++++ .../java/org/openo/sfc/entity/PortChainReq4N.java | 84 ++++++++ .../java/org/openo/sfc/entity/PortChainReq4S.java | 34 ++++ .../org/openo/sfc/entity/PortPairGroupReq.java | 44 +++++ .../org/openo/sfc/entity/PortPairGroupReq4N.java | 68 +++++++ .../org/openo/sfc/entity/PortPairGroupReq4S.java | 33 ++++ .../src/main/java/org/openo/sfc/entity/Result.java | 32 +++ .../org/openo/sfc/entity/SdnControllerInfo.java | 47 +++++ .../org/openo/sfc/entity/portpair/PortInfo.java | 61 ++++++ .../org/openo/sfc/entity/portpair/PortPairReq.java | 63 ++++++ .../openo/sfc/entity/portpair/PortPairReq4N.java | 112 +++++++++++ .../openo/sfc/entity/portpair/PortPairReq4S.java | 34 ++++ .../entity/portpair/ServiceFunctionParameter.java | 41 ++++ .../org/openo/sfc/health/ConsoleHealthCheck.java | 35 ++++ .../org/openo/sfc/resources/DriverResource.java | 214 +++++++++++++++++++++ .../openo/sfc/resources/MsbServiceRegister.java | 72 +++++++ .../java/org/openo/sfc/service/ConfigInfo.java | 30 +++ .../openo/sfc/service/ISdnControllerService.java | 87 +++++++++ .../java/org/openo/sfc/service/MsbService.java | 35 ++++ .../org/openo/sfc/service/SdnServiceConsumer.java | 38 ++++ .../main/java/org/openo/sfc/utils/SfcConst.java | 24 +++ .../java/org/openo/sfc/utils/SfcDriverUtil.java | 105 ++++++++++ .../java/org/openo/sfc/wrapper/N2sReqWrapper.java | 106 ++++++++++ 43 files changed, 3101 insertions(+) create mode 100644 zte/sfc-driver/plugin-standalone/plugin-standalone.iml create mode 100644 zte/sfc-driver/plugin-standalone/pom.xml create mode 100644 zte/sfc-driver/plugin-standalone/src/main/assembly/conf/console.yml create mode 100644 zte/sfc-driver/plugin-standalone/src/main/assembly/run.bat create mode 100644 zte/sfc-driver/plugin-standalone/src/main/assembly/run.sh create mode 100644 zte/sfc-driver/plugin-standalone/src/main/assembly/stop.sh create mode 100644 zte/sfc-driver/pom.xml create mode 100644 zte/sfc-driver/sfc-driver-parent.iml create mode 100644 zte/sfc-driver/sfc-driver/dependency-reduced-pom.xml create mode 100644 zte/sfc-driver/sfc-driver/pom.xml create mode 100644 zte/sfc-driver/sfc-driver/sfc-driver.iml create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/SfcDriver.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/SfcDriverConfig.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/ChainParameter.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/DelReqInfo.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/FlowClassfierReq.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/FlowClassfierReq4N.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/FlowClassifierReq4S.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/MsbRegisterEntity.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/NodeEntity.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortChainReq.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortChainReq4N.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortChainReq4S.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortPairGroupReq.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortPairGroupReq4N.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortPairGroupReq4S.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/Result.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/SdnControllerInfo.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/portpair/PortInfo.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/portpair/PortPairReq.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/portpair/PortPairReq4N.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/portpair/PortPairReq4S.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/portpair/ServiceFunctionParameter.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/health/ConsoleHealthCheck.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/resources/DriverResource.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/resources/MsbServiceRegister.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/service/ConfigInfo.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/service/ISdnControllerService.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/service/MsbService.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/service/SdnServiceConsumer.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/utils/SfcConst.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/utils/SfcDriverUtil.java create mode 100644 zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/wrapper/N2sReqWrapper.java diff --git a/zte/sfc-driver/plugin-standalone/plugin-standalone.iml b/zte/sfc-driver/plugin-standalone/plugin-standalone.iml new file mode 100644 index 0000000..5a98a60 --- /dev/null +++ b/zte/sfc-driver/plugin-standalone/plugin-standalone.iml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/zte/sfc-driver/plugin-standalone/pom.xml b/zte/sfc-driver/plugin-standalone/pom.xml new file mode 100644 index 0000000..e5cd1c7 --- /dev/null +++ b/zte/sfc-driver/plugin-standalone/pom.xml @@ -0,0 +1,160 @@ + + + + + org.openo.nfvo.sfc-driver-parent + sfc-driver-parent + 1.1.0-SNAPSHOT + + 4.0.0 + org.openo.nfvo.sfc-driver-standalone + nfvo-drivers-sdnc-zte-sfc-driver + nfvo/drivers/sdnc/zte/sfc-driver/plugin-standalone + pom + 1.1.0-SNAPSHOT + + + + org.openo.nfvo.sfc-driver + sfc-driver + ${project.version} + + + + + sfc-driver + + + + + + maven-resources-plugin + + + copy-resources + process-resources + + copy-resources + + + ${basedir}/target/assembly/ + + + src/main/assembly/ + false + + **/* + + + + + true + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.8 + + + copy-jar + + copy + + prepare-package + + + + org.openo.nfvo.sfc-driver + sfc-driver + jar + true + target/assembly/ + sfc-service.jar + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + zip + package + + run + + + + + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + package + + attach-artifact + + + + + target/nfvo-drivers-sdnc-zte-sfc-driver-${project.version}.zip + zip + + + + + + + + + + + + diff --git a/zte/sfc-driver/plugin-standalone/src/main/assembly/conf/console.yml b/zte/sfc-driver/plugin-standalone/src/main/assembly/conf/console.yml new file mode 100644 index 0000000..4860afd --- /dev/null +++ b/zte/sfc-driver/plugin-standalone/src/main/assembly/conf/console.yml @@ -0,0 +1,63 @@ +# +# Copyright 2016 [ZTE] and others. +# +# 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. +# + +template: Hello, %s! + +defaultName: ${DW_DEFAULT_NAME:-Stranger} + +msbServiceUrl: http://127.0.0.1:80 + +# use the simple server factory if you only want to run on a single port +#server: +# type: simple +# connector: +# type: http +# port: 8080 + +server: + type: simple + rootPath: '/openoapi/ztesdncdriver/v1/*' + applicationContextPath: / + adminContextPath: /admin + connector: + type: http + port: 8411 + +# Logging settings. +logging: + + # The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL. + level: ALL + + # Logger-specific levels. + loggers: + + # Sets the level for 'com.example.app' to DEBUG. + com.example: DEBUG + + appenders: + - type: console + threshold: INFO + timeZone: UTC + logFormat: "%-6level [%d{HH:mm:ss.SSS}] [%t] %logger{5} - %X{code} %msg %n" + - type: file + threshold: INFO + logFormat: "%-6level [%d{HH:mm:ss.SSS}] [%t] %logger{5} - %X{code} %msg %n" + currentLogFilename: ./logs/application.log + archivedLogFilenamePattern: ./logs/application-%d{yyyy-MM-dd}-%i.log.gz + archivedFileCount: 7 + timeZone: UTC + diff --git a/zte/sfc-driver/plugin-standalone/src/main/assembly/run.bat b/zte/sfc-driver/plugin-standalone/src/main/assembly/run.bat new file mode 100644 index 0000000..46e88bb --- /dev/null +++ b/zte/sfc-driver/plugin-standalone/src/main/assembly/run.bat @@ -0,0 +1,21 @@ +@REM +@REM Copyright 2016 [ZTE] and others. +@REM +@REM Licensed under the Apache License, Version 2.0 (the "License"); +@REM you may not use this file except in compliance with the License. +@REM You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, software +@REM distributed under the License is distributed on an "AS IS" BASIS, +@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@REM See the License for the specific language governing permissions and +@REM limitations under the License. +@REM + +rem set JAVA_HOME=D:\JDK1.7\jdk\jdk\windows +set port=8789 +set jvm_opts= -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=%port%,server=y,suspend=n + +"%JAVA_HOME%/bin/java" -jar %jvm_opts% sfc-service.jar server conf/console.yml \ No newline at end of file diff --git a/zte/sfc-driver/plugin-standalone/src/main/assembly/run.sh b/zte/sfc-driver/plugin-standalone/src/main/assembly/run.sh new file mode 100644 index 0000000..ae8318a --- /dev/null +++ b/zte/sfc-driver/plugin-standalone/src/main/assembly/run.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# +# Copyright 2016 ZTE 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. +# +# Author: Zhang Zhou +# email: zhang.zhou1@zte.com.cn +# + +#JAVA_HOME="/home/conductortest/jdk1.7/jdk/linux" + +DIRNAME=`dirname $0` +RUNHOME=`cd $DIRNAME/; pwd` +echo @RUNHOME@ $RUNHOME + +#JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::") +echo @JAVA_HOME@ $JAVA_HOME +JAVA="$JAVA_HOME/bin/java" +echo @JAVA@ $JAVA +JAVA_VERSION=`$JAVA -version 2>&1 |awk 'NR==1{ sub(/"/,""); print substr($3,1,3)}'` +echo @JAVA_VERSION@ $JAVA_VERSION +if [ $JAVA_VERSION = "1.8" ] +then + JAVA_OPTS="-Xms16m -Xmx128m -XX:+UseSerialGC -XX:MaxMetaspaceSize=64m -XX:NewRatio=2" +else + JAVA_OPTS="-Xms16m -Xmx128m -XX:+UseSerialGC -XX:MaxPermSize=64m -XX:NewRatio=2" +fi +port=8779 +#JAVA_OPTS="$JAVA_OPTS -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=$port,server=y,suspend=n" +echo @JAVA_OPTS@ $JAVA_OPTS + +class_path="$RUNHOME/:$RUNHOME/sfc-service.jar" +echo @class_path@ $class_path + +"$JAVA" $JAVA_OPTS -classpath "$class_path" org.openo.sfc.SfcDriver server "$RUNHOME/conf/console.yml" + + diff --git a/zte/sfc-driver/plugin-standalone/src/main/assembly/stop.sh b/zte/sfc-driver/plugin-standalone/src/main/assembly/stop.sh new file mode 100644 index 0000000..693c429 --- /dev/null +++ b/zte/sfc-driver/plugin-standalone/src/main/assembly/stop.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# +# Copyright 2016 ZTE 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. +# +# Author: Zhang Zhou +# email: zhang.zhou1@zte.com.cn +# + +DIRNAME=`dirname $0` +HOME=`cd $DIRNAME/; pwd` +SFC_Main_Class="sfc-service.jar" + +echo ================== sfc info ============================================= +echo HOME=$HOME +echo SFC_Main_Class=$SFC_Main_Class +echo =============================================================================== +cd $HOME; pwd + +echo @WORK_DIR@ $HOME + +function save_sfc_pid(){ + sfc_id=`ps -ef | grep $SFC_Main_Class | grep $HOME | grep -v grep | awk '{print $2}'` + echo $sfc_id +} + +function kill_apiroute_process(){ + ps -p $sfc_id + if [ $? == 0 ]; then + kill -9 $sfc_id + fi +} + +save_sfc_pid; +echo @C_CMD@ kill -9 $sfc_id +kill_apiroute_process; \ No newline at end of file diff --git a/zte/sfc-driver/pom.xml b/zte/sfc-driver/pom.xml new file mode 100644 index 0000000..dac74d1 --- /dev/null +++ b/zte/sfc-driver/pom.xml @@ -0,0 +1,37 @@ + + + + + org.openo.nfvo + nfvo-root + 1.1.0-SNAPSHOT + ../../../../pom.xml + + 4.0.0 + org.openo.nfvo.sfc-driver-parent + sfc-driver-parent + 1.1.0-SNAPSHOT + nfvo/drivers/sdnc/zte/sfc-driver + pom + + sfc-driver + plugin-standalone + + + diff --git a/zte/sfc-driver/sfc-driver-parent.iml b/zte/sfc-driver/sfc-driver-parent.iml new file mode 100644 index 0000000..64ee2d1 --- /dev/null +++ b/zte/sfc-driver/sfc-driver-parent.iml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + diff --git a/zte/sfc-driver/sfc-driver/dependency-reduced-pom.xml b/zte/sfc-driver/sfc-driver/dependency-reduced-pom.xml new file mode 100644 index 0000000..3facf6f --- /dev/null +++ b/zte/sfc-driver/sfc-driver/dependency-reduced-pom.xml @@ -0,0 +1,159 @@ + + + + + + + sfc-driver-parent + com.zte.ums.sfc.components.sfc-driver + 1.15.10.B2-SNAPSHOT + + 4.0.0 + com.zte.ums.sfc.components.sfc-driver + sfc-driver + sdno/20.components/sfc-driver + 1.15.10.B2-SNAPSHOT + + + + maven-jar-plugin + 2.4 + + + + true + + + + + + maven-shade-plugin + 2.3 + + + package + + shade + + + + + + com.zte.ums.sfc.console.SfcApp + + + + + + + true + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + maven-dependency-plugin + + + copy-dependencies + package + + copy-dependencies + + + + + io.dropwizard + dropwizard-core + ${dropwizard.version} + true + + + + + + + + + + + + org.glassfish.jersey.media + jersey-media-multipart + ${jersey.version} + + + org.glassfish.jersey.containers + jersey-container-servlet-core + ${jersey.version} + + + org.glassfish.jersey.containers + jersey-container-servlet + 2.16 + + + org.glassfish.jersey.core + jersey-client + 2.16 + + + org.glassfish.jersey.core + jersey-common + 2.16 + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + ${jackson-version} + + + org.codehaus.jackson + jackson-jaxrs + 1.9.11 + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson-version} + + + com.google.code.gson + gson + 2.2.4 + + + + + 0.8.0 + 1.5.3 + 2.16 + 9.2.9.v20150224 + 2.5.1 + + + diff --git a/zte/sfc-driver/sfc-driver/pom.xml b/zte/sfc-driver/sfc-driver/pom.xml new file mode 100644 index 0000000..6be12f3 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/pom.xml @@ -0,0 +1,194 @@ + + + + + org.openo.nfvo.sfc-driver-parent + sfc-driver-parent + 1.1.0-SNAPSHOT + + 4.0.0 + org.openo.nfvo.sfc-driver + sfc-driver + nfvo/drivers/sdnc/zte/sfc-driver/sfc-driver + jar + 1.1.0-SNAPSHOT + + 0.8.0 + 9.2.9.v20150224 + 2.5.1 + 2.16 + 1.5.3 + + + + + + + org.glassfish.jersey.media + jersey-media-multipart + ${jersey.version} + + + + org.glassfish.jersey.containers + jersey-container-servlet-core + ${jersey.version} + + + + org.glassfish.jersey.containers + jersey-container-servlet + 2.16 + + + org.glassfish.jersey.core + jersey-client + 2.16 + + + org.glassfish.jersey.core + jersey-common + 2.16 + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + ${jackson-version} + + + + org.codehaus.jackson + jackson-jaxrs + 1.9.11 + + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson-version} + + + + + + + + io.dropwizard + dropwizard-core + ${dropwizard.version} + + + io.dropwizard + dropwizard-assets + ${dropwizard.version} + + + io.swagger + swagger-jersey2-jaxrs + ${swagger.version} + compile + + + com.eclipsesource.jaxrs + consumer + 2.3 + + + + com.google.code.gson + gson + 2.2.4 + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + true + + + + + + org.apache.maven.plugins + maven-shade-plugin + 2.3 + + true + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + package + + shade + + + + + + com.zte.ums.sfc.console.sfcDriver + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + package + + copy-dependencies + + + + + io.dropwizard + dropwizard-core + ${dropwizard.version} + true + + + + + + + + + diff --git a/zte/sfc-driver/sfc-driver/sfc-driver.iml b/zte/sfc-driver/sfc-driver/sfc-driver.iml new file mode 100644 index 0000000..86337b5 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/sfc-driver.iml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/SfcDriver.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/SfcDriver.java new file mode 100644 index 0000000..be0e025 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/SfcDriver.java @@ -0,0 +1,94 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc; + +import com.fasterxml.jackson.annotation.JsonInclude; +import io.dropwizard.Application; +import io.dropwizard.assets.AssetsBundle; +import io.dropwizard.server.SimpleServerFactory; +import io.dropwizard.setup.Bootstrap; +import io.dropwizard.setup.Environment; +import io.swagger.jaxrs.config.BeanConfig; +import io.swagger.jaxrs.listing.ApiListingResource; +import org.openo.sfc.health.ConsoleHealthCheck; +import org.openo.sfc.resources.DriverResource; +import org.openo.sfc.service.ConfigInfo; +import org.openo.sfc.resources.MsbServiceRegister; +import org.openo.sfc.utils.SfcConst; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SfcDriver extends Application { + + private static final Logger LOGGER = LoggerFactory.getLogger(SfcDriver.class); + + public static void main(String[] args) throws Exception { + new SfcDriver().run(args); + } + + @Override + public String getName() { + return SfcConst.SERVICE_NAME; + } + + @Override + public void initialize(Bootstrap bootstrap) { + bootstrap.addBundle(new AssetsBundle("/iui", "/", "index.html", "iui")); + bootstrap.addBundle(new AssetsBundle("/api-doc", "/api-doc", "index.html", "api-doc")); + } + + @Override + public void run(SfcDriverConfig configuration, + Environment environment) { + final DriverResource driverResource = new DriverResource(); + final ConsoleHealthCheck healthCheck = + new ConsoleHealthCheck(configuration.getTemplate()); + environment.healthChecks().register("template", healthCheck); + environment.jersey().register(driverResource); + ConfigInfo.setConfig(configuration); + + registerService(); + initSwaggerConfig(environment, configuration); + } + + + private void initSwaggerConfig(Environment environment, SfcDriverConfig configuration) { + environment.jersey().register(new ApiListingResource()); + environment.getObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL); + + BeanConfig config = new BeanConfig(); + config.setTitle(" Console Service rest API"); + config.setVersion("1.0.0"); + config.setResourcePackage("org.openo.sfc.resources"); + //swagger rest api basepath + SimpleServerFactory simpleServerFactory = (SimpleServerFactory) configuration.getServerFactory(); + String basePath = simpleServerFactory.getApplicationContextPath(); + + basePath = basePath.endsWith("/") ? basePath : (new StringBuilder()).append(basePath).append('/').toString(); + basePath = basePath + "service"; + LOGGER.info("getApplicationContextPath: " + basePath); + config.setBasePath(basePath); + config.setScan(true); + } + + private void registerService() + { + Thread msbRegisterThread = new Thread(new MsbServiceRegister()); + msbRegisterThread.setName("Register Service 2 MSB"); + msbRegisterThread.start(); + } + +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/SfcDriverConfig.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/SfcDriverConfig.java new file mode 100644 index 0000000..6c03cfd --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/SfcDriverConfig.java @@ -0,0 +1,61 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.dropwizard.Configuration; +import org.hibernate.validator.constraints.NotEmpty; + + +public class SfcDriverConfig extends Configuration { + @NotEmpty + private String template; + + @NotEmpty + private String defaultName = "Stranger"; + + @NotEmpty + private String msbServiceUrl; + + @JsonProperty + public String getTemplate() { + return template; + } + + @JsonProperty + public void setTemplate(String template) { + this.template = template; + } + + @JsonProperty + public String getDefaultName() { + return defaultName; + } + @JsonProperty + public void setDefaultName(String name) { + this.defaultName = name; + } + + public String getMsbServiceUrl() { + return msbServiceUrl; + } + + public void setMsbServiceUrl(String msbServiceUrl) { + this.msbServiceUrl = msbServiceUrl; + } + +} \ No newline at end of file diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/ChainParameter.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/ChainParameter.java new file mode 100644 index 0000000..d145695 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/ChainParameter.java @@ -0,0 +1,43 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.entity; + +import com.google.gson.annotations.SerializedName; + +public class ChainParameter { + @SerializedName("chain-parameter") + private String chainParameter; + @SerializedName("chain-parameter-value") + private String chainParamValue; + + public String getChainParameter() { + return chainParameter; + } + + public void setChainParameter(String chainParameter) { + this.chainParameter = chainParameter; + } + + public String getChainParamValue() { + return chainParamValue; + } + + public void setChainParamValue(String chainParamValue) { + this.chainParamValue = chainParamValue; + } + + +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/DelReqInfo.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/DelReqInfo.java new file mode 100644 index 0000000..e3fd40b --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/DelReqInfo.java @@ -0,0 +1,46 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.entity; + +public class DelReqInfo { + private String sdnControllerId; + private String url; + private String id; + + public String getSdnControllerId() { + return sdnControllerId; + } + + public void setSdnControllerId(String sdnControllerId) { + this.sdnControllerId = sdnControllerId; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/FlowClassfierReq.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/FlowClassfierReq.java new file mode 100644 index 0000000..19b91e7 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/FlowClassfierReq.java @@ -0,0 +1,110 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.entity; + +import com.google.gson.annotations.SerializedName; + +public class FlowClassfierReq { + private String protocol; + @SerializedName("source-port-range-min") + private int sourcePortRangeMin; + @SerializedName("source-port-range-max") + private int sourcePortRangeMax; + @SerializedName("destination-port-range-min") + private int destinationPortRangeMin; + @SerializedName("destination-port-range-max") + private int destinationPortRangeMax; + @SerializedName("source-ip-range") + private String sourceIpRange; + @SerializedName("destination-ip-range") + private String destinationIpRange; + @SerializedName("ip-dscp") + private long ipDscp; + private String uuid; + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public long getIpDscp() { + return ipDscp; + } + + public void setIpDscp(long ipDscp) { + this.ipDscp = ipDscp; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public int getSourcePortRangeMin() { + return sourcePortRangeMin; + } + + public void setSourcePortRangeMin(int sourcePortRangeMin) { + this.sourcePortRangeMin = sourcePortRangeMin; + } + + public int getSourcePortRangeMax() { + return sourcePortRangeMax; + } + + public void setSourcePortRangeMax(int sourcePortRangeMax) { + this.sourcePortRangeMax = sourcePortRangeMax; + } + + public int getDestinationPortRangeMin() { + return destinationPortRangeMin; + } + + public void setDestinationPortRangeMin(int destinationPortRangeMin) { + this.destinationPortRangeMin = destinationPortRangeMin; + } + + public int getDestinationPortRangeMax() { + return destinationPortRangeMax; + } + + public void setDestinationPortRangeMax(int destinationPortRangeMax) { + this.destinationPortRangeMax = destinationPortRangeMax; + } + + + public String getSrcIpRange() { + return sourceIpRange; + } + + public void setSrcIpRange(String srcIpRange) { + this.sourceIpRange = srcIpRange; + } + + public String getDestinationIpRange() { + return destinationIpRange; + } + + public void setDestinationIpRange(String destinationIpRange) { + this.destinationIpRange = destinationIpRange; + } +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/FlowClassfierReq4N.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/FlowClassfierReq4N.java new file mode 100644 index 0000000..3eb1853 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/FlowClassfierReq4N.java @@ -0,0 +1,109 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.entity; + +public class FlowClassfierReq4N { + private String url; + private String sdnControllerId; + private String name; + private String description; + private int dscp; + private String ip_proto; + private String source_port_range; + private String dest_port_range; + private String source_ip_range; + private String dest_ip_range; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getSdnControllerId() { + return sdnControllerId; + } + + public void setSdnControllerId(String sdnControllerId) { + this.sdnControllerId = sdnControllerId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getDscp() { + return dscp; + } + + public void setDscp(int dscp) { + this.dscp = dscp; + } + + public String getIp_proto() { + return ip_proto; + } + + public void setIp_proto(String ip_proto) { + this.ip_proto = ip_proto; + } + + public String getSource_port_range() { + return source_port_range; + } + + public void setSource_port_range(String source_port_range) { + this.source_port_range = source_port_range; + } + + public String getDest_port_range() { + return dest_port_range; + } + + public void setDest_port_range(String dest_port_range) { + this.dest_port_range = dest_port_range; + } + + public String getSource_ip_range() { + return source_ip_range; + } + + public void setSource_ip_range(String source_ip_range) { + this.source_ip_range = source_ip_range; + } + + public String getDest_ip_range() { + return dest_ip_range; + } + + public void setDest_ip_range(String dest_ip_range) { + this.dest_ip_range = dest_ip_range; + } +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/FlowClassifierReq4S.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/FlowClassifierReq4S.java new file mode 100644 index 0000000..b0b91e1 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/FlowClassifierReq4S.java @@ -0,0 +1,35 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.entity; + +import com.google.gson.annotations.SerializedName; + +import java.util.ArrayList; + +public class FlowClassifierReq4S { + public ArrayList getSfcFlowClassifier() { + return sfcFlowClassifier; + } + + public void setSfcFlowClassifier(ArrayList sfcFlowClassifier) { + this.sfcFlowClassifier = sfcFlowClassifier; + } + + @SerializedName("sfc-flow-classifier") + ArrayList sfcFlowClassifier; + + +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/MsbRegisterEntity.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/MsbRegisterEntity.java new file mode 100644 index 0000000..b22b2c2 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/MsbRegisterEntity.java @@ -0,0 +1,78 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.entity; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import java.util.ArrayList; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class MsbRegisterEntity { + private String serviceName; + private String version; + private String url; + private String protocol; + private String visualRange; + private ArrayList nodes; + + public String getServiceName() { + return serviceName; + } + + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getVisualRange() { + return visualRange; + } + + public void setVisualRange(String visualRange) { + this.visualRange = visualRange; + } + + public ArrayList getNodes() { + return nodes; + } + + public void setNodes(ArrayList nodes) { + this.nodes = nodes; + } +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/NodeEntity.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/NodeEntity.java new file mode 100644 index 0000000..80c6700 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/NodeEntity.java @@ -0,0 +1,49 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.entity; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class NodeEntity { + private String ip; + private String port; + private String ttl; + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public String getPort() { + return port; + } + + public void setPort(String port) { + this.port = port; + } + + public String getTtl() { + return ttl; + } + + public void setTtl(String ttl) { + this.ttl = ttl; + } +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortChainReq.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortChainReq.java new file mode 100644 index 0000000..62e975d --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortChainReq.java @@ -0,0 +1,67 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.entity; + +import com.google.gson.annotations.SerializedName; + +import java.util.ArrayList; +import java.util.Map; + +public class PortChainReq { + @SerializedName("port-pair-groups") + private ArrayList portPairGroups; + @SerializedName("flow-classifiers") + private ArrayList flowClassifiers; + private String uuid; + @SerializedName("chain-parameters") + private ArrayList chainParams; + + + public ArrayList getChainParams() { + return chainParams; + } + + public void setChainParams(ArrayList chainParams) { + this.chainParams = chainParams; + } + + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + private Map chainParameters; + + public ArrayList getPortPairGroups() { + return portPairGroups; + } + + public void setPortPairGroups(ArrayList portPairGroups) { + this.portPairGroups = portPairGroups; + } + + public ArrayList getFlowClassifiers() { + return flowClassifiers; + } + + public void setFlowClassifiers(ArrayList flowClassifiers) { + this.flowClassifiers = flowClassifiers; + } +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortChainReq4N.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortChainReq4N.java new file mode 100644 index 0000000..f05a4c8 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortChainReq4N.java @@ -0,0 +1,84 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.entity; + +import java.util.ArrayList; + +public class PortChainReq4N { + private String sdnControllerId; + private String url; + private String name; + private String description; + private ArrayList flowClassifiers; + private ArrayList portPairGroups; + private boolean symmetric; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getSdnControllerId() { + return sdnControllerId; + } + + public void setSdnControllerId(String sdnControllerId) { + this.sdnControllerId = sdnControllerId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public ArrayList getFlowClassifiers() { + return flowClassifiers; + } + + public void setFlowClassifiers(ArrayList flowClassifiers) { + this.flowClassifiers = flowClassifiers; + } + + public ArrayList getPortPairGroups() { + return portPairGroups; + } + + public void setPortPairGroups(ArrayList portPairGroups) { + this.portPairGroups = portPairGroups; + } + + public boolean isSymmetric() { + return symmetric; + } + + public void setSymmetric(boolean symmetric) { + this.symmetric = symmetric; + } +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortChainReq4S.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortChainReq4S.java new file mode 100644 index 0000000..0a404f0 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortChainReq4S.java @@ -0,0 +1,34 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.entity; + +import com.google.gson.annotations.SerializedName; + +import java.util.ArrayList; + +public class PortChainReq4S { + + public ArrayList getPortChainReqs() { + return portChainReqs; + } + + public void setPortChainReqs(ArrayList portChainReqs) { + this.portChainReqs = portChainReqs; + } + + @SerializedName("port-chain") + ArrayList portChainReqs; +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortPairGroupReq.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortPairGroupReq.java new file mode 100644 index 0000000..b512ccd --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortPairGroupReq.java @@ -0,0 +1,44 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.entity; + +import com.google.gson.annotations.SerializedName; + +import java.util.List; + + +public class PortPairGroupReq { + private String uuid; + @SerializedName("port-pairs") + List portPairs; + + public List getPortPairs() { + return portPairs; + } + + public void setPortPairs(List portPairs) { + this.portPairs = portPairs; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortPairGroupReq4N.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortPairGroupReq4N.java new file mode 100644 index 0000000..80dbf5d --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortPairGroupReq4N.java @@ -0,0 +1,68 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.entity; + +import java.util.List; + + +public class PortPairGroupReq4N { + String sdnControllerId; + String url; + String name; + String description; + List portPairs; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public String getSdnControllerId() { + return sdnControllerId; + } + + public void setSdnControllerId(String sdnControllerId) { + this.sdnControllerId = sdnControllerId; + } + + public void setDescription(String description) { + this.description = description; + } + + public List getPortPairs() { + return portPairs; + } + + public void setPortPairs(List portPairs) { + this.portPairs = portPairs; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortPairGroupReq4S.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortPairGroupReq4S.java new file mode 100644 index 0000000..3a9bc8e --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/PortPairGroupReq4S.java @@ -0,0 +1,33 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.entity; + +import com.google.gson.annotations.SerializedName; + +import java.util.ArrayList; + +public class PortPairGroupReq4S { + public ArrayList getPortPairGroupReqs() { + return portPairGroupReqs; + } + + public void setPortPairGroupReqs(ArrayList portPairGroupReqs) { + this.portPairGroupReqs = portPairGroupReqs; + } + + @SerializedName("port-pair-group") + ArrayList portPairGroupReqs; +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/Result.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/Result.java new file mode 100644 index 0000000..e124606 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/Result.java @@ -0,0 +1,32 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.entity; + +public class Result { + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + private String id; + + public Result(String uuid) { + this.id = uuid; + } +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/SdnControllerInfo.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/SdnControllerInfo.java new file mode 100644 index 0000000..9386f7f --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/SdnControllerInfo.java @@ -0,0 +1,47 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.entity; + +public class SdnControllerInfo { + String url; + String userName; + String password; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/portpair/PortInfo.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/portpair/PortInfo.java new file mode 100644 index 0000000..e77a437 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/portpair/PortInfo.java @@ -0,0 +1,61 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.entity.portpair; + + +import com.google.gson.annotations.SerializedName; + +public class PortInfo { + private String encapsulation; + private String ip; + private String mac; + @SerializedName("port-name") + private String portName; + + public String getEncapsulation() { + return encapsulation; + } + + + public String getPortName() { + return portName; + } + + public void setPortName(String portName) { + this.portName = portName; + } + + public void setEncapsulation(String encapsulation) { + this.encapsulation = encapsulation; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public String getMac() { + return mac; + } + + public void setMac(String mac) { + this.mac = mac; + } +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/portpair/PortPairReq.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/portpair/PortPairReq.java new file mode 100644 index 0000000..c10a7f3 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/portpair/PortPairReq.java @@ -0,0 +1,63 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.entity.portpair; + +import com.google.gson.annotations.SerializedName; + +import java.util.ArrayList; + + +public class PortPairReq { + private String uuid; + private PortInfo ingress; + private PortInfo egress; + @SerializedName("service-function-parameters") + private ArrayList serviceFunctionParameters; + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public ArrayList getServiceFunctionParameters() { + return serviceFunctionParameters; + } + + public void setServiceFunctionParameters(ArrayList serviceFunctionParameters) { + this.serviceFunctionParameters = serviceFunctionParameters; + } + + public PortInfo getIngress() { + return ingress; + } + + public void setIngress(PortInfo ingress) { + this.ingress = ingress; + } + + public PortInfo getEgress() { + return egress; + } + + public void setEgress(PortInfo egress) { + this.egress = egress; + } + + +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/portpair/PortPairReq4N.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/portpair/PortPairReq4N.java new file mode 100644 index 0000000..1c8769b --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/portpair/PortPairReq4N.java @@ -0,0 +1,112 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.entity.portpair; + +import java.util.Map; + + +public class PortPairReq4N { + private String sdnControllerId; + private String url; + private String name; + private String description; + private String sfType; + private boolean nshAware; + private boolean requestReclassification; + private PortInfo ingress; + private PortInfo egress; + private Map sfParam; + + public String getSdnControllerId() { + return sdnControllerId; + } + + public void setSdnControllerId(String sdnControllerId) { + this.sdnControllerId = sdnControllerId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getSfType() { + return sfType; + } + + public void setSfType(String sfType) { + this.sfType = sfType; + } + + public boolean isNshAware() { + return nshAware; + } + + public void setNshAware(boolean nshAware) { + this.nshAware = nshAware; + } + + public boolean isRequestReclassification() { + return requestReclassification; + } + + public void setRequestReclassification(boolean requestReclassification) { + this.requestReclassification = requestReclassification; + } + + public PortInfo getIngress() { + return ingress; + } + + public void setIngress(PortInfo ingress) { + this.ingress = ingress; + } + + public PortInfo getEgress() { + return egress; + } + + public void setEgress(PortInfo egress) { + this.egress = egress; + } + + public Map getSfParam() { + return sfParam; + } + + public void setSfParam(Map sfParam) { + this.sfParam = sfParam; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/portpair/PortPairReq4S.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/portpair/PortPairReq4S.java new file mode 100644 index 0000000..4403c92 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/portpair/PortPairReq4S.java @@ -0,0 +1,34 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.entity.portpair; + +import com.google.gson.annotations.SerializedName; + +import java.util.ArrayList; + +public class PortPairReq4S { + public ArrayList getPortPair() { + return portPair; + } + + public void setPortPair(ArrayList portPair) { + this.portPair = portPair; + } + + @SerializedName("port-pair") + ArrayList portPair; + +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/portpair/ServiceFunctionParameter.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/portpair/ServiceFunctionParameter.java new file mode 100644 index 0000000..444f8a7 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/entity/portpair/ServiceFunctionParameter.java @@ -0,0 +1,41 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.entity.portpair; + +import com.google.gson.annotations.SerializedName; + +public class ServiceFunctionParameter { + @SerializedName("service-function-parameter") + private String serviceFunctionParamter; + @SerializedName("service-function-parameter-value") + private String getServiceFunctionParamterValue; + + public String getServiceFunctionParamter() { + return serviceFunctionParamter; + } + + public void setServiceFunctionParamter(String serviceFunctionParamter) { + this.serviceFunctionParamter = serviceFunctionParamter; + } + + public String getGetServiceFunctionParamterValue() { + return getServiceFunctionParamterValue; + } + + public void setGetServiceFunctionParamterValue(String getServiceFunctionParamterValue) { + this.getServiceFunctionParamterValue = getServiceFunctionParamterValue; + } +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/health/ConsoleHealthCheck.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/health/ConsoleHealthCheck.java new file mode 100644 index 0000000..aee8468 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/health/ConsoleHealthCheck.java @@ -0,0 +1,35 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.health; + +import com.codahale.metrics.health.HealthCheck; + +public class ConsoleHealthCheck extends HealthCheck { + private final String template; + + public ConsoleHealthCheck(String template) { + this.template = template; + } + + @Override + protected Result check() throws Exception { + final String saying = String.format(template, "TEST"); + if (!saying.contains("TEST")) { + return Result.unhealthy("template doesn't include a name"); + } + return Result.healthy(); + } +} \ No newline at end of file diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/resources/DriverResource.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/resources/DriverResource.java new file mode 100644 index 0000000..8c402f7 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/resources/DriverResource.java @@ -0,0 +1,214 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.resources; + +import com.codahale.metrics.annotation.Timed; +import org.openo.sfc.entity.DelReqInfo; +import org.openo.sfc.entity.FlowClassfierReq4N; +import org.openo.sfc.entity.FlowClassifierReq4S; +import org.openo.sfc.entity.PortChainReq4N; +import org.openo.sfc.entity.PortChainReq4S; +import org.openo.sfc.entity.PortPairGroupReq4N; +import org.openo.sfc.entity.PortPairGroupReq4S; +import org.openo.sfc.entity.Result; +import org.openo.sfc.entity.portpair.PortPairReq4N; +import org.openo.sfc.entity.portpair.PortPairReq4S; +import org.openo.sfc.service.SdnServiceConsumer; +import org.openo.sfc.utils.SfcDriverUtil; +import org.openo.sfc.wrapper.N2sReqWrapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.ws.rs.DELETE; +import javax.ws.rs.NotFoundException; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Path("/") +public class DriverResource { + private static final Logger LOGGER = LoggerFactory.getLogger(DriverResource.class); +// +// @POST +// @Path("/checksdncontroller") +// @Produces(MediaType.APPLICATION_JSON) +// @Timed +// public Result checkSdnController(SdnControllerInfo sdnInfo) +// throws Exception { +// if (sdnInfo == null ) { +// throw new NotFoundException("SdnControllerInfo is null"); +// } +// return SdnServiceConsumer.getSdnConProxy(sdnInfo.getUrl()).querySdnController(); +// } + + @POST + @Path("/createportpair") + @Produces(MediaType.APPLICATION_JSON) + @Timed + public Result createPortPair(PortPairReq4N portPairReq4N) + throws Exception { + if (portPairReq4N == null) { + throw new NotFoundException("SdnControllerInfo is null"); + } + LOGGER.info(SfcDriverUtil.toJson(portPairReq4N)); + PortPairReq4S portPairReq = N2sReqWrapper.convertPortPair(portPairReq4N); + String portPairReqJson = SfcDriverUtil.toJson(portPairReq); + LOGGER.info(portPairReqJson); + SdnServiceConsumer.getSdnConProxy(portPairReq4N.getUrl()).createPortPair(SfcDriverUtil.generateAuthorization(), portPairReqJson); +// +// if(rsp.getStatus() == SfcConst.HTTP_POST_OK) +// { +// return new Result(portPairReq.getPortPair().get(0).getUuid()); +// } +// return rsp; + + return new Result(portPairReq.getPortPair().get(0).getUuid()); + } + + @POST + @Path("/createportpairgroup") + @Produces(MediaType.APPLICATION_JSON) + @Timed + public Result createPortPairGroup(PortPairGroupReq4N portPairGroupReq4N) + throws Exception { + if (portPairGroupReq4N == null) { + throw new NotFoundException("SdnControllerInfo is null"); + } + LOGGER.info(SfcDriverUtil.toJson(portPairGroupReq4N)); + PortPairGroupReq4S portPairGroupReq4S = N2sReqWrapper.convertPortPairGroup(portPairGroupReq4N); + String portPairGroupReqJson = SfcDriverUtil.toJson(portPairGroupReq4S); + LOGGER.info(portPairGroupReqJson); + SdnServiceConsumer.getSdnConProxy(portPairGroupReq4N.getUrl()).createPortPairGroup( + SfcDriverUtil.generateAuthorization(), portPairGroupReqJson); +// if(rsp.getStatus() == SfcConst.HTTP_POST_OK) +// { +// return new Result(portPairGroupReq4S.getPortPairGroupReqs().get(0).getUuid()); +// } +// +// return rsp; + + return new Result(portPairGroupReq4S.getPortPairGroupReqs().get(0).getUuid()); + + } + + @POST + @Path("/createflowclassfier") + @Produces(MediaType.APPLICATION_JSON) + @Timed + public Result createFlowClassfier(FlowClassfierReq4N flowClassfierReq4N) + throws Exception { + if (flowClassfierReq4N == null) { + throw new NotFoundException("FlowClassfierReq4N is null"); + } + LOGGER.info(SfcDriverUtil.toJson(flowClassfierReq4N)); + FlowClassifierReq4S flowClassfierReq4S = N2sReqWrapper. + convertFlowClassfier(flowClassfierReq4N); + String uuid = flowClassfierReq4S.getSfcFlowClassifier().get(0).getUuid(); + String flowClassifierJson = SfcDriverUtil.toJson(flowClassfierReq4S); + LOGGER.info(flowClassifierJson); + SdnServiceConsumer.getSdnConProxy(flowClassfierReq4N.getUrl()).createFlowCla(SfcDriverUtil.generateAuthorization(), flowClassifierJson); +// if(rsp.getStatus() == SfcConst.HTTP_POST_OK) +// { +// return new Result(uuid); +// } +// else +// return rsp; + + return new Result(uuid); + } + + @POST + @Path("/createportchain") + @Produces(MediaType.APPLICATION_JSON) + @Timed + public Result creatPortChain(PortChainReq4N portChainReq4N) + throws Exception { + if (portChainReq4N == null) { + throw new NotFoundException("PortChainReq4N is null"); + } + LOGGER.info(SfcDriverUtil.toJson(portChainReq4N)); + PortChainReq4S portChainReq = N2sReqWrapper.converPortChain(portChainReq4N); + String portChainReqJson = SfcDriverUtil.toJson(portChainReq); + LOGGER.info(portChainReqJson); + SdnServiceConsumer.getSdnConProxy(portChainReq4N.getUrl()).createPortChain( + SfcDriverUtil.generateAuthorization(), portChainReqJson); +// if(rsp.getStatus() == SfcConst.HTTP_POST_OK) +// { +// return new Result(portChainReq.getPortChainReqs().get(0).getUuid()); +// } +// return rsp; + + return new Result(portChainReq.getPortChainReqs().get(0).getUuid()); + + } + + @DELETE + @Path("/delportpair") + @Produces(MediaType.APPLICATION_JSON) + @Timed + public void delPortPair(DelReqInfo delReqInfo) + throws Exception { + if (delReqInfo == null) { + throw new NotFoundException("DelReqInfo is null"); + } + LOGGER.info(SfcDriverUtil.toJson(delReqInfo)); + SdnServiceConsumer.getSdnConProxy(delReqInfo.getUrl()).deletePortPair(SfcDriverUtil.generateAuthorization(), delReqInfo.getId()); + + } + + @DELETE + @Path("/delportpairgroup") + @Produces(MediaType.APPLICATION_JSON) + @Timed + public void delPortPairGroup(DelReqInfo delReqInfo) + throws Exception { + if (delReqInfo == null) { + throw new NotFoundException("DelReqInfo is null"); + } + LOGGER.info(SfcDriverUtil.toJson(delReqInfo)); + SdnServiceConsumer.getSdnConProxy(delReqInfo.getUrl()).deletePortPairGroup(SfcDriverUtil.generateAuthorization(), delReqInfo.getId()); + + } + + @DELETE + @Path("/delclassifier") + @Produces(MediaType.APPLICATION_JSON) + @Timed + public void delFlowClassfier(DelReqInfo delReqInfo) + throws Exception { + if (delReqInfo == null) { + throw new NotFoundException("DelReqInfo is null"); + } + LOGGER.info(SfcDriverUtil.toJson(delReqInfo)); + SdnServiceConsumer.getSdnConProxy(delReqInfo.getUrl()).deleteFlowClassifiers(SfcDriverUtil.generateAuthorization(), delReqInfo.getId()); + + } + + @DELETE + @Path("/delchain") + @Produces(MediaType.APPLICATION_JSON) + @Timed + public void delPortChain(DelReqInfo delReqInfo) + throws Exception { + if (delReqInfo == null) { + throw new NotFoundException("DelReqInfo is null"); + } + LOGGER.info(SfcDriverUtil.toJson(delReqInfo)); + SdnServiceConsumer.getSdnConProxy(delReqInfo.getUrl()).deletePortChain(SfcDriverUtil.generateAuthorization(), delReqInfo.getId()); + + } +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/resources/MsbServiceRegister.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/resources/MsbServiceRegister.java new file mode 100644 index 0000000..a2a0527 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/resources/MsbServiceRegister.java @@ -0,0 +1,72 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.resources; + +import com.google.gson.Gson; +import org.openo.sfc.entity.MsbRegisterEntity; +import org.openo.sfc.service.ConfigInfo; +import org.openo.sfc.service.SdnServiceConsumer; +import org.openo.sfc.utils.SfcDriverUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class MsbServiceRegister implements Runnable { + private final Logger LOGGER = LoggerFactory.getLogger(MsbServiceRegister.class); + MsbRegisterEntity entity; + public MsbServiceRegister() + { + initInfo(); + } + + private void initInfo() + { + entity = SfcDriverUtil.getMsbRegisterInfo(); + + } + + @Override + public void run() { + boolean flag = false; + int retryTimes=0; + while (!flag && retryTimes<20) + { + try { + LOGGER.info("Register Msb start:"); + LOGGER.info(SfcDriverUtil.toJson(entity)); + SdnServiceConsumer.getMsbRegisterService(ConfigInfo.getConfig().getMsbServiceUrl()). + registerServce("false",entity); + LOGGER.info("Register Msb end:"); + flag = true; + break; + } catch (Exception e) { + LOGGER.info("Register Msb failed"); + e.printStackTrace(); + threadSleep(30000); + } + } + + } + + private void threadSleep(int second) { + LOGGER.info("start sleep ...."); + try { + Thread.sleep(second); + } catch (InterruptedException error) { + LOGGER.error("thread sleep error.errorMsg:" + error.getMessage()); + } + LOGGER.info("sleep end ."); + } +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/service/ConfigInfo.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/service/ConfigInfo.java new file mode 100644 index 0000000..9227dc2 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/service/ConfigInfo.java @@ -0,0 +1,30 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.service; + +import org.openo.sfc.SfcDriverConfig; + +public class ConfigInfo { + public static SfcDriverConfig getConfig() { + return config; + } + + public static void setConfig(SfcDriverConfig sfcDriverConfig) { + config = sfcDriverConfig; + } + + private static SfcDriverConfig config; +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/service/ISdnControllerService.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/service/ISdnControllerService.java new file mode 100644 index 0000000..376d28d --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/service/ISdnControllerService.java @@ -0,0 +1,87 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.service; + +import org.openo.sfc.entity.Result; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + + +@Path("/restconf/config/neutron:neutron") +public interface ISdnControllerService { + + @Path("/") + @GET + @Produces(MediaType.APPLICATION_JSON) + public Result querySdnController() throws Exception; + + @Path("/port-pairs") + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public Response createPortPair(@HeaderParam("Authorization") String authorization, String portPairReq4S) throws Exception; + + @Path("/port-pair-groups") + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public Response createPortPairGroup(@HeaderParam("Authorization") String authorization, String ppg4S) throws Exception; + + @Path("/sfc-flow-classifiers") + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public Response createFlowCla(@HeaderParam("Authorization") String authorization, String flowClassfierReq) throws Exception; + + + @Path("/port-chains") + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public Response createPortChain(@HeaderParam("Authorization") String authorization, String portChainReq4S) throws Exception; + + @Path("/port-pairs/port-pair/{id}") + @DELETE + @Produces(MediaType.APPLICATION_JSON) + public Response deletePortPair(@HeaderParam("Authorization") String authorization, @PathParam("id") String id) throws Exception; + + + @Path("/port-pair-groups/port-pair-group/{id}") + @DELETE + @Produces(MediaType.APPLICATION_JSON) + public Response deletePortPairGroup(@HeaderParam("Authorization") String authorization, @PathParam("id") String uuid) throws Exception; + + @Path("/sfc-flow-classifiers/sfc-flow-classifier/{id}") + @DELETE + @Produces(MediaType.APPLICATION_JSON) + public Response deleteFlowClassifiers(@HeaderParam("Authorization") String authorization, @PathParam("id") String id) throws Exception; + + @Path("/port-chains/port-chain/{id}") + @DELETE + @Produces(MediaType.APPLICATION_JSON) + public Response deletePortChain(@HeaderParam("Authorization") String authorization, @PathParam("id") String id) throws Exception; + +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/service/MsbService.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/service/MsbService.java new file mode 100644 index 0000000..3734256 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/service/MsbService.java @@ -0,0 +1,35 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.service; + +import org.openo.sfc.entity.MsbRegisterEntity; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +@Path("/openoapi/microservices/v1/services") +public interface MsbService { + @Path("") + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public MsbRegisterEntity registerServce(@QueryParam("createOrUpdate") String createOrUpdate, + MsbRegisterEntity entity)throws Exception; +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/service/SdnServiceConsumer.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/service/SdnServiceConsumer.java new file mode 100644 index 0000000..18460b2 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/service/SdnServiceConsumer.java @@ -0,0 +1,38 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.service; + +import com.eclipsesource.jaxrs.consumer.ConsumerFactory; +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; +import org.glassfish.jersey.client.ClientConfig; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class SdnServiceConsumer { + private static final Logger logger = LoggerFactory.getLogger(SdnServiceConsumer.class.getName()); + + public static ISdnControllerService getSdnConProxy(String url) throws Exception { + return ConsumerFactory.createConsumer(url, new ClientConfig().register(JacksonJsonProvider.class), + ISdnControllerService.class); + } + + public static MsbService getMsbRegisterService(String url) throws Exception { + return ConsumerFactory.createConsumer(url, new ClientConfig().register(JacksonJsonProvider.class), + MsbService.class); + } +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/utils/SfcConst.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/utils/SfcConst.java new file mode 100644 index 0000000..ee361be --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/utils/SfcConst.java @@ -0,0 +1,24 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.utils; + +public interface SfcConst { + public static final int HTTP_OK = 200; + public static final int HTTP_POST_OK = 204; + public static final String SERVICE_NAME = "ztesdncdriver"; + public static final String SERVICE_URL="/openoapi/ztesdncdriver/v1"; + +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/utils/SfcDriverUtil.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/utils/SfcDriverUtil.java new file mode 100644 index 0000000..38891f7 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/utils/SfcDriverUtil.java @@ -0,0 +1,105 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.utils; + +import com.google.gson.Gson; +import org.openo.sfc.entity.ChainParameter; +import org.openo.sfc.entity.MsbRegisterEntity; +import org.openo.sfc.entity.NodeEntity; +import org.openo.sfc.entity.portpair.ServiceFunctionParameter; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + +public class SfcDriverUtil { + + public static String generateUuid() { + return UUID.randomUUID().toString(); + + } + + public static ArrayList generateSfParams(Map sfHashParams) { + ArrayList serviceParameters = new ArrayList(); + if (sfHashParams != null) { + //serviceParameters.putAll(portPairReq4N.getSfParam()); + Set keySet = sfHashParams.keySet(); + Iterator iter = keySet.iterator(); + while (iter.hasNext()) { + String keyName = iter.next().toString(); + ServiceFunctionParameter sfParam = new ServiceFunctionParameter(); + sfParam.setServiceFunctionParamter(keyName); + sfParam.setGetServiceFunctionParamterValue(sfHashParams.get(keyName).toString()); + serviceParameters.add(sfParam); + } + } + return serviceParameters; + } + + public static ChainParameter generateChainParam(String key, String value) { + ChainParameter cp = new ChainParameter(); + cp.setChainParameter(key); + cp.setChainParamValue(value); + return cp; + } + + public static String toJson(Object obj) { + Gson gson = new Gson(); + return gson.toJson(obj); + } + + public static String generateAuthorization() { + String userName = "admin"; + String password = "admin"; + String usernameAndPassword = userName + ":" + password; +// String headName = "Authorization"; + return "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(usernameAndPassword.getBytes()); + } + + public static MsbRegisterEntity getMsbRegisterInfo() { + MsbRegisterEntity entity = new MsbRegisterEntity(); + entity.setServiceName(SfcConst.SERVICE_NAME); + entity.setVersion("v1"); + //entity.setUrl(SfcConst.SERVICE_URL); + entity.setUrl("/openoapi/ztesdncdriver/v1"); + entity.setProtocol("REST"); + entity.setVisualRange("1"); + ArrayList nodes = new ArrayList(); + NodeEntity node = new NodeEntity(); + node.setIp(getLocalIp()); + node.setPort("8411"); + node.setTtl("1"); + nodes.add(node); + entity.setNodes(nodes); + return entity; + } + + public static String getLocalIp() + { + try { + InetAddress addr = InetAddress.getLocalHost(); + return addr.getHostAddress().toString(); + } catch (UnknownHostException e) { + e.printStackTrace(); + } + return ""; + } + +} diff --git a/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/wrapper/N2sReqWrapper.java b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/wrapper/N2sReqWrapper.java new file mode 100644 index 0000000..a072192 --- /dev/null +++ b/zte/sfc-driver/sfc-driver/src/main/java/org/openo/sfc/wrapper/N2sReqWrapper.java @@ -0,0 +1,106 @@ +/** + * Copyright 2016 [ZTE] and others. + * + * 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.openo.sfc.wrapper; + +import org.openo.sfc.entity.ChainParameter; +import org.openo.sfc.entity.FlowClassfierReq; +import org.openo.sfc.entity.FlowClassfierReq4N; +import org.openo.sfc.entity.FlowClassifierReq4S; +import org.openo.sfc.entity.PortChainReq; +import org.openo.sfc.entity.PortChainReq4N; +import org.openo.sfc.entity.PortChainReq4S; +import org.openo.sfc.entity.PortPairGroupReq; +import org.openo.sfc.entity.PortPairGroupReq4N; +import org.openo.sfc.entity.PortPairGroupReq4S; +import org.openo.sfc.entity.portpair.PortPairReq; +import org.openo.sfc.entity.portpair.PortPairReq4N; +import org.openo.sfc.entity.portpair.PortPairReq4S; +import org.openo.sfc.entity.portpair.ServiceFunctionParameter; +import org.openo.sfc.utils.SfcDriverUtil; + +import java.util.ArrayList; + + +public class N2sReqWrapper { + public static PortPairReq4S convertPortPair(PortPairReq4N portPairReq4N) { + PortPairReq portPairReq = new PortPairReq(); + portPairReq.setIngress(portPairReq4N.getIngress()); + portPairReq.setEgress(portPairReq4N.getEgress()); + ArrayList serviceFunctionParameters = new ArrayList(); + serviceFunctionParameters.addAll(SfcDriverUtil.generateSfParams(portPairReq4N.getSfParam())); + portPairReq.setServiceFunctionParameters(serviceFunctionParameters); + portPairReq.setUuid(SfcDriverUtil.generateUuid()); + ArrayList portPairList = new ArrayList(); + portPairList.add(portPairReq); + PortPairReq4S portPairReq4S = new PortPairReq4S(); + portPairReq4S.setPortPair(portPairList); + return portPairReq4S; + } + + public static PortPairGroupReq4S convertPortPairGroup(PortPairGroupReq4N ppg4N) { + PortPairGroupReq ppg4S = new PortPairGroupReq(); + ppg4S.setPortPairs(ppg4N.getPortPairs()); + ppg4S.setUuid(SfcDriverUtil.generateUuid()); + PortPairGroupReq4S portPairGroupReq4S = new PortPairGroupReq4S(); + ArrayList portPairGroupReqs = new ArrayList(); + portPairGroupReqs.add(ppg4S); + portPairGroupReq4S.setPortPairGroupReqs(portPairGroupReqs); + + return portPairGroupReq4S; + } + + public static FlowClassifierReq4S convertFlowClassfier(FlowClassfierReq4N flowClassfierReq4N) { + ArrayList flowClassifiers = new ArrayList(); + FlowClassfierReq flowClassfierReq = new FlowClassfierReq(); + flowClassfierReq.setProtocol(flowClassfierReq4N.getIp_proto()); +// flowClassfierReq.setSourcePortRangeMin(Integer.parseInt(flowClassfierReq4N. +// getSource_port_range().split(",")[0])); +// flowClassfierReq.setSourcePortRangeMax(Integer.parseInt(flowClassfierReq4N. +// getSource_port_range().split(",")[1])); +// flowClassfierReq.setDestinationPortRangeMin(Integer.parseInt( +// flowClassfierReq4N.getDest_port_range().split(",")[0])); +// flowClassfierReq.setDestinationPortRangeMax(Integer.parseInt( +// flowClassfierReq4N.getDest_port_range().split(",")[1])); + flowClassfierReq.setDestinationIpRange(flowClassfierReq4N.getDest_ip_range()); + flowClassfierReq.setSrcIpRange(flowClassfierReq4N.getSource_ip_range()); + flowClassfierReq.setIpDscp(flowClassfierReq4N.getDscp()); + flowClassfierReq.setUuid(SfcDriverUtil.generateUuid()); + flowClassifiers.add(flowClassfierReq); + FlowClassifierReq4S flowClassifierReq4S = new FlowClassifierReq4S(); + flowClassifierReq4S.setSfcFlowClassifier(flowClassifiers); + + return flowClassifierReq4S; + } + + public static PortChainReq4S converPortChain(PortChainReq4N portChainReq4N) { + PortChainReq portChainReq = new PortChainReq(); + portChainReq.setPortPairGroups(portChainReq4N.getPortPairGroups()); + portChainReq.setFlowClassifiers(portChainReq4N.getFlowClassifiers()); + portChainReq.setUuid(SfcDriverUtil.generateUuid()); + + ArrayList chainParam = new ArrayList(); + chainParam.add(SfcDriverUtil.generateChainParam("symmetric", portChainReq4N.isSymmetric() ? "true" : "false")); + portChainReq.setChainParams(chainParam); + ArrayList portChains = new ArrayList(); + portChains.add(portChainReq); + PortChainReq4S portChainReq4S = new PortChainReq4S(); + portChainReq4S.setPortChainReqs(portChains); + return portChainReq4S; + } + + +} -- 2.16.6