org.opendaylight.controller.sal.utils,
org.opendaylight.controller.sal.packet,
org.opendaylight.controller.sal.inventory,
+ org.opendaylight.controller.sal.flowprogrammer,
!org.codehaus.enunciate.jaxrs
</Import-Package>
</instructions>
import org.opendaylight.controller.sal.core.NodeConnector;
import org.opendaylight.controller.sal.core.Property;
import org.opendaylight.controller.sal.utils.Status;
+import org.opendaylight.controller.sal.flowprogrammer.Flow;
import org.opendaylight.affinity.affinity.AffinityLink;
public List<Host> getAllElementsByHost(AffinityGroup ag);
public List<Entry<Host, Host>> getAllFlowsByHost(AffinityLink al);
public List<Entry<AffinityIdentifier, AffinityIdentifier>> getAllFlowsByAffinityIdentifier(AffinityLink al);
+
+ public Status addFlowRulesForRedirect(AffinityLink al) throws Exception;
+ public Status pushFlowRule(Flow flow);
}
org.opendaylight.controller.sal.utils,
org.opendaylight.controller.sal.packet,
org.opendaylight.controller.sal.inventory,
+ org.opendaylight.controller.tutorial_L2_forwarding,
+ org.opendaylight.controller.sal.flowprogrammer,
+ org.opendaylight.controller.sal.match,
+ org.opendaylight.controller.sal.action,
+ org.opendaylight.controller.switchmanager,
org.slf4j,
org.apache.felix.dm,
org.eclipse.osgi.framework.console,
<artifactId>affinity</artifactId>
<version>0.4.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>tutorial_L2_forwarding</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
import org.opendaylight.affinity.affinity.IAffinityManagerAware;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerService;
+import org.opendaylight.controller.tutorial_L2_forwarding.TutorialL2Forwarding;
+import org.opendaylight.controller.switchmanager.ISwitchManager;
/**
* AffinityManager Bundle Activator
IClusterContainerServices.class).setCallbacks(
"setClusterContainerService",
"unsetClusterContainerService").setRequired(true));
+ c.add(createContainerServiceDependency(containerName).setService(
+ IFlowProgrammerService.class).setCallbacks(
+ "setFlowProgrammerService", "unsetFlowProgrammerService")
+ .setRequired(true));
+ c.add(createContainerServiceDependency(containerName).setService(
+ TutorialL2Forwarding.class).setCallbacks(
+ "setL2AgentService", "unsetL2AgentService")
+ .setRequired(true));
+ c.add(createContainerServiceDependency(containerName).setService(
+ ISwitchManager.class).setCallbacks(
+ "setSwitchManager", "unsetSwitchManager")
+ .setRequired(true));
}
}
}
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
+import java.net.UnknownHostException;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import org.opendaylight.controller.sal.core.NodeTable;
import org.opendaylight.controller.sal.core.Property;
import org.opendaylight.controller.sal.core.UpdateType;
+import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerService;
import org.opendaylight.controller.sal.flowprogrammer.Flow;
+import org.opendaylight.controller.sal.match.Match;
+import org.opendaylight.controller.sal.match.MatchType;
+import org.opendaylight.controller.sal.match.MatchField;
+import org.opendaylight.controller.sal.action.Action;
+import org.opendaylight.controller.sal.action.Output;
+
import org.opendaylight.controller.sal.reader.FlowOnNode;
import org.opendaylight.controller.sal.reader.IReadService;
import org.opendaylight.controller.sal.reader.IReadServiceListener;
import org.opendaylight.affinity.affinity.AffinityIdentifier;
import org.opendaylight.affinity.affinity.IAffinityManager;
import org.opendaylight.affinity.affinity.IAffinityManagerAware;
+
+import org.opendaylight.controller.hosttracker.IfIptoHost;
+import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;
+import org.opendaylight.controller.switchmanager.ISwitchManager;
+import org.opendaylight.controller.tutorial_L2_forwarding.TutorialL2Forwarding;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final String SAVE = "Save";
private String affinityLinkFileName = null;
private String affinityGroupFileName = null;
+ private IFlowProgrammerService fps = null;
+ private ISwitchManager switchManager = null;
+ private TutorialL2Forwarding l2agent = null;
private ConcurrentMap<String, AffinityGroup> affinityGroupList;
private ConcurrentMap<String, AffinityLink> affinityLinkList;
this.hostTracker = null;
}
}
+ public void setFlowProgrammerService(IFlowProgrammerService s)
+ {
+ this.fps = s;
+ }
+
+ public void unsetFlowProgrammerService(IFlowProgrammerService s) {
+ if (this.fps == s) {
+ this.fps = null;
+ }
+ }
+ public void setL2Agent(TutorialL2Forwarding s)
+ {
+ this.l2agent = s;
+ }
+
+ public void unsetL2Agent(TutorialL2Forwarding s) {
+ if (this.l2agent == s) {
+ this.l2agent = null;
+ }
+ }
+
+ /*
+ public void setForwardingRulesManager(
+ IForwardingRulesManager forwardingRulesManager) {
+ this.ruleManager = forwardingRulesManager;
+ }
+ public void unsetForwardingRulesManager(
+ IForwardingRulesManager forwardingRulesManager) {
+ if (this.ruleManager == forwardingRulesManager) {
+ this.ruleManager = null;
+ }
+ }
+ */
+
public Status addAffinityLink(AffinityLink al) {
boolean putNewLink = false;
return new Status(StatusCode.SUCCESS);
}
+
+ /**
+ * Fetch all node connectors. Each switch port will receive a flow rule. Do not stop on error.
+ */
+ public Status pushFlowRule(Flow flow) {
+ /* Get all node connectors. */
+ Set<Node> nodes = switchManager.getNodes();
+ Status success = new Status(StatusCode.SUCCESS);
+ Status notfound = new Status(StatusCode.NOTFOUND);
+
+ if (nodes == null) {
+ log.debug("No nodes in network.");
+ return success;
+ }
+ for (Node node: nodes) {
+ Set<NodeConnector> ncs = switchManager.getNodeConnectors(node);
+ if (ncs == null) {
+ continue;
+ }
+ Status status = fps.addFlow(node, flow);
+ if (!status.isSuccess()) {
+ log.debug("Error during addFlow: {} on {}. The failure is: {}",
+ flow, node, status.getDescription());
+ }
+ }
+ return success;
+ }
+
+ /**
+ * add flow rules for each node connector.
+ */
+ public Status addFlowRulesForRedirect(AffinityLink al) throws Exception {
+ Match match = new Match();
+ List<Action> actions = new ArrayList<Action>();
+
+ InetAddress address1, address2;
+ InetAddress mask;
+ mask = InetAddress.getByName("255.255.255.255");
+
+ Flow f = new Flow(match, actions);
+
+ List<Entry<Host,Host>> hostPairList= getAllFlowsByHost(al);
+ for (Entry<Host,Host> hostPair : hostPairList) {
+ /* Create a match for each host pair in the affinity link. */
+
+ Host host1 = hostPair.getKey();
+ Host host2 = hostPair.getValue();
+ address1 = host1.getNetworkAddress();
+ address2 = host2.getNetworkAddress();
+
+ match.setField(MatchType.NW_SRC, address1, mask);
+ match.setField(MatchType.NW_DST, address2, mask);
+
+
+ /* For each end point, discover the mac address of the
+ * host. Then lookup the L2 table to find the port to send
+ * this flow along. Program the flow. */
+
+ byte [] mac = ((HostNodeConnector) host1).getDataLayerAddressBytes();
+ NodeConnector dst_connector = l2agent.lookupMacAddress(mac);
+ actions.add(new Output(dst_connector));
+ }
+ return new Status(StatusCode.SUCCESS);
+ }
+
public Status removeAffinityLink(String name) {
affinityLinkList.remove(name);
return new Status(StatusCode.SUCCESS);
<packaging>jar</packaging>
<properties>
- <yang.version>0.5.7-SNAPSHOT</yang.version>
+ <yang.version>0.5.8-SNAPSHOT</yang.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>maven-sal-api-gen-plugin</artifactId>
- <version>0.5.7-SNAPSHOT</version>
+ <version>0.5.8-SNAPSHOT</version>
<type>jar</type>
</dependency>
</dependencies>
</build>
<dependencies>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-binding</artifactId>
- <version>${yang.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-common</artifactId>
- <version>${yang.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools.model</groupId>
- <artifactId>ietf-inet-types</artifactId>
- <version>2010.09.24-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools.model</groupId>
- <artifactId>ietf-yang-types</artifactId>
- <version>2010.09.24-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-ext</artifactId>
- <version>2013.09.07-SNAPSHOT</version>
- </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.model</groupId>
+ <artifactId>model-inventory</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-binding</artifactId>
+ <version>${yang.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-common</artifactId>
+ <version>${yang.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <artifactId>ietf-inet-types</artifactId>
+ <version>2010.09.24-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <artifactId>ietf-yang-types</artifactId>
+ <version>2010.09.24-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-ext</artifactId>
+ <version>2013.09.07-SNAPSHOT</version>
+ </dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
import ietf-inet-types { prefix inet; }
import ietf-yang-types { prefix yang; }
import yang-ext { prefix ext; }
-// import inventory {prefix inv;}
+ import opendaylight-inventory {prefix inv;}
- revision "2013-09-16" {
+ revision "2013-09-25" {
description "Initial revision of affinity model to be reviewed";
}
+++ /dev/null
-module affinity-topology {
- namespace "urn:opendaylight:affinity";
- prefix affinity;
-
- import ietf-inet-types { prefix inet; }
- import ietf-yang-types { prefix yang; }
- import yang-ext { prefix ext; }
-
- revision "2013-09-16" {
- description "Initial revision of affinity model";
- }
-
- typedef affinity-group-ref {
- type instance-identifier;
- }
-
- typedef affinity-link-ref {
- type instance-identifier;
- }
-
- grouping affinity-group {
- leaf id {
- type string;
- }
- list affinity-identifier {
- key id;
- leaf id {
- type string;
- }
- leaf address {
- description "Mac or Inet address";
- type union {
- type inet:ip-address;
- type yang:mac-address;
- }
- }
- }
- }
-
- 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;
- }
- }
-
- 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 get-affinity-groups {
- output {
- list affinity-group {
- key id;
- uses affinity-group;
- }
- }
- }
- rpc get-affinity-links {
-
- }
- rpc get-affinity-group {
-
- }
- rpc get-affinity-link {
-
- }
-}
-
-
</properties>
<modules>
- <module>affinity/api</module>
-<!-- <module>affinity/yang</module> -->
+ <module>affinity/api</module>
+ <module>affinity/yang</module>
<module>affinity/implementation</module>
<module>affinity/integrationtest</module>
<module>affinity/northbound</module>