Added a couple of Northbound API functions. More to come. 40/1040/1
authorSuchi Raman <suchi.raman@plexxi.com>
Thu, 29 Aug 2013 11:11:04 +0000 (07:11 -0400)
committerSuchi Raman <suchi.raman@plexxi.com>
Thu, 29 Aug 2013 11:11:04 +0000 (07:11 -0400)
Signed-off-by: Suchi Raman <suchi.raman@plexxi.com>
affinity/affinity-api.txt
affinity/api/META-INF/MANIFEST.MF
affinity/implementation/META-INF/MANIFEST.MF
affinity/northbound/src/main/java/org/opendaylight/controller/affinity/northbound/AffinityGroupList.java [new file with mode: 0644]
affinity/northbound/src/main/java/org/opendaylight/controller/affinity/northbound/AffinityLinkList.java [moved from affinity/northbound/src/main/java/org/opendaylight/controller/affinity/northbound/Affinities.java with 60% similarity]
affinity/northbound/src/main/java/org/opendaylight/controller/affinity/northbound/AffinityNorthbound.java
affinity/northbound/src/main/resources/META-INF/MANIFEST.MF

index b13ab0cd5a63220e150a261b74e5d8cbe906dccd..bbac202a938de254afa4a4dda9ea95f351c584cb 100644 (file)
@@ -4,6 +4,8 @@ Create an affinity group:
 Fetch an affinity group given its name: 
 /affinity/nb/v2/{container}/group/{name}
 
+======
+
 Add affinity element to affinity group: 
 /affinity/nb/v2/{container}/add/{groupname}/mac/{address}
  /affinity/nb/v2/{container}/add/{groupname}/ip/{address}
index 0725535b687ba849d743387d60e62a6faa86f4b4..203de7b05ff33662e68c2fd48572b7823308cf73 100644 (file)
@@ -1,5 +1,5 @@
 Manifest-Version: 1.0\r
-Bnd-LastModified: 1377719919818\r
+Bnd-LastModified: 1377774582874\r
 Build-Jdk: 1.6.0_37\r
 Built-By: sraman\r
 Bundle-ManifestVersion: 2\r
index 2fbb4a1ecf6ff98dace4c5c05297cf455d548f76..5be0a1a489e3071212b723c9891d497640db86f5 100644 (file)
@@ -1,5 +1,5 @@
 Manifest-Version: 1.0\r
-Bnd-LastModified: 1377719922284\r
+Bnd-LastModified: 1377774584891\r
 Build-Jdk: 1.6.0_37\r
 Built-By: sraman\r
 Bundle-Activator: org.opendaylight.controller.affinity.internal.Activato\r
diff --git a/affinity/northbound/src/main/java/org/opendaylight/controller/affinity/northbound/AffinityGroupList.java b/affinity/northbound/src/main/java/org/opendaylight/controller/affinity/northbound/AffinityGroupList.java
new file mode 100644 (file)
index 0000000..8cd3946
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013 Plexxi, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.affinity.northbound;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.opendaylight.controller.affinity.AffinityGroup;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+public class AffinityGroupList {
+        @XmlElement (name="affinity")
+        List<AffinityGroup> affinityGroupList;
+
+        public AffinityGroupList() {
+        }
+        public AffinityGroupList (List<AffinityGroup> aff) {
+            this.affinityGroupList = aff;
+        }
+        public List<AffinityGroup> getAffinityList() {
+                return affinityGroupList;
+        }
+        public void setAffinityList(List<AffinityGroup> aff) {
+                this.affinityGroupList = aff;
+        }
+}
similarity index 60%
rename from affinity/northbound/src/main/java/org/opendaylight/controller/affinity/northbound/Affinities.java
rename to affinity/northbound/src/main/java/org/opendaylight/controller/affinity/northbound/AffinityLinkList.java
index 7f9aca22f25e2224e5421e89cf2acef28de54c66..133e312391f0a0f029d82f8a7059786be17167af 100644 (file)
@@ -15,23 +15,23 @@ import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
-import org.opendaylight.controller.affinity.AffinityConfig;
+import org.opendaylight.controller.affinity.AffinityLink;
 
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
-public class Affinities {
+public class AffinityLinkList {
         @XmlElement (name="affinity")
-        List<AffinityConfig> affinityList;
+        List<AffinityLink> affinityLinkList;
 
-        public Affinities() {
+        public AffinityLinkList() {
         }
-        public Affinities (List<AffinityConfig> aff) {
-            this.affinityList = aff;
+        public AffinityLinkList (List<AffinityLink> aff) {
+            this.affinityLinkList = aff;
         }
-        public List<AffinityConfig> getAffinityList() {
-                return affinityList;
+        public List<AffinityLink> getAffinityList() {
+                return affinityLinkList;
         }
-        public void setAffinityList(List<AffinityConfig> aff) {
-                this.affinityList = aff;
+        public void setAffinityList(List<AffinityLink> aff) {
+                this.affinityLinkList = aff;
         }
 }
index 082c75fe47809ecfe287aaa454e3e9b2d2b817c9..8552e070d7cee9654cc9e9de7424843549014590 100644 (file)
@@ -98,61 +98,69 @@ public class AffinityNorthbound {
         return affinityManager;
     }
 
-/*
- * getAllAffinities()
- * getAffinity(String name)
- * addAffinity(name, ip1, ip2, type)
- * removeAffinity(String name)
- */
     /**
-     * Retrieve a list of all affinities in this container.
+     * Add an affinity to the configuration database
+     *
+     * @param containerName
+     *            Name of the Container
+     * @param affinityGroupName
+     *            Name of the new affinity group being added
+     * @return Response as dictated by the HTTP Response Status code
      */
-    @Path("/{containerName}/affinities")
-    @GET
-    @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    @TypeHint(Affinities.class)
+
+    @Path("/{containerName}/create/group/{affinityGroupName}")
+    @PUT
+    @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+    @TypeHint(Response.class)
     @StatusCodes({
             @ResponseCode(code = 200, condition = "Operation successful"),
-            @ResponseCode(code = 404, condition = "The containerName is not found"),
-            @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
-    public Affinities getAllAffinities(@PathParam("containerName") String containerName) {
+            @ResponseCode(code = 404, condition = "The Container Name or nodeId or configuration name is not found"),
+            @ResponseCode(code = 503, condition = "One or more of Controller services are unavailable") })
+    public Response createAffinityGroup(
+            @PathParam("containerName") String containerName,
+            @PathParam("affinityGroupName") String affinityGroupName) {
 
-        if (!NorthboundUtils.isAuthorized(
-                getUserName(), containerName, Privilege.READ, this)) {
-            throw new UnauthorizedException(
-                    "User is not authorized to perform this operation on container "
-                            + containerName);
+        if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.WRITE, this)) {
+            throw new UnauthorizedException("User is not authorized to perform this operation on container "
+                                            + containerName);
         }
 
         IAffinityManager affinityManager = getIfAffinityManagerService(containerName);
         if (affinityManager == null) {
             throw new ServiceUnavailableException("Affinity Manager "
-                    + RestMessages.SERVICEUNAVAILABLE.toString());
+                                                  + RestMessages.SERVICEUNAVAILABLE.toString());
+        }
+
+        AffinityGroup ag1 = new AffinityGroup(affinityGroupName);
+        Status ret = affinityManager.addAffinityGroup(ag1);
+        if (ret.isSuccess()) {
+            return Response.status(Response.Status.CREATED).build();
         }
-        return new Affinities(affinityManager.getAffinityConfigList());
+        throw new InternalServerErrorException(ret.getDescription());
     }
+
     /**
-     * Returns details of affinityName affinity.
+     * Returns details of an affinity group.
      *
      * @param containerName
      *            Name of the Container. The Container name for the base
      *            controller is "default".
-     * @param affinityName
-     *            Name of the affinity being retrieved.
+     * @param affinityGroupName
+     *            Name of the affinity group being retrieved.
      * @return affinity configuration that matches the affinity name.
      */
-    @Path("/{containerName}/{affinityName}")
+    @Path("/{containerName}/group/{affinityGroupName}")
     @GET
     @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    @TypeHint(AffinityConfig.class)
+    @TypeHint(AffinityGroup.class)
     @StatusCodes({
             @ResponseCode(code = 200, condition = "Operation successful"),
             @ResponseCode(code = 404, condition = "The containerName is not found"),
             @ResponseCode(code = 415, condition = "Affinity name is not found"),
             @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
-    public AffinityConfig getAffinityDetails(
+    public AffinityGroup getAffinityGroupDetails(
             @PathParam("containerName") String containerName,
-            @PathParam("affinityName") String affinityName) {
+            @PathParam("affinityGroupName") String affinityGroupName) {
         if (!NorthboundUtils.isAuthorized(
                 getUserName(), containerName, Privilege.READ, this)) {
             throw new UnauthorizedException(
@@ -165,102 +173,11 @@ public class AffinityNorthbound {
                                                   + RestMessages.SERVICEUNAVAILABLE.toString());
         }
 
-        AffinityConfig ac = affinityManager.getAffinityConfig(affinityName);
-        if (ac == null) {
+        AffinityGroup ag = affinityManager.getAffinityGroup(affinityGroupName);
+        if (ag == null) {
             throw new ResourceNotFoundException(RestMessages.SERVICEUNAVAILABLE.toString());
         } else {
-            return ac;
-        }
-    }
-    /**
-     * Delete an affinity
-     *
-     * @param containerName
-     *            Name of the Container
-     * @param affinityName
-     *            affinity name 'String'
-     * @return Response as dictated by the HTTP Response Status code
-     */
-
-    @Path("/{containerName}/{affinityName}")
-    @DELETE
-    @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    @TypeHint(Response.class)
-    @StatusCodes({
-            @ResponseCode(code = 200, condition = "Operation successful"),
-            @ResponseCode(code = 404, condition = "The Container Name or nodeId or configuration name is not found"),
-            @ResponseCode(code = 503, condition = "One or more of Controller services are unavailable") })
-    public Response deleteAffinity(
-            @PathParam("containerName") String containerName,
-            @PathParam("affinityName") String affinityName) {
-
-        if (!NorthboundUtils.isAuthorized(
-                getUserName(), containerName, Privilege.WRITE, this)) {
-            throw new UnauthorizedException(
-                    "User is not authorized to perform this operation on container "
-                            + containerName);
+            return ag;
         }
-
-        IAffinityManager affinityManager = getIfAffinityManagerService(containerName);
-        if (affinityManager == null) {
-            throw new ServiceUnavailableException("Affinity Manager "
-                    + RestMessages.SERVICEUNAVAILABLE.toString());
-        }
-
-        Status ret = affinityManager.removeAffinityConfig(affinityName);
-        if (ret.isSuccess()) {
-            return Response.ok().build();
-        }
-        throw new ResourceNotFoundException(ret.getDescription());
-    }
-
-    /**
-     * Add an affinity to the configuration database
-     *
-     * @param containerName
-     *            Name of the Container
-     * @param affinityName
-     *            Name of the new affinity being added
-     * @param networkAddress1
-     *            IP address of the flow source
-     * @param networkAddress2
-     *            IP address of the flow destination
-     * @param affinityAttribute
-     *            Type of affinity being added
-     * @return Response as dictated by the HTTP Response Status code
-     */
-
-    @Path("/{containerName}/{affinityName}/{networkAddress1}/{networkAddress2}/{affinityAttribute}")
-    @PUT
-    @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-    @TypeHint(Response.class)
-    @StatusCodes({
-            @ResponseCode(code = 200, condition = "Operation successful"),
-            @ResponseCode(code = 404, condition = "The Container Name or nodeId or configuration name is not found"),
-            @ResponseCode(code = 503, condition = "One or more of Controller services are unavailable") })
-    public Response addAffinity(
-            @PathParam("containerName") String containerName,
-            @PathParam("affinityName") String affinityName,
-            @PathParam("networkAddress1") String networkAddress1,
-            @PathParam("networkAddress2") String networkAddress2,
-            @PathParam("affinityAttribute") String affinityAttribute) {
-
-        if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.WRITE, this)) {
-            throw new UnauthorizedException("User is not authorized to perform this operation on container "
-                                            + containerName);
-        }
-
-        IAffinityManager affinityManager = getIfAffinityManagerService(containerName);
-        if (affinityManager == null) {
-            throw new ServiceUnavailableException("Affinity Manager "
-                                                  + RestMessages.SERVICEUNAVAILABLE.toString());
-        }
-
-        AffinityConfig ac = new AffinityConfig(affinityName, networkAddress1, networkAddress2, affinityAttribute);
-        Status ret = affinityManager.updateAffinityConfig(ac);
-        if (ret.isSuccess()) {
-            return Response.status(Response.Status.CREATED).build();
-        }
-        throw new InternalServerErrorException(ret.getDescription());
     }
 }
index effe66ad2a47f588cbd264e4574af1746d23c538..aaff04539e8a995db7a058b6b9d18e127eb9b812 100644 (file)
@@ -1,5 +1,5 @@
 Manifest-Version: 1.0\r
-Bnd-LastModified: 1377097334954\r
+Bnd-LastModified: 1377774585678\r
 Build-Jdk: 1.6.0_37\r
 Built-By: sraman\r
 Bundle-ManifestVersion: 2\r