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 /zte/sfc-driver/sfc-driver/src | |
parent | 19f83964f264666ceb26d55043e3f6cd05087257 (diff) |
Create seed codes of nfvo
Change-Id: I72a426c6be55f8a6a0200f6dedd2486bee067062
Issue-Id: VFC-52
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
Diffstat (limited to 'zte/sfc-driver/sfc-driver/src')
32 files changed, 2091 insertions, 0 deletions
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; + } + + +} |