import org.opendaylight.affinity.affinity.IAffinityManagerAware;
import org.opendaylight.controller.hosttracker.IfIptoHost;
+import org.opendaylight.controller.hosttracker.IfNewHostNotify;
import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;
import org.opendaylight.controller.switchmanager.ISwitchManager;
import org.opendaylight.affinity.l2agent.IfL2Agent;
import org.slf4j.LoggerFactory;
/**
- * The class caches latest network nodes statistics as notified by reader
- * services and provides API to retrieve them.
+ * Affinity configuration.
*/
-public class AffinityManagerImpl implements IAffinityManager, IConfigurationContainerAware, IObjectReader, ICacheUpdateAware<Long, String> {
+public class AffinityManagerImpl implements IAffinityManager, IfNewHostNotify,
+ IConfigurationContainerAware, IObjectReader, ICacheUpdateAware<Long, String> {
private static final Logger log = LoggerFactory.getLogger(AffinityManagerImpl.class);
private static String ROOT = GlobalConstants.STARTUPHOME.toString();
return hostPairList;
}
+ private void notifyHostUpdate(HostNodeConnector host, boolean added) {
+ if (host == null) {
+ return;
+ }
+ log.info("Host update received (new = {}).", added);
+ }
+
+ @Override
+ public void notifyHTClient(HostNodeConnector host) {
+ notifyHostUpdate(host, true);
+ }
+
+ @Override
+ public void notifyHTClientHostRemoved(HostNodeConnector host) {
+ notifyHostUpdate(host, false);
+ }
+
+
@Override
public Status saveConfiguration() {
return saveAffinityConfig();
--- /dev/null
+module affinity-config-all {
+ 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;}
+
+ revision "2013-09-25" {
+ description "Initial revision of affinity model to be reviewed";
+ }
+
+
+ //**************************************************
+ // Stationary location -- switch + port, includes physical or virtual
+ // ports for example within a hypervisor representing a virtual switch.
+ //**************************************************
+ grouping affinity-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 have a corresponding
+ // endpoint on the network, for example, for traffic from a set of
+ // external addresses (north-south traffic in a data center), the source
+ // IP address domain is not required to map exactly to endpoints or node
+ // connectors on the network. We assume that there will be a resolution
+ // service that resolves one of these into an endpoint, when the address
+ // is present on the network.
+ //**************************************************
+ grouping affinity-address-domain {
+ leaf id {
+ type string;
+ }
+ // Address is either an IP address, IP prefix, IP range, or
+ // MAC address, or MAC range. Address may also be a transport
+ // protocol layer address.
+
+ leaf address {
+ description "Mac or Inet address";
+ type union {
+ type inet:ip-address;
+ type inet:ip-prefix; // tbd
+ type inet:ip-range; // tbd
+ type yang:vlanid; // tbd
+ type yang:mac-address;
+ type yang:mac-address-range;
+ type yang:tp-address; // tbd
+ }
+ }
+ }
+
+ typedef affinity-group-ref {
+ type instance-identifier;
+ }
+
+ typedef affinity-link-ref {
+ type instance-identifier;
+ }
+
+ typedef network-service-chain-ref {
+ type instance-identifier;
+ }
+
+ //**************************************************
+ // Affinity group
+ //**************************************************
+ grouping affinity-group {
+ leaf id {
+ type string;
+ }
+ list affinity-identifiers {
+ key id;
+ uses affinity-identifier;
+ }
+ }
+
+ //**************************************************
+ // 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 affinity-link {
+ leaf id {
+ type string;
+ }
+ leaf from-affinity-group {
+ type affinity-group-ref;
+ }
+ leaf to-affinity-group {
+ type affinity-group-ref;
+ }
+ container attribute {
+ uses affinity-attribute;
+ }
+ }
+
+ //**************************************************
+ // Affinity attribute. Each is expanded in their own grouping construct below.
+ //**************************************************
+ grouping affinity-attribute {
+ leaf id {
+ type string;
+ }
+ choice attribute-type {
+ description "affinity attribute";
+ // Apply access control to selected flows.
+ case access-control {
+ leaf access-control {
+ type values {
+ enum permit;
+ enum deny;
+ }
+ }
+ }
+
+ // Apply waypoint routing to the selected flows and send it through service chain.
+ case network-service-chain {
+ leaf network-service-chain {
+ type network-service-chain-ref;
+ }
+ }
+ }
+ }
+
+ //**************************************************
+ // Network service chain configuration.
+ //**************************************************
+ 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 affinity-config {
+ list affinity-group {
+ key id;
+ ext:context-instance "affinity-group-context";
+ uses affinity-group;
+ }
+ list affinity-link {
+ key id;
+ ext:context-instance "affinity-link-context";
+ uses affinity-link;
+ }
+ }
+
+ //******************************
+ // RPCs to create affinity groups, add endpoints and address domains.
+ //******************************
+ rpc create-affinity-group {
+ input {
+ uses affinity-group;
+ }
+ output {
+ leaf status {
+ type string;
+ }
+ }
+ }
+
+ rpc add-affinity-endpoint {
+ input {
+ leaf affinity-endpoint {
+ type inv:node-connector-id;
+ }
+ }
+ output {
+ leaf status {
+ type string;
+ }
+ }
+ }
+
+ rpc add-affinity-domain {
+ input {
+ leaf affinity-domain {
+ type affinity-domain;
+ }
+ }
+ output {
+ leaf status {
+ type string;
+ }
+ }
+ }
+
+ rpc get-affinity-groups {
+ output {
+ list affinity-group {
+ key id;
+ uses affinity-group;
+ }
+ }
+ }
+ rpc get-affinity-links;
+ rpc get-affinity-group;
+ rpc get-affinity-link;
+
+ rpc get-stats-per-affinity-link;
+
+ //**************************************************
+ // Notifications
+ //**************************************************
+ notification new-affinity-endpoint;
+ notification new-affinity-domain;
+ notification modify-affinity-attribute;
+}
+
+
+++ /dev/null
-module affinity-topology-all {
- 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;}
-
- revision "2013-09-25" {
- description "Initial revision of affinity model to be reviewed";
- }
-
- typedef affinity-group-ref {
- type instance-identifier;
- }
-
- typedef affinity-link-ref {
- type instance-identifier;
- }
-
- grouping affinity-group {
- leaf id {
- type string;
- }
- list affinity-identifiers {
- key id;
- uses affinity-identifier;
- }
- }
-
- grouping affinity-link {
- leaf id {
- type string;
- }
- leaf from-affinity-group {
- type affinity-group-ref;
- }
- leaf to-affinity-group {
- type affinity-group-ref;
- }
- leaf attribute {
- type string;
- }
- }
-
- grouping affinity-identifier {
- leaf id {
- type string;
- }
- // Address is either an IP address, IP prefix, or MAC address.
- leaf address {
- description "Mac or Inet address";
- type union {
- type inet:ip-address;
- type inet:ip-prefix;
- type yang:mac-address;
- }
- }
- }
-
- // Various types of affinity topologies. Used in union 'affinity-attribute'.
-
- // Isolate flows according to certain constraints.
- grouping isolate-path {
- leaf max-flows-per-link {
- type uint16;
- }
- }
-
- // Route through shortest path per l2/l3 semantics.
- grouping shortest-path {
- leaf max-flows-per-link {
- type uint16;
- }
- }
-
- // oversubscription path
- grouping oversubscription-path {
- leaf max-link-oversubscription-percent {
- type uint16;
- }
- }
-
- // Affinity attribute.
- grouping affinity-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 oversubscription-path {
- container oversubscription-path {
- uses oversubscription-path;
- }
- }
- }
- }
-
- identity affinity-group-context {
- description "Identity used to mark affinity-group context";
- }
- identity affinity-link-context {
- description "Identity used to mark affinity-link context";
- }
-
- container affinity-topology {
- list affinity-group {
- key id;
- ext:context-instance "affinity-group-context";
- uses affinity-group;
- }
- list affinity-link {
- key id;
- ext:context-instance "affinity-link-context";
- uses affinity-link;
- }
- }
-
- rpc create-affinity-group {
- input {
- uses affinity-group;
- }
- }
- rpc add-affinity-element {
- input {
- container element {
- uses affinity-identifier;
- }
- leaf group {
- type affinity-group-ref;
- }
- }
- }
-
- rpc get-affinity-groups {
- output {
- list affinity-group {
- key id;
- uses affinity-group;
- }
- }
- }
- rpc get-affinity-links {
-
- }
- rpc get-affinity-group {
-
- }
- rpc get-affinity-link {
-
- }
-}
-
-