Change-Id: If18530dc407e3fc64329d8aa251b148b30bd5a8e
Signed-off-by: Alessandro Boch <aboch@cisco.com>
@XmlElement
private String name;
@XmlElement
private String name;
+ /** The vlan. */
+ @XmlElement
+ private String dlVlan;
+
/** The network Source. */
@XmlElement
private String nwSrc;
/** The network Source. */
@XmlElement
private String nwSrc;
public ContainerFlowConfig(String name, String srcIP, String dstIP, String proto, String srcPort,
String dstPort) {
this.name = name;
public ContainerFlowConfig(String name, String srcIP, String dstIP, String proto, String srcPort,
String dstPort) {
this.name = name;
this.nwSrc = srcIP;
this.nwDst = dstIP;
this.protocol = proto;
this.nwSrc = srcIP;
this.nwDst = dstIP;
this.protocol = proto;
public ContainerFlowConfig(ContainerFlowConfig containerFlowConfig) {
this.name = containerFlowConfig.name;
public ContainerFlowConfig(ContainerFlowConfig containerFlowConfig) {
this.name = containerFlowConfig.name;
+ this.dlVlan = containerFlowConfig.dlVlan;
this.nwSrc = containerFlowConfig.nwSrc;
this.nwDst = containerFlowConfig.nwDst;
this.protocol = containerFlowConfig.protocol;
this.nwSrc = containerFlowConfig.nwSrc;
this.nwDst = containerFlowConfig.nwDst;
this.protocol = containerFlowConfig.protocol;
+ /**
+ * Returns the vlan id.
+ *
+ * @return the Vlan Id
+ */
+ public String getVlan() {
+ return (dlVlan == null || dlVlan.isEmpty()) ? null : dlVlan;
+ }
+
/**
* Returns the Source IP Address.
*
/**
* Returns the Source IP Address.
*
result = prime * result
+ ((protocol == null) ? 0 : protocol.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result
+ ((protocol == null) ? 0 : protocol.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((dlVlan == null) ? 0 : dlVlan.hashCode());
result = prime * result + ((nwDst == null) ? 0 : nwDst.hashCode());
result = prime * result + ((tpDst == null) ? 0 : tpDst.hashCode());
result = prime * result + ((nwSrc == null) ? 0 : nwSrc.hashCode());
result = prime * result + ((nwDst == null) ? 0 : nwDst.hashCode());
result = prime * result + ((tpDst == null) ? 0 : tpDst.hashCode());
result = prime * result + ((nwSrc == null) ? 0 : nwSrc.hashCode());
return false;
}
ContainerFlowConfig other = (ContainerFlowConfig) obj;
return false;
}
ContainerFlowConfig other = (ContainerFlowConfig) obj;
- if (matchName(other) && matchSrcIP(other)
+ if (matchName(other) && matchDlVlan(other) && matchSrcIP(other)
&& matchDstIP(other) && matchProtocol(other)
&& matchSrcPort(other) && matchDstPort(other)) {
return true;
&& matchDstIP(other) && matchProtocol(other)
&& matchSrcPort(other) && matchDstPort(other)) {
return true;
return name.equals(flowSpec.name);
}
return name.equals(flowSpec.name);
}
+ /**
+ * Match Source IP Address.
+ *
+ * @param flowSpec Flow Specification
+ * @return true, if successful
+ */
+ private boolean matchDlVlan(ContainerFlowConfig flowSpec) {
+ if (dlVlan == flowSpec.dlVlan) {
+ return true;
+ }
+ if (dlVlan == null || flowSpec.dlVlan == null) {
+ return false;
+ }
+ return dlVlan.equals(flowSpec.dlVlan);
+ }
/**
* Match Source IP Address.
/**
* Match Source IP Address.
return this.tpDst.equals(flowSpec.tpDst);
}
return this.tpDst.equals(flowSpec.tpDst);
}
+ /**
+ * Returns the vlan id number
+ *
+ * @return the vlan id number
+ */
+ public Short getVlanId() {
+ Short vlan = 0;
+ try {
+ vlan = Short.parseShort(dlVlan);
+ } catch (NumberFormatException e) {
+
+ }
+ return vlan;
+ }
+
/**
* Returns the Source IP Address mask length.
*
/**
* Returns the Source IP Address mask length.
*
if (!hasValidName()) {
return new Status(StatusCode.BADREQUEST, "Invalid name");
}
if (!hasValidName()) {
return new Status(StatusCode.BADREQUEST, "Invalid name");
}
- Status status = validateIPs();
+ Status status = validateVlan();
+ if (!status.isSuccess()) {
+ return status;
+ }
+ status = validateIPs();
if (!status.isSuccess()) {
return status;
}
if (!status.isSuccess()) {
return status;
}
return (name != null && !name.isEmpty() && name.matches(regexName));
}
return (name != null && !name.isEmpty() && name.matches(regexName));
}
+ /**
+ * Validates the vlan number
+ *
+ * @return the result of the check as Status object
+ */
+ private Status validateVlan() {
+ if (dlVlan != null) {
+ short vlanId = 0;
+ try {
+ vlanId = Short.parseShort(dlVlan);
+ } catch (NumberFormatException e) {
+ return new Status(StatusCode.BADREQUEST, "Invalid vlan id");
+ }
+ if (vlanId < 0 || vlanId > 0xfff) {
+ return new Status(StatusCode.BADREQUEST, "Invalid vlan id");
+ }
+ }
+ return new Status(StatusCode.SUCCESS);
+ }
+
/**
* Validates the network addresses, checks syntax and semantic
*
/**
* Validates the network addresses, checks syntax and semantic
*
package org.opendaylight.controller.containermanager.northbound;
package org.opendaylight.controller.containermanager.northbound;
-import java.security.Principal;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
* Response body in XML:
* <flow-spec-config>
*     <name>ssh</name>
* Response body in XML:
* <flow-spec-config>
*     <name>ssh</name>
+ *     <dlVlan>52</dlVlan>
*     <nwSrc>10.0.0.101</nwSrc>
*     <nwDst>10.0.0.102</nwDst>
*     <protocol>IPv4</protocol>
*     <nwSrc>10.0.0.101</nwSrc>
*     <nwDst>10.0.0.102</nwDst>
*     <protocol>IPv4</protocol>
* Response body in JSON:
* {
* "protocol" : "IPv4",
* Response body in JSON:
* {
* "protocol" : "IPv4",
* "nwDst" : "10.0.0.102",
* "name" : "ssh",
* "nwSrc" : "10.0.0.101",
* "nwDst" : "10.0.0.102",
* "name" : "ssh",
* "nwSrc" : "10.0.0.101",
* <flow-spec-configs>
*     <flow-spec-config>
*       <name>ssh</name>
* <flow-spec-configs>
*     <flow-spec-config>
*       <name>ssh</name>
+ *       <dlVlan>52</dlVlan>
*       <nwSrc>10.0.0.101</nwSrc>
*       <nwDst>10.0.0.102</nwDst>
*       <protocol>IPv4</protocol>
*       <nwSrc>10.0.0.101</nwSrc>
*       <nwDst>10.0.0.102</nwDst>
*       <protocol>IPv4</protocol>
*     </flow-spec-config>
*     <flow-spec-config>
*       <name>http2</name>
*     </flow-spec-config>
*     <flow-spec-config>
*       <name>http2</name>
+ *       <dlVlan>123</dlVlan>
*       <nwSrc>10.0.0.201</nwSrc>
*       <nwDst>10.0.0.202</nwDst>
*       <protocol></protocol>
*       <nwSrc>10.0.0.201</nwSrc>
*       <nwDst>10.0.0.202</nwDst>
*       <protocol></protocol>
* "flow-spec-config": [
* {
* "name": "http",
* "flow-spec-config": [
* {
* "name": "http",
* "nwSrc": "10.0.0.201",
* "nwDst": "10.0.0.202",
* "protocol": "",
* "nwSrc": "10.0.0.201",
* "nwDst": "10.0.0.202",
* "protocol": "",
* },
* {
* "name": "ssh",
* },
* {
* "name": "ssh",
* "nwSrc": "10.0.0.101",
* "nwDst": "10.0.0.102",
* "protocol": "IPv4",
* "nwSrc": "10.0.0.101",
* "nwDst": "10.0.0.102",
* "protocol": "IPv4",
* Request body in XML:
* <flow-spec-config>
*     <name>http</name>
* Request body in XML:
* <flow-spec-config>
*     <name>http</name>
+ *     <dlVlan>25</dlVlan>
*     <nwSrc>10.0.0.101</nwSrc>
*     <nwDst>10.0.0.102</nwDst>
*     <protocol></protocol>
*     <nwSrc>10.0.0.101</nwSrc>
*     <nwDst>10.0.0.102</nwDst>
*     <protocol></protocol>
*
* Request body in JSON:
* {
*
* Request body in JSON:
* {
- * "protocol" : "",
- * "nwDst" : "10.0.0.102",
* "nwSrc" : "10.0.0.101",
* "nwSrc" : "10.0.0.101",
+ * "nwDst" : "10.0.0.102",
+ * "protocol" : "",
* "tpSrc" : "80",
* "tpDst" : "100"
* }
* "tpSrc" : "80",
* "tpDst" : "100"
* }