This module doesn't depend on any of the Opendaylight components.
This library module can also be used independently in a non-OSGi environment.
-- northbound : Provides AD-SAL style Northbound REST APIs.
- Supports the legacy v2 APIs to provide backward compatibility for Hydrogen Release
- Also supports the newer v3 APIs to provide schema-independent access to the OVSDB protocol.
-
- openstack
+-- net-virt : Handles the Openstack Neutron ML2 and Network Service calls and performs all the logic required
for Network Virtualization.
4. Once karaf has started and you see the Opendaylight ascii art in the console, the last step
is to start the OVSDB plugin framework with the following command in the karaf console:
- "feature:install odl-ovsdb-openstack odl-ovsdb-northbound" (without quotation marks).
+ "feature:install odl-ovsdb-openstack" (without quotation marks).
Sample output from Karaf console :
odl-ovsdb-library | 1.0.0-SNAPSHOT | x | ovsdb-1.0.0-SNAPSHOT | OVSDB :: Library
odl-ovsdb-schema-openvswitch | 1.0.0-SNAPSHOT | x | ovsdb-1.0.0-SNAPSHOT | OVSDB :: Schema :: Open_vSwitch
odl-ovsdb-schema-hardwarevtep | 1.0.0-SNAPSHOT | x | ovsdb-1.0.0-SNAPSHOT | OVSDB :: Schema :: hardware_vtep
- odl-ovsdb-plugin | 1.0.0-SNAPSHOT | x | ovsdb-1.0.0-SNAPSHOT | OpenDaylight :: OVSDB :: Plugin
- odl-ovsdb-northbound | 0.6.0-SNAPSHOT | | ovsdb-1.0.0-SNAPSHOT | OpenDaylight :: OVSDB :: Northbound
odl-ovsdb-openstack | 1.0.0-SNAPSHOT | x | ovsdb-1.0.0-SNAPSHOT | OpenDaylight :: OVSDB :: OpenStack Network Virtual
odl-ovsdb-ovssfc | 0.0.1-SNAPSHOT | | ovsdb-0.0.1-SNAPSHOT | OpenDaylight :: OVSDB :: OVS Service Function Chai
+++ /dev/null
-<?xml version="1.0"?>
-<enunciate label="full" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd">
-
- <services>
- <rest defaultRestSubcontext="/ovsdb/nb/v2"/>
- </services>
-
- <modules>
- <docs docsDir="rest" title="OVSDB Table operations over REST" includeExampleXml="true" includeExampleJson="true"/>
- </modules>
-</enunciate>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright (C) 2014 Red Hat, 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
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>commons</artifactId>
- <version>1.4.0-SNAPSHOT</version>
- <relativePath>../commons/parent</relativePath>
- </parent>
-
- <artifactId>northbound</artifactId>
- <version>0.8.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
- <description>The OVSDB Plugin integration project is a project for OpenDaylight that will implement the Open vSwitch Database RFC 7047 management protocol allowing the Southbound configuration of vSwitches and a network virtualization implementation.</description>
- <url>https://wiki.opendaylight.org/view/OVSDB_Integration:Main</url>
- <licenses>
- <license>
- <name>Eclipse Public License v1.0</name>
- <url>http://www.eclipse.org/legal/epl-v10.html</url>
- </license>
- </licenses>
- <developers>
- <developer>
- <name>Sam Hague</name>
- <email>shague@gmail.com</email>
- <url>https://github.com/shague</url>
- </developer>
- </developers>
- <scm>
- <connection>scm:git:ssh://git.opendaylight.org:29418/ovsdb.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/ovsdb.git</developerConnection>
- <tag>HEAD</tag>
- <url>https://wiki.opendaylight.org/view/OVSDB_Integration:Main</url>
- </scm>
-
- <dependencies>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- </dependency>
- <dependency>
- <groupId>org.codehaus.enunciate</groupId>
- <artifactId>enunciate-core-annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>commons.northbound</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>library</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>plugin</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>utils.servicehelper</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Import-Package>org.opendaylight.controller.sal.utils,
- org.opendaylight.controller.northbound.commons,
- org.opendaylight.controller.northbound.commons.exception,
- org.opendaylight.controller.northbound.commons.utils,
- com.sun.jersey.spi.container.servlet,
- org.opendaylight.controller.sal.core,
- org.opendaylight.controller.sal.authorization,
- org.opendaylight.ovsdb.plugin.api,
- org.opendaylight.ovsdb.lib,
- org.opendaylight.ovsdb.lib.jsonrpc,
- org.opendaylight.ovsdb.lib.notation,
- org.opendaylight.ovsdb.lib.operations,
- org.opendaylight.ovsdb.lib.message,
- org.opendaylight.ovsdb.lib.schema,
- org.opendaylight.ovsdb.lib.schema.typed,
- javax.ws.rs,
- javax.ws.rs.core,
- javax.xml.bind,
- javax.xml.bind.annotation,
- org.slf4j,
- org.apache.catalina.filters,
- !org.codehaus.enunciate.jaxrs,*</Import-Package>
- <Export-Package/>
- <Web-ContextPath>/ovsdb/nb</Web-ContextPath>
- <Jaxrs-Resources>,${classes;ANNOTATION;javax.ws.rs.Path}</Jaxrs-Resources>
- </instructions>
- <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.codehaus.enunciate</groupId>
- <artifactId>maven-enunciate-plugin</artifactId>
- <version>${enunciate.version}</version>
- </plugin>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Red Hat, 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.ovsdb.northbound;
-
-import com.fasterxml.jackson.databind.SerializationFeature;
-import java.util.List;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.opendaylight.controller.northbound.commons.exception.InternalServerErrorException;
-import org.opendaylight.ovsdb.lib.OvsdbClient;
-import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * Northbound interface for OVSDB Databases
- */
-public class DatabaseResource {
-
- String nodeId;
- ObjectMapper objectMapper;
- DatabaseResource(String id) {
- this.nodeId = id;
- objectMapper = new ObjectMapper();
- objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
- }
-
- private DatabaseSchema getDatabaseSchema (String databaseName) {
- String csDatabaseName = this.caseSensitiveDatabaseName(databaseName);
- OvsdbClient client = NodeResource.getOvsdbClient(nodeId, this);
- return client.getDatabaseSchema(csDatabaseName);
- }
-
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- public Response getDatabases(){
- OvsdbClient client = NodeResource.getOvsdbClient(nodeId, this);
- try {
- List<String> databases = client.getDatabases().get();
- if (databases == null) {
- return Response.noContent().build();
- }
- String response = objectMapper.writeValueAsString(databases);
- return Response.status(Response.Status.OK)
- .entity(response)
- .build();
- } catch (Exception e) {
- throw new InternalServerErrorException("Failed due to exception " + e.getMessage());
- }
- }
-
- @GET
- @Path("{name}")
- @Produces(MediaType.APPLICATION_JSON)
- public Response getDatabases(@PathParam("name") String name) throws JsonProcessingException {
- DatabaseSchema dbSchema = this.getDatabaseSchema(name);
- String response = objectMapper.writeValueAsString(dbSchema);
- return Response.status(Response.Status.OK)
- .entity(response)
- .build();
- }
-
- @Path("{name}/table")
- public TableResource getDatabaseTables(@PathParam("name") String name){
- String csDatabaseName = this.caseSensitiveDatabaseName(name);
- return new TableResource(nodeId, csDatabaseName);
- }
-
- private String caseSensitiveDatabaseName (String ciDatabaseName) {
- OvsdbClient client = NodeResource.getOvsdbClient(nodeId, this);
- try {
- List<String> databases = client.getDatabases().get();
- if (databases == null) {
- return ciDatabaseName;
- }
- for (String csDatabaseName : databases) {
- if (csDatabaseName.equalsIgnoreCase(ciDatabaseName)) {
- return csDatabaseName;
- }
- }
- return ciDatabaseName;
- } catch (Exception e) {
- return ciDatabaseName;
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Red Hat, 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.ovsdb.northbound;
-
-import com.fasterxml.jackson.databind.SerializationFeature;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.List;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.opendaylight.controller.northbound.commons.RestMessages;
-import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
-import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.ovsdb.lib.OvsdbClient;
-import org.opendaylight.ovsdb.plugin.api.Connection;
-import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
-import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.collect.Lists;
-
-/**
- * Northbound Interface for OVSDB Nodes
- */
-public class NodeResource {
- ObjectMapper objectMapper;
- public NodeResource () {
- objectMapper = new ObjectMapper();
- objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
- }
-
- public static Node getOvsdbNode(String nodeId, Object bundleClassRef) {
- OvsdbConnectionService connectionService =
- (OvsdbConnectionService)ServiceHelper.
- getGlobalInstance(OvsdbConnectionService.class, bundleClassRef);
- if (connectionService == null) {
- throw new ServiceUnavailableException("Ovsdb ConnectionService "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- Node node = connectionService.getNode(nodeId);
- if (node == null) {
- throw new ResourceNotFoundException("Node "+nodeId+" not found");
- }
-
- return node;
- }
-
- public static Connection getOvsdbConnection(String nodeId, Object bundleClassRef) {
- OvsdbConnectionService connectionService =
- (OvsdbConnectionService)ServiceHelper.
- getGlobalInstance(OvsdbConnectionService.class, bundleClassRef);
- if (connectionService == null) {
- throw new ServiceUnavailableException("Ovsdb ConnectionService "
- + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- Node node = connectionService.getNode(nodeId);
- if (node == null) {
- throw new ResourceNotFoundException("Node "+nodeId+" not found");
- }
-
- Connection connection = connectionService.getConnection(node);
- if (connection == null) {
- throw new ResourceNotFoundException("Connection for "+nodeId+" not available");
- }
-
- return connection;
- }
-
- public static OvsdbClient getOvsdbClient(String nodeId, Object bundleClassRef) {
- Connection connection = NodeResource.getOvsdbConnection(nodeId, bundleClassRef);
- OvsdbClient client = connection.getClient();
- if (client == null) {
- throw new ResourceNotFoundException("No Ovsdb Client to handle Node "+nodeId);
- }
- return client;
- }
-
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- public Response getNodes() throws JsonProcessingException {
- OvsdbConnectionService connectionService = (OvsdbConnectionService)ServiceHelper.getGlobalInstance(OvsdbConnectionService.class, this);
- List<Node> nodes = connectionService.getNodes();
- if (nodes == null) {
- return Response.noContent().build();
- }
-
- List<String> nodeIds = Lists.newArrayList();
- for (Node node : nodes) {
- nodeIds.add(node.getId().getValue());
- }
- Collections.sort(nodeIds);
-
- String response = objectMapper.writeValueAsString(nodeIds);
- return Response.status(Response.Status.OK)
- .entity(response)
- .build();
- }
-
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response createNode(InputStream is){
- return Response.noContent().build();
- }
-
- @GET
- @Path("{id}")
- @Produces(MediaType.APPLICATION_JSON)
- public Response getNode(@PathParam("id") String id) throws JsonProcessingException {
- OvsdbClient client = NodeResource.getOvsdbClient(id, this);
- String response = objectMapper.writeValueAsString(client.getConnectionInfo());
- return Response.status(Response.Status.OK)
- .entity(response)
- .build();
- }
-
- @PUT
- @Path("{id}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response updateNode(@PathParam("id") String id, InputStream is){
- return Response.noContent().build();
- }
-
- @DELETE
- @Path("{id}")
- public Response deleteNode(@PathParam("id") String id){
- return Response.noContent().build();
- }
-
- @Path("{id}/database")
- public DatabaseResource getNodeDatabase(@PathParam("id") String nodeId){
- return new DatabaseResource(nodeId);
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Red Hat, 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.ovsdb.northbound;
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.SecurityContext;
-import javax.ws.rs.core.UriInfo;
-
-import org.codehaus.enunciate.jaxrs.ResponseCode;
-import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.codehaus.enunciate.jaxrs.TypeHint;
-import org.opendaylight.controller.northbound.commons.RestMessages;
-import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
-import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
-import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
-import org.opendaylight.controller.sal.authorization.Privilege;
-import org.opendaylight.ovsdb.plugin.api.Status;
-import org.opendaylight.ovsdb.lib.OvsdbClient;
-import org.opendaylight.ovsdb.lib.notation.Row;
-import org.opendaylight.ovsdb.lib.notation.UUID;
-import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
-import org.opendaylight.ovsdb.plugin.api.OvsVswitchdSchemaConstants;
-import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
-import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
-import org.opendaylight.ovsdb.plugin.api.StatusWithUuid;
-import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
-* OVSDB Northbound REST API.<br>
-* This class provides REST APIs to Create, Read, Update and Delete OVSDB Row in any of the ovsdb table
-* database one at a time. The JSON used to create rows is in the same format as the OVSDB JSON-RPC messages.
-* This format is documented in the <a href="http://openvswitch.org/ovs-vswitchd.conf.db.5.pdf">OVSDB Schema</a>
-* and in <a href="http://tools.ietf.org/rfc/rfc7047.txt">RFC 7047</a>.
-*
-* <br>
-* <br>
-* Authentication scheme : <b>HTTP Basic</b><br>
-* Authentication realm : <b>opendaylight</b><br>
-* Transport : <b>HTTP and HTTPS</b><br>
-* <br>
-* HTTPS Authentication is disabled by default.
-*/
-
-@Path("/v2/")
-@Deprecated
-public class OvsdbNorthboundV2 {
-
- @Context
- private UriInfo _uriInfo;
- private String username;
-
- @Context
- public void setSecurityContext(SecurityContext context) {
- if (context != null && context.getUserPrincipal() != null) {
- username = context.getUserPrincipal().getName();
- }
- }
-
- protected String getUserName() {
- return username;
- }
-
- /**
- * Create a Row for Open_vSwitch schema
- *
- * @param nodeType type of node e.g OVS
- * @param nodeId ID of the node
- * @param tableName name of the OVSDB table
- * @param rowJson the {@link OvsdbRow} Row that is being inserted
- *
- * @return Response as dictated by the HTTP Response Status code
- *
- * <br>
- * Examples:
- * <br>
- * Create a Bridge Row:
- * <pre>
- *
- * Request URL:
- * POST http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/bridge/rows
- *
- * JSON:
- * {
- * "row": {
- * "Bridge": {
- * "name": "bridge1",
- * "datapath_type": "OPENFLOW"
- * }
- * }
- * }
- * </pre>
- *
- *
- * Create a Port Row:
- * <pre>
- *
- * Request URL:
- * POST http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/port/rows
- *
- * JSON:
- * {
- * "parent_uuid": "b01cd26b-9c63-4216-8cf2-55f7087adab1",
- * "row": {
- * "Port": {
- * "name": "port1",
- * "mac": [
- * "set",
- * "00:00:00:00:00:01"
- * ],
- * "tag": [
- * "set",
- * 200
- * ]
- * }
- * }
- * }
- * </pre>
- *
- *
- * Create an Interface Row:
- * <pre>
- *
- * Request URL:
- * POST http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/interface/rows
- *
- * JSON:
- * {
- * "parent_uuid": "c7b54c9b-9b25-4801-a81d-d7bc489d4840",
- * "row": {
- * "Interface": {
- * "name": "br2",
- * "mac": [
- * "set",
- * "00:00:bb:bb:00:01"
- * ],
- * "admin_state": "up"
- * }
- * }
- * }
- * </pre>
- *
- *
- * Create an SSL Row:
- * <pre>
- *
- * Request URL:
- * POST http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/SSL/rows
- *
- * JSON:
- * {
- * "row": {
- * "SSL": {
- * "name": "mySSL",
- * "ca_cert": "ca_cert",
- * "bootstrap_ca_cert": true,
- * "certificate": "pieceofpaper",
- * "private_key": "private"
- * }
- * }
- * }
- * </pre>
- *
- *
- * Create an sFlow Row:
- * <pre>
- *
- * Request URL:
- * POST http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/sflow/rows
- *
- * JSON:
- * {
- * "parent_uuid": "6b3072ba-a120-4db9-82f8-a8ce4eae6942",
- * "row": {
- * "sFlow": {
- * "agent": [
- * "set",
- * "agent_string"
- * ],
- * "targets": [
- * "set",
- * "targets_string"
- * ]
- * }
- * }
- * }
- * </pre>
- *
- *
- * Create a QoS Row:
- * <pre>
- *
- * Request URL:
- * POST http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/qos/rows
- *
- * JSON:
- * {
- * "parent_uuid": "b109dbcf-47bb-4121-b244-e623b3421d6e",
- * "row": {
- * "QoS": {
- * "type": "linux-htb"
- * }
- * }
- * }
- * </pre>
- *
- *
- * Create a Queue Row:
- * <pre>
- *
- * Request URL:
- * POST http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/queue/rows
- *
- * {
- * "parent_uuid": "b16eae7d-7e97-46d2-95d1-333d1de4a3d7",
- * "row": {
- * "Queue": {
- * "dscp": [
- * "set",
- * "25"
- * ]
- * }
- * }
- * }
- * </pre>
- *
- *
- * Create a Netflow Row:
- * <pre>
- *
- * Request URL:
- * POST http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/netflow/rows
- *
- * JSON:
- * {
- * "parent_uuid": "b01cd26b-9c63-4216-8cf2-55f7087adab1",
- * "row": {
- * "NetFlow": {
- * "targets": [
- * "set",
- * [
- * "192.168.1.102:9998"
- * ]
- * ],
- * "active_timeout": "0"
- * }
- * }
- * }
- * </pre>
- *
- *
- * Create a Manager Row:
- * <pre>
- *
- * Request URL:
- * POST http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/manager/rows
- *
- * JSON:
- * {
- * "parent_uuid": "8d3fb89b-5fac-4631-a990-f5a4e7f5383a",
- * "row": {
- * "Manager": {
- * "target": "a_string",
- * "is_connected": true,
- * "state": "active"
- * }
- * }
- * }
- * </pre>
- * @throws IOException
- * @throws ExecutionException
- * @throws InterruptedException
- */
-
- @Path("/node/{nodeType}/{nodeId}/tables/{tableName}/rows")
- @POST
- @StatusCodes({ @ResponseCode(code = 201, condition = "Row Inserted successfully"),
- @ResponseCode(code = 400, condition = "Invalid data passed"),
- @ResponseCode(code = 401, condition = "User not authorized to perform this operation")})
- @Consumes({ MediaType.APPLICATION_JSON})
- public Response addRow(@PathParam("nodeType") String nodeType, @PathParam("nodeId") String nodeId,
- @PathParam("tableName") String tableName, JsonNode rowJson) throws IOException, InterruptedException, ExecutionException {
-
- if (!NorthboundUtils.isAuthorized(getUserName(), "default", Privilege.WRITE, this)) {
- throw new UnauthorizedException("User is not authorized to perform this operation");
- }
-
- OvsdbConfigurationService
- ovsdbTable = (OvsdbConfigurationService)ServiceHelper.getGlobalInstance(OvsdbConfigurationService.class,
- this);
- if (ovsdbTable == null) {
- throw new ServiceUnavailableException("OVS Configuration Service " + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- OvsdbConnectionService
- connectionService = (OvsdbConnectionService)ServiceHelper.getGlobalInstance(OvsdbConnectionService.class, this);
- Node node = connectionService.getNode(nodeId);
-
- OvsdbClient client = connectionService.getConnection(node).getClient();
- OvsdbRow localRow = OvsdbRow.fromJsonNode(client, OvsVswitchdSchemaConstants.DATABASE_NAME, rowJson);
- String bckCompatibleTableName = this.getBackwardCompatibleTableName(client, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName);
-
- if (localRow == null) {
- return Response.status(Response.Status.BAD_REQUEST).build();
- }
-
- StatusWithUuid
- statusWithUuid = ovsdbTable.insertRow(node, bckCompatibleTableName, localRow.getParentUuid(), localRow.getRow());
-
- if (statusWithUuid.isSuccess()) {
- UUID uuid = statusWithUuid.getUuid();
- return Response.status(Response.Status.CREATED)
- .header("Location", String.format("%s/%s", _uriInfo.getAbsolutePath().toString(),
- uuid.toString()))
- .entity(uuid.toString())
- .build();
- }
- return NorthboundUtils.getResponse(
- new org.opendaylight.controller.sal.utils.Status(
- org.opendaylight.controller.sal.utils.StatusCode.SUCCESS));
- }
-
- /**
- * Read a Row
- *
- * @param nodeType type of node e.g OVS
- * @param nodeId ID of the node
- * @param tableName name of the ovsdb table
- * @param rowUuid UUID of the row being read
- *
- * @return Row corresponding to the UUID.
- *
- * <br>
- * Examples:
- * <br>
- * <pre>
- * Get a specific Bridge Row:
- * GET http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/bridge/rows/6f4c602c-026f-4390-beea-d50d6d448100
- *
- * Get a specific Port Row:
- * GET http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/port/rows/6f4c602c-026f-4390-beea-d50d6d448100
- *
- * Get a specific Interface Row:
- * GET http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/interface/rows/6f4c602c-026f-4390-beea-d50d6d448100
- *
- * Get a specific Controller Row:
- * GET http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/controller/rows/6f4c602c-026f-4390-beea-d50d6d448100
- *
- * Get a specific SSL Row:
- * GET http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/SSL/rows/6f4c602c-026f-4390-beea-d50d6d448100
- *
- * Get a specific sFlow Row:
- * GET http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/sflow/rows/6f4c602c-026f-4390-beea-d50d6d448100
- *
- * Get a specific QoS Row:
- * GET http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/qos/rows/6f4c602c-026f-4390-beea-d50d6d448100
- *
- * Get a specific Queue Row:
- * GET http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/queue/rows/6f4c602c-026f-4390-beea-d50d6d448100
- *
- * Get a specific Netflow Row:
- * GET http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/netflow/rows/6f4c602c-026f-4390-beea-d50d6d448100
- *
- * Get a specific Manager Row:
- * GET http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/manager/rows/6f4c602c-026f-4390-beea-d50d6d448100
- * </pre>
- */
-
- @Path("/node/{nodeType}/{nodeId}/tables/{tableName}/rows/{rowUuid}")
- @GET
- @StatusCodes({ @ResponseCode(code = 200, condition = "Row Updated successfully"),
- @ResponseCode(code = 400, condition = "Invalid data passed"),
- @ResponseCode(code = 401, condition = "User not authorized to perform this operation")})
- @Produces({ MediaType.APPLICATION_JSON})
- @TypeHint(Row.class)
- public Row getRow(@PathParam("nodeType") String nodeType, @PathParam("nodeId") String nodeId,
- @PathParam("tableName") String tableName, @PathParam("rowUuid") String rowUuid) {
-
- if (!NorthboundUtils.isAuthorized(getUserName(), "default", Privilege.WRITE, this)) {
- throw new UnauthorizedException("User is not authorized to perform this operation");
- }
-
- OvsdbConfigurationService
- ovsdbTable = (OvsdbConfigurationService)ServiceHelper.getGlobalInstance(OvsdbConfigurationService.class,
- this);
- if (ovsdbTable == null) {
- throw new ServiceUnavailableException("UserManager " + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- OvsdbConnectionService
- connectionService = (OvsdbConnectionService)ServiceHelper.getGlobalInstance(OvsdbConnectionService.class, this);
- Node node = connectionService.getNode(nodeId);
- OvsdbClient client = connectionService.getConnection(node).getClient();
- String bckCompatibleTableName = this.getBackwardCompatibleTableName(client, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName);
-
- Row row;
- try {
- row = ovsdbTable.getRow(node, bckCompatibleTableName, rowUuid);
- } catch (Exception e) {
- throw new BadRequestException(e.getMessage());
- }
- return row;
- }
-
- /**
- * Read all Rows of a table
- *
- * @param nodeType type of node e.g OVS
- * @param nodeId ID of the node
- * @param tableName name of the ovsdb table
- *
- * @return All the Rows of a table
- *
- * <br>
- * Examples:
- * <br>
- * <pre>
- * Get all Bridge Rows:
- * GET http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/bridge/rows
- *
- * Get all Port Rows:
- * GET http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/port/rows
- *
- * Get all Interface Rows:
- * GET http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/interface/rows
- *
- * Get all Controller Rows:
- * GET http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/controller/rows
- *
- * Get all SSL Rows:
- * GET http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/SSL/rows
- *
- * Get all sFlow Rows:
- * GET http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/sflow/rows
- *
- * Get all QoS Rows:
- * GET http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/qos/rows
- *
- * Get all Queue Rows:
- * GET http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/queue/rows
- *
- * Get all Netflow Rows:
- * GET http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/netflow/rows
- *
- * Get all Manager Rows:
- * GET http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/manager/rows
- *
- * Get all Open vSwitch Rows:
- * GET http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/open_vswitch/rows
- * </pre>
- */
-
- @Path("/node/{nodeType}/{nodeId}/tables/{tableName}/rows")
- @GET
- @StatusCodes({ @ResponseCode(code = 200, condition = "Row Updated successfully"),
- @ResponseCode(code = 400, condition = "Invalid data passed"),
- @ResponseCode(code = 401, condition = "User not authorized to perform this operation")})
- @Produces({ MediaType.APPLICATION_JSON})
- @TypeHint(OvsdbRows.class)
- public OvsdbRows getAllRows(@PathParam("nodeType") String nodeType, @PathParam("nodeId") String nodeId,
- @PathParam("tableName") String tableName) {
- if (!NorthboundUtils.isAuthorized(getUserName(), "default", Privilege.WRITE, this)) {
- throw new UnauthorizedException("User is not authorized to perform this operation");
- }
-
- OvsdbConfigurationService
- ovsdbTable = (OvsdbConfigurationService)ServiceHelper.getGlobalInstance(OvsdbConfigurationService.class,
- this);
- if (ovsdbTable == null) {
- throw new ServiceUnavailableException("UserManager " + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- OvsdbConnectionService
- connectionService = (OvsdbConnectionService)ServiceHelper.getGlobalInstance(OvsdbConnectionService.class, this);
- Node node = connectionService.getNode(nodeId);
- OvsdbClient client = connectionService.getConnection(node).getClient();
- String bckCompatibleTableName = this.getBackwardCompatibleTableName(client, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName);
- Map<String, Row> rows;
- try {
- rows = ovsdbTable.getRows(node, bckCompatibleTableName);
- } catch (Exception e) {
- throw new BadRequestException(e.getMessage());
- }
- return new OvsdbRows(rows);
- }
-
- /*
- /**
- * Update a Row
- *
- * @param nodeType type of node e.g OVS
- * @param nodeId ID of the node
- * @param tableName name of the ovsdb table
- * @param rowUuid UUID of the row being updated
- * @param row the {@link OVSDBRow} Row that is being updated
- *
- * @return Response as dictated by the HTTP Response Status code
- *
- * <br>
- * Examples:
- * <br>
- * Update the Bridge row to add a controller
- * <pre>
- *
- * Request URL:
- * PUT http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/bridge/rows/b01cd26b-9c63-4216-8cf2-55f7087adab1
- *
- * JSON:
- * {
- * "row": {
- * "Bridge": {
- * "controller": [
- * "set",
- * [
- * [
- * "uuid",
- * "a566e8b4-fc38-499b-8623-6087d5b36b72"
- * ]
- * ]
- * ]
- * }
- * }
- * }
- * </pre>
- */
-
- @Path("/node/{nodeType}/{nodeId}/tables/{tableName}/rows/{rowUuid}")
- @PUT
- @StatusCodes({ @ResponseCode(code = 200, condition = "Row Updated successfully"),
- @ResponseCode(code = 400, condition = "Invalid data passed"),
- @ResponseCode(code = 401, condition = "User not authorized to perform this operation")})
- @Consumes({ MediaType.APPLICATION_JSON})
- public Response updateRow(@PathParam("nodeType") String nodeType, @PathParam("nodeId") String nodeId,
- @PathParam("tableName") String tableName, @PathParam("rowUuid") String rowUuid,
- JsonNode rowJson) {
-
- if (!NorthboundUtils.isAuthorized(getUserName(), "default", Privilege.WRITE, this)) {
- throw new UnauthorizedException("User is not authorized to perform this operation");
- }
-
- OvsdbConfigurationService
- ovsdbTable = (OvsdbConfigurationService)ServiceHelper.getGlobalInstance(OvsdbConfigurationService.class,
- this);
- if (ovsdbTable == null) {
- throw new ServiceUnavailableException("OVS Configuration Service " + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- OvsdbConnectionService
- connectionService = (OvsdbConnectionService)ServiceHelper.getGlobalInstance(OvsdbConnectionService.class, this);
- Node node = connectionService.getNode(nodeId);
- OvsdbClient client = connectionService.getConnection(node).getClient();
- String bckCompatibleTableName = this.getBackwardCompatibleTableName(client, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName);
- OvsdbRow localRow = OvsdbRow.fromJsonNode(client, OvsVswitchdSchemaConstants.DATABASE_NAME, rowJson);
-
- if (localRow == null) {
- return Response.status(Response.Status.BAD_REQUEST).build();
- }
-
- ovsdbTable.updateRow(node, bckCompatibleTableName, localRow.getParentUuid(), rowUuid, localRow.getRow());
- return NorthboundUtils.getResponse(
- new org.opendaylight.controller.sal.utils.Status(
- org.opendaylight.controller.sal.utils.StatusCode.SUCCESS));
- }
-
- /**
- * Delete a row
- *
- * @param nodeType type of node e.g OVS
- * @param nodeId ID of the node
- * @param tableName name of the ovsdb table
- * @param uuid UUID of the Row to be removed
- *
- * @return Response as dictated by the HTTP Response Status code
- *
- * <br>
- * Examples:
- * <br>
- * <pre>
- * Delete a specific Bridge Row:
- * DELETE http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/bridge/rows/6f4c602c-026f-4390-beea-d50d6d448100
- *
- * Delete a specific Port Row:
- * DELETE http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/port/rows/6f4c602c-026f-4390-beea-d50d6d448100
- *
- * Delete a specific Interface Row:
- * DELETE http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/interface/rows/6f4c602c-026f-4390-beea-d50d6d448100
- *
- * Delete a specific Controller Row:
- * DELETE http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/controller/rows/6f4c602c-026f-4390-beea-d50d6d448100
- *
- * Delete a specific SSL Row:
- * DELETE http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/SSL/rows/6f4c602c-026f-4390-beea-d50d6d448100
- *
- * Delete a specific sFlow Row:
- * DELETE http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/sflow/rows/6f4c602c-026f-4390-beea-d50d6d448100
- *
- * Delete a specific QoS Row:
- * DELETE http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/qos/rows/6f4c602c-026f-4390-beea-d50d6d448100
- *
- * Delete a specific Queue Row:
- * DELETE http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/queue/rows/6f4c602c-026f-4390-beea-d50d6d448100
- *
- * Delete a specific Netflow Row:
- * DELETE http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/netflow/rows/6f4c602c-026f-4390-beea-d50d6d448100
- *
- * Delete a specific Manager Row:
- * DELETE http://localhost:8080/ovsdb/nb/v2/node/OVS/HOST1/tables/manager/rows/6f4c602c-026f-4390-beea-d50d6d448100
- * </pre>
- */
-
- @Path("/node/{nodeType}/{nodeId}/tables/{tableName}/rows/{uuid}")
- @DELETE
- @StatusCodes({ @ResponseCode(code = 204, condition = "User Deleted Successfully"),
- @ResponseCode(code = 401, condition = "User not authorized to perform this operation"),
- @ResponseCode(code = 404, condition = "The userName passed was not found"),
- @ResponseCode(code = 500, condition = "Internal Server Error : Removal of user failed"),
- @ResponseCode(code = 503, condition = "Service unavailable") })
- public Response removeRow(@PathParam("nodeType") String nodeType, @PathParam("nodeId") String nodeId,
- @PathParam("tableName") String tableName, @PathParam("uuid") String uuid) {
- if (!NorthboundUtils.isAuthorized(getUserName(), "default", Privilege.WRITE, this)) {
- throw new UnauthorizedException("User is not authorized to perform this operation");
- }
-
- OvsdbConfigurationService
- ovsdbTable = (OvsdbConfigurationService)ServiceHelper.getGlobalInstance(OvsdbConfigurationService.class,
- this);
- if (ovsdbTable == null) {
- throw new ServiceUnavailableException("OVS Configuration Service " + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- OvsdbConnectionService
- connectionService = (OvsdbConnectionService)ServiceHelper.getGlobalInstance(OvsdbConnectionService.class, this);
- Node node = connectionService.getNode(nodeId);
- OvsdbClient client = connectionService.getConnection(node).getClient();
- String bckCompatibleTableName = this.getBackwardCompatibleTableName(client, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName);
-
- Status status = ovsdbTable.deleteRow(node, bckCompatibleTableName, uuid);
- if (status.isSuccess()) {
- return Response.noContent().build();
- }
- return NorthboundUtils.getResponse(
- new org.opendaylight.controller.sal.utils.Status(
- org.opendaylight.controller.sal.utils.StatusCode.SUCCESS));
- }
-
- private String getBackwardCompatibleTableName(OvsdbClient client, String databaseName, String tableName) {
- DatabaseSchema dbSchema = client.getDatabaseSchema(databaseName);
- if (dbSchema == null || tableName == null) {
- return tableName;
- }
- for (String dbTableName : dbSchema.getTables()) {
- if (dbTableName.equalsIgnoreCase(tableName)) {
- return dbTableName;
- }
- }
- return tableName;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Red Hat, 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.ovsdb.northbound;
-
-import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
-import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
-import org.opendaylight.controller.sal.authorization.Privilege;
-
-import javax.ws.rs.Path;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.SecurityContext;
-import javax.ws.rs.core.UriInfo;
-
-/**
-* OVSDB Northbound V3 REST API
-*/
-
-@Path("/v3/")
-public class OvsdbNorthboundV3 {
- @Context
- private UriInfo _uriInfo;
- private String username;
-
- @Context
- public void setSecurityContext(SecurityContext context) {
- if (context != null && context.getUserPrincipal() != null) {
- username = context.getUserPrincipal().getName();
- }
- }
-
- protected String getUserName() {
- return username;
- }
-
- @Path("node")
- public NodeResource getNode(){
- if (!NorthboundUtils.isAuthorized(getUserName(), "default", Privilege.WRITE, this)) {
- throw new UnauthorizedException("User is not authorized to perform this operation");
- }
- return new NodeResource();
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2013, 2015 Red Hat, 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.ovsdb.northbound;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.concurrent.ExecutionException;
-
-import org.opendaylight.ovsdb.lib.OvsdbClient;
-import org.opendaylight.ovsdb.lib.notation.Row;
-import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
-import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-public class OvsdbRow {
- private static final Logger LOG = LoggerFactory.getLogger(OvsdbRow.class);
- private static final String PARENTUUID = "parent_uuid";
- private static final String PARENTTABLE = "parent_table";
- private static final String PARENTCOLUMN = "parent_column";
- private static final String ROW = "row";
-
- private String parentUuid;
- private String parentTable;
- private String parentColumn;
- private String tableName;
- private Row<GenericTableSchema> row;
-
- public OvsdbRow() {
- }
-
- public OvsdbRow(String parentUuid, String tableName, Row<GenericTableSchema> row) {
- this.parentUuid = parentUuid;
- this.tableName = tableName;
- this.row = row;
- }
-
- public OvsdbRow(String parentTable, String parentUuid, String parentColumn, String tableName, Row<GenericTableSchema> row) {
- this.parentTable = parentTable;
- this.parentColumn = parentColumn;
- this.parentUuid = parentUuid;
- this.tableName = tableName;
- this.row = row;
- }
-
- public static OvsdbRow fromJsonNode(OvsdbClient client, String dbName, JsonNode json) {
- JsonNode parentUuidNode = json.get(PARENTUUID);
- String parentUuid = null;
- if (parentUuidNode != null) {
- parentUuid = parentUuidNode.asText();
- }
- JsonNode parentTableNode = json.get(PARENTTABLE);
- String parentTable = null;
- if (parentTableNode != null) {
- parentTable = parentTableNode.asText();
- }
- JsonNode parentColumnNode = json.get(PARENTCOLUMN);
- String parentColumn = null;
- if (parentColumnNode != null) {
- parentColumn = parentColumnNode.asText();
- }
- JsonNode rowNode = json.get(ROW);
- if (rowNode == null) {
- return null;
- }
- Iterator<String> fieldNames = rowNode.fieldNames();
- if (fieldNames.hasNext()) {
- String tableName = fieldNames.next();
- try {
- Row<GenericTableSchema> row = getRow(client, dbName, tableName, rowNode.get(tableName));
- return new OvsdbRow(parentTable, parentUuid, parentColumn, tableName, row);
- } catch (InterruptedException | ExecutionException | IOException e) {
- LOG.error("Error retrieving the row for {}", tableName, e);
- return null;
- }
- }
- return null;
- }
-
- public static Row<GenericTableSchema> getRow(OvsdbClient client, String dbName, String tableName, JsonNode rowJson) throws InterruptedException, ExecutionException, IOException {
- DatabaseSchema dbSchema = client.getSchema(dbName).get();
- GenericTableSchema schema = dbSchema.table(tableName, GenericTableSchema.class);
- return schema.createRow((ObjectNode)rowJson);
- }
-
- public String getParentTable() {
- return parentTable;
- }
-
- public String getParentUuid() {
- return parentUuid;
- }
-
- public String getParentColumn() {
- return parentColumn;
- }
-
- public String getTableName() {
- return tableName;
- }
-
- public Row<GenericTableSchema> getRow() {
- return row;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013, 2015 Red Hat, 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.ovsdb.northbound;
-
-import java.util.Map;
-
-import org.opendaylight.ovsdb.lib.notation.Row;
-
-@Deprecated
-public class OvsdbRows {
- Map<String, Row> rows;
-
- public OvsdbRows(Map<String, Row> rows) {
- super();
- this.rows = rows;
- }
-
- public Map<String, Row> getRows() {
- return rows;
- }
-
- public void setRows(Map<String, Row> rows) {
- this.rows = rows;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Red Hat, 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.ovsdb.northbound;
-
-import com.fasterxml.jackson.databind.SerializationFeature;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.Map;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.opendaylight.controller.northbound.commons.RestMessages;
-import org.opendaylight.controller.northbound.commons.exception.BadRequestException;
-import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.ovsdb.lib.OvsdbClient;
-import org.opendaylight.ovsdb.lib.notation.Row;
-import org.opendaylight.ovsdb.lib.notation.UUID;
-import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
-import org.opendaylight.ovsdb.plugin.api.OvsVswitchdSchemaConstants;
-import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
-import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * Northbound interface for OVSDB Rows
- */
-public class RowResource {
-
- String nodeId;
- String databaseName;
- String tableName;
- ObjectMapper objectMapper;
-
- public RowResource(String nodeId, String databaseName, String tableName) {
- this.nodeId = nodeId;
- this.databaseName = databaseName;
- this.tableName = tableName;
- objectMapper = new ObjectMapper();
- objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
- }
-
- private OvsdbRow getOvsdbRow (InputStream stream) throws IOException {
- StringBuilder rowNodeStrBuilder = new StringBuilder();
- BufferedReader in = new BufferedReader(new InputStreamReader(stream));
- String line = null;
- while ((line = in.readLine()) != null) {
- rowNodeStrBuilder.append(line);
- }
- JsonNode jsonNode = objectMapper.readTree(rowNodeStrBuilder.toString());
- OvsdbClient client = NodeResource.getOvsdbClient(nodeId, this);
- return OvsdbRow.fromJsonNode(client, OvsVswitchdSchemaConstants.DATABASE_NAME, jsonNode);
- }
-
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- public Response getRows() throws JsonProcessingException {
- OvsdbConfigurationService
- ovsdbTable = (OvsdbConfigurationService)ServiceHelper.getGlobalInstance(OvsdbConfigurationService.class,
- this);
- if (ovsdbTable == null) {
- throw new ServiceUnavailableException("Ovsdb ConfigurationService " + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- Node node = NodeResource.getOvsdbNode(nodeId, this);
- Map<UUID,Row<GenericTableSchema>> rows = null;
- try {
- rows = ovsdbTable.getRows(node, databaseName, tableName);
- } catch (Exception e) {
- throw new BadRequestException(e.getMessage());
- }
- String response = objectMapper.writeValueAsString(rows);
- return Response.status(Response.Status.OK)
- .entity(response)
- .build();
- }
-
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response createRow(InputStream stream) throws IOException {
- OvsdbRow localRow = this.getOvsdbRow(stream);
- if (localRow == null) {
- return Response.status(Response.Status.BAD_REQUEST).build();
- }
- OvsdbConfigurationService
- ovsdbTable = (OvsdbConfigurationService)ServiceHelper.getGlobalInstance(OvsdbConfigurationService.class,
- this);
- if (ovsdbTable == null) {
- throw new ServiceUnavailableException("OVS Configuration Service " + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- Node node = NodeResource.getOvsdbNode(nodeId, this);
- Row row = ovsdbTable.insertTree(node, OvsVswitchdSchemaConstants.DATABASE_NAME, tableName,
- localRow.getParentTable(), new UUID(localRow.getParentUuid()), localRow.getParentColumn(),
- localRow.getRow());
- String response = objectMapper.writeValueAsString(row);
- return Response.status(Response.Status.CREATED)
- .entity(response)
- .build();
- }
-
- @GET
- @Path("{id}")
- @Produces(MediaType.APPLICATION_JSON)
- public Response getRowDetails(@PathParam("id") String id) throws JsonProcessingException {
- OvsdbConfigurationService
- ovsdbTable = (OvsdbConfigurationService)ServiceHelper.getGlobalInstance(OvsdbConfigurationService.class,
- this);
- if (ovsdbTable == null) {
- throw new ServiceUnavailableException("Ovsdb ConfigurationService " + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- Node node = NodeResource.getOvsdbNode(nodeId, this);
- Row<GenericTableSchema> row = null;
- try {
- row = ovsdbTable.getRow(node, databaseName, tableName, new UUID(id));
- } catch (Exception e) {
- throw new BadRequestException(e.getMessage());
- }
- String response = objectMapper.writeValueAsString(row);
- return Response.status(Response.Status.OK)
- .entity(response)
- .build();
- }
-
- @PUT
- @Path("{id}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response updateRow(@PathParam("id") String id, InputStream stream) throws IOException{
- OvsdbRow localRow = this.getOvsdbRow(stream);
- if (localRow == null) {
- return Response.status(Response.Status.BAD_REQUEST).build();
- }
- OvsdbConfigurationService ovsdbTable = (OvsdbConfigurationService)ServiceHelper.getGlobalInstance(OvsdbConfigurationService.class,
- this);
- if (ovsdbTable == null) {
- throw new ServiceUnavailableException("OVS Configuration Service " + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- Node node = NodeResource.getOvsdbNode(nodeId, this);
- Row<GenericTableSchema> row = ovsdbTable.updateRow(node, databaseName, tableName, new UUID(id), localRow.getRow(), true);
- String response = objectMapper.writeValueAsString(row);
- return Response.status(Response.Status.OK)
- .entity(response)
- .build();
- }
-
- @DELETE
- @Path("{id}")
- @Consumes(MediaType.APPLICATION_JSON)
- public Response deleteRow(@PathParam("id") String id){
- OvsdbConfigurationService
- ovsdbTable = (OvsdbConfigurationService)ServiceHelper.getGlobalInstance(OvsdbConfigurationService.class,
- this);
- if (ovsdbTable == null) {
- throw new ServiceUnavailableException("Ovsdb ConfigurationService " + RestMessages.SERVICEUNAVAILABLE.toString());
- }
-
- Node node = NodeResource.getOvsdbNode(nodeId, this);
- try {
- ovsdbTable.deleteRow(node, databaseName, tableName, new UUID(id));
- } catch (Exception e) {
- throw new BadRequestException(e.getMessage());
- }
- return Response.status(Response.Status.OK)
- .build();
-
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Red Hat, 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.ovsdb.northbound;
-
-import com.fasterxml.jackson.databind.SerializationFeature;
-import java.util.Set;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.opendaylight.ovsdb.lib.OvsdbClient;
-import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
-import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
-import org.opendaylight.ovsdb.lib.schema.TableSchema;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * Northbound interface for OVSDB tables
- */
-public class TableResource {
- ObjectMapper objectMapper;
- String databaseName;
- String nodeId;
-
- TableResource(String nodeId, String databaseName){
- this.nodeId = nodeId;
- this.databaseName = databaseName;
- objectMapper = new ObjectMapper();
- objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
- }
-
- private DatabaseSchema getDatabaseSchema (String databaseName) {
- OvsdbClient client = NodeResource.getOvsdbClient(nodeId, this);
- return client.getDatabaseSchema(databaseName);
- }
-
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- public Response getTables() throws JsonProcessingException {
- DatabaseSchema dbSchema = this.getDatabaseSchema(databaseName);
- if (dbSchema == null) {
- return Response.noContent().build();
- }
- String response = objectMapper.writeValueAsString(dbSchema.getTables());
- return Response.status(Response.Status.OK)
- .entity(response)
- .build();
- }
-
- @GET
- @Path("{name}")
- @Produces(MediaType.APPLICATION_JSON)
- public Response getTableDetails(@PathParam("name") String name) throws JsonProcessingException {
- String csTableName = this.caseSensitiveTableName(databaseName, name);
- DatabaseSchema dbSchema = this.getDatabaseSchema(databaseName);
- if (dbSchema == null) {
- return Response.noContent().build();
- }
- TableSchema<GenericTableSchema> tableSchema = dbSchema.table(csTableName, GenericTableSchema.class);
- String response = objectMapper.writeValueAsString(tableSchema);
- return Response.status(Response.Status.OK)
- .entity(response)
- .build();
- }
-
- @Path("{name}/row")
- public RowResource getDatabaseTables(@PathParam("name") String name){
- return new RowResource(nodeId, databaseName, name);
- }
-
- private String caseSensitiveTableName (String databaseName, String ciTableName) {
- DatabaseSchema dbSchema = this.getDatabaseSchema(databaseName);
- if (dbSchema == null) {
- return ciTableName;
- }
- Set<String> tables = dbSchema.getTables();
- if (tables == null) {
- return ciTableName;
- }
- for (String tableName : tables) {
- if (tableName.equalsIgnoreCase(ciTableName)) {
- return tableName;
- }
- }
- return ciTableName;
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
- <servlet>
- <servlet-name>OVSDB</servlet-name>
- <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
- <init-param>
- <param-name>javax.ws.rs.Application</param-name>
- <param-value> org.opendaylight.controller.northbound.commons.NorthboundApplication</param-value>
- </init-param>
- <init-param>
- <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
- <param-value>true</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>OVSDB</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
- <filter>
- <filter-name>CorsFilter</filter-name>
- <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
- <init-param>
- <param-name>cors.allowed.origins</param-name>
- <param-value>*</param-value>
- </init-param>
- <init-param>
- <param-name>cors.allowed.methods</param-name>
- <param-value>GET,POST,HEAD,OPTIONS,PUT,DELETE</param-value>
- </init-param>
- <init-param>
- <param-name>cors.allowed.headers</param-name>
- <param-value>Content-Type,X-Requested-With,accept,authorization, origin,Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value>
- </init-param>
- <init-param>
- <param-name>cors.exposed.headers</param-name>
- <param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
- </init-param>
- <init-param>
- <param-name>cors.support.credentials</param-name>
- <param-value>true</param-value>
- </init-param>
- <init-param>
- <param-name>cors.preflight.maxage</param-name>
- <param-value>10</param-value>
- </init-param>
- </filter>
- <filter-mapping>
- <filter-name>CorsFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>NB api</web-resource-name>
- <url-pattern>/*</url-pattern>
- <http-method>POST</http-method>
- <http-method>GET</http-method>
- <http-method>PUT</http-method>
- <http-method>PATCH</http-method>
- <http-method>DELETE</http-method>
- <http-method>HEAD</http-method>
- </web-resource-collection>
- <auth-constraint>
- <role-name>System-Admin</role-name>
- <role-name>Network-Admin</role-name>
- </auth-constraint>
- </security-constraint>
-
- <security-role>
- <role-name>System-Admin</role-name>
- </security-role>
- <security-role>
- <role-name>Network-Admin</role-name>
- </security-role>
-
- <login-config>
- <auth-method>BASIC</auth-method>
- <realm-name>opendaylight</realm-name>
- </login-config>
-</web-app>
+++ /dev/null
-/*
- * Copyright (C) 2015 Red Hat, Inc.
- *
- * 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
- *
- * Authors : Sam Hague
- */
-package org.opendaylight.ovsdb.northbound;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.fail;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.when;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.google.common.collect.Lists;
-import java.util.List;
-import javax.ws.rs.core.Response;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException;
-import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException;
-import org.opendaylight.ovsdb.plugin.api.Connection;
-import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
-import org.opendaylight.ovsdb.plugin.impl.ConnectionServiceImpl;
-import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(ServiceHelper.class)
-public class NodeResourceTest {
- private static final String OVS = "OVS";
- private static final String IDENTIFIER = "192.168.120.31:45001";
- private static final String IDENTIFIER2 = "192.168.120.31:45002";
- private static final String OVS_IDENTIFIER = OVS + "|" + IDENTIFIER;
- private static final String OVS_IDENTIFIER2 = OVS + "|" + IDENTIFIER2;
- private static final String BAD_IDENTIFIER = "BAD" + "|" + IDENTIFIER;
-
- @Test
- public void testGetOvsdbNode () {
- ConnectionServiceImpl connectionService = new ConnectionServiceImpl();
- Connection connection = new Connection(IDENTIFIER, null);
- connectionService.putOvsdbConnection(IDENTIFIER, connection);
-
- PowerMockito.mockStatic(ServiceHelper.class);
- when(ServiceHelper.getGlobalInstance(eq(OvsdbConnectionService.class), anyObject()))
- .thenReturn(null)
- .thenReturn(connectionService)
- .thenReturn(connectionService);
-
- try {
- NodeResource.getOvsdbNode(IDENTIFIER, this);
- fail("Expected an ServiceUnavailableException to be thrown");
- } catch (ServiceUnavailableException e) {
- assertSame(ServiceUnavailableException.class, e.getClass());
- }
-
- try {
- NodeResource.getOvsdbNode(BAD_IDENTIFIER, this);
- fail("Expected an ResourceNotFoundException to be thrown");
- } catch (ResourceNotFoundException e) {
- assertSame(ResourceNotFoundException.class, e.getClass());
- }
-
- Node node = NodeResource.getOvsdbNode(OVS_IDENTIFIER, this);
- assertNotNull("Node " + OVS_IDENTIFIER + " is null", node);
- }
-
- @Test
- public void testGetOvsdbConnection () {
- ConnectionServiceImpl connectionService = new ConnectionServiceImpl();
- Connection connection = new Connection(IDENTIFIER, null);
- connectionService.putOvsdbConnection(IDENTIFIER, connection);
-
- PowerMockito.mockStatic(ServiceHelper.class);
- when(ServiceHelper.getGlobalInstance(eq(OvsdbConnectionService.class), anyObject()))
- .thenReturn(null)
- .thenReturn(connectionService)
- .thenReturn(connectionService);
-
- try {
- NodeResource.getOvsdbConnection(IDENTIFIER, this);
- fail("Expected an ServiceUnavailableException to be thrown");
- } catch (ServiceUnavailableException e) {
- assertSame(ServiceUnavailableException.class, e.getClass());
- }
-
- try {
- NodeResource.getOvsdbConnection(BAD_IDENTIFIER, this);
- fail("Expected an ResourceNotFoundException to be thrown");
- } catch (ResourceNotFoundException e) {
- assertSame(ResourceNotFoundException.class, e.getClass());
- }
-
- Connection testConnection = NodeResource.getOvsdbConnection(IDENTIFIER, this);
- assertNotNull("Connection " + OVS_IDENTIFIER + " is null", testConnection);
- }
-
- @Test
- public void testGetNodes () {
- ConnectionServiceImpl connectionService = new ConnectionServiceImpl();
-
- PowerMockito.mockStatic(ServiceHelper.class);
- when(ServiceHelper.getGlobalInstance(eq(OvsdbConnectionService.class), anyObject()))
- .thenReturn(connectionService)
- .thenReturn(connectionService)
- .thenReturn(connectionService);
-
- NodeResource nodeResource = new NodeResource();
-
- // Check getNodes when there are no nodes
- try {
- Response response = nodeResource.getNodes();
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
- assertNotNull("entity should not be null", response.getEntity());
- String id = "";
- List<String> ids = Lists.newArrayList();
- ids.add(id);
- assertEquals("there should be no nodes", ids.toString(), response.getEntity());
- } catch (JsonProcessingException ex) {
- fail("Exception should not have been caught");
- }
-
- // Check getNodes when there is a node
- Connection connection = new Connection(IDENTIFIER, null);
- connectionService.putOvsdbConnection(IDENTIFIER, connection);
-
- try {
- Response response = nodeResource.getNodes();
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
- assertNotNull("entity should not be null", response.getEntity());
- String id = "\"" + OVS_IDENTIFIER + "\"";
- List<String> ids = Lists.newArrayList();
- ids.add(id);
- assertEquals(OVS_IDENTIFIER + " should be found", ids.toString(), response.getEntity());
- } catch (JsonProcessingException ex) {
- fail("Exception should not have been caught");
- }
-
- // Check getNodes when there are multiple nodes
- connection = new Connection(IDENTIFIER2, null);
- connectionService.putOvsdbConnection(IDENTIFIER2, connection);
-
- try {
- Response response = nodeResource.getNodes();
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
- assertNotNull("entity should not be null", response.getEntity());
- String id = "\"" + OVS_IDENTIFIER + "\"";
- String id2 = "\"" + OVS_IDENTIFIER2 + "\"";
- List<String> ids = Lists.newArrayList();
- ids.add(id);
- ids.add(id2);
- assertEquals(OVS_IDENTIFIER + " and " + OVS_IDENTIFIER2 + " should be found",
- ids.toString().replaceAll("\\s",""), response.getEntity());
- } catch (JsonProcessingException ex) {
- fail("Exception should not have been caught");
- }
- }
-}
+++ /dev/null
-/*
-* Copyright (C) 2014 Red Hat, Inc.
-*
-* 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
-*
-* Authors : Sam Hague
-*/
-package org.opendaylight.ovsdb.northbound;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.fail;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.security.Principal;
-import javax.ws.rs.core.SecurityContext;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException;
-import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils;
-import org.opendaylight.controller.sal.authorization.Privilege;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(NorthboundUtils.class)
-public class OvsdbNorthboundV3Test {
- private static final String USER = "admin";
-
- @Test
- public void testSetSecurityContext () {
- SecurityContext securityContext = mock(SecurityContext.class);
- Principal principal = mock(Principal.class);
-
- when(securityContext.getUserPrincipal()).thenReturn(null)
- .thenReturn(principal);
- when(principal.getName()).thenReturn(USER);
-
- OvsdbNorthboundV3 ovsdbNorthboundV3 = new OvsdbNorthboundV3();
-
- // Check if SecurityContext is null
- ovsdbNorthboundV3.setSecurityContext(null);
- String userName = ovsdbNorthboundV3.getUserName();
- assertNull(userName);
-
- // Check if user has no Principal
- ovsdbNorthboundV3.setSecurityContext(securityContext);
- userName = ovsdbNorthboundV3.getUserName();
- assertNull(userName);
-
- // Success case
- ovsdbNorthboundV3.setSecurityContext(securityContext);
- userName = ovsdbNorthboundV3.getUserName();
- assertEquals(USER, userName);
- }
-
- @Test
- public void testGetNode () {
- PowerMockito.mockStatic(NorthboundUtils.class);
- when(NorthboundUtils.isAuthorized(anyString(), eq("default"), eq(Privilege.WRITE), anyObject()))
- .thenReturn(false)
- .thenReturn(true);
-
- OvsdbNorthboundV3 ovsdbNorthboundV3 = new OvsdbNorthboundV3();
-
- // Check for unauthorized user
- try {
- NodeResource nodeResource = ovsdbNorthboundV3.getNode();
- fail("Expected an UnauthorizedException to be thrown");
- } catch (UnauthorizedException e) {
- assertSame(UnauthorizedException.class, e.getClass());
- }
-
- // Success case
- NodeResource nodeResource = ovsdbNorthboundV3.getNode();
- assertNotNull(nodeResource);
- }
-}
portSecurityRule,vmIp.getIpAddress(), write,
Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
break;
+ case MatchUtils.ICMP:
+ egressAclIcmp(dpid, segmentationId, attachedMac,
+ portSecurityRule, vmIp.getIpAddress(),write,
+ Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
+ break;
default:
LOG.error("programPortSecurityAcl: Protocol not supported", portSecurityRule);
break;
egressAclUdp(dpid, segmentationId, attachedMac,
portSecurityRule, null, write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
break;
+ case MatchUtils.ICMP:
+ egressAclIcmp(dpid, segmentationId, attachedMac,
+ portSecurityRule, null, write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
+ break;
default:
LOG.error("programPortSecurityAcl: Protocol not supported", portSecurityRule);
}
syncFlow(flowId, nodeBuilder, matchBuilder, protoPortMatchPriority, write, false);
}
+
+ /**
+ * Creates a egress match with src macaddress. If dest address is specified
+ * destination specific match will be created. Otherwise a match with a
+ * CIDR will be created.
+ * @param dpidLong the dpid
+ * @param segmentationId the segmentation id
+ * @param srcMac the source mac address.
+ * @param portSecurityRule the security rule in the SG
+ * @param dstAddress the source IP address
+ * @param write add or delete
+ * @param protoPortMatchPriority the protocol match priority
+ */
+ private void egressAclIcmp(Long dpidLong, String segmentationId, String srcMac,
+ NeutronSecurityRule portSecurityRule, String dstAddress,
+ boolean write, Integer protoPortMatchPriority) {
+ MatchBuilder matchBuilder = new MatchBuilder();
+ String flowId = "Egress_ICMP" + segmentationId + "_" + srcMac + "_";
+ matchBuilder = MatchUtils.createEtherMatchWithType(matchBuilder,srcMac,null);
+ matchBuilder = MatchUtils.createICMPv4Match(matchBuilder,
+ portSecurityRule.getSecurityRulePortMin().shortValue(),
+ portSecurityRule.getSecurityRulePortMax().shortValue());
+ if (null != dstAddress) {
+ flowId = flowId + dstAddress;
+ matchBuilder = MatchUtils.addRemoteIpPrefix(matchBuilder,null,
+ MatchUtils.iPv4PrefixFromIPv4Address(dstAddress));
+ } else if (null != portSecurityRule.getSecurityRuleRemoteIpPrefix()) {
+ flowId = flowId + portSecurityRule.getSecurityRuleRemoteIpPrefix();
+ matchBuilder = MatchUtils.addRemoteIpPrefix(matchBuilder,null,
+ new Ipv4Prefix(portSecurityRule.getSecurityRuleRemoteIpPrefix()));
+ }
+ String nodeName = Constants.OPENFLOW_NODE_PREFIX + dpidLong;
+ NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
+ syncFlow(flowId, nodeBuilder, matchBuilder, protoPortMatchPriority, write, false);
+
+ }
+
/**
* Creates a egress match with src macaddress. If dest address is specified
* destination specific match will be created. Otherwise a match with a
ingressAclUdp(dpid, segmentationId, attachedMac, portSecurityRule,vmIp.getIpAddress(),
write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
break;
+ case MatchUtils.ICMP:
+ ingressAclIcmp(dpid, segmentationId, attachedMac, portSecurityRule, vmIp.getIpAddress(),
+ write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
+ break;
default:
LOG.error("programPortSecurityAcl: Protocol not supported", portSecurityRule);
break;
ingressAclUdp(dpid, segmentationId, attachedMac,
portSecurityRule, null, write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
break;
+ case MatchUtils.ICMP:
+ ingressAclIcmp(dpid, segmentationId, attachedMac, portSecurityRule, null,
+ write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
+ break;
default:
LOG.error("programPortSecurityAcl: Protocol not supported", portSecurityRule);
}
}
+ /**
+ * Creates a ingress match to the dst macaddress. If src address is specified
+ * source specific match will be created. Otherwise a match with a CIDR will
+ * be created.
+ * @param dpidLong the dpid
+ * @param segmentationId the segmentation id
+ * @param dstMac the destination mac address.
+ * @param portSecurityRule the security rule in the SG
+ * @param srcAddress the destination IP address
+ * @param write add or delete
+ * @param protoPortMatchPriority the protocol match priority
+ */
+ private void ingressAclIcmp(Long dpidLong, String segmentationId, String dstMac,
+ NeutronSecurityRule portSecurityRule, String srcAddress,
+ boolean write, Integer protoPortMatchPriority) {
+
+ MatchBuilder matchBuilder = new MatchBuilder();
+ FlowBuilder flowBuilder = new FlowBuilder();
+ String flowId = "ingressAclICMP" + segmentationId + "_" + dstMac;
+ matchBuilder = MatchUtils.createEtherMatchWithType(matchBuilder,null,dstMac);
+ matchBuilder = MatchUtils.createICMPv4Match(matchBuilder,
+ portSecurityRule.getSecurityRulePortMin().shortValue(),
+ portSecurityRule.getSecurityRulePortMax().shortValue());
+ if (null != srcAddress) {
+ flowId = flowId + srcAddress;
+ matchBuilder = MatchUtils.addRemoteIpPrefix(matchBuilder,
+ MatchUtils.iPv4PrefixFromIPv4Address(srcAddress), null);
+
+ } else if (null != portSecurityRule.getSecurityRuleRemoteIpPrefix()) {
+ flowId = flowId + portSecurityRule.getSecurityRuleRemoteIpPrefix();
+ matchBuilder = MatchUtils.addRemoteIpPrefix(matchBuilder,
+ new Ipv4Prefix(portSecurityRule.getSecurityRuleRemoteIpPrefix()),null);
+ }
+ String nodeName = Constants.OPENFLOW_NODE_PREFIX + dpidLong;
+ NodeBuilder nodeBuilder = createNodeBuilder(nodeName);
+ flowId = flowId + "_Permit_";
+ syncFlow(flowId, nodeBuilder, matchBuilder, protoPortMatchPriority, write, false);
+ }
+
public void ingressACLTcpSyn(Long dpidLong, String segmentationId, String attachedMac, boolean write,
Integer securityRulePortMin, Integer protoPortMatchPriority) {
verify(commitFuture, times(2)).get();
}
+ /**
+ * Test ICMP add with code, type and CIDR selected.
+ */
+ @Test
+ public void testProgramPortSecurityACLRuleAddIcmp1() throws Exception {
+ when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("icmp");
+ when(portSecurityRule.getSecurityRulePortMax()).thenReturn(50);
+ when(portSecurityRule.getSecurityRulePortMin()).thenReturn(50);
+ when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
+
+ egressAclServiceSpy.programPortSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,neutronSrcIpList,true);
+
+ verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
+ verify(writeTransaction, times(1)).submit();
+ verify(commitFuture, times(1)).get();
+ }
+
+ /**
+ * Test ICMP remove with code, type and CIDR selected.
+ */
+ @Test
+ public void testProgramPortSecurityACLRuleRemoveIcmp1() throws Exception {
+ when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("icmp");
+ when(portSecurityRule.getSecurityRulePortMax()).thenReturn(50);
+ when(portSecurityRule.getSecurityRulePortMin()).thenReturn(50);
+ when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
+
+ egressAclServiceSpy.programPortSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,neutronSrcIpList,false);
+
+ verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
+ verify(writeTransaction, times(1)).submit();
+ verify(commitFuture, times(1)).get();
+ }
+
+ /**
+ * Test ICMP add with code, type and remote SG selected.
+ */
+ @Test
+ public void testProgramPortSecurityACLRuleAddIcmp2() throws Exception {
+ when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("icmp");
+ when(portSecurityRule.getSecurityRulePortMax()).thenReturn(50);
+ when(portSecurityRule.getSecurityRulePortMin()).thenReturn(50);
+ when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
+ when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+
+ egressAclServiceSpy.programPortSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,neutronSrcIpList,true);
+
+ verify(writeTransaction, times(4)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
+ verify(writeTransaction, times(2)).submit();
+ verify(commitFuture, times(2)).get();
+ }
+
+ /**
+ * Test ICMP remove with code, type and remote SG selected.
+ */
+ @Test
+ public void testProgramPortSecurityACLRuleRemoveIcmp2() throws Exception {
+ when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("icmp");
+ when(portSecurityRule.getSecurityRulePortMax()).thenReturn(50);
+ when(portSecurityRule.getSecurityRulePortMin()).thenReturn(50);
+ when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
+ when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+
+ egressAclServiceSpy.programPortSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,neutronSrcIpList,false);
+
+ verify(writeTransaction, times(2)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
+ verify(writeTransaction, times(2)).submit();
+ verify(commitFuture, times(2)).get();
+ }
+
/**
* Test IPv4 invalid ether type test case.
*/
verify(commitFuture, times(2)).get();
}
+ /**
+ * Test ICMP add with code, type and CIDR selected.
+ */
+ @Test
+ public void testProgramPortSecurityACLRuleAddIcmp1() throws Exception {
+ when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("icmp");
+ when(portSecurityRule.getSecurityRulePortMax()).thenReturn(50);
+ when(portSecurityRule.getSecurityRulePortMin()).thenReturn(50);
+ when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
+
+ ingressAclServiceSpy.programPortSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,neutronSrcIpList,true);
+
+ verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
+ verify(writeTransaction, times(1)).submit();
+ verify(commitFuture, times(1)).get();
+ }
+
+ /**
+ * Test ICMP remove with code, type and CIDR selected.
+ */
+ @Test
+ public void testProgramPortSecurityACLRuleRemoveIcmp1() throws Exception {
+ when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("icmp");
+ when(portSecurityRule.getSecurityRulePortMax()).thenReturn(50);
+ when(portSecurityRule.getSecurityRulePortMin()).thenReturn(50);
+ when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
+
+ ingressAclServiceSpy.programPortSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,neutronSrcIpList,false);
+
+ verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
+ verify(writeTransaction, times(1)).submit();
+ verify(commitFuture, times(1)).get();
+ }
+
+ /**
+ * Test ICMP add with code, type and remote SG selected.
+ */
+ @Test
+ public void testProgramPortSecurityACLRuleAddIcmp2() throws Exception {
+ when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("icmp");
+ when(portSecurityRule.getSecurityRulePortMax()).thenReturn(50);
+ when(portSecurityRule.getSecurityRulePortMin()).thenReturn(50);
+ when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
+ when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+
+ ingressAclServiceSpy.programPortSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,neutronSrcIpList,true);
+
+ verify(writeTransaction, times(4)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
+ verify(writeTransaction, times(2)).submit();
+ verify(commitFuture, times(2)).get();
+ }
+
+ /**
+ * Test ICMP remove with code, type and remote SG selected.
+ */
+ @Test
+ public void testProgramPortSecurityACLRuleRemoveIcmp2() throws Exception {
+ when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("icmp");
+ when(portSecurityRule.getSecurityRulePortMax()).thenReturn(50);
+ when(portSecurityRule.getSecurityRulePortMin()).thenReturn(50);
+ when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
+ when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+
+ ingressAclServiceSpy.programPortSecurityAcl(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,neutronSrcIpList,false);
+
+ verify(writeTransaction, times(2)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
+ verify(writeTransaction, times(2)).submit();
+ verify(commitFuture, times(2)).get();
+ }
+
/**
* Test IPv4 invalid ether type test case.
*/
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright (C) 2014 Red Hat, 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
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>commons</artifactId>
- <version>1.4.0-SNAPSHOT</version>
- <relativePath>../commons/parent</relativePath>
- </parent>
-
- <artifactId>plugin-mdsal-adapter</artifactId>
- <version>1.2.1-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.dependencymanager</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <!-- Yang Models -->
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>concepts</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>yang-binding</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-inet-types</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller.model</groupId>
- <artifactId>model-inventory</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.openflowplugin.model</groupId>
- <artifactId>model-flow-service</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>yang-ext</artifactId>
- </dependency>
- <!-- Controller Dependencies -->
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>library</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>plugin</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.ovsdb</groupId>
- <artifactId>schema.openvswitch</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>2.4.0</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Import-Package>
- org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.*,
- org.opendaylight.controller.sal.binding.api,
- org.opendaylight.ovsdb.plugin.api,
- org.apache.felix.dm,
- org.slf4j,
- org.eclipse.osgi.framework.console,
- org.osgi.framework,
- javax.net.ssl,
- *
- </Import-Package>
- <Embed-Transitive>true</Embed-Transitive>
- <Bundle-Activator>
- org.opendaylight.ovsdb.plugin.md.Activator
- </Bundle-Activator>
- </instructions>
- <manifestLocation>${project.basedir}/META-INF</manifestLocation>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2013, 2015 Red Hat, 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.ovsdb.plugin.md;
-
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
-import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
-import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryListener;
-
-import org.apache.felix.dm.Component;
-
-/**
- * OSGi Bundle Activator for the Neutron providers
- */
-public class Activator extends ComponentActivatorAbstractBase {
- /**
- * Function called when the activator starts just after some
- * initializations are done by the
- * ComponentActivatorAbstractBase.
- */
- @Override
- public void init() {
- }
-
- /**
- * Function called when the activator stops just before the
- * cleanup done by ComponentActivatorAbstractBase.
- *
- */
- @Override
- public void destroy() {
- }
-
- /**
- * Function that is used to communicate to dependency manager the
- * list of known implementations for services inside a container.
- *
- * @return An array containing all the CLASS objects that will be
- * instantiated in order to get an fully working implementation
- * Object
- */
- @Override
- public Object[] getImplementations() {
- Object[] res = {OvsdbBindingAwareProviderImpl.class,
- OvsdbInventoryManager.class };
- return res;
- }
-
- /**
- * Function that is called when configuration of the dependencies
- * is required.
- *
- * @param c dependency manager Component object, used for
- * configuring the dependencies exported and imported
- * @param imp Implementation class that is being configured,
- * needed as long as the same routine can configure multiple
- * implementations
- * @param containerName The containerName being configured, this allow
- * also optional per-container different behavior if needed, usually
- * should not be the case though.
- */
- @Override
- public void configureInstance(Component c, Object imp,
- String containerName) {
-
- if (imp.equals(OvsdbBindingAwareProviderImpl.class)) {
- c.setInterface(OvsdbBindingAwareProvider.class.getName(), null);
- c.add(createServiceDependency()
- .setService(BindingAwareBroker.class)
- .setRequired(true));
- }
-
- if (imp.equals(OvsdbInventoryManager.class)) {
- c.setInterface(OvsdbInventoryListener.class.getName(), null);
- c.add(createServiceDependency()
- .setService(OvsdbBindingAwareProvider.class)
- .setRequired(true));
- c.add(createServiceDependency()
- .setService(OvsdbConfigurationService.class)
- .setRequired(true));
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013, 2015 Red Hat, 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.ovsdb.plugin.md;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.sal.binding.api.NotificationService;
-
-/**
- * Created by dave on 01/08/2014.
- */
-public interface OvsdbBindingAwareProvider {
- public DataBroker getDataBroker();
- public NotificationService getNotificationService();
-}
+++ /dev/null
-/*
- * Copyright (c) 2013, 2015 Red Hat, 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.ovsdb.plugin.md;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.NotificationService;
-
-import org.apache.felix.dm.Component;
-import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class OvsdbBindingAwareProviderImpl extends AbstractBindingAwareProvider implements OvsdbBindingAwareProvider {
-
- private DataBroker dataBroker;
- private NotificationProviderService notificationService;
-
- static final Logger logger = LoggerFactory.getLogger(OvsdbBindingAwareProvider.class);
-
- private BundleContext bc;
- private volatile BindingAwareBroker broker;
-
- void init(Component c) {
- this.bc = c.getDependencyManager().getBundleContext();
- broker.registerProvider(this, this.bc);
- logger.info("OVSDB MD-SAL Inventory Adapter Registered With the MD-SAL");
- }
-
- void destroy() {
- this.dataBroker = null;
- this.notificationService = null;
- }
-
- @Override
- public void onSessionInitiated(BindingAwareBroker.ProviderContext providerContext) {
- this.dataBroker = providerContext.getSALService(DataBroker.class);
- this.notificationService = providerContext.getSALService(NotificationProviderService.class);
- }
-
- @Override
- public DataBroker getDataBroker() {
- return this.dataBroker;
- }
-
- @Override
- public NotificationService getNotificationService() {
- return this.notificationService;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013, 2015 Red Hat, 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.ovsdb.plugin.md;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.sal.utils.HexEncode;
-import org.opendaylight.ovsdb.lib.notation.Row;
-import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
-import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryListener;
-import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.ovsdb.node.inventory.rev140731.OvsdbCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.ovsdb.node.inventory.rev140731.OvsdbCapableNodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.ovsdb.node.inventory.rev140731.OvsdbManagedNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.ovsdb.node.inventory.rev140731.OvsdbManagedNodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.ovsdb.node.inventory.rev140731.nodes.node.OvsdbBridge;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.ovsdb.node.inventory.rev140731.nodes.node.OvsdbBridgeBuilder;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-
-/**
- * Handle OVSDB Inventory Updates and create the necessary entries in the MD-SAL config datastore
- */
-public class OvsdbInventoryManager implements OvsdbInventoryListener {
-
- // Dependencies injected by OSGi
- private volatile OvsdbBindingAwareProvider provider;
- private volatile OvsdbConfigurationService ovsdbConfigurationService;
-
- static final String OVS_NODE_PREFIX = "openvswitch:";
- static final String OPENFLOW_NODE_PREFIX = "openflow:";
-
- static final Logger LOGGER = LoggerFactory.getLogger(OvsdbInventoryManager.class);
-
-
- /**
- * Called by the framework when the bundle is started
- */
- public void start() {
- //ToDo: Add existing nodes from inventory
- //This case is required for surviving controller reboot
- }
-
- /**
- * When an AD-SAL node is added by the OVSDB Inventory Service, Add an MD-SAL node
- *
- * @param node The AD-SAL node
- * @param address The {@link java.net.InetAddress} of the Node
- * @param port The ephemeral port number used by this connection
- */
- @Override
- public synchronized void nodeAdded(org.opendaylight.controller.sal.core.Node node,
- InetAddress address,
- int port) {
- DataBroker dataBroker = provider.getDataBroker();
- Preconditions.checkNotNull(dataBroker);
-
- NodeId nodeId = new NodeId(OVS_NODE_PREFIX + node.getNodeIDString());
- NodeKey nodeKey = new NodeKey(nodeId);
-
- OvsdbCapableNode ovsdbNode = new OvsdbCapableNodeBuilder()
- .setIpAddress(Utils.convertIpAddress(address))
- .setPort(new PortNumber(port))
- .setManagedNodes(new ArrayList<NodeId>())
- .build();
-
- Node newNode = new NodeBuilder()
- .setId(nodeId)
- .setKey(nodeKey)
- .addAugmentation(OvsdbCapableNode.class, ovsdbNode)
- .build();
-
- InstanceIdentifier<Node> path = InstanceIdentifier.builder(Nodes.class)
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class, nodeKey)
- .toInstance();
-
- WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
- tx.put(LogicalDatastoreType.CONFIGURATION, path, newNode, true);
- try {
- tx.submit().get();
- LOGGER.debug("Removed Node {}", path.toString());
- } catch (InterruptedException | ExecutionException e) {
- LOGGER.error(e.getMessage(), e);
- }
- }
-
- /**
- * When an AD-SAL node is removed by the OVSDB Inventory Service, Remove the MD-SAL node
- *
- * @param node The AD-SAL node
- */
- @Override
- public synchronized void nodeRemoved(org.opendaylight.controller.sal.core.Node node) {
- DataBroker dataBroker = provider.getDataBroker();
- Preconditions.checkNotNull(dataBroker);
-
- NodeId nodeId = new NodeId(new NodeId(OVS_NODE_PREFIX + node.getNodeIDString()));
- NodeKey nodeKey = new NodeKey(nodeId);
-
- InstanceIdentifier<Node> path = InstanceIdentifier.builder(Nodes.class)
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class, nodeKey)
- .toInstance();
-
- WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
- tx.delete(LogicalDatastoreType.CONFIGURATION, path);
- try {
- tx.submit().get();
- LOGGER.debug("Removed Node {}", path.toString());
- } catch (InterruptedException | ExecutionException e) {
- LOGGER.error(e.getMessage(), e);
- }
- }
-
- /**
- * Handle OVSDB row removed When a Bridge row is removed, the OpenFlow Node is deleted The parent OVSDB node is
- * updated and the OpenFlow node removed from it's managed-nodes list
- *
- * @param node The AD-SAL node
- * @param tableName The name of modified table
- * @param uuid The UUID of the deleted row
- * @param row The deleted Row
- */
- @Override
- public synchronized void rowRemoved(org.opendaylight.controller.sal.core.Node node,
- String tableName,
- String uuid,
- Row row,
- Object context) {
- if (tableName.equalsIgnoreCase(ovsdbConfigurationService.getTableName(node, Bridge.class))) {
- LOGGER.debug("OVSDB Bridge Row removed on node {}", node.toString());
- DataBroker dataBroker = provider.getDataBroker();
- Preconditions.checkNotNull(dataBroker);
-
- Bridge bridge = ovsdbConfigurationService.getTypedRow(node, Bridge.class, row);
- Set<String> dpidString = bridge.getDatapathIdColumn().getData();
- Long dpid = HexEncode.stringToLong((String) dpidString.toArray()[0]);
-
- NodeId openflowNodeId = new NodeId(OPENFLOW_NODE_PREFIX + dpid.toString());
- NodeKey openflowNodeKey = new NodeKey(openflowNodeId);
-
- InstanceIdentifier<Node> openflowNodePath = InstanceIdentifier.builder(Nodes.class)
- .child(Node.class, openflowNodeKey)
- .toInstance();
-
- NodeId ovsdbNodeId = new NodeId(OVS_NODE_PREFIX + node.getNodeIDString());
- NodeKey ovsdbNodeKey = new NodeKey(ovsdbNodeId);
-
- InstanceIdentifier<OvsdbCapableNode> ovsdbNodePath = InstanceIdentifier.builder(Nodes.class)
- .child(Node.class, ovsdbNodeKey)
- .augmentation(OvsdbCapableNode.class)
- .toInstance();
-
- // Read the current OVSDB Node from the DataStore
- ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
- OvsdbCapableNode ovsdbNode;
- try {
- Optional<OvsdbCapableNode> data = tx.read(LogicalDatastoreType.CONFIGURATION, ovsdbNodePath).get();
- if (!data.isPresent()) {
- LOGGER.error("OVSDB node not updated. Parent node for {} does not exist", ovsdbNodePath.toString());
- return;
- }
- ovsdbNode = data.get();
- } catch (InterruptedException | ExecutionException e) {
- LOGGER.error("OVSDB node not updated. Parent node for {} does not exist", ovsdbNodePath.toString());
- return;
- }
-
- // Update the list of Nodes
- List<NodeId> managedNodesList = ovsdbNode.getManagedNodes();
- managedNodesList.remove(openflowNodeId);
-
- // Write changes to DataStore
- OvsdbCapableNode updatedNode = new OvsdbCapableNodeBuilder(ovsdbNode)
- .setManagedNodes(managedNodesList)
- .build();
- tx.delete(LogicalDatastoreType.CONFIGURATION, openflowNodePath);
- tx.put(LogicalDatastoreType.CONFIGURATION, ovsdbNodePath, updatedNode);
-
- try {
- tx.submit().get();
- LOGGER.debug("Transaction success for delete of {} and update of {}",
- openflowNodePath.toString(),
- ovsdbNodePath.toString());
- } catch (InterruptedException | ExecutionException e) {
- LOGGER.error(e.getMessage(), e);
- }
- }
- }
-
- /**
- * Handle OVSDB row updates When a Bridge row is updated and it contains a DPID then add a new OpenFlow node to the
- * inventory A relationship is created between the OpenFlow and OVSDB nodes
- *
- * @param node The AD-SAL node
- * @param tableName The name of the updated table
- * @param uuid The UUID of the updated row
- * @param old The old contents of the row
- * @param row The updated Row
- */
- @Override
- public synchronized void rowUpdated(org.opendaylight.controller.sal.core.Node node,
- String tableName,
- String uuid,
- Row old,
- Row row) {
- LOGGER.debug("OVSDB Bridge Row updated on node {}", node.toString());
- if (tableName.equalsIgnoreCase(ovsdbConfigurationService.getTableName(node, Bridge.class))) {
- DataBroker dataBroker = provider.getDataBroker();
- Bridge bridge = ovsdbConfigurationService.getTypedRow(node, Bridge.class, row);
-
- Set<String> dpidString = bridge.getDatapathIdColumn().getData();
- Long dpid;
- try {
- dpid = HexEncode.stringToLong((String) dpidString.toArray()[0]);
- } catch (ArrayIndexOutOfBoundsException e) {
- return;
- }
-
- NodeId openflowNodeId = new NodeId(OPENFLOW_NODE_PREFIX + dpid.toString());
- NodeKey openflowNodeKey = new NodeKey(openflowNodeId);
-
- InstanceIdentifier<OvsdbManagedNode> openflowNodepath = InstanceIdentifier.builder(Nodes.class)
- .child(Node.class, openflowNodeKey)
- .augmentation(OvsdbManagedNode.class)
- .toInstance();
-
- NodeId ovsdbNodeId = new NodeId(OVS_NODE_PREFIX + node.getNodeIDString());
- NodeKey ovsdbNodeKey = new NodeKey(ovsdbNodeId);
-
- InstanceIdentifier<OvsdbCapableNode> ovsdbNodePath = InstanceIdentifier.builder(Nodes.class)
- .child(Node.class, ovsdbNodeKey)
- .augmentation(OvsdbCapableNode.class)
- .toInstance();
-
- // Create an OvsdbBridge object using the information from the update
- OvsdbBridge ovsdbBridge = new OvsdbBridgeBuilder()
- .setBridgeName(bridge.getName())
- .setBridgeUuid(uuid)
- .setManagedBy(ovsdbNodeId)
- .build();
-
- // Add the bridge to the OvsdbManagedNode
- OvsdbManagedNode ovsdbManagedNode = new OvsdbManagedNodeBuilder()
- .setOvsdbBridge(ovsdbBridge)
- .build();
-
- // Read the current OVSDB Node from the DataStore
- ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
- OvsdbCapableNode ovsdbNode;
- try {
- Optional<OvsdbCapableNode> data = tx.read(LogicalDatastoreType.CONFIGURATION, ovsdbNodePath).get();
- if (!data.isPresent()) {
- LOGGER.error("OVSDB node not updated. Parent node for {} does not exist", ovsdbNodePath.toString());
- return;
- }
- ovsdbNode = data.get();
- } catch (InterruptedException | ExecutionException e) {
- throw new RuntimeException("Node does not exist");
- }
-
- // Update the list of Nodes
- List<NodeId> managedNodesList = ovsdbNode.getManagedNodes();
- managedNodesList.add(openflowNodeId);
-
- // Create a delta object
- OvsdbCapableNode updatedNode = new OvsdbCapableNodeBuilder(ovsdbNode)
- .setManagedNodes(managedNodesList)
- .build();
-
- // Create parent if we get to this node before openflowplugin
- tx.put(LogicalDatastoreType.CONFIGURATION, openflowNodepath, ovsdbManagedNode, true);
- tx.put(LogicalDatastoreType.CONFIGURATION, ovsdbNodePath, updatedNode);
-
- try {
- tx.submit().get();
- LOGGER.debug("Transaction success for addition of {} and update of {}",
- openflowNodepath.toString(),
- ovsdbNodePath.toString());
- } catch (InterruptedException | ExecutionException e) {
- LOGGER.error(e.getMessage(), e);
- }
- }
- }
-
- @Override
- public synchronized void rowAdded(org.opendaylight.controller.sal.core.Node node,
- String tableName,
- String uuid,
- Row row) {
- // noop
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2013, 2015 Red Hat, 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.ovsdb.plugin.md;
-
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.Inet4Address;
-import java.net.InetAddress;
-
-/**
- * Utilities to convert Java types to the types specified in the Yang models
- */
-public final class Utils {
-
- static final Logger logger = LoggerFactory.getLogger(Utils.class);
-
- /**
- * Returns a {@link org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress}
- * from a @{link java.net.InetAddress}
- */
- public static IpAddress convertIpAddress(InetAddress inetAddress){
-
- if (inetAddress instanceof Inet4Address){
- Ipv4Address ipv4Address = new Ipv4Address(inetAddress.getHostAddress());
- return new IpAddress(ipv4Address);
- }
- else {
- Ipv6Address ipv6Address = new Ipv6Address(inetAddress.getHostAddress());
- return new IpAddress(ipv6Address);
- }
- }
-}
+++ /dev/null
-module ovsdb-node-inventory {
- namespace "urn:opendaylight:ovsdb-node-inventory";
- prefix "ovsdbinv";
-
- import opendaylight-inventory {
- prefix inv;
- revision-date "2013-08-19";
- }
-
- import yang-ext {
- prefix ext;
- revision-date "2013-07-09";
- }
-
- import ietf-inet-types {
- prefix inet;
- revision-date "2010-09-24";
- }
-
- import flow-node-inventory {
- prefix flowcapable;
- revision-date "2013-08-19";
- }
-
- revision "2014-07-31" {
- description "Initial revision of the OVSDB Inventory model";
- }
-
- grouping ovsdb-bridge-attributes {
- leaf bridge-uuid {
- description "The unique identifier of the bridge";
- type string;
- }
-
- leaf bridge-name {
- description "The name of the bridge";
- type string;
- }
-
- leaf managed-by {
- description "The OVSDB which this bridge belongs to";
- type inv:node-id;
- }
- }
-
- grouping ovsdb-node-attributes {
- leaf ip-address {
- description "The IP Address of an OVSDB node";
- type inet:ip-address;
- }
-
- leaf port {
- description "The port that an OVSDB node is connected on";
- type inet:port-number;
- }
-
- leaf-list managed-nodes {
- type inv:node-id;
- }
- }
-
- augment /inv:nodes/inv:node {
- ext:augment-identifier "ovsdb-managed-node";
- // when "/inv:nodes/inv:node/flowcapable:manufacturer = '*'";
- container ovsdb-bridge {
- uses ovsdb-bridge-attributes;
- }
- }
-
- augment /inv:nodes/inv:node {
- ext:augment-identifier "ovsdb-capable-node";
- uses ovsdb-node-attributes;
- }
-
-}
+++ /dev/null
-package org.opendaylight.ovsdb.plugin.md;
-
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.net.Inet4Address;
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-public class UtilsTest {
-
- static final String IPV4_ADDRESS = "10.10.10.10";
- static final String IPV6_ADDRESS = "2001:db8:0:0:0:ff00:42:8329";
-
- @Test
- public void testConvertIpAddress() throws UnknownHostException {
-
- InetAddress addressV4 = Inet4Address.getByName(IPV4_ADDRESS);
- InetAddress addressV6 = Inet6Address.getByName(IPV6_ADDRESS);
-
- IpAddress ipAddresV4 = Utils.convertIpAddress(addressV4);
- IpAddress ipAddresV6 = Utils.convertIpAddress(addressV6);
-
- Assert.assertEquals(IPV4_ADDRESS, ipAddresV4.getIpv4Address().getValue());
- Assert.assertEquals(IPV6_ADDRESS, ipAddresV6.getIpv6Address().getValue());
- }
-}
\ No newline at end of file
<module>karaf</module>
<!-- OVSDB Components -->
<module>southbound</module>
- <module>northbound</module>
<module>openstack</module>
<module>ovsdb-artifacts</module>
<module>schemas</module>
+++ /dev/null
-{
- "id": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "name": "OVSDB Northbound APIs",
- "description": "Northbound APIs exposed by ovsdb.northbound bundle",
- "order": [
- "1aaa544a-7d79-3159-84b5-89574ff7f3e2",
- "190627e6-ef20-863f-998b-e019034874c4",
- "d70a4755-d62a-dfcd-e363-dbe931af99a0"
- ],
- "folders": [
- {
- "id": "f0bc8237-daf6-5584-4011-1549618623b5",
- "name": "01 BRIDGE",
- "description": "",
- "order": [
- "085fa6c6-1d5b-8afb-4e4a-56cafe5e8bd0",
- "aed6c263-4d42-ca35-669f-33a00c3d9c82",
- "6f5b8f9a-3e66-16b0-7a16-62a96313eab5",
- "7e41f2e4-6797-64f0-ebd2-b4b634b6a559",
- "2ced04cd-b934-9a0a-576d-8640b6a0b80e"
- ],
- "collection_name": "OVSDB Northbound APIs",
- "collection_id": "b4485302-3406-776b-fb0c-94d74c76dc36"
- },
- {
- "id": "d5c6f3fa-0354-d2db-a2e8-4cb29ade5580",
- "name": "02 PORT",
- "description": "",
- "order": [
- "2990bcf5-976b-413a-f732-9a21d26d2146",
- "618382e3-a833-04d1-f917-c40e70c176cb",
- "39cdc358-7c75-d1cc-34ff-081e74254748",
- "4945fedc-a9c9-5b38-478f-df9ea0d1248a"
- ],
- "collection_name": "OVSDB Northbound APIs",
- "collection_id": "b4485302-3406-776b-fb0c-94d74c76dc36"
- },
- {
- "id": "10aeabc5-bd4b-b64f-31b6-82cbe9c7e9de",
- "name": "03 INTERFACE",
- "description": "",
- "order": [
- "a37af20f-0e43-3fe1-9f3b-c42a264fa3a1",
- "4b21a8b1-1703-bc2c-8716-7dcdab57300a",
- "0753fa84-8a0e-7727-1d45-5b5eb8c74de0"
- ],
- "collection_name": "OVSDB Northbound APIs",
- "collection_id": "b4485302-3406-776b-fb0c-94d74c76dc36"
- },
- {
- "id": "704ce201-08b0-59b4-eba0-c0a22d14d64a",
- "name": "04 CONTROLLER",
- "description": "",
- "order": [
- "7fc7d8cd-244d-58a0-febf-9814729b9422",
- "646be7a5-a484-329a-1039-02b53e1b05fc",
- "d239a9ea-8247-3d47-0d3a-2a1063c0177a"
- ],
- "collection_name": "OVSDB Northbound APIs",
- "collection_id": "b4485302-3406-776b-fb0c-94d74c76dc36"
- },
- {
- "id": "c49bb77a-920b-9653-232b-6a35fae3229f",
- "name": "05 SSL",
- "description": "",
- "order": [
- "3c4a6bb9-30e8-fdf1-1cf3-a3e187537924",
- "6c1b9611-b195-c64c-684f-a639e7ae3946",
- "989d5e9c-47a9-206a-c225-dc0e796f096a"
- ],
- "collection_name": "OVSDB Northbound APIs",
- "collection_id": "b4485302-3406-776b-fb0c-94d74c76dc36"
- },
- {
- "id": "7d339efa-b5a2-ecb5-1639-7c99ab2beb08",
- "name": "06 sFlow",
- "description": "",
- "order": [
- "88f1ec23-5471-97a8-2633-c89c51c20071",
- "9b2eaefc-5cc0-958a-0926-2b18fea54b88",
- "5eab776e-dd13-2a7f-90c3-fabc4d98d481"
- ],
- "collection_name": "OVSDB Northbound APIs",
- "collection_id": "b4485302-3406-776b-fb0c-94d74c76dc36"
- },
- {
- "id": "75c166a9-e5de-c7bd-59b4-20e512c89ef4",
- "name": "07 Qos",
- "description": "",
- "order": [
- "5e1f52b7-3295-9485-377f-6988c401a8cd",
- "d565f3fb-4a9a-3e61-9e8e-87324427c979",
- "40323a39-f07f-695a-2428-e888dd9c7cf1",
- "c3c1dd3a-1f8e-947d-f729-2eef56795fef"
- ],
- "collection_name": "OVSDB Northbound APIs",
- "collection_id": "b4485302-3406-776b-fb0c-94d74c76dc36"
- },
- {
- "id": "ebb04a01-9318-78ba-7d7d-590688434f35",
- "name": "08 Queue",
- "description": "",
- "order": [
- "b1af09ee-f6b9-cddd-9087-6d8dc5b958a4",
- "d32420de-40fd-d407-59c5-e1c3b8ea359c",
- "2d670425-e1ae-c615-1fe1-b27c0ddf4c43",
- "9d887d97-a323-a847-a163-ca6e62ad96fe"
- ],
- "collection_name": "OVSDB Northbound APIs",
- "collection_id": "b4485302-3406-776b-fb0c-94d74c76dc36"
- },
- {
- "id": "dc13be48-4ea4-7d32-63df-d367c6df6e70",
- "name": "09 NetFlow",
- "description": "",
- "order": [
- "c7ab23bd-2d49-71a0-7a40-31ee0f44b2b0",
- "76c04544-3be0-e330-75e1-509919d781f0",
- "f8d9b165-7fa7-e0bd-b634-b45d550a3114"
- ],
- "collection_name": "OVSDB Northbound APIs",
- "collection_id": "b4485302-3406-776b-fb0c-94d74c76dc36"
- },
- {
- "id": "1fe328ce-a0f2-2512-36b2-21c854081873",
- "name": "10 Manager",
- "description": "",
- "order": [
- "3d34de25-8015-98e5-957b-eb3cef69175f",
- "1aaa544a-7d79-3159-84b5-89574ff7f3e2",
- "baab428a-b056-bd23-906d-290933aee25f"
- ],
- "collection_name": "OVSDB Northbound APIs",
- "collection_id": "b4485302-3406-776b-fb0c-94d74c76dc36"
- },
- {
- "id": "40018e32-d0ca-4a2f-5f06-bff5c95382f8",
- "name": "11 IPFIX",
- "description": "",
- "order": [
- "a01a045e-e642-8e39-f2cc-baf37ec5dfc5",
- "485249a8-94d2-b61b-a6b9-addfe8fb1495",
- "8f74bdb1-1f10-69f4-da1d-cd878df784e5"
- ],
- "collection_name": "OVSDB Northbound APIs",
- "collection_id": "b4485302-3406-776b-fb0c-94d74c76dc36"
- }
- ],
- "timestamp": 1384305639019,
- "synced": false,
- "requests": [
- {
- "id": "0753fa84-8a0e-7727-1d45-5b5eb8c74de0",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/interface/rows/45bf1633-1411-4c92-87f8-b1492eed2ff6",
- "data": "",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "dataMode": "raw",
- "method": "DELETE",
- "version": 2,
- "time": 1385442001088,
- "name": "DELETE interface row given UUID",
- "description": "package org.opendaylight.ovsdb.plugin\n\nclass ConfigurationService\n\nMethod: deleteInterfaceRow()",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "085fa6c6-1d5b-8afb-4e4a-56cafe5e8bd0",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/bridge/rows",
- "data": [],
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "dataMode": "params",
- "method": "GET",
- "version": 2,
- "time": 1384863804932,
- "name": "GET all bridge rows",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "190627e6-ef20-863f-998b-e019034874c4",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/open_vswitch/rows",
- "data": [],
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "dataMode": "params",
- "method": "GET",
- "version": 2,
- "time": 1384895597912,
- "name": "GET all open_vswitch rows",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "1aaa544a-7d79-3159-84b5-89574ff7f3e2",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/manager/rows",
- "data": "{\n \"parent_uuid\":\"8d3fb89b-5fac-4631-a990-f5a4e7f5383a\",\n \"row\":{\n \"Manager\":{\n \"target\":\"a_string\",\n \"is_connected\": true,\n \"state\":\"active\"\n }\n }\n}",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "dataMode": "raw",
- "method": "POST",
- "version": 2,
- "time": 1384920841537,
- "name": "INSERT a Manager Row",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "2990bcf5-976b-413a-f732-9a21d26d2146",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/port/rows",
- "data": [],
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "dataMode": "params",
- "method": "GET",
- "version": 2,
- "time": 1384863858721,
- "name": "GET all port rows",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "2ced04cd-b934-9a0a-576d-8640b6a0b80e",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/bridge/rows/66ad493c-23cf-45e7-b5a5-1901fb3165f4",
- "pathVariables": {},
- "method": "PUT",
- "data": "{\n \"row\":{\n \"Bridge\":{\n \"netflow\": [\"55f5d382-17fd-4c42-850d-02c282a67c20\",\"60db8cde-26e6-4bf9-bb08-cd1da68d1fcc\"]\n \n }\n }\n}",
- "dataMode": "raw",
- "version": 2,
- "time": 1386202840003,
- "name": "Update (PUT) Bridge table",
- "description": "Please note that the UUID used here must be one of the existing UUID of a Row in Bridge Table.\n\nAlso the Update must be done ONLY on the fields that needs update. Should NOT send all the immutable fields again. Update will fail in that case.",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "2d670425-e1ae-c615-1fe1-b27c0ddf4c43",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/queue/rows/cd1d39f2-0e8d-4164-a5ab-926329cd1c61",
- "pathVariables": {},
- "method": "DELETE",
- "data": "",
- "dataMode": "raw",
- "version": 2,
- "time": 1386291032110,
- "name": "DELETE a Queue row given a UUID (ROOT TABLE)",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "39cdc358-7c75-d1cc-34ff-081e74254748",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/port/rows/2f93780e-ce56-4cce-9f7c-579be7996651",
- "data": "",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "dataMode": "raw",
- "method": "DELETE",
- "version": 2,
- "time": 1385084358582,
- "name": "DELETE port row given UUID",
- "description": "package org.opendaylight.ovsdb.plugin\n\nclass ConfigurationService\n\nMethod: deletePortRow()",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "3c4a6bb9-30e8-fdf1-1cf3-a3e187537924",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/SSL/rows",
- "pathVariables": {},
- "method": "GET",
- "data": [],
- "dataMode": "params",
- "version": 2,
- "time": 1385766024370,
- "name": "GET all SSL row",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "3d34de25-8015-98e5-957b-eb3cef69175f",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/manager/rows",
- "data": [],
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "dataMode": "params",
- "method": "GET",
- "version": 2,
- "time": 1384920805653,
- "name": "GET all manager rows",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "40323a39-f07f-695a-2428-e888dd9c7cf1",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/qos/rows/739f3929-3a3e-45b1-88ea-afc09df0ca5c",
- "pathVariables": {},
- "method": "DELETE",
- "data": "",
- "dataMode": "raw",
- "version": 2,
- "time": 1386292478840,
- "name": "DELETE a QoS row given a UUID (ROOT TABLE)",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "485249a8-94d2-b61b-a6b9-addfe8fb1495",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/ipfix/rows",
- "pathVariables": {},
- "method": "POST",
- "data": "{\n \"parent_uuid\":\"2e5c0418-e70c-406b-9ad9-58585ac10c19\",\n \"row\":{\n \"IPFIX\":{\n \"targets\":[\n \"set\", [\"192.168.56.1:5555\"]]\n }\n }\n}",
- "dataMode": "raw",
- "name": "Insert a IPFIX row",
- "description": "",
- "descriptionFormat": "html",
- "time": 1396821935199,
- "version": 2,
- "responses": [],
- "tests": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "synced": false
- },
- {
- "id": "4945fedc-a9c9-5b38-478f-df9ea0d1248a",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/port/rows/97a82ec9-e85e-4a48-9b77-ca4a41128b90",
- "pathVariables": {},
- "method": "PUT",
- "data": "{\n \"row\":{\n \"Port\":{\n \"qos\": [\n \"ab2b6f2d-5cb4-4dcf-ac1b-c989ae3d76ce\"\n ]\n }\n }\n}",
- "dataMode": "raw",
- "version": 2,
- "time": 1386208729980,
- "name": "Update Port Table",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "4b21a8b1-1703-bc2c-8716-7dcdab57300a",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/interface/rows",
- "pathVariables": {},
- "method": "POST",
- "data": "{\n \"parent_uuid\":\"ea70e5b1-8b21-4caf-a102-0b85b6c63119\",\n \"row\":{\n \"Interface\":{\n \"name\":\"s1-1125-1\",\n \"mac\":[\"00:00:bb:bb:00:01\"],\n \"admin_state\":\"up\"\n }\n }\n}",
- "dataMode": "raw",
- "version": 2,
- "tests": "",
- "time": 1396829465324,
- "name": "Create row: Interface Table",
- "description": "package org.opendaylight.ovsdb.plugin\npublic class ConfigurationService\n\nMethod: insertInterfaceRow\n",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "5e1f52b7-3295-9485-377f-6988c401a8cd",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/qos/rows",
- "pathVariables": {},
- "method": "GET",
- "data": [],
- "dataMode": "params",
- "version": 2,
- "time": 1385833787440,
- "name": "GET all QoS rows",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "5eab776e-dd13-2a7f-90c3-fabc4d98d481",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/sflow/rows/",
- "pathVariables": {},
- "method": "DELETE",
- "data": "",
- "dataMode": "raw",
- "version": 2,
- "time": 1385832734561,
- "name": "DELETE an sFlow row given a UUID",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "618382e3-a833-04d1-f917-c40e70c176cb",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/port/rows",
- "pathVariables": {},
- "method": "POST",
- "data": "{\n \"parent_uuid\":\"6b3072ba-a120-4db9-82f8-a8ce4eae6942\",\n \"row\":{\n \"Port\":{\n \"name\":\"krb1\",\n \"mac\":[\"00:00:00:00:00:01\"],\n \"tag\":[200]\n }\n }\n}",
- "dataMode": "raw",
- "version": 2,
- "tests": "",
- "time": 1396829482311,
- "name": "Create a Port and add it to a Bridge",
- "description": "Please note that the parent_uuid of this HTTP Data is the UUID of the Bridge that was created in the previous step.\n\nWatch out for the return value which is the UUID of the port that was just created. This UUID must be used as the parent_uuid for the interface addition. Also look out for the HTTP headers that is returned and it has a location field that can be used for both DELETE and UPDATE operations later.\n",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "646be7a5-a484-329a-1039-02b53e1b05fc",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/controller/rows/68e97a9a-9f2c-497a-b39b-7f1e37c30c6f",
- "data": "",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "dataMode": "raw",
- "method": "DELETE",
- "version": 2,
- "time": 1385391658840,
- "name": "DELETE controller row given UUID",
- "description": "package org.opendaylight.ovsdb.plugin\n\nclass ConfigurationService\n\nMethod: deleteControllerRow()",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "6c1b9611-b195-c64c-684f-a639e7ae3946",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/SSL/rows",
- "pathVariables": {},
- "method": "POST",
- "data": "{\n \"row\":{\n \"SSL\":{\n \"name\":\"mySSL\",\n \"ca_cert\" : \"ca_cert\",\n \"bootstrap_ca_cert\" : true,\n \"certificate\":\"pieceofpaper\",\n \"private_key\" : \"private\"\n }\n }\n}\n",
- "dataMode": "raw",
- "version": 2,
- "time": 1385766215625,
- "name": "INSERT an SSL row",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "6f5b8f9a-3e66-16b0-7a16-62a96313eab5",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/bridge/rows",
- "pathVariables": {},
- "method": "POST",
- "data": "{\n \"row\":{\n \"Bridge\":{\n \"name\":\"br25\",\n \"datapath_type\":\"OPENFLOW\"\n }\n }\n}",
- "dataMode": "raw",
- "version": 2,
- "tests": "",
- "time": 1396829500172,
- "name": "Create a Bridge",
- "description": "Watch out for the return value which is the UUID of the bridge that was just created.\nThis UUID must be used as the parent_uuid for the port addition.\n\nAlso look out for the HTTP headers that is returned and it has a location field that can be used for both DELETE and UPDATE operations later.",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "76c04544-3be0-e330-75e1-509919d781f0",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/netflow/rows",
- "pathVariables": {},
- "method": "POST",
- "data": "{\n \"parent_uuid\":\"817d2e33-448d-4f2e-b183-7f835e93922f\",\n \"row\" : {\n \"NetFlow\":{\n \"targets\" : [\n \"set\", [\"192.168.1.102:9998\"]],\n \"active_timeout\" : \"0\"\n }\n } \n}",
- "dataMode": "raw",
- "version": 2,
- "tests": "",
- "time": 1396822912058,
- "name": "INSERT a NetFlow row",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "id": "7e41f2e4-6797-64f0-ebd2-b4b634b6a559",
- "name": "DELETE a Bridge row given UUID",
- "description": "Please note that the UUID used here must be one of the existing UUID of a Row in Bridge Table",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/bridge/rows/45677cc9-bed2-4def-9986-b05a9b59f1f4",
- "method": "DELETE",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "data": "",
- "dataMode": "raw",
- "timestamp": 0,
- "version": 2,
- "time": 1384465149749,
- "synced": false
- },
- {
- "id": "7fc7d8cd-244d-58a0-febf-9814729b9422",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/controller/rows",
- "data": [],
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "dataMode": "params",
- "method": "GET",
- "version": 2,
- "time": 1384898533812,
- "name": "GET all controller rows",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "88f1ec23-5471-97a8-2633-c89c51c20071",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/sflow/rows",
- "pathVariables": {},
- "method": "GET",
- "data": [],
- "dataMode": "params",
- "version": 2,
- "time": 1385832695823,
- "name": "GET all sFlow rows",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "8f74bdb1-1f10-69f4-da1d-cd878df784e5",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/ipfix/rows/715fb52c-63bb-495a-8dca-f3f824fbf8fb",
- "pathVariables": {},
- "method": "DELETE",
- "data": "",
- "dataMode": "raw",
- "version": 2,
- "tests": "",
- "time": 1396823075244,
- "name": "DELETE a IPFIX row given a UUID",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "989d5e9c-47a9-206a-c225-dc0e796f096a",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/SSL/rows/6c2a532c-96df-49ce-8f3f-f83c39e47122",
- "pathVariables": {},
- "method": "DELETE",
- "data": "",
- "dataMode": "raw",
- "version": 2,
- "time": 1385766788123,
- "name": "DELETE an SSL row given a UUID",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "9b2eaefc-5cc0-958a-0926-2b18fea54b88",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/sflow/rows",
- "pathVariables": {},
- "method": "POST",
- "data": "{\n \"parent_uuid\": \"a8c88ae9-fc08-498b-8ec8-2fd86627055d\",\n \"row\": {\n \"sFlow\": {\n \"targets\": [\n \"set\",\n [\n \"targets_string\"\n ]\n ]\n }\n }\n}",
- "dataMode": "raw",
- "version": 2,
- "tests": "",
- "time": 1396827237234,
- "name": "INSERT an sFlow row",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "9d887d97-a323-a847-a163-ca6e62ad96fe",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/qos/rows/ab2b6f2d-5cb4-4dcf-ac1b-c989ae3d76ce",
- "pathVariables": {},
- "method": "PUT",
- "data": "{\n \"row\":{\n \"QoS\":{\n \"queues\": {\n \"1\" : { \"val\": \"0fbe6ced-16cf-4a39-8a79-e7c8c31f63a9\"}\n }\n }\n }\n}",
- "dataMode": "raw",
- "version": 2,
- "time": 1386287453591,
- "name": "UPDATE a queue in QOS",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "a01a045e-e642-8e39-f2cc-baf37ec5dfc5",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/ipfix/rows",
- "pathVariables": {},
- "method": "GET",
- "data": [],
- "dataMode": "params",
- "name": "GET all IPFIX rows",
- "description": "",
- "descriptionFormat": "html",
- "time": 1396821857102,
- "version": 2,
- "responses": [],
- "tests": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "synced": false
- },
- {
- "id": "a37af20f-0e43-3fe1-9f3b-c42a264fa3a1",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/interface/rows",
- "data": [],
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "dataMode": "params",
- "method": "GET",
- "version": 2,
- "time": 1384866802408,
- "name": "GET all interface rows",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "id": "aed6c263-4d42-ca35-669f-33a00c3d9c82",
- "name": "GET a bridge row given a UUID",
- "description": "Please note that the UUID used here must be one of the existing UUID of a Row in Bridge Table",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/bridge/rows/45677cc9-bed2-4def-9986-b05a9b59f1f4",
- "method": "GET",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "data": "",
- "dataMode": "raw",
- "timestamp": 0,
- "version": 2,
- "time": 1384465185771,
- "synced": false
- },
- {
- "id": "b1af09ee-f6b9-cddd-9087-6d8dc5b958a4",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/queue/rows",
- "pathVariables": {},
- "method": "GET",
- "data": [],
- "dataMode": "params",
- "version": 2,
- "time": 1385846165644,
- "name": "GET all Queue rows",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "baab428a-b056-bd23-906d-290933aee25f",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/manager/rows/",
- "pathVariables": {},
- "method": "DELETE",
- "data": "",
- "dataMode": "raw",
- "version": 2,
- "time": 1385866190653,
- "name": "DELETE a Manager row given UUID",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "c3c1dd3a-1f8e-947d-f729-2eef56795fef",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/qos/rows/ab2b6f2d-5cb4-4dcf-ac1b-c989ae3d76ce",
- "pathVariables": {},
- "method": "PUT",
- "data": "{\n \"row\":{\n \"QoS\":{\n \"Queues\": {\n \"queue_value\" : \"5afa70b6-7c74-4972-9d98-874e6307807d\"\n }\n }\n }\n}",
- "dataMode": "raw",
- "version": 2,
- "time": 1386212074539,
- "name": "UPDATE a QoS row ",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "c7ab23bd-2d49-71a0-7a40-31ee0f44b2b0",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/netflow/rows",
- "pathVariables": {},
- "method": "GET",
- "data": [],
- "dataMode": "params",
- "version": 2,
- "time": 1385853862100,
- "name": "GET all NetFlow rows",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "d239a9ea-8247-3d47-0d3a-2a1063c0177a",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/controller/rows",
- "pathVariables": {},
- "method": "POST",
- "data": "{\n \"parent_uuid\" : \"a8c88ae9-fc08-498b-8ec8-2fd86627055d\",\n \"row\" : {\n \t\"Controller\": {\n \"target\": \"1.1.1.1\"\n \t}\n\t}\t\n}",
- "dataMode": "raw",
- "version": 2,
- "tests": "",
- "time": 1396828737787,
- "name": "Add Controller to Bridge",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "d32420de-40fd-d407-59c5-e1c3b8ea359c",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/queue/rows",
- "pathVariables": {},
- "method": "POST",
- "data": "{\n \"parent_uuid\": \"c5f7ce39-847c-4a69-bf8a-2a0181898581\",\n \"row\": {\n \"Queue\": {\n \"dscp\" : [\n \"set\",\n [\n 25\n ]\n ]\n }\n }\n}",
- "dataMode": "raw",
- "version": 2,
- "tests": "",
- "time": 1396828046762,
- "name": "INSERT a Queue row",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "d565f3fb-4a9a-3e61-9e8e-87324427c979",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/qos/rows",
- "pathVariables": {},
- "method": "POST",
- "data": "{\n \"parent_uuid\" : \"b109dbcf-47bb-4121-b244-e623b3421d6e\",\n \"row\" : {\n \t\"QoS\": {\n \"type\": \"linux-htb\"\n \t}\n\t}\t\n}",
- "dataMode": "raw",
- "version": 2,
- "time": 1386291627774,
- "name": "INSERT a QoS row",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "d70a4755-d62a-dfcd-e363-dbe931af99a0",
- "url": "http://{{controllerHost}}:{{controllerPort}}/controller/nb/v2/connectionmanager/node/HOST1/address/192.168.1.102/port/6640/",
- "data": [],
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\n",
- "dataMode": "params",
- "method": "PUT",
- "version": 2,
- "time": 1385493381229,
- "name": "Connect controller to OVSDB server",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- },
- {
- "id": "f8d9b165-7fa7-e0bd-b634-b45d550a3114",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "url": "http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v2/node/OVS/HOST1/tables/netflow/rows/60db8cde-26e6-4bf9-bb08-cd1da68d1fcc",
- "pathVariables": {},
- "method": "DELETE",
- "data": "",
- "dataMode": "raw",
- "version": 2,
- "time": 1386202872294,
- "name": "DELETE a NetFlow row given UUID",
- "description": "",
- "collectionId": "b4485302-3406-776b-fb0c-94d74c76dc36",
- "responses": [],
- "synced": false
- }
- ]
-}
\ No newline at end of file
+++ /dev/null
-{
- "id":"4bc6df66-04c6-f750-e6a4-2518f667f85e",
- "name":"OVSDB Northbound v3 APIs",
- "timestamp":1416933391257,
- "requests":[
- {
- "collectionId":"4bc6df66-04c6-f750-e6a4-2518f667f85e",
- "id":"28f2c9fe-06a8-55fa-eb95-ae6d93fc271e",
- "name":"GET node database table Manager info",
- "description":"",
- "url":"http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v3/node/OVS|192.168.120.31:48161/database/Open_vSwitch/table/Manager",
- "method":"GET",
- "headers":"Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "data":[
-
- ],
- "dataMode":"params",
- "timestamp":0,
- "responses":[
-
- ],
- "version":2
- },
- {
- "collectionId":"4bc6df66-04c6-f750-e6a4-2518f667f85e",
- "id":"2ceafd22-6467-e29b-f5b9-a947196a365d",
- "name":"GET config",
- "description":"",
- "url":"http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v3/config",
- "method":"GET",
- "headers":"Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "data":[
-
- ],
- "dataMode":"params",
- "timestamp":0,
- "responses":[
-
- ],
- "version":2
- },
- {
- "collectionId":"4bc6df66-04c6-f750-e6a4-2518f667f85e",
- "id":"31423e07-7f63-cace-1d92-eade985c8058",
- "name":"GET node database table list",
- "description":"",
- "url":"http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v3/node/OVS|192.168.120.31:48161/database/Open_vSwitch/table",
- "method":"GET",
- "headers":"Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "data":[
-
- ],
- "dataMode":"params",
- "timestamp":0,
- "responses":[
-
- ],
- "version":2
- },
- {
- "collectionId":"4bc6df66-04c6-f750-e6a4-2518f667f85e",
- "id":"52f720c9-424b-f48f-65aa-ef9a9bb29f40",
- "name":"GET node",
- "description":"",
- "url":"http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v3/node/OVS|192.168.120.31:48161",
- "method":"GET",
- "headers":"Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "data":[
-
- ],
- "dataMode":"params",
- "timestamp":0,
- "responses":[
-
- ],
- "version":2
- },
- {
- "collectionId":"4bc6df66-04c6-f750-e6a4-2518f667f85e",
- "id":"9d327275-fd29-6b72-9ac8-3bbd38c5364d",
- "name":"GET node database list",
- "description":"",
- "url":"http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v3/node/OVS|192.168.120.31:48161/database",
- "method":"GET",
- "headers":"Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "data":[
-
- ],
- "dataMode":"params",
- "timestamp":0,
- "responses":[
-
- ],
- "version":2
- },
- {
- "collectionId":"4bc6df66-04c6-f750-e6a4-2518f667f85e",
- "id":"9f6858b9-198b-5368-7987-9468354ae06b",
- "name":"GET node database table Open-vSwitch rows uuid",
- "description":"",
- "url":"http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v3/node/OVS|192.168.120.31:48161/database/Open_vSwitch/table/Open_vSwitch/row/626d6b88-821f-474c-9680-2b74dfafdcd1",
- "method":"GET",
- "headers":"Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "data":[
-
- ],
- "dataMode":"params",
- "timestamp":0,
- "responses":[
-
- ],
- "version":2
- },
- {
- "collectionId":"4bc6df66-04c6-f750-e6a4-2518f667f85e",
- "id":"b8fff80d-cb81-280a-2a88-e0b28d4d23d3",
- "name":"GET node database table Open-vSwitch",
- "description":"",
- "url":"http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v3/node/OVS|192.168.120.31:48161/database/Open_vSwitch/table/Open_vSwitch",
- "method":"GET",
- "headers":"Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "data":[
-
- ],
- "dataMode":"params",
- "timestamp":0,
- "responses":[
-
- ],
- "version":2
- },
- {
- "collectionId":"4bc6df66-04c6-f750-e6a4-2518f667f85e",
- "id":"c508233b-ed4b-c03d-0446-3e206b513203",
- "name":"GET node database table Open-vSwitch rows",
- "description":"",
- "url":"http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v3/node/OVS|192.168.120.31:48161/database/Open_vSwitch/table/Open_vSwitch/row",
- "method":"GET",
- "headers":"Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "data":[
-
- ],
- "dataMode":"params",
- "timestamp":0,
- "responses":[
-
- ],
- "version":2
- },
- {
- "collectionId":"4bc6df66-04c6-f750-e6a4-2518f667f85e",
- "id":"d8d420f8-826d-af7e-951b-2d29a51c6033",
- "name":"GET node database info",
- "description":"",
- "url":"http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v3/node/OVS|192.168.120.31:48161/database/Open_vSwitch",
- "method":"GET",
- "headers":"Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "data":[
-
- ],
- "dataMode":"params",
- "timestamp":0,
- "responses":[
-
- ],
- "version":2
- },
- {
- "collectionId":"4bc6df66-04c6-f750-e6a4-2518f667f85e",
- "id":"e650b8cc-d983-f329-be2e-153a5601e34c",
- "name":"GET all nodes",
- "description":"",
- "url":"http://{{controllerHost}}:{{controllerPort}}/ovsdb/nb/v3/node",
- "method":"GET",
- "headers":"Authorization: Basic YWRtaW46YWRtaW4=\nAccept: application/json\nContent-Type: application/json\n",
- "data":[
-
- ],
- "dataMode":"params",
- "timestamp":0,
- "responses":[
-
- ],
- "version":2
- }
- ]
-}
\ No newline at end of file
Contents
--------
-1. localhost.json.postman_environment : Environment that associates address and port to localhost:8080 in templates for the collections below.
+- localhost.json.postman_environment : Environment that associates address and port to localhost:8080 in templates for the collections below.
-2. Mininet_Demo_OVSDB_OF.json.postman_collection : Collection of REST-APIs used in the Mininet demo (http://www.youtube.com/watch?v=8iWhMVlflwE)
+- Mininet_Demo_OVSDB_OF.json.postman_collection : Collection of REST-APIs used in the Mininet demo (http://www.youtube.com/watch?v=8iWhMVlflwE)
-3. OVSDB_Northbound_APIs.json.postman_collection : Collection of REST-APIs detailing on all the ovsdb.northbound APIs.
+- OVSDB_Southbound.postman_collection : Collection of RESTCONF APIs for using the OVSDB MD-SAL Southbound
-4. OVSDB_Southbound.postman_collection : Collection of RESTCONF APIs for using the OVSDB MD-SAL Southbound
+- Neutron-v2.0-LBaaS-API-Examples_July15.json.postman_collection.txt : Collection of REST-APIs to interact with LBaas pool/pool member/loadbalancer.
-5. Neutron-v2.0-LBaaS-API-Examples_July15.json.postman_collection.txt : Collection of REST-APIs to interact with LBaas pool/pool member/loadbalancer.
-
-6. showOvsdbMdsal.py : Dumps mdsal related info from running ODL that is related to ovsdb and netvirt. Use 'showOvsdbMdsal.py -h' for usage
+- showOvsdbMdsal.py : Dumps mdsal related info from running ODL that is related to ovsdb and netvirt. Use 'showOvsdbMdsal.py -h' for usage
type string;
}
}
-
+
list manager-entry {
description "Node managers info";
config false;
description "Uri that user set to connect to the controller";
type inet:uri;
}
- leaf is-connected {
+ leaf connected {
type boolean;
}
+ leaf number_of_connections {
+ type uint32;
+ }
}
}
public void onDataChanged(
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
LOG.trace("onDataChanged: {}", changes);
- for (Entry<InstanceIdentifier<?>, DataObject> created : changes.getCreatedData().entrySet()) {
- // TODO validate we have the correct kind of InstanceIdentifier
- if (created.getValue() instanceof OvsdbNodeAugmentation) {
- OvsdbNodeAugmentation ovsdbNode = (OvsdbNodeAugmentation)created.getValue();
- ConnectionInfo key = ovsdbNode.getConnectionInfo();
- InstanceIdentifier<Node> iid = cm.getInstanceIdentifier(key);
- if ( iid != null) {
- LOG.warn("Connection to device {} already exists. Plugin does not allow multiple connections "
- + "to same device, hence dropping the request {}", key, ovsdbNode);
- return;
- }
- }
- }
// Connect first if we have to:
connect(changes);
for (Entry<InstanceIdentifier<?>, DataObject> created : changes.getCreatedData().entrySet()) {
// TODO validate we have the correct kind of InstanceIdentifier
if (created.getValue() instanceof OvsdbNodeAugmentation) {
- try {
- cm.connect((InstanceIdentifier<Node>) created.getKey(),
- (OvsdbNodeAugmentation) created.getValue());
- } catch (UnknownHostException e) {
- LOG.warn("Failed to connect to ovsdbNode", e);
+ OvsdbNodeAugmentation ovsdbNode = (OvsdbNodeAugmentation)created.getValue();
+ ConnectionInfo key = ovsdbNode.getConnectionInfo();
+ InstanceIdentifier<Node> iid = cm.getInstanceIdentifier(key);
+ if ( iid != null) {
+ LOG.warn("Connection to device {} already exists. Plugin does not allow multiple connections "
+ + "to same device, hence dropping the request {}", key, ovsdbNode);
+ } else {
+ try {
+ cm.connect((InstanceIdentifier<Node>) created.getKey(),
+ (OvsdbNodeAugmentation) created.getValue());
+ } catch (UnknownHostException e) {
+ LOG.warn("Failed to connect to ovsdbNode", e);
+ }
}
}
}
public class SouthboundMapper {
private static final Logger LOG = LoggerFactory.getLogger(SouthboundMapper.class);
+ private static final String N_CONNECTIONS_STR = "n_connections";
private static NodeId createNodeId(OvsdbConnectionInstance client) {
NodeKey key = client.getInstanceIdentifier().firstKeyOf(Node.class, NodeKey.class);
final Manager manager) {
if (manager != null && manager.getTargetColumn() != null) {
+ long numberOfConnections = 0;
final String targetString = (String)manager.getTargetColumn().getData();
+
+ final Map<String, String> statusAttributeMap = manager.getStatusColumn().getData();
+ if (statusAttributeMap.containsKey(N_CONNECTIONS_STR)) {
+ String numberOfConnectionValueStr = statusAttributeMap.get(N_CONNECTIONS_STR);
+ numberOfConnections = Integer.parseInt(numberOfConnectionValueStr);
+ } else {
+ final boolean isConnected = manager.getIsConnectedColumn().getData();
+ if (isConnected) {
+ numberOfConnections = 1;
+ }
+ }
managerEntries.add(new ManagerEntryBuilder()
.setTarget(new Uri(targetString))
- .setIsConnected(manager.getIsConnectedColumn().getData()).build());
+ .setNumberOfConnections(numberOfConnections)
+ .setConnected(manager.getIsConnectedColumn().getData()).build());
}
}
private Map<UUID, OpenVSwitch> oldOpenVSwitchRows;
private Map<UUID, Manager> removedManagerRows;
private Map<UUID, OpenVSwitch> updatedOpenVSwitchRows;
+ private Map<UUID, Manager> updatedManagerRows;
public OvsdbManagersRemovedCommand(OvsdbConnectionInstance key,
TableUpdates updates, DatabaseSchema dbSchema) {
super(key, updates, dbSchema);
updatedOpenVSwitchRows = TyperUtils.extractRowsUpdated(OpenVSwitch.class, getUpdates(), getDbSchema());
oldOpenVSwitchRows = TyperUtils.extractRowsOld(OpenVSwitch.class, getUpdates(), getDbSchema());
+ updatedManagerRows = TyperUtils.extractRowsUpdated(Manager.class, getUpdates(), getDbSchema());
removedManagerRows = TyperUtils.extractRowsRemoved(Manager.class,
getUpdates(), getDbSchema());
}
if (openVSwitch.getManagerOptionsColumn() == null
|| !openVSwitch.getManagerOptionsColumn().getData().contains(managerUuid)) {
Manager manager = removedManagerRows.get(managerUuid);
- if (manager != null && manager.getTargetColumn() != null) {
- InstanceIdentifier<ManagerEntry> iid = ovsdbNodeIid
- .augmentation(OvsdbNodeAugmentation.class)
- .child(ManagerEntry.class,
- new ManagerEntryKey(
- new Uri(manager.getTargetColumn().getData())));
- result.add(iid);
+ if (!checkIfManagerPresentInUpdatedManagersList(manager)) {
+ if (manager != null && manager.getTargetColumn() != null) {
+ InstanceIdentifier<ManagerEntry> iid = ovsdbNodeIid
+ .augmentation(OvsdbNodeAugmentation.class)
+ .child(ManagerEntry.class,
+ new ManagerEntryKey(
+ new Uri(manager.getTargetColumn().getData())));
+ result.add(iid);
+ }
+
}
}
}
return result;
}
+ private boolean checkIfManagerPresentInUpdatedManagersList(Manager removedManager) {
+ for (Map.Entry<UUID, Manager> updatedManager : updatedManagerRows.entrySet()) {
+ if (updatedManager.getValue().getTargetColumn().getData()
+ .equals(removedManager.getTargetColumn().getData())) {
+ return true;
+ }
+ }
+ return false;
+ }
}
import org.opendaylight.ovsdb.southbound.OvsdbConnectionInstance;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ManagedNodeEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ManagerEntry;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class OvsdbNodeRemoveCommand extends AbstractTransactionCommand {
private static final Logger LOG = LoggerFactory.getLogger(OvsdbNodeRemoveCommand.class);
+ private static final long ONE_CONNECTED_MANAGER = 1;
+ private static final long ONE_ACTIVE_CONNECTION_IN_PASSIVE_MODE = 1;
public OvsdbNodeRemoveCommand(OvsdbConnectionInstance key,TableUpdates updates,DatabaseSchema dbSchema) {
super(key,updates,dbSchema);
if (ovsdbNodeOptional.isPresent()) {
Node ovsdbNode = ovsdbNodeOptional.get();
OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class);
- if (ovsdbNodeAugmentation != null) {
- if (ovsdbNodeAugmentation.getManagedNodeEntry() != null) {
- for (ManagedNodeEntry managedNode : ovsdbNodeAugmentation.getManagedNodeEntry()) {
- transaction.delete(LogicalDatastoreType.OPERATIONAL, managedNode.getBridgeRef().getValue());
+ if (checkIfOnlyConnectedManager(ovsdbNodeAugmentation)) {
+ if (ovsdbNodeAugmentation != null) {
+ if (ovsdbNodeAugmentation.getManagedNodeEntry() != null) {
+ for (ManagedNodeEntry managedNode : ovsdbNodeAugmentation.getManagedNodeEntry()) {
+ transaction.delete(
+ LogicalDatastoreType.OPERATIONAL, managedNode.getBridgeRef().getValue());
+ }
+ } else {
+ LOG.debug("{} had no managed nodes", ovsdbNode.getNodeId().getValue());
}
} else {
- LOG.debug("{} had no managed nodes", ovsdbNode.getNodeId().getValue());
+ LOG.warn("{} had no OvsdbNodeAugmentation", ovsdbNode.getNodeId().getValue());
}
+ transaction.delete(LogicalDatastoreType.OPERATIONAL,
+ getOvsdbConnectionInstance().getInstanceIdentifier());
} else {
- LOG.warn("{} had no OvsdbNodeAugmentation", ovsdbNode.getNodeId().getValue());
+ LOG.debug("Other southbound plugin instances in cluster are connected to the device,"
+ + " not deleting OvsdbNode form data store.");
}
- transaction.delete(LogicalDatastoreType.OPERATIONAL,
- getOvsdbConnectionInstance().getInstanceIdentifier());
}
} catch (Exception e) {
LOG.warn("Failure to delete ovsdbNode {}",e);
}
}
+ private boolean checkIfOnlyConnectedManager(OvsdbNodeAugmentation ovsdbNodeAugmentation) {
+ ManagerEntry onlyConnectedManager = null;
+ if (ovsdbNodeAugmentation != null) {
+ int connectedManager = 0;
+ for (ManagerEntry manager : ovsdbNodeAugmentation.getManagerEntry()) {
+ if (manager.isConnected()) {
+ connectedManager++;
+ if (connectedManager > ONE_CONNECTED_MANAGER) {
+ return false;
+ }
+ onlyConnectedManager = manager;
+ }
+ }
+ if (connectedManager == 0) {
+ return true;
+ }
+ }
+ /*When switch is listening in passive mode, this number represent number of active connection to the device
+ This is to handle the controller initiated connection scenario, where all the controller will connect, but
+ switch will have only one manager.
+ */
+ if (onlyConnectedManager.getNumberOfConnections().longValue() > ONE_ACTIVE_CONNECTION_IN_PASSIVE_MODE) {
+ return false;
+ }
+ return true;
+ }
}
MemberModifier.suppress(MemberMatcher.method(OvsdbDataChangeListener.class, "disconnect", AsyncDataChangeEvent.class));
MemberModifier.suppress(MemberMatcher.method(OvsdbDataChangeListener.class, "init", AsyncDataChangeEvent.class));
- //iid not null case
- InstanceIdentifier<Node> iid = mock(InstanceIdentifier.class);
- when(cm.getInstanceIdentifier(any(ConnectionInfo.class))).thenReturn(iid);
-
- ovsdbDataChangeListener.onDataChanged(changes);
- verify(changes).getCreatedData();
- verify(ovsdbNode).getConnectionInfo();
- verify(cm).getInstanceIdentifier(any(ConnectionInfo.class));
- PowerMockito.verifyPrivate(ovsdbDataChangeListener, times(0)).invoke("connect", any(AsyncDataChangeEvent.class));
-
//iid null case
when(cm.getInstanceIdentifier(any(ConnectionInfo.class))).thenReturn(null);
ovsdbDataChangeListener.onDataChanged(changes);
public static final String TCP = "tcp";
public static final String UDP = "udp";
private static final int TCP_SYN = 0x0002;
+ public static final String ICMP = "icmp";
/**
* Create Ingress Port Match dpidLong, inPort
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>binding-parent</artifactId>
+ <version>0.8.0-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <artifactId>utils.mdsal-utils</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-api</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2015 Red Hat, 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.ovsdb.utils.mdsal.utils;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MdsalUtils {
+ private static final Logger LOG = LoggerFactory.getLogger(MdsalUtils.class);
+ private DataBroker databroker = null;
+
+ /**
+ * Class constructor setting the data broker.
+ *
+ * @param dataBroker the {@link org.opendaylight.controller.md.sal.binding.api.DataBroker}
+ */
+ public MdsalUtils(DataBroker dataBroker) {
+ this.databroker = dataBroker;
+ }
+
+ /**
+ * Executes delete as a blocking transaction.
+ *
+ * @param store {@link LogicalDatastoreType} which should be modified
+ * @param path {@link InstanceIdentifier} to read from
+ * @param <D> the data object type
+ * @return the result of the request
+ */
+ public <D extends org.opendaylight.yangtools.yang.binding.DataObject> boolean delete(
+ final LogicalDatastoreType store, final InstanceIdentifier<D> path) {
+ boolean result = false;
+ final WriteTransaction transaction = databroker.newWriteOnlyTransaction();
+ transaction.delete(store, path);
+ CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
+ try {
+ future.checkedGet();
+ result = true;
+ } catch (TransactionCommitFailedException e) {
+ LOG.warn("Failed to delete {} ", path, e);
+ }
+ return result;
+ }
+
+ /**
+ * Executes merge as a blocking transaction.
+ *
+ * @param logicalDatastoreType {@link LogicalDatastoreType} which should be modified
+ * @param path {@link InstanceIdentifier} for path to read
+ * @param <D> the data object type
+ * @return the result of the request
+ */
+ public <D extends org.opendaylight.yangtools.yang.binding.DataObject> boolean merge(
+ final LogicalDatastoreType logicalDatastoreType, final InstanceIdentifier<D> path, D data) {
+ boolean result = false;
+ final WriteTransaction transaction = databroker.newWriteOnlyTransaction();
+ transaction.merge(logicalDatastoreType, path, data, true);
+ CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
+ try {
+ future.checkedGet();
+ result = true;
+ } catch (TransactionCommitFailedException e) {
+ LOG.warn("Failed to merge {} ", path, e);
+ }
+ return result;
+ }
+
+ /**
+ * Executes put as a blocking transaction.
+ *
+ * @param logicalDatastoreType {@link LogicalDatastoreType} which should be modified
+ * @param path {@link InstanceIdentifier} for path to read
+ * @param <D> the data object type
+ * @return the result of the request
+ */
+ public <D extends org.opendaylight.yangtools.yang.binding.DataObject> boolean put(
+ final LogicalDatastoreType logicalDatastoreType, final InstanceIdentifier<D> path, D data) {
+ boolean result = false;
+ final WriteTransaction transaction = databroker.newWriteOnlyTransaction();
+ transaction.put(logicalDatastoreType, path, data, true);
+ CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
+ try {
+ future.checkedGet();
+ result = true;
+ } catch (TransactionCommitFailedException e) {
+ LOG.warn("Failed to put {} ", path, e);
+ }
+ return result;
+ }
+
+ /**
+ * Executes read as a blocking transaction.
+ *
+ * @param store {@link LogicalDatastoreType} to read
+ * @param path {@link InstanceIdentifier} for path to read
+ * @param <D> the data object type
+ * @return the result as the data object requested
+ */
+ public <D extends org.opendaylight.yangtools.yang.binding.DataObject> D read(
+ final LogicalDatastoreType store, final InstanceIdentifier<D> path) {
+ D result = null;
+ final ReadOnlyTransaction transaction = databroker.newReadOnlyTransaction();
+ Optional<D> optionalDataObject;
+ CheckedFuture<Optional<D>, ReadFailedException> future = transaction.read(store, path);
+ try {
+ optionalDataObject = future.checkedGet();
+ if (optionalDataObject.isPresent()) {
+ result = optionalDataObject.get();
+ } else {
+ LOG.debug("{}: Failed to read {}",
+ Thread.currentThread().getStackTrace()[1], path);
+ }
+ } catch (ReadFailedException e) {
+ LOG.warn("Failed to read {} ", path, e);
+ }
+ transaction.close();
+ return result;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Inocybe 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.ovsdb.utils.mdsal.utils;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
+
+/**
+ * Unit test for class {@link MdsalUtils}
+ *
+ */
+@RunWith(MockitoJUnitRunner.class)
+@SuppressWarnings({ "unchecked", "rawtypes" })
+public class MdsalUtilsTest {
+
+ @InjectMocks private MdsalUtils mdsalUtils;
+
+ @Mock private DataBroker databroker;
+
+ @Test
+ public void testDelete() {
+ WriteTransaction writeTransaction = mock(WriteTransaction.class);
+ when(databroker.newWriteOnlyTransaction()).thenReturn(writeTransaction);
+ CheckedFuture<Void, TransactionCommitFailedException> future = mock(CheckedFuture.class);
+ when(writeTransaction.submit()).thenReturn(future );
+
+ boolean result = mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, mock(InstanceIdentifier.class));
+
+ verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
+ verify(writeTransaction, times(1)).submit();
+
+ assertTrue("Error, the delete transaction failed", result);
+ }
+
+ @Test
+ public void testMerge() {
+ WriteTransaction writeTransaction = mock(WriteTransaction.class);
+ when(databroker.newWriteOnlyTransaction()).thenReturn(writeTransaction);
+ CheckedFuture<Void, TransactionCommitFailedException> future = mock(CheckedFuture.class);
+ when(writeTransaction.submit()).thenReturn(future );
+
+ boolean result = mdsalUtils.merge(LogicalDatastoreType.CONFIGURATION, mock(InstanceIdentifier.class), mock(DataObject.class));
+
+ verify(writeTransaction, times(1)).merge(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(DataObject.class), anyBoolean());
+ verify(writeTransaction, times(1)).submit();
+
+ assertTrue("Error, the merge transaction failed", result);
+ }
+
+ @Test
+ public void testPut() {
+ WriteTransaction writeTransaction = mock(WriteTransaction.class);
+ when(databroker.newWriteOnlyTransaction()).thenReturn(writeTransaction);
+ CheckedFuture<Void, TransactionCommitFailedException> future = mock(CheckedFuture.class);
+ when(writeTransaction.submit()).thenReturn(future );
+
+ boolean result = mdsalUtils.put(LogicalDatastoreType.CONFIGURATION, mock(InstanceIdentifier.class), mock(DataObject.class));
+
+ verify(writeTransaction, times(1)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(DataObject.class), anyBoolean());
+ verify(writeTransaction, times(1)).submit();
+
+ assertTrue("Error, the put transaction failed", result);
+ }
+
+ @Test
+ public void testRead() throws ReadFailedException {
+ ReadOnlyTransaction readOnlyTransaction = mock(ReadOnlyTransaction.class);
+ when(databroker.newReadOnlyTransaction()).thenReturn(readOnlyTransaction);
+ CheckedFuture<Optional, ReadFailedException> future = mock(CheckedFuture.class);
+ Optional opt = mock(Optional.class);
+ when(opt.isPresent()).thenReturn(true);
+ DataObject obj = mock(DataObject.class);
+ when(opt.get()).thenReturn(obj );
+ when(future.checkedGet()).thenReturn(opt);
+ when(readOnlyTransaction.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class))).thenReturn(future);
+
+ DataObject result = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, mock(InstanceIdentifier.class));
+
+ verify(readOnlyTransaction, times(1)).read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
+ verify(readOnlyTransaction, times(1)).close();
+
+ assertEquals("Error, the read transaction failed", obj, result);
+ }
+}
<module>mdsal-node</module>
<module>mdsal-openflow</module>
<module>servicehelper</module>
+ <module>mdsal-utils</module>
</modules>
</project>