diff options
author | fujinhua <fu.jinhua@zte.com.cn> | 2017-06-30 14:14:29 +0800 |
---|---|---|
committer | fujinhua <fu.jinhua@zte.com.cn> | 2017-06-30 14:14:29 +0800 |
commit | 6346805afd9fcf4c56966751e41ee959391e8788 (patch) | |
tree | 2b61b0f39ac1784648edb20aa20f31693725dfb8 | |
parent | 19f83964f264666ceb26d55043e3f6cd05087257 (diff) |
Create seed codes of nfvo
Change-Id: I72a426c6be55f8a6a0200f6dedd2486bee067062
Issue-Id: VFC-52
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
43 files changed, 3101 insertions, 0 deletions
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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. + +--> +<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="false"> + <output url="file://$MODULE_DIR$/target/classes" /> + <output-test url="file://$MODULE_DIR$/target/test-classes" /> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <excludeFolder url="file://$MODULE_DIR$/target" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="module" module-name="sfc-driver" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-core:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-util:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.5.0" level="project" /> + <orderEntry type="library" name="Maven: com.google.guava:guava:18.0" level="project" /> + <orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.0" level="project" /> + <orderEntry type="library" name="Maven: joda-time:joda-time:2.7" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-jackson:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.5.1" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.5.1" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk7:2.5.1" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-guava:2.5.1" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-afterburner:2.5.1" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-joda:2.5.1" level="project" /> + <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.10" level="project" /> + <orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.1.2" level="project" /> + <orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.1.2" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-validation:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: org.hibernate:hibernate-validator:5.1.3.Final" level="project" /> + <orderEntry type="library" name="Maven: javax.validation:validation-api:1.1.0.Final" level="project" /> + <orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.1.3.GA" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml:classmate:1.0.0" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish:javax.el:3.0.0" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-configuration:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.5.1" level="project" /> + <orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.12" level="project" /> + <orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.3.2" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-logging:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard.metrics:metrics-logback:3.1.0" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard.metrics:metrics-core:3.1.0" level="project" /> + <orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.10" level="project" /> + <orderEntry type="library" name="Maven: org.slf4j:log4j-over-slf4j:1.7.10" level="project" /> + <orderEntry type="library" name="Maven: org.slf4j:jcl-over-slf4j:1.7.10" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-util:9.2.9.v20150224" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-metrics:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-lifecycle:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-server:9.2.9.v20150224" level="project" /> + <orderEntry type="library" name="Maven: javax.servlet:javax.servlet-api:3.1.0" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-http:9.2.9.v20150224" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-io:9.2.9.v20150224" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-jersey:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.jersey.core:jersey-server:2.16" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.jersey.core:jersey-common:2.6" level="project" /> + <orderEntry type="library" name="Maven: javax.ws.rs:javax.ws.rs-api:2.0" level="project" /> + <orderEntry type="library" name="Maven: javax.annotation:javax.annotation-api:1.2" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.jersey.bundles.repackaged:jersey-guava:2.6" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.hk2:hk2-api:2.2.0" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.hk2:hk2-utils:2.2.0" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.hk2.external:aopalliance-repackaged:2.2.0" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.hk2.external:javax.inject:2.2.0-b10" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.hk2:hk2-locator:2.2.0" level="project" /> + <orderEntry type="library" name="Maven: org.javassist:javassist:3.18.2-GA" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.hk2:osgi-resource-locator:1.0.1" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.jersey.core:jersey-client:2.6" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.jersey.media:jersey-media-jaxb:2.16" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.jersey.ext:jersey-metainf-services:2.16" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard.metrics:metrics-jersey2:3.1.0" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard.metrics:metrics-annotation:3.1.0" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.5.1" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:2.5.1" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.5.1" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.jersey.containers:jersey-container-servlet:2.16" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.jersey.containers:jersey-container-servlet-core:2.1" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-webapp:9.2.9.v20150224" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-xml:9.2.9.v20150224" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-servlet:9.2.9.v20150224" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-security:9.2.9.v20150224" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-continuation:9.2.9.v20150224" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-servlets:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-jetty:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard.metrics:metrics-jetty9:3.1.0" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-servlets:9.2.9.v20150224" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard.metrics:metrics-jvm:3.1.0" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard.metrics:metrics-servlets:3.1.0" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard.metrics:metrics-healthchecks:3.1.0" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard.metrics:metrics-json:3.1.0" level="project" /> + <orderEntry type="library" name="Maven: net.sourceforge.argparse4j:argparse4j:0.4.4" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty.toolchain.setuid:jetty-setuid-java:1.0.2" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-assets:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: io.swagger:swagger-jersey2-jaxrs:1.5.3" level="project" /> + <orderEntry type="library" name="Maven: io.swagger:swagger-jaxrs:1.5.3" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.4.5" level="project" /> + <orderEntry type="library" name="Maven: org.codehaus.woodstox:stax2-api:3.1.4" level="project" /> + <orderEntry type="library" name="Maven: io.swagger:swagger-core:1.5.3" level="project" /> + <orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.3" level="project" /> + <orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.3" level="project" /> + <orderEntry type="library" name="Maven: org.reflections:reflections:0.9.9" level="project" /> + <orderEntry type="library" name="Maven: com.google.code.findbugs:annotations:2.0.1" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.jersey.media:jersey-media-multipart:2.1" level="project" /> + <orderEntry type="library" name="Maven: org.jvnet.mimepull:mimepull:1.8" level="project" /> + <orderEntry type="library" name="Maven: com.eclipsesource.jaxrs:consumer:2.3" level="project" /> + <orderEntry type="library" name="Maven: com.google.code.gson:gson:2.2.4" level="project" /> + </component> +</module> + 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <parent> + <groupId>org.openo.nfvo.sfc-driver-parent</groupId> + <artifactId>sfc-driver-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>org.openo.nfvo.sfc-driver-standalone</groupId> + <artifactId>nfvo-drivers-sdnc-zte-sfc-driver</artifactId> + <name>nfvo/drivers/sdnc/zte/sfc-driver/plugin-standalone</name> + <packaging>pom</packaging> + <version>1.1.0-SNAPSHOT</version> + + <dependencies> + <dependency> + <groupId>org.openo.nfvo.sfc-driver</groupId> + <artifactId>sfc-driver</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + + <properties> + <packagename>sfc-driver</packagename> + </properties> + <build> + + <plugins> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <executions> + <execution> + <id>copy-resources</id> + <phase>process-resources</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <outputDirectory>${basedir}/target/assembly/</outputDirectory> + <resources> + <resource> + <directory>src/main/assembly/</directory> + <filtering>false</filtering> + <includes> + <include>**/*</include> + </includes> + </resource> + + </resources> + <overwrite>true</overwrite> + </configuration> + </execution> + + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <version>2.8</version> + <executions> + <execution> + <id>copy-jar</id> + <goals> + <goal>copy</goal> + </goals> + <phase>prepare-package</phase> + <configuration> + <artifactItems> + <artifactItem> + <groupId>org.openo.nfvo.sfc-driver</groupId> + <artifactId>sfc-driver</artifactId> + <type>jar</type> + <overWrite>true</overWrite> + <outputDirectory>target/assembly/</outputDirectory> + <destFileName>sfc-service.jar</destFileName> + </artifactItem> + </artifactItems> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <executions> + <execution> + <id>zip</id> + <phase>package</phase> + <goals> + <goal>run</goal> + </goals> + <configuration> + <tasks name="${project.artifactId}"> + <zip destfile="target/nfvo-drivers-sdnc-zte-sfc-driver-${project.version}.zip" update="true"> + <zipfileset dir="target/assembly" includes="**"/> + </zip> + </tasks> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>attach-artifacts</id> + <phase>package</phase> + <goals> + <goal>attach-artifact</goal> + </goals> + <configuration> + <artifacts> + <artifact> + <file>target/nfvo-drivers-sdnc-zte-sfc-driver-${project.version}.zip</file> + <type>zip</type> + </artifact> + </artifacts> + </configuration> + </execution> + </executions> + </plugin> +<!--<plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <executions> + <execution> + <id>deploy-zip-file</id> + <phase>deploy</phase> + <configuration> + <groupId>${deploy.nfv.groupid}</groupId> + <artifactId>${uepPackageid}</artifactId> + <version>${project.version}</version> + <packaging>zip</packaging> + <file>target/${uepPackageid}-${project.version}.zip</file> + </configuration> + </execution> + </executions> +</plugin>--> + + + </plugins> + </build> +</project> 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 @@ +<?xml version="1.0"?> +<!-- + + 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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.openo.nfvo</groupId> + <artifactId>nfvo-root</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../../../../pom.xml</relativePath> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>org.openo.nfvo.sfc-driver-parent</groupId> + <artifactId>sfc-driver-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <name>nfvo/drivers/sdnc/zte/sfc-driver</name> + <packaging>pom</packaging> + <modules> + <module>sfc-driver</module> + <module>plugin-standalone</module> + </modules> + +</project> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + + 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. + +--> + +<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="false"> + <output url="file://$MODULE_DIR$/target/classes" /> + <output-test url="file://$MODULE_DIR$/target/test-classes" /> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/sfc-driver/src/main/java" isTestSource="false" /> + <excludeFolder url="file://$MODULE_DIR$/target" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + </component> +</module> + 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 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + + 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. + +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <parent> + <artifactId>sfc-driver-parent</artifactId> + <groupId>com.zte.ums.sfc.components.sfc-driver</groupId> + <version>1.15.10.B2-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>com.zte.ums.sfc.components.sfc-driver</groupId> + <artifactId>sfc-driver</artifactId> + <name>sdno/20.components/sfc-driver</name> + <version>1.15.10.B2-SNAPSHOT</version> + <build> + <plugins> + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <version>2.4</version> + <configuration> + <archive> + <manifest> + <addDefaultImplementationEntries>true</addDefaultImplementationEntries> + </manifest> + </archive> + </configuration> + </plugin> + <plugin> + <artifactId>maven-shade-plugin</artifactId> + <version>2.3</version> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + <configuration> + <transformers> + <transformer /> + <transformer> + <mainClass>com.zte.ums.sfc.console.SfcApp</mainClass> + </transformer> + </transformers> + </configuration> + </execution> + </executions> + <configuration> + <createDependencyReducedPom>true</createDependencyReducedPom> + <filters> + <filter> + <artifact>*:*</artifact> + <excludes> + <exclude>META-INF/*.SF</exclude> + <exclude>META-INF/*.DSA</exclude> + <exclude>META-INF/*.RSA</exclude> + </excludes> + </filter> + </filters> + </configuration> + </plugin> + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>copy-dependencies</id> + <phase>package</phase> + <goals> + <goal>copy-dependencies</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>io.dropwizard</groupId> + <artifactId>dropwizard-core</artifactId> + <version>${dropwizard.version}</version> + <overWrite>true</overWrite> + </artifactItem> + </artifactItems> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.glassfish.jersey.media</groupId> + <artifactId>jersey-media-multipart</artifactId> + <version>${jersey.version}</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.containers</groupId> + <artifactId>jersey-container-servlet-core</artifactId> + <version>${jersey.version}</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.containers</groupId> + <artifactId>jersey-container-servlet</artifactId> + <version>2.16</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-client</artifactId> + <version>2.16</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-common</artifactId> + <version>2.16</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.dataformat</groupId> + <artifactId>jackson-dataformat-xml</artifactId> + <version>${jackson-version}</version> + </dependency> + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-jaxrs</artifactId> + <version>1.9.11</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + <version>${jackson-version}</version> + </dependency> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <version>2.2.4</version> + </dependency> + </dependencies> + </dependencyManagement> + <properties> + <dropwizard.version>0.8.0</dropwizard.version> + <swagger.version>1.5.3</swagger.version> + <jersey.version>2.16</jersey.version> + <jetty.version>9.2.9.v20150224</jetty.version> + <jackson-version>2.5.1</jackson-version> + </properties> +</project> + 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.openo.nfvo.sfc-driver-parent</groupId> + <artifactId>sfc-driver-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>org.openo.nfvo.sfc-driver</groupId> + <artifactId>sfc-driver</artifactId> + <name>nfvo/drivers/sdnc/zte/sfc-driver/sfc-driver</name> + <packaging>jar</packaging> + <version>1.1.0-SNAPSHOT</version> + <properties> + <dropwizard.version>0.8.0</dropwizard.version> + <jetty.version>9.2.9.v20150224</jetty.version> + <jackson-version>2.5.1</jackson-version> + <jersey.version>2.16</jersey.version> + <swagger.version>1.5.3</swagger.version> + </properties> + + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.glassfish.jersey.media</groupId> + <artifactId>jersey-media-multipart</artifactId> + <version>${jersey.version}</version> + </dependency> + + <dependency> + <groupId>org.glassfish.jersey.containers</groupId> + <artifactId>jersey-container-servlet-core</artifactId> + <version>${jersey.version}</version> + </dependency> + + <dependency> + <groupId>org.glassfish.jersey.containers</groupId> + <artifactId>jersey-container-servlet</artifactId> + <version>2.16</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-client</artifactId> + <version>2.16</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-common</artifactId> + <version>2.16</version> + </dependency> + + <dependency> + <groupId>com.fasterxml.jackson.dataformat</groupId> + <artifactId>jackson-dataformat-xml</artifactId> + <version>${jackson-version}</version> + </dependency> + + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-jaxrs</artifactId> + <version>1.9.11</version> + </dependency> + + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + <version>${jackson-version}</version> + </dependency> + + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>io.dropwizard</groupId> + <artifactId>dropwizard-core</artifactId> + <version>${dropwizard.version}</version> + </dependency> + <dependency> + <groupId>io.dropwizard</groupId> + <artifactId>dropwizard-assets</artifactId> + <version>${dropwizard.version}</version> + </dependency> + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-jersey2-jaxrs</artifactId> + <version>${swagger.version}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>com.eclipsesource.jaxrs</groupId> + <artifactId>consumer</artifactId> + <version>2.3</version> + </dependency> + + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <version>2.2.4</version> + </dependency> + + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>2.4</version> + <configuration> + <archive> + <manifest> + <addDefaultImplementationEntries>true</addDefaultImplementationEntries> + </manifest> + </archive> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <version>2.3</version> + <configuration> + <createDependencyReducedPom>true</createDependencyReducedPom> + <filters> + <filter> + <artifact>*:*</artifact> + <excludes> + <exclude>META-INF/*.SF</exclude> + <exclude>META-INF/*.DSA</exclude> + <exclude>META-INF/*.RSA</exclude> + </excludes> + </filter> + </filters> + </configuration> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>shade</goal> + </goals> + <configuration> + <transformers> + <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> + <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> + <mainClass>com.zte.ums.sfc.console.sfcDriver</mainClass> + </transformer> + </transformers> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>copy-dependencies</id> + <phase>package</phase> + <goals> + <goal>copy-dependencies</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>io.dropwizard</groupId> + <artifactId>dropwizard-core</artifactId> + <version>${dropwizard.version}</version> + <overWrite>true</overWrite> + </artifactItem> + </artifactItems> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + + 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. + +--> + +<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="false"> + <output url="file://$MODULE_DIR$/target/classes" /> + <output-test url="file://$MODULE_DIR$/target/test-classes" /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" /> + <excludeFolder url="file://$MODULE_DIR$/target" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-core:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-util:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.5.1" level="project" /> + <orderEntry type="library" name="Maven: com.google.guava:guava:18.0" level="project" /> + <orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.0" level="project" /> + <orderEntry type="library" name="Maven: joda-time:joda-time:2.7" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-jackson:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.5.1" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.5.1" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk7:2.5.1" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-guava:2.5.1" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-afterburner:2.5.1" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-joda:2.5.1" level="project" /> + <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.10" level="project" /> + <orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.1.2" level="project" /> + <orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.1.2" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-validation:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: org.hibernate:hibernate-validator:5.1.3.Final" level="project" /> + <orderEntry type="library" name="Maven: javax.validation:validation-api:1.1.0.Final" level="project" /> + <orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.1.3.GA" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml:classmate:1.0.0" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish:javax.el:3.0.0" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-configuration:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.5.1" level="project" /> + <orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.12" level="project" /> + <orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.3.2" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-logging:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard.metrics:metrics-logback:3.1.0" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard.metrics:metrics-core:3.1.0" level="project" /> + <orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.10" level="project" /> + <orderEntry type="library" name="Maven: org.slf4j:log4j-over-slf4j:1.7.10" level="project" /> + <orderEntry type="library" name="Maven: org.slf4j:jcl-over-slf4j:1.7.10" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-util:9.2.9.v20150224" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-metrics:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-lifecycle:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-server:9.2.9.v20150224" level="project" /> + <orderEntry type="library" name="Maven: javax.servlet:javax.servlet-api:3.1.0" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-http:9.2.9.v20150224" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-io:9.2.9.v20150224" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-jersey:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.jersey.core:jersey-server:2.16" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.jersey.core:jersey-common:2.6" level="project" /> + <orderEntry type="library" name="Maven: javax.ws.rs:javax.ws.rs-api:2.0.1" level="project" /> + <orderEntry type="library" name="Maven: javax.annotation:javax.annotation-api:1.2" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.jersey.bundles.repackaged:jersey-guava:2.6" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.hk2:hk2-api:2.2.0" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.hk2:hk2-utils:2.2.0" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.hk2.external:aopalliance-repackaged:2.2.0" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.hk2.external:javax.inject:2.4.0-b09" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.hk2:hk2-locator:2.2.0" level="project" /> + <orderEntry type="library" name="Maven: org.javassist:javassist:3.18.2-GA" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.hk2:osgi-resource-locator:1.0.1" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.jersey.core:jersey-client:2.6" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.jersey.media:jersey-media-jaxb:2.16" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.jersey.ext:jersey-metainf-services:2.16" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard.metrics:metrics-jersey2:3.1.0" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard.metrics:metrics-annotation:3.1.0" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.5.1" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:2.5.1" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.5.1" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.jersey.containers:jersey-container-servlet:2.16" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.jersey.containers:jersey-container-servlet-core:2.16" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-webapp:9.2.9.v20150224" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-xml:9.2.9.v20150224" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-servlet:9.2.9.v20150224" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-security:9.2.9.v20150224" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-continuation:9.2.9.v20150224" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-servlets:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-jetty:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard.metrics:metrics-jetty9:3.1.0" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-servlets:9.2.9.v20150224" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard.metrics:metrics-jvm:3.1.0" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard.metrics:metrics-servlets:3.1.0" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard.metrics:metrics-healthchecks:3.1.0" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard.metrics:metrics-json:3.1.0" level="project" /> + <orderEntry type="library" name="Maven: net.sourceforge.argparse4j:argparse4j:0.4.4" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty.toolchain.setuid:jetty-setuid-java:1.0.2" level="project" /> + <orderEntry type="library" name="Maven: io.dropwizard:dropwizard-assets:0.8.0" level="project" /> + <orderEntry type="library" name="Maven: io.swagger:swagger-jersey2-jaxrs:1.5.3" level="project" /> + <orderEntry type="library" name="Maven: io.swagger:swagger-jaxrs:1.5.3" level="project" /> + <orderEntry type="library" name="Maven: com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.5.1" level="project" /> + <orderEntry type="library" name="Maven: org.codehaus.woodstox:stax2-api:3.1.4" level="project" /> + <orderEntry type="library" name="Maven: io.swagger:swagger-core:1.5.3" level="project" /> + <orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.3" level="project" /> + <orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.3" level="project" /> + <orderEntry type="library" name="Maven: org.reflections:reflections:0.9.9" level="project" /> + <orderEntry type="library" name="Maven: com.google.code.findbugs:annotations:2.0.1" level="project" /> + <orderEntry type="library" name="Maven: org.glassfish.jersey.media:jersey-media-multipart:2.16" level="project" /> + <orderEntry type="library" name="Maven: org.jvnet.mimepull:mimepull:1.9.3" level="project" /> + <orderEntry type="library" name="Maven: com.eclipsesource.jaxrs:consumer:2.3" level="project" /> + <orderEntry type="library" name="Maven: com.google.code.gson:gson:2.2.4" level="project" /> + </component> +</module> + 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<SfcDriverConfig> { + + 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<SfcDriverConfig> 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<FlowClassfierReq> getSfcFlowClassifier() { + return sfcFlowClassifier; + } + + public void setSfcFlowClassifier(ArrayList<FlowClassfierReq> sfcFlowClassifier) { + this.sfcFlowClassifier = sfcFlowClassifier; + } + + @SerializedName("sfc-flow-classifier") + ArrayList<FlowClassfierReq> 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<NodeEntity> 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<NodeEntity> getNodes() { + return nodes; + } + + public void setNodes(ArrayList<NodeEntity> 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<String> portPairGroups; + @SerializedName("flow-classifiers") + private ArrayList<String> flowClassifiers; + private String uuid; + @SerializedName("chain-parameters") + private ArrayList<ChainParameter> chainParams; + + + public ArrayList<ChainParameter> getChainParams() { + return chainParams; + } + + public void setChainParams(ArrayList<ChainParameter> chainParams) { + this.chainParams = chainParams; + } + + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + private Map chainParameters; + + public ArrayList<String> getPortPairGroups() { + return portPairGroups; + } + + public void setPortPairGroups(ArrayList<String> portPairGroups) { + this.portPairGroups = portPairGroups; + } + + public ArrayList<String> getFlowClassifiers() { + return flowClassifiers; + } + + public void setFlowClassifiers(ArrayList<String> 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<String> flowClassifiers; + private ArrayList<String> 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<String> getFlowClassifiers() { + return flowClassifiers; + } + + public void setFlowClassifiers(ArrayList<String> flowClassifiers) { + this.flowClassifiers = flowClassifiers; + } + + public ArrayList<String> getPortPairGroups() { + return portPairGroups; + } + + public void setPortPairGroups(ArrayList<String> 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<PortChainReq> getPortChainReqs() { + return portChainReqs; + } + + public void setPortChainReqs(ArrayList<PortChainReq> portChainReqs) { + this.portChainReqs = portChainReqs; + } + + @SerializedName("port-chain") + ArrayList<PortChainReq> 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<String> portPairs; + + public List<String> getPortPairs() { + return portPairs; + } + + public void setPortPairs(List<String> 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<String> 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<String> getPortPairs() { + return portPairs; + } + + public void setPortPairs(List<String> 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<PortPairGroupReq> getPortPairGroupReqs() { + return portPairGroupReqs; + } + + public void setPortPairGroupReqs(ArrayList<PortPairGroupReq> portPairGroupReqs) { + this.portPairGroupReqs = portPairGroupReqs; + } + + @SerializedName("port-pair-group") + ArrayList<PortPairGroupReq> 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<ServiceFunctionParameter> serviceFunctionParameters; + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public ArrayList<ServiceFunctionParameter> getServiceFunctionParameters() { + return serviceFunctionParameters; + } + + public void setServiceFunctionParameters(ArrayList<ServiceFunctionParameter> 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<PortPairReq> getPortPair() { + return portPair; + } + + public void setPortPair(ArrayList<PortPairReq> portPair) { + this.portPair = portPair; + } + + @SerializedName("port-pair") + ArrayList<PortPairReq> 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<ServiceFunctionParameter> generateSfParams(Map sfHashParams) { + ArrayList<ServiceFunctionParameter> serviceParameters = new ArrayList<ServiceFunctionParameter>(); + 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<NodeEntity> nodes = new ArrayList<NodeEntity>(); + 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<ServiceFunctionParameter> serviceFunctionParameters = new ArrayList<ServiceFunctionParameter>(); + serviceFunctionParameters.addAll(SfcDriverUtil.generateSfParams(portPairReq4N.getSfParam())); + portPairReq.setServiceFunctionParameters(serviceFunctionParameters); + portPairReq.setUuid(SfcDriverUtil.generateUuid()); + ArrayList<PortPairReq> portPairList = new ArrayList<PortPairReq>(); + 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<PortPairGroupReq> portPairGroupReqs = new ArrayList<PortPairGroupReq>(); + portPairGroupReqs.add(ppg4S); + portPairGroupReq4S.setPortPairGroupReqs(portPairGroupReqs); + + return portPairGroupReq4S; + } + + public static FlowClassifierReq4S convertFlowClassfier(FlowClassfierReq4N flowClassfierReq4N) { + ArrayList<FlowClassfierReq> 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<ChainParameter> chainParam = new ArrayList<ChainParameter>(); + chainParam.add(SfcDriverUtil.generateChainParam("symmetric", portChainReq4N.isSymmetric() ? "true" : "false")); + portChainReq.setChainParams(chainParam); + ArrayList<PortChainReq> portChains = new ArrayList<PortChainReq>(); + portChains.add(portChainReq); + PortChainReq4S portChainReq4S = new PortChainReq4S(); + portChainReq4S.setPortChainReqs(portChains); + return portChainReq4S; + } + + +} |