if(!hasValidProtocol()) {
return new Status(StatusCode.BADREQUEST, "Invalid IP protocol");
}
+ if (!hasValidPorts()) {
+ return new Status(StatusCode.BADREQUEST, "Invalid Source or Destination Port");
+ }
if (this.getMatches().get(0).getMatches() == 0) {
return new Status(StatusCode.BADREQUEST, "Flow Spec is empty");
}
return new Status(StatusCode.SUCCESS);
}
+ /**
+ * Validate the protocol field. Either it can be a enum defined in IPProtocols.java
+ * or a value between 1 and 255
+ *
+ * @return true if a valid protocol value
+ */
private boolean hasValidProtocol() {
if (protocol != null && !protocol.isEmpty()) {
- return (this.getProtoNum() != 0 || protocol.equalsIgnoreCase("any"));
+ short proto = this.getProtoNum();
+ return (((proto != 0) && (proto > 0) && (proto < 256)) || protocol.equalsIgnoreCase("any"));
}
return true;
}
+
+ /**
+ *
+ * @param tpPort
+ * String representing the transport protocol port number
+ * @return true if tpPort contains a decimal value between 0 and 65535
+ */
+ private boolean hasValidPort(String tpPort) {
+ try {
+ int port = Integer.decode(tpPort);
+ return ((port >= 0) && (port <= 0xffff));
+ } catch (NumberFormatException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Validate the transport protocol source and destination ports as
+ * entered by users.
+ *
+ * @return true if ports are defined and are in valid range
+ */
+ private boolean hasValidPorts() {
+ if (tpSrc !=null && !tpSrc.isEmpty()) {
+ if (!hasValidPort(tpSrc)) {
+ return false;
+ }
+ }
+
+ if (tpDst !=null && !tpDst.isEmpty()) {
+ return hasValidPort(tpDst);
+ }
+ return true;
+ }
+
/**
* Returns the matches.
* If unidirectional flag is set, there will be only one match in the list
.getProtocolNumberByte(this.protocol));
}
if (this.tpSrc != null && !this.tpSrc.trim().isEmpty()) {
- Short srcPort = 0;
- try {
- srcPort = Short.parseShort(tpSrc);
- } catch (NumberFormatException e) {
- throw e;
- }
- match.setField(MatchType.TP_SRC, srcPort);
+ match.setField(MatchType.TP_SRC, Integer.valueOf(tpSrc).shortValue());
}
if (this.tpDst != null && !this.tpDst.trim().isEmpty()) {
- Short dstPort = 0;
- try {
- dstPort = Short.parseShort(tpDst);
- } catch (NumberFormatException e) {
- throw e;
- }
- match.setField(MatchType.TP_DST, dstPort);
+ match.setField(MatchType.TP_DST, Integer.valueOf(tpDst).shortValue());
}
matches.add(match);
return ((to >= 0) && (to <= 0xffff));
}
+ public boolean isProtocolValid(String protocol) {
+ int protocol_number = IPProtocols.getProtocolNumberInt(protocol);
+ if (protocol_number < 1 || protocol_number > 255) {
+ return false;
+ }
+ return true;
+ }
+
private Status conflictWithContainerFlow(IContainer container) {
// Return true if it's default container
if (container.getName().equals(GlobalConstants.DEFAULT.toString())) {
}
}
+ if ((protocol != null) && !isProtocolValid(protocol)) {
+ return new Status(StatusCode.BADREQUEST, String.format("Protocol %s is not valid", protocol));
+ }
+
if ((tosBits != null) && !isTOSBitsValid(tosBits)) {
return new Status(StatusCode.BADREQUEST, String.format("IP ToS bits %s is not in the range 0 - 63",
tosBits));
Assert.assertEquals(nodeId, (Integer) nodeInfo.getInt("id"));
Assert.assertEquals(nodeType, nodeInfo.getString("type"));
- JSONArray propsArray = node.getJSONArray("properties");
-
- for (int j = 0; j < propsArray.length(); j++) {
- JSONObject properties = propsArray.getJSONObject(j);
- String propName = properties.getString("name");
- if (propName.equals("timeStamp")) {
- if (timestamp == null || timestampName == null) {
- Assert.assertFalse("Timestamp exist", true);
- } else {
- Assert.assertEquals(timestamp, (Integer) properties.getInt("value"));
- Assert.assertEquals(timestampName, properties.getString("timestampName"));
- }
- }
- if (propName.equals("actions")) {
- if (actionsValue == null) {
- Assert.assertFalse("Actions exist", true);
- } else {
- Assert.assertEquals(actionsValue, (Integer) properties.getInt("value"));
- }
- }
- if (propName.equals("capabilities")) {
- if (capabilitiesValue == null) {
- Assert.assertFalse("Capabilities exist", true);
- } else {
- Assert.assertEquals(capabilitiesValue, (Integer) properties.getInt("value"));
- }
- }
- if (propName.equals("tables")) {
- if (tablesValue == null) {
- Assert.assertFalse("Tables exist", true);
- } else {
- Assert.assertEquals(tablesValue, (Integer) properties.getInt("value"));
- }
- }
- if (propName.equals("buffers")) {
- if (buffersValue == null) {
- Assert.assertFalse("Buffers exist", true);
- } else {
- Assert.assertEquals(buffersValue, (Integer) properties.getInt("value"));
- }
- }
+ JSONObject properties = node.getJSONObject("properties");
+
+ if (timestamp == null || timestampName == null) {
+ Assert.assertFalse(properties.has("timeStamp"));
+ } else {
+ Assert.assertEquals(timestamp, (Integer) properties.getJSONObject("timeStamp").getInt("value"));
+ Assert.assertEquals(timestampName, properties.getJSONObject("timeStamp").getString("name"));
+ }
+ if (actionsValue == null) {
+ Assert.assertFalse(properties.has("actions"));
+ } else {
+ Assert.assertEquals(actionsValue, (Integer) properties.getJSONObject("actions").getInt("value"));
+ }
+ if (capabilitiesValue == null) {
+ Assert.assertFalse(properties.has("capabilities"));
+ } else {
+ Assert.assertEquals(capabilitiesValue,
+ (Integer) properties.getJSONObject("capabilities").getInt("value"));
+ }
+ if (tablesValue == null) {
+ Assert.assertFalse(properties.has("tables"));
+ } else {
+ Assert.assertEquals(tablesValue, (Integer) properties.getJSONObject("tables").getInt("value"));
+ }
+ if (buffersValue == null) {
+ Assert.assertFalse(properties.has("buffers"));
+ } else {
+ Assert.assertEquals(buffersValue, (Integer) properties.getJSONObject("buffers").getInt("value"));
}
}
JSONObject nodeConnector = nodeConnectorProperties.getJSONObject("nodeconnector");
JSONObject node = nodeConnector.getJSONObject("node");
+ JSONObject properties = nodeConnectorProperties.getJSONObject("properties");
Assert.assertEquals(ncId, (Integer) nodeConnector.getInt("id"));
Assert.assertEquals(ncType, nodeConnector.getString("type"));
Assert.assertEquals(nodeId, (Integer) node.getInt("id"));
Assert.assertEquals(nodeType, node.getString("type"));
-
- JSONArray propsArray = nodeConnectorProperties.getJSONArray("properties");
- for (int j = 0; j < propsArray.length(); j++) {
- JSONObject properties = propsArray.getJSONObject(j);
- String propName = properties.getString("name");
- if (propName.equals("state")) {
- if (state == null) {
- Assert.assertFalse("State exist", true);
- } else {
- Assert.assertEquals(state, (Integer) properties.getInt("value"));
- }
- }
- if (propName.equals("capabilities")) {
- if (capabilities == null) {
- Assert.assertFalse("Capabilities exist", true);
- } else {
- Assert.assertEquals(capabilities, (Integer) properties.getInt("value"));
- }
- }
- if (propName.equals("bandwidth")) {
- if (bandwidth == null) {
- Assert.assertFalse("bandwidth exist", true);
- } else {
- Assert.assertEquals(bandwidth, (Integer) properties.getInt("value"));
- }
- }
+ if (state == null) {
+ Assert.assertFalse(properties.has("state"));
+ } else {
+ Assert.assertEquals(state, (Integer) properties.getJSONObject("state").getInt("value"));
+ }
+ if (capabilities == null) {
+ Assert.assertFalse(properties.has("capabilities"));
+ } else {
+ Assert.assertEquals(capabilities,
+ (Integer) properties.getJSONObject("capabilities").getInt("value"));
+ }
+ if (bandwidth == null) {
+ Assert.assertFalse(properties.has("bandwidth"));
+ } else {
+ Assert.assertEquals(bandwidth, (Integer) properties.getJSONObject("bandwidth").getInt("value"));
}
}
json = new JSONObject(jt);
node = getJsonInstance(json, "nodeProperties", nodeId_1);
Assert.assertNotNull(node);
-
- JSONArray propsArray = node.getJSONArray("properties");
-
- for (int j = 0; j < propsArray.length(); j++) {
- JSONObject properties = propsArray.getJSONObject(j);
- String propName = properties.getString("name");
- if (propName.equals("tier")) {
- Assert.assertEquals(1001, properties.getInt("value"));
- }
- if (propName.equals("description")) {
- Assert.assertEquals("node1", properties.getString("value"));
- }
- }
+ Assert.assertEquals(1001, node.getJSONObject("properties").getJSONObject("tier").getInt("value"));
+ Assert.assertEquals("node1", node.getJSONObject("properties").getJSONObject("description").getString("value"));
// Test delete nodeConnector property
// Delete state property of nodeconnector1
JSONObject headNC = edge.getJSONObject("headNodeConnector");
JSONObject headNode = headNC.getJSONObject("node");
-
- JSONArray propsArray = edgeProp.getJSONArray("properties");
-
- JSONObject bandw = null;
- JSONObject stt = null;
- JSONObject ltc = null;
-
- for (int j = 0; j < propsArray.length(); j++) {
- JSONObject props = propsArray.getJSONObject(j);
- String propName = props.getString("name");
- if (propName.equals("bandwidth")) {
- bandw = props;
- }
- if (propName.equals("state")) {
- stt = props;
- }
- if (propName.equals("latency")) {
- ltc = props;
- }
- }
+ JSONObject Props = edgeProp.getJSONObject("properties");
+ JSONObject bandw = Props.getJSONObject("bandwidth");
+ JSONObject stt = Props.getJSONObject("state");
+ JSONObject ltc = Props.getJSONObject("latency");
if (headNC.getInt("id") == headNC1_nodeConnId) {
Assert.assertEquals(headNode.getString("type"), nodeType);
Integer nodeId_1 = 3366;
String nodeConnectorType_1 = "STUB";
Integer nodeConnectorId_1 = 12;
-
String nodeType_2 = "STUB";
Integer nodeId_2 = 4477;
String nodeConnectorType_2 = "STUB";
}
}
}
-
// Configure the OSGi container
@Configuration
public Option[] config() {
org.slf4j,
org.apache.catalina.filters,
org.codehaus.jackson.jaxrs,
+ org.codehaus.jackson.annotate,
!org.codehaus.enunciate.jaxrs
</Import-Package>
<Web-ContextPath>/controller/nb/v2/switchmanager</Web-ContextPath>
package org.opendaylight.controller.switchmanager.northbound;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonProperty;
import org.opendaylight.controller.sal.core.NodeConnector;
import org.opendaylight.controller.sal.core.Property;
private NodeConnector nodeconnector;
@XmlElementRef
@XmlElementWrapper
+ @JsonIgnore
private Set<Property> properties;
// JAXB required constructor
this.properties = properties;
}
+ @JsonProperty(value="properties")
+ public Map<String, Property> getMapProperties() {
+ Map<String, Property> map = new HashMap<String, Property>();
+ for (Property p : properties) {
+ map.put(p.getName(), p);
+ }
+ return map;
+ }
+
+ public void setMapProperties(Map<String, Property> propertiesMap) {
+ this.properties = new HashSet<Property>(propertiesMap.values());
+ }
+
public Set<Property> getProperties() {
return properties;
}
package org.opendaylight.controller.switchmanager.northbound;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonProperty;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.core.Property;
private Node node;
@XmlElementRef
@XmlElementWrapper
+ @JsonIgnore
private Set<Property> properties;
// JAXB required constructor
this.properties = properties;
}
+ @JsonProperty(value="properties")
+ public Map<String, Property> getMapProperties() {
+ Map<String, Property> map = new HashMap<String, Property>();
+ for (Property p : properties) {
+ map.put(p.getName(), p);
+ }
+ return map;
+ }
+
+ public void setMapProperties(Map<String, Property> propertiesMap) {
+ this.properties = new HashSet<Property>(propertiesMap.values());
+ }
+
public Set<Property> getProperties() {
return properties;
}
org.opendaylight.controller.usermanager,
org.opendaylight.controller.topologymanager,
com.sun.jersey.spi.container.servlet,
+ org.codehaus.jackson.annotate,
javax.ws.rs,
javax.ws.rs.core,
javax.xml.bind,
package org.opendaylight.controller.topology.northbound;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonProperty;
import org.opendaylight.controller.sal.core.Edge;
import org.opendaylight.controller.sal.core.Property;
private Edge edge;
@XmlElementRef
@XmlElementWrapper
+ @JsonIgnore
private Set<Property> properties;
// JAXB required constructor
this.properties = properties;
}
+ @JsonProperty(value="properties")
+ public Map<String, Property> getMapProperties() {
+ Map<String, Property> map = new HashMap<String, Property>();
+ for (Property p : properties) {
+ map.put(p.getName(), p);
+ }
+ return map;
+ }
+
+ public void setMapProperties(Map<String, Property> propertiesMap) {
+ this.properties = new HashSet<Property>(propertiesMap.values());
+ }
+
public Set<Property> getProperties() {
return properties;
}
-
public void setProperties(Set<Property> properties) {
this.properties = properties;
}
package org.opendaylight.controller.sal.core;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
*/
@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
public class Actions extends Property {
private static final long serialVersionUID = 1L;
@XmlElement(name="value")
package org.opendaylight.controller.sal.core;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
/**
* seconds.
*/
@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
@SuppressWarnings("serial")
public class AdvertisedBandwidth extends Bandwidth {
public static final String AdvertisedBandwidthPropName = "advertisedBandwidth";
package org.opendaylight.controller.sal.core;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
* seconds.
*/
@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
public class Bandwidth extends Property {
private static final long serialVersionUID = 1L;
package org.opendaylight.controller.sal.core;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
* Describes supported buffers (#packets)
*/
@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
public class Buffers extends Property {
private static final long serialVersionUID = 1L;
@XmlElement(name="value")
package org.opendaylight.controller.sal.core;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
* Describes supported capabilities
*/
@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
public class Capabilities extends Property {
private static final long serialVersionUID = 1L;
@XmlElement(name="value")
package org.opendaylight.controller.sal.core;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
*/
@XmlRootElement
@SuppressWarnings("serial")
+@XmlAccessorType(XmlAccessType.NONE)
public class Config extends Property {
@XmlElement(name="value")
private short configValue;
package org.opendaylight.controller.sal.core;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
*/
@XmlRootElement
@SuppressWarnings("serial")
+@XmlAccessorType(XmlAccessType.NONE)
public class Description extends Property {
@XmlElement(name="value")
private String descriptionValue;
package org.opendaylight.controller.sal.core;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
* The class represents the forwarding mode property of a node.
*/
@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
@SuppressWarnings("serial")
public class ForwardingMode extends Property {
@XmlElement(name="value")
package org.opendaylight.controller.sal.core;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
* Describe a latency in picoseconds or multiple of its.
*/
@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
public class Latency extends Property {
private static final long serialVersionUID = 1L;
package org.opendaylight.controller.sal.core;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
* The class represents the Name property of an element.
*/
@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
@SuppressWarnings("serial")
public class Name extends Property {
@XmlElement(name="value")
package org.opendaylight.controller.sal.core;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
/**
* bits per seconds.
*/
@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
public class PeerBandwidth extends Bandwidth {
private static final long serialVersionUID = 1L;
import java.io.Serializable;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
* element
*/
@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
@XmlSeeAlso({ Config.class, Name.class, State.class, TimeStamp.class,
Latency.class, Bandwidth.class, Tier.class, Actions.class,
AdvertisedBandwidth.class, Buffers.class, Capabilities.class,
package org.opendaylight.controller.sal.core;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
*
*/
@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
@SuppressWarnings("serial")
public class State extends Property {
@XmlElement(name="value")
package org.opendaylight.controller.sal.core;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
/**
* seconds.
*/
@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
public class SupportedBandwidth extends Bandwidth {
private static final long serialVersionUID = 1L;
public static final String SupportedBandwidthPropName = "supportedBandwidth";
package org.opendaylight.controller.sal.core;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
* Describes supported # of datapath tables
*/
@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
public class Tables extends Property {
private static final long serialVersionUID = 1L;
@XmlElement(name="value")
package org.opendaylight.controller.sal.core;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
*
*/
@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
@SuppressWarnings("serial")
public class Tier extends Property {
@XmlElement(name="value")
import java.util.Date;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
* to qualify what are we talking about
*/
@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
public class TimeStamp extends Property {
private static final long serialVersionUID = 1L;
@XmlElement(name = "value")
private long timestamp;
- @XmlElement(name = "timestampName")
+ @XmlElement(name = "name")
private String timestampName;
public static final String TimeStampPropName = "timeStamp";
WESP("WESP",141),
ROHC("ROHC",142);
*/
- private static final String regexNumberString = "^[0-9]+$";
+ private static final String regexDecimalString = "^[0-9]{3}$";
+ private static final String regexHexString = "^(0(x|X))[0-9a-fA-F]{2}$";
private String protocolName;
private int protocolNumber;
}
public static short getProtocolNumberShort(String name) {
- if (name.matches(regexNumberString)) {
+ if (name.matches(regexHexString)) {
+ return Short.valueOf(Short.decode(name));
+ }
+ if (name.matches(regexDecimalString)) {
return Short.valueOf(name);
}
for (IPProtocols proto : IPProtocols.values()) {
}
public static int getProtocolNumberInt(String name) {
- if (name.matches(regexNumberString)) {
+ if (name.matches(regexHexString)) {
+ return Integer.valueOf(Integer.decode(name));
+ }
+ if (name.matches(regexDecimalString)) {
return Integer.valueOf(name);
}
for (IPProtocols proto : IPProtocols.values()) {
}
public static byte getProtocolNumberByte(String name) {
- if (name.matches(regexNumberString)) {
+ if (name.matches(regexHexString)) {
+ return Integer.valueOf(Integer.decode(name)).byteValue();
+ }
+ if (name.matches(regexDecimalString)) {
return Integer.valueOf(name).byteValue();
}
for (IPProtocols proto : IPProtocols.values()) {
import ietf-inet-types {prefix inet;}
import ietf-yang-types {prefix yang;}
- import opendaylight-flow-types {prefix flow-types;}
+ import opendaylight-flow-types {prefix flow-types;}
- revision "2013-09-17" {
+ revision "2013-09-18" {
description "Initial revision of group service";
}
- typedef group-ref {
- type instance-identifier;
- }
-
- grouping group-types {
- leaf group-type {
- type enumeration {
- enum group-all;
- enum group_select;
- enum group_indirect;
- enum group_ff;
- }
- }
- }
-
- grouping group {
+ typedef group-ref {
+ type instance-identifier;
+ }
+
+ grouping group-types {
+ leaf group-type {
+ type enumeration {
+ enum group-all;
+ enum group_select;
+ enum group_indirect;
+ enum group_ff;
+ }
+ }
+ }
+
+ grouping group {
uses group-types;
-
- leaf group-id {
+
+ leaf group-id {
type group-ref;
}
-
- container buckets {
- list bucket {
- key "order";
- leaf order {
- type int32;
- }
-
- leaf weight {
- type uint16;
- }
-
- leaf watch_port {
- type uint32;
- }
-
- leaf watch_group {
- type uint32;
- }
-
- container actions {
- list action {
- key "action-order";
- leaf action-order {
- type int32;
- }
+
+ container buckets {
+ list bucket {
+ key "order";
+ leaf order {
+ type int32;
+ }
+
+ leaf weight {
+ type uint16;
+ }
+
+ leaf watch_port {
+ type uint32;
+ }
+
+ leaf watch_group {
+ type uint32;
+ }
+
+ container actions {
+ list action {
+ key "action-order";
+ leaf action-order {
+ type int32;
+ }
+
+ uses flow-types:action;
+ }
+ }
+ }
+ }
+ }
+
+ grouping group-statistics-request {
+ list group-stats {
+ key "group-id";
- uses flow-types:action;
- }
- }
- }
- }
+ leaf group-id {
+ type int32;
+ }
+ }
}
-
- grouping group-statistics-request {
- list group-stats {
- key "group-id";
-
- leaf group-id {
- type int32;
- }
- }
- }
-
- grouping group-statistics {
-
- leaf group-id {
+
+ grouping group-statistics {
+
+ leaf group-id {
type int32;
- }
-
- leaf ref-count {
+ }
+
+ leaf ref-count {
type yang:counter32;
- }
-
- leaf packet-count {
+ }
+
+ leaf packet-count {
type yang:counter64;
}
-
+
leaf byte-count {
type yang:counter64;
}
type yang:counter32;
}
}
-
- container buckets {
- list bucket-counter {
- key "order";
- leaf order {
- type int32;
- }
-
- leaf packet-count {
- type yang:counter64;
- }
-
- leaf byte-count {
- type yang:counter64;
- }
- }
- }
+
+ container buckets {
+ list bucket-counter {
+ key "order";
+ leaf order {
+ type int32;
+ }
+
+ leaf packet-count {
+ type yang:counter64;
+ }
+
+ leaf byte-count {
+ type yang:counter64;
+ }
+ }
+ }
}
- grouping group-statistics-reply {
- list group-stats {
- key "group-stats-order";
- leaf group-stats-order {
- type int32;
- }
-
- uses group-statistics;
- }
- }
-
- grouping group-desc-stats {
- list group-desc-stats {
- key "order-id";
-
- leaf order-id {
- type int32;
- }
-
- uses group;
- }
- }
-
+ grouping group-statistics-reply {
+ list group-stats {
+ key "group-stats-order";
+ leaf group-stats-order {
+ type int32;
+ }
+
+ uses group-statistics;
+ }
+ }
+
+ grouping group-desc-stats {
+ list group-desc-stats {
+ key "order-id";
+
+ leaf order-id {
+ type int32;
+ }
+
+ uses group;
+ }
+ }
+
grouping group-features {
- list group-features {
- key "order";
- leaf order {
- type int32;
- }
-
- uses group-types;
- type capabilities {
- enum select-weight;
- enum select-liveness;
- enum chaining;
- enum chaining-checks;
- }
+ list group-features {
+ key "order";
+ leaf order {
+ type int32;
+ }
+
+ uses group-types;
+ type capabilities {
+ enum select-weight;
+ enum select-liveness;
+ enum chaining;
+ enum chaining-checks;
+ }
- leaf-list max-groups {
- type uint32;
- description "Maximum number of groups for each type";
- max-elements 4;
- }
-
- leaf-list actions {
- type uint32;
- description "Bitmap number OFPAT_* that are supported";
- max-elements 4;
- }
- }
- }
+ leaf-list max-groups {
+ type uint32;
+ description "Maximum number of groups for each type";
+ max-elements 4;
+ }
+
+ leaf-list actions {
+ type uint32;
+ description "Bitmap number OFPAT_* that are supported";
+ max-elements 4;
+ }
+ }
+ }
}
\ No newline at end of file
--- /dev/null
+module opendaylight-meter-types {
+ namespace "urn:opendaylight:meter:types";
+ prefix meter;
+
+ import ietf-inet-types {prefix inet;}
+ import ietf-yang-types {prefix yang;}
+
+
+ revision "2013-09-18" {
+ description "Initial revision of meter service";
+ }
+
+ typedef meter-ref {
+ type instance-identifier;
+ }
+
+ grouping meter-flags {
+ leaf flags {
+ type enumeration {
+ enum meter-kbps;
+ enum meter_pktps;
+ enum meter_burst;
+ enum meter_stats;
+ }
+ }
+ }
+
+ grouping meter-band-type {
+ leaf flags {
+ type enumeration {
+ enum ofpmbt-drop;
+ enum ofpmbt-dscp-remark;
+ enum ofpmbt-experimenter;
+ }
+ }
+ }
+
+ grouping band-type {
+ choice band-type {
+ case drop {
+ leaf rate {
+ type uint32;
+ }
+
+ leaf burst-size {
+ type uint32;
+ }
+ }
+
+ case dscp-remark {
+ leaf rate {
+ type uint32;
+ }
+
+ leaf burst-size {
+ type uint32;
+ }
+
+ leaf perc_level {
+ type uint8;
+ }
+ }
+
+ case experimenter {
+ leaf rate {
+ type uint32;
+ }
+
+ leaf burst-size {
+ type uint32;
+ }
+
+ leaf experimenter {
+ type uint32;
+ }
+ }
+ }
+ }
+
+ grouping meter {
+
+ uses meter-flags;
+
+ leaf meter-id {
+ type meter-ref;
+ }
+
+ container meter-band-headers {
+ list meter-band-header {
+ key "order";
+ leaf order {
+ type int32;
+ }
+
+ container meter-band-types {
+ uses meter-band-type;
+ }
+
+ leaf burst-size {
+ type uint32;
+ }
+ uses band-type;
+ }
+ }
+ }
+
+ grouping meter-stats-config-request {
+ list meter-stats {
+ key "meter-id";
+
+ leaf meter-id {
+ type int32;
+ }
+ }
+ }
+
+ grouping meter-statistics {
+
+ leaf meter-id {
+ type int32;
+ }
+
+ leaf flow-count {
+ type yang:counter32;
+ }
+
+ leaf packet-in-count {
+ type yang:counter64;
+ }
+
+ leaf byte-in-count {
+ type yang:counter64;
+ }
+
+ container duration {
+ leaf second {
+ type yang:counter32;
+ }
+ leaf nanosecond {
+ type yang:counter32;
+ }
+ }
+
+ container meter-band-stats {
+ list band-stat {
+ key "order";
+ leaf order {
+ type int32;
+ }
+
+ leaf packet-band-count {
+ type yang:counter64;
+ }
+
+ leaf byte-band-count {
+ type yang:counter64;
+ }
+ }
+ }
+ }
+
+ grouping meter-statistics-reply {
+ list meter-stats {
+ key "meter-stats-order";
+ leaf meter-stats-order {
+ type int32;
+ }
+ uses meter-statistics;
+ }
+ }
+
+ grouping meter-config-stats {
+ list meter-config-stats {
+ key "meter-config-order";
+
+ leaf meter-config-order {
+ type int32;
+ }
+
+ uses meter;
+ }
+ }
+
+ grouping meter-features {
+ list meter-features {
+ key "meter-feature-order";
+
+ leaf meter-feature-order {
+ type yang:counter32;
+ }
+
+ leaf max_meter {
+ type yang:counter32;
+ }
+
+ leaf band_types {
+ type yang:counter32;
+ }
+
+ leaf capabilities {
+ type yang:counter32;
+ }
+
+ leaf max_bands {
+ type uint8;
+ }
+
+ leaf max_color {
+ type uint8;
+ }
+ }
+ }
+}
\ No newline at end of file
import ietf-inet-types {prefix inet;}
import opendaylight-group-types {prefix group-type;}
- revision "2013-09-17" {
+ revision "2013-09-18" {
description "Initial revision of group service";
}
-
+
grouping node-group {
leaf node {
type inv:node-ref;
--- /dev/null
+module sal-meter {
+ namespace "urn:opendaylight:meter:service";
+ prefix meter;
+
+ import yang-ext {prefix ext;}
+ import opendaylight-inventory {prefix inv;}
+ import ietf-inet-types {prefix inet;}
+ import opendaylight-meter-types {prefix meter-type;}
+
+ revision "2013-09-18" {
+ description "Initial revision of meter service";
+ }
+
+ metering node-meter {
+ leaf node {
+ type inv:node-ref;
+ }
+
+ uses meter-type:meter;
+ }
+
+ /** Base configuration structure **/
+ metering meter-update {
+ container original-meter {
+ uses meter-type:meter;
+ }
+ container updated-meter {
+ uses meter-type:meter;
+ }
+ }
+
+ rpc add-meter {
+ input {
+ uses node-meter;
+ }
+ }
+
+ rpc remove-meter {
+ input {
+ uses node-meter;
+ }
+ }
+
+ rpc update-meter {
+ input {
+ uses node-meter;
+ }
+ }
+}
\ No newline at end of file