Yang will provide just the northbound interface (rpcs and notifications).
The state maintained by AffinityManager will remain unchanged.
Builds fine.
Signed-off-by: Suchi Raman <suchi.raman@plexxi.com>
<configuration>
<instructions>
<Import-Package>
+ org.opendaylight.controller.sal.common.util,
+ org.opendaylight.yang.gen.v1.affinity.rev130925,
+ org.opendaylight.yang.gen.v1.affinity.rev130925.addendpoint.input,
+ org.opendaylight.yang.gen.v1.affinity.rev130925.host_endpoint,
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924,
+ org.opendaylight.yangtools.yang.common,
org.opendaylight.affinity.affinity,
org.opendaylight.affinity.l2agent,
org.opendaylight.affinity.nfchainagent,
<artifactId>sal</artifactId>
<version>0.5.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-common-util</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>forwardingrulesmanager</artifactId>
<artifactId>l2agent</artifactId>
<version>0.4.1-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.affinity</groupId>
+ <artifactId>model</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.affinity</groupId>
<artifactId>nfchainagent</artifactId>
<version>0.4.1-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <artifactId>ietf-inet-types</artifactId>
+ <version>2010.09.24-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
package org.opendaylight.affinity.affinity.internal;
+
+import org.opendaylight.yang.gen.v1.affinity.rev130925.AffinityService;
+import org.opendaylight.yang.gen.v1.affinity.rev130925.HostEndpoint;
+import org.opendaylight.yang.gen.v1.affinity.rev130925.host_endpoint.L2address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
+
+import org.opendaylight.yang.gen.v1.affinity.rev130925.CreategroupInput;
+import org.opendaylight.yang.gen.v1.affinity.rev130925.AddendpointInput;
+
+import java.util.concurrent.Future;
+import org.opendaylight.controller.sal.common.util.Futures;
+import org.opendaylight.controller.sal.common.util.Rpcs;
+
+import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
/**
* Affinity configuration.
*/
-public class AffinityManagerImpl implements IAffinityManager, IfNewHostNotify,
+public class AffinityManagerImpl implements IAffinityManager, AffinityService, IfNewHostNotify,
IConfigurationContainerAware, IObjectReader, ICacheUpdateAware<Long, String> {
private static final Logger log = LoggerFactory.getLogger(AffinityManagerImpl.class);
return nfchainagent.removeNfchain(nfccname);
}
+
+ /* public methods for the yang service. */
+ public Future<RpcResult<Void>> creategroup(CreategroupInput input) {
+ AffinityGroup ag1 = new AffinityGroup(input.getName());
+
+ /* Correctly translate between status fields. */
+ Status ret = addAffinityGroup(ag1);
+ RpcResult<Void> result = Rpcs.<Void> getRpcResult(true, null, Collections.<RpcError> emptySet());
+ return Futures.immediateFuture(result);
+ }
+
+ public Future<RpcResult<Void>> addendpoint(AddendpointInput input) {
+ AffinityGroup ag = getAffinityGroup(input.getGroupname());
+ RpcResult<Void> result;
+
+ if (ag != null) {
+ HostEndpoint endpoint = input.getEndpoint();
+ L2address l2address = endpoint.getL2address();
+ Ipv4Prefix l3address = endpoint.getL3address();
+
+ /* ag.addL2address(); */
+ ag.addInetMask(l3address.toString());
+ result = Rpcs.<Void> getRpcResult(true, null, Collections.<RpcError> emptySet());
+ } else {
+ result = Rpcs.<Void> getRpcResult(false, null, Collections.<RpcError> emptySet());
+ }
+ return Futures.immediateFuture(result);
+ }
}
<groupId>org.opendaylight.affinity</groupId>
<artifactId>model</artifactId>
<version>1.0-SNAPSHOT</version>
- <packaging>jar</packaging>
+ <packaging>bundle</packaging>
<properties>
<yang.version>0.5.9-SNAPSHOT</yang.version>
+++ /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;
- }
- }
-
- typedef level {
- type enumeration {
- enum high;
- enum medium;
- enum low;
- }
- }
-
- //**************************************************
- // 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;
- }
- }
- // Assign a priority
- case set-priority {
- leaf priority {
- type level;
- }
- }
- }
- }
-
-
- // 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;
-
-}
-
-
--- /dev/null
+module affinity {
+ namespace "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.
+ //**************************************************
+ grouping switch_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)
+ //**************************************************
+
+ // xxx -- Includes access port on a hypervisor ovswitch to which a VM is connected.
+ grouping host_endpoint {
+ container l2address {
+ leaf vlan {
+ type l2types:vlan-id;
+ }
+ leaf mac {
+ type yang:mac-address;
+ }
+ }
+
+ // l3-domain-address is IPv4 prefix
+ leaf l3address {
+ type inet:ipv4-prefix;
+ }
+ }
+
+ typedef group-ref {
+ type instance-identifier;
+ }
+
+ typedef link-ref {
+ type instance-identifier;
+ }
+
+ //**************************************************
+ // Affinity group
+ //**************************************************
+ grouping group {
+ leaf id {
+ type string;
+ }
+ list endpoints {
+ key id;
+ uses host_endpoint;
+ }
+ }
+
+ //**************************************************
+ // 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;
+ }
+ }
+
+ //**************************************************
+ // Affinity attribute. Each is expanded in their own grouping construct below.
+ //**************************************************
+ // Various types of affinity topologies. Used in union 'attribute'.
+
+ // Affinity attribute. xxx add case statements for each type later.
+ grouping attribute {
+ leaf attribute-type {
+ description "affinity attribute";
+ type string;
+ }
+ }
+
+ // 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 creategroup {
+ input {
+ leaf name {
+ type string;
+ }
+ }
+ }
+
+ rpc addendpoint {
+ input {
+ leaf groupname {
+ type string;
+ }
+ container endpoint {
+ uses host_endpoint;
+ }
+ }
+ }
+
+/*
+ rpc getgroups {
+ 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;
+*/
+}
+
+