--- /dev/null
+module affinity-config {
+ namespace "urn:opendaylight:affinity";
+ prefix affinity;
+
+ import ietf-inet-types { prefix inet; }
+ import ietf-yang-types { prefix yang; }
+ import yang-ext { prefix ext; }
+ import opendaylight-inventory {prefix inv;}
+ import opendaylight-l2-types { prefix l2types; }
+
+ revision "2013-09-25" {
+ description "Initial revision of affinity model to be reviewed";
+ }
+
+
+ //**************************************************
+ // Switch + port. Access port on a physical switch.
+ // Includes access port on a hypervisor ovswitch to which a VM is connected.
+ //**************************************************
+ grouping endpoint {
+ leaf switch-port {
+ type inv:node-connector-id;
+ }
+ }
+
+ //**************************************************
+ // Affinity address domain: This represents a domain (i.e, set) of one or
+ // more addresses. An affinity address may not always have a corresponding
+ // endpoint on the network, for example, an address domain representing
+ // external addresses, or north-south traffic in a data center). Here the
+ // IP address domain representing such external addresses does not map to
+ // endpoints or node connectors on the network.
+ //
+ // Affinity address domains specify one or more of the following:
+ // layer 2 address (vlan + mac range)
+ // layer 3 address (IP prefix)
+ //**************************************************
+
+ grouping address-domain {
+ // l2-domain-address is vlan + MAC address range
+ container l2-address {
+ leaf vlan-id {
+ type l2types:vlan-id;
+ }
+ container mac-address-range {
+ uses mac-address-range;
+ }
+ }
+
+ // l3-domain-address is IPv4 prefix
+ leaf l3-address {
+ type inet:ipv4-prefix;
+ }
+ }
+
+ grouping mac-address-range {
+ leaf start-address {
+ type yang:mac-address;
+ }
+ leaf end-address {
+ type yang:mac-address;
+ }
+ }
+
+ typedef group-ref {
+ type instance-identifier;
+ }
+
+ typedef link-ref {
+ type instance-identifier;
+ }
+
+ grouping element {
+ leaf id {
+ type string;
+ }
+ choice element {
+ description "affinity element";
+ case endpoint {
+ uses endpoint;
+ }
+
+ case address-domain {
+ uses address-domain;
+ }
+ }
+ }
+ //**************************************************
+ // Affinity group
+ //**************************************************
+ grouping group {
+ leaf id {
+ type string;
+ }
+ list element {
+ key id;
+ uses element;
+ }
+ }
+
+ //**************************************************
+ // Affinity link connects one group (from group) to another (to
+ // group). It represents a set of flows that start from the source group
+ // and end in the destination group. An affinity link has attributes
+ // (policies) attached to it that represent how these flows must be
+ // handled. An affinity link also has directionality associated with
+ // it. A bidirectional affinity link is equivalent to two unidirectional
+ // affinity links, one in each direction.
+ //**************************************************
+ grouping link {
+ leaf id {
+ type string;
+ }
+ leaf from-group {
+ type group-ref;
+ }
+ leaf to-group {
+ type group-ref;
+ }
+ container attribute {
+ uses attribute;
+ }
+ }
+
+ grouping access-control-rule {
+ leaf proto {
+ type string; // "tcp" or "udp"
+ }
+ leaf port-number {
+ type inet:port-number;
+ }
+ // permit flag - false here means no access to be allowed for
+ // flows in the affinity link matching the traffic spec.
+ leaf permit {
+ type boolean;
+ }
+ }
+
+ grouping access-control {
+ list rules {
+ key id;
+ uses access-control-rule;
+ }
+ }
+
+ //**************************************************
+ // Affinity attribute. Each is expanded in their own grouping construct below.
+ //**************************************************
+ // Various types of affinity topologies. Used in union 'attribute'.
+
+ // Affinity attribute.
+ grouping attribute {
+ leaf id {
+ type string;
+ }
+ choice attribute-type {
+ description "affinity attribute";
+ case isolate-path {
+ container isolate-path {
+ uses isolate-path;
+ }
+ }
+ case shortest-path {
+ container shortest-path {
+ uses shortest-path;
+ }
+ }
+ case bandwidth-optimized-path {
+ container bandwidth-optimized-path {
+ uses bandwidth-optimized-path;
+ }
+ }
+ // Redirect through service chain.
+ case redirect-path {
+ leaf redirect-path {
+ type network-service-chain-ref;
+ }
+ }
+ // Apply access control to selected flows.
+ case access-control {
+ container access-control {
+ uses access-control;
+ }
+ }
+ }
+ }
+
+
+ // Isolate flows according to certain constraints.
+ grouping isolate-path {
+ leaf max-flows-per-link {
+ type uint16;
+ }
+ leaf strict {
+ type boolean;
+ }
+ }
+
+ // Route through shortest path
+ grouping shortest-path {
+ leaf max-flows-per-link {
+ type uint16;
+ }
+ leaf strict {
+ type boolean;
+ }
+ }
+
+ // bandwidth optimized path
+ grouping bandwidth-optimized-path {
+ leaf max-link-oversubscription-percent {
+ type uint16;
+ }
+ leaf strict {
+ type boolean;
+ }
+ }
+
+ //**************************************************
+ // Network service chain configuration.
+ //**************************************************
+ typedef network-service-chain-ref {
+ type instance-identifier;
+ }
+
+ grouping network-service-chain {
+ leaf id {
+ type string;
+ }
+ list service-chain {
+ key id;
+ uses network-service-function;
+ }
+ }
+
+ //**************************************************
+ // Network-service-function represented by one of the following
+ // types of addresses.
+ //**************************************************
+ grouping network-service-function {
+ leaf id {
+ type string;
+ }
+ // Address is either an IP address, MAC address, or switch/port.
+ leaf location {
+ description "Mac or Inet address";
+ type union {
+ type inv:node-connector-id;
+ type yang:mac-address;
+ type inet:ip-address;
+ }
+ }
+ }
+
+ // Main container that represents the complete set of affinity
+ // groups and links. Each set is represented as a YANG list with 'id'
+ // as the key. List contains affinity group and affinity link objects
+ // defined above.
+ container config {
+ list group {
+ key id;
+ ext:context-instance "group-context";
+ uses group;
+ }
+ list link {
+ key id;
+ ext:context-instance "link-context";
+ uses link;
+ }
+ }
+
+ //******************************
+ // RPCs to create affinity groups, add endpoints and address domains.
+ //******************************
+ rpc create-group {
+ input {
+ uses group;
+ }
+ output {
+ leaf status {
+ type string;
+ }
+ }
+ }
+
+ rpc add-endpoint {
+ input {
+ leaf endpoint {
+ type inv:node-connector-id;
+ }
+ }
+ output {
+ leaf status {
+ type string;
+ }
+ }
+ }
+
+ rpc add-domain {
+ input {
+ container domain {
+ uses address-domain;
+ }
+ }
+ output {
+ leaf status {
+ type string;
+ }
+ }
+ }
+
+ rpc get-groups {
+ output {
+ list group {
+ key id;
+ uses group;
+ }
+ }
+ }
+ rpc get-links;
+ rpc get-group;
+ rpc get-link;
+
+ rpc get-stats-per-link;
+
+ //**************************************************
+ // Notifications
+ //**************************************************
+ notification new-endpoint;
+ notification new-domain;
+ notification modify-attribute;
+
+}
+
+