List<String> nodeIds = Lists.newArrayList();
for (Node node : nodes) {
- nodeIds.add(node.toString());
+ nodeIds.add(node.getId().getValue());
}
String response = objectMapper.writeValueAsString(nodeIds);
*/
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.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.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@RunWith(PowerMockRunner.class)
@PrepareForTest(ServiceHelper.class)
public class NodeResourceTest {
+ static final Logger LOG = LoggerFactory.getLogger(NodeResourceTest.class);
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
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 = new String();
+ 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 = new String("\"" + 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 = new String("\"" + OVS_IDENTIFIER + "\"");
+ String id2 = new String("\"" + 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");
+ }
+ }
}
public FlowCapableNodeDataChangeListener (DataBroker dataBroker) {
LOG.info("Registering FlowCapableNodeChangeListener");
- registration = dataBroker.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
- createFlowCapableNodePath(), this, AsyncDataBroker.DataChangeScope.ONE);
+ registration = dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+ createFlowCapableNodePath(), this, AsyncDataBroker.DataChangeScope.BASE);
}
@Override
for (Map.Entry<InstanceIdentifier<?>, DataObject> updated : changes.getUpdatedData().entrySet()) {
InstanceIdentifier<?> iID = updated.getKey();
String openflowId = iID.firstKeyOf(Node.class, NodeKey.class).getId().getValue();
- LOG.trace(">>>>> updated iiD: {} - first: {} - NodeKey: {}",
+ LOG.info(">>>>> updated iiD: {} - first: {} - NodeKey: {}",
iID, iID.firstIdentifierOf(Node.class), openflowId);
Node openFlowNode = NodeUtils.getOpenFlowNode(openflowId);
if (nodeCache.contains(openFlowNode)) {
private void notifyNodeUpdated (Node openFlowNode) {
final String openflowId = openFlowNode.getId().getValue();
- LOG.trace("notifyNodeUpdated: Node {} from Controller's inventory Service", openflowId);
+ LOG.info("notifyNodeUpdated: Node {} from Controller's inventory Service", openflowId);
// TODO: will do something amazing here, someday
}
{
- "id": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
- "name": "Ovsdb Southbound Collection",
- "timestamp": 1424977469540,
- "order": [
- "25991d63-bce2-fd31-6504-c5602b0a7099",
- "19541dee-f73c-ac03-ff4e-36d65a313624",
- "2ee8a356-bfdb-7f09-40a6-4e471e4b9bc3",
- "da0ea53d-ea33-c15f-5140-9eb339445ee1",
- "b542ee70-45fd-824f-ab33-a5c3bae38d24",
- "91d7a25c-13a7-486d-f23e-1e90c485d78e"
- ],
- "owner": 0,
- "sharedWithTeam": false,
- "synced": false,
- "subscribed": false,
- "hasRequests": true,
- "requests": [
- {
- "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
- "id": "19541dee-f73c-ac03-ff4e-36d65a313624",
- "name": "Get Operational Topology",
- "description": "",
- "url": "http://localhost:8080/restconf/operational/network-topology:network-topology/",
- "method": "GET",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\n",
- "data": [],
- "dataMode": "params",
- "timestamp": 0,
- "responses": [],
- "version": 2,
- "owner": 0,
- "preRequestScript": "",
- "tests": "",
- "synced": false
- },
- {
- "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
- "id": "25991d63-bce2-fd31-6504-c5602b0a7099",
- "name": "Create Specific Config OvsdbNode",
- "description": "",
- "url": "http://localhost:8080/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F127.0.0.1: 16640",
- "method": "PUT",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "version": 2,
- "time": 1425926377425,
- "owner": 0,
- "preRequestScript": "",
- "tests": "",
- "synced": false,
- "rawModeData": "{\n \"network-topology:node\": [\n {\n \"node-id\": \"ovsdb:/127.0.0.1: 16640\",\n \"ovsdb:port\": 16640,\n \"ovsdb:ip\": \"127.0.0.1\"\n }\n ]\n}"
- },
- {
- "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
- "id": "2ee8a356-bfdb-7f09-40a6-4e471e4b9bc3",
- "name": "Create Specific Config Bridge",
- "description": "",
- "url": "http://localhost:8080/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2F127.0.0.1:16640%2Fbridge%2Fbr02",
- "method": "PUT",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
- "data": [],
- "dataMode": "raw",
- "timestamp": 0,
- "version": 2,
- "time": 1426530506948,
- "owner": 0,
- "preRequestScript": "",
- "tests": "",
- "synced": false,
- "rawModeData": "{\n \"network-topology:node\": [\n {\n \"node-id\": \"ovsdb://127.0.0.1:16640/bridge/br02\",\n \"ovsdb:bridge-name\": \"br02\",\n \"ovsdb:datapath-id\": \"00:00:b2:bf:48:25:f2:4b\",\n \"ovsdb:protocol-entry\": [\n {\n \"protocol\": \"ovsdb:ovsdb-bridge-protocol-openflow-13\"\n }\n ],\n \"ovsdb:controller-entry\": [\n {\n \"target\": \"tcp:127.0.0.1:6633\"\n }\n ],\n \"ovsdb:managed-by\": \"/network-topology:network-topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node[network-topology:node-id='ovsdb://127.0.0.1:16640']\"\n }\n ]\n}"
- },
- {
- "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
- "id": "91d7a25c-13a7-486d-f23e-1e90c485d78e",
- "name": "Get Specific Config OvsdbNode",
- "description": "",
- "url": "http://localhost:8080/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F127.0.0.1: 16640",
- "method": "GET",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\n",
- "data": [],
- "dataMode": "params",
- "timestamp": 0,
- "responses": [],
- "version": 2,
- "owner": 0,
- "preRequestScript": "",
- "tests": "",
- "synced": false
- },
- {
- "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
- "id": "b542ee70-45fd-824f-ab33-a5c3bae38d24",
- "name": "Get Config Topology",
- "description": "",
- "url": "http://localhost:8080/restconf/config/network-topology:network-topology/",
- "method": "GET",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\n",
- "data": [],
- "dataMode": "params",
- "timestamp": 0,
- "responses": [],
- "version": 2,
- "owner": 0,
- "preRequestScript": "",
- "tests": "",
- "synced": false
- },
- {
- "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
- "id": "da0ea53d-ea33-c15f-5140-9eb339445ee1",
- "name": "Delete Specific Config OvsdbNode",
- "description": "",
- "url": "http://localhost:8080/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F127.0.0.1: 16640",
- "method": "DELETE",
- "headers": "Authorization: Basic YWRtaW46YWRtaW4=\n",
- "data": [],
- "dataMode": "params",
- "timestamp": 0,
- "responses": [],
- "version": 2,
- "owner": 0,
- "preRequestScript": "",
- "tests": "",
- "synced": false
- }
- ]
-}
\ No newline at end of file
+ "id": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
+ "name": "Ovsdb Southbound Collection",
+ "timestamp": 1424977469540,
+ "order": [
+ "25991d63-bce2-fd31-6504-c5602b0a7099",
+ "19541dee-f73c-ac03-ff4e-36d65a313624",
+ "2ee8a356-bfdb-7f09-40a6-4e471e4b9bc3",
+ "da0ea53d-ea33-c15f-5140-9eb339445ee1",
+ "b542ee70-45fd-824f-ab33-a5c3bae38d24",
+ "91d7a25c-13a7-486d-f23e-1e90c485d78e"
+ ],
+ "requests": [
+ {
+ "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
+ "id": "19541dee-f73c-ac03-ff4e-36d65a313624",
+ "name": "Get Operational Topology",
+ "description": "",
+ "url": "http:\/\/localhost:8080\/restconf\/operational\/network-topology:network-topology\/",
+ "method": "GET",
+ "headers": "Authorization: Basic YWRtaW46YWRtaW4=\n",
+ "data": [
+
+ ],
+ "dataMode": "params",
+ "timestamp": 0,
+ "responses": [
+
+ ],
+ "version": 2
+ },
+ {
+ "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
+ "id": "25991d63-bce2-fd31-6504-c5602b0a7099",
+ "name": "Create Specific Config OvsdbNode",
+ "description": "",
+ "url": "http:\/\/localhost:8080\/restconf\/config\/network-topology:network-topology\/topology\/ovsdb:1\/node\/ovsdb:%2F127.0.0.1: 16640",
+ "method": "PUT",
+ "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application\/json\n",
+ "data": "{\n \"network-topology:node\": [\n {\n \"node-id\": \"ovsdb:\/127.0.0.1: 16640\",\n \"ovsdb:port\": 16640,\n \"ovsdb:ip\": \"127.0.0.1\"\n }\n ]\n}",
+ "dataMode": "raw",
+ "timestamp": 0,
+ "version": 2,
+ "time": 1425926377425
+ },
+ {
+ "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
+ "id": "2ee8a356-bfdb-7f09-40a6-4e471e4b9bc3",
+ "name": "Create Specific Config Bridge",
+ "description": "",
+ "url": "http:\/\/localhost:8080\/restconf\/config\/network-topology:network-topology\/topology\/ovsdb:1\/node\/ovsdb:%2F%2F127.0.0.1:16640%2Fbridge%2Fbr02",
+ "method": "PUT",
+ "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application\/json\n",
+ "data": "{\n \"network-topology:node\": [\n {\n \"node-id\": \"ovsdb:\/\/127.0.0.1:16640\/bridge\/br02\",\n \"ovsdb:bridge-name\": \"br02\",\n \"ovsdb:protocol-entry\": [\n {\n \"protocol\": \"ovsdb:ovsdb-bridge-protocol-openflow-13\"\n }\n ],\n \"ovsdb:controller-entry\": [\n {\n \"target\": \"tcp:127.0.0.1:6633\"\n }\n ],\n \"ovsdb:fail-mode\": \"ovsdb:ovsdb-fail-mode-secure\",\n \"ovsdb:managed-by\": \"\/network-topology:network-topology\/network-topology:topology[network-topology:topology-id='ovsdb:1']\/network-topology:node[network-topology:node-id='ovsdb:\/\/127.0.0.1:16640']\"\n }\n ]\n}",
+ "dataMode": "raw",
+ "timestamp": 0,
+ "version": 2,
+ "time": 1426707526682
+ },
+ {
+ "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
+ "id": "91d7a25c-13a7-486d-f23e-1e90c485d78e",
+ "name": "Get Specific Config OvsdbNode",
+ "description": "",
+ "url": "http:\/\/localhost:8080\/restconf\/config\/network-topology:network-topology\/topology\/ovsdb:1\/node\/ovsdb:%2F127.0.0.1: 16640",
+ "method": "GET",
+ "headers": "Authorization: Basic YWRtaW46YWRtaW4=\n",
+ "data": [
+
+ ],
+ "dataMode": "params",
+ "timestamp": 0,
+ "responses": [
+
+ ],
+ "version": 2
+ },
+ {
+ "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
+ "id": "b542ee70-45fd-824f-ab33-a5c3bae38d24",
+ "name": "Get Config Topology",
+ "description": "",
+ "url": "http:\/\/localhost:8080\/restconf\/config\/network-topology:network-topology\/",
+ "method": "GET",
+ "headers": "Authorization: Basic YWRtaW46YWRtaW4=\n",
+ "data": [
+
+ ],
+ "dataMode": "params",
+ "timestamp": 0,
+ "responses": [
+
+ ],
+ "version": 2
+ },
+ {
+ "collectionId": "2e3d9bd8-1388-bf50-19bf-7eb4b06dbfb1",
+ "id": "da0ea53d-ea33-c15f-5140-9eb339445ee1",
+ "name": "Delete Specific Config OvsdbNode",
+ "description": "",
+ "url": "http:\/\/localhost:8080\/restconf\/config\/network-topology:network-topology\/topology\/ovsdb:1\/node\/ovsdb:%2F127.0.0.1: 16640",
+ "method": "DELETE",
+ "headers": "Authorization: Basic YWRtaW46YWRtaW4=\n",
+ "data": [
+
+ ],
+ "dataMode": "params",
+ "timestamp": 0,
+ "responses": [
+
+ ],
+ "version": 2
+ }
+ ]
+}
RFC 2579: Textual Conventions for SMIv2";
}
+ identity datapath-type-base {
+ description "Base identity for all OVSDB datapath types";
+ }
+
+ identity datapath-type-system {
+ description "Datapath type for the kernel datapath";
+ base datapath-type-base;
+ }
+
+ identity datapath-type-netdev {
+ description "Datapath type for the userspace datapath";
+ base datapath-type-base;
+ }
+
identity ovsdb-bridge-protocol-base {
description "Base identity for all ovsdb-bridge-protocols";
}
base ovsdb-bridge-protocol-base;
}
+ identity ovsdb-fail-mode-base {
+ description "Base identity for ovsdb-failmode";
+ }
+
+ identity ovsdb-fail-mode-standalone {
+ description "Identity for ovsdb-failmode standalone";
+ base ovsdb-fail-mode-base;
+ }
+
+ identity ovsdb-fail-mode-secure {
+ definition "Identity for ovsdb-failmode standalone";
+ base ovsdb-fail-mode-base;
+ }
+
grouping ovsdb-bridge-attributes {
leaf bridge-uuid {
description "The unique identifier of the bridge";
type datapath-id;
}
+ leaf datapath-type {
+ description "The datapath type of the bridge";
+ type identityref {
+ base datapath-type-base;
+ }
+ }
+
+ leaf fail-mode {
+ description "Failmode of the bridge";
+ type identityref {
+ base ovsdb-fail-mode-base;
+ }
+ }
+
leaf flow-node {
description "Flow node corresponding to this bridge";
type flow-node-ref;
base interface-type-base;
}
+ identity interface-type-tap {
+ description "Interface type for tun/tap interfaces";
+ base interface-type-base;
+ }
+
+ identity interface-type-geneve {
+ description "Interface type for geneve interfaces";
+ base interface-type-base;
+ }
+
+ identity interface-type-gre {
+ description "Interface type for gre interfaces";
+ base interface-type-base;
+ }
+
+ identity interface-type-ipsec-gre {
+ description "Interface type for ipsec-gre interfaces";
+ base interface-type-base;
+ }
+
+ identity interface-type-gre64 {
+ description "Interface type for gre64 interfaces";
+ base interface-type-base;
+ }
+
+ identity interface-type-ipsec-gre64 {
+ description "Interface type for ipsec-gre64 interfaces";
+ base interface-type-base;
+ }
+
+ identity interface-type-lisp {
+ description "Interface type for lisp interfaces";
+ base interface-type-base;
+ }
+
+ identity interface-type-dpdk {
+ description "Interface type for dpdk interfaces";
+ base interface-type-base;
+ }
+
+ identity interface-type-dpdkr {
+ description "Interface type for dpdk ring interfaces";
+ base interface-type-base;
+ }
+
grouping ovsdb-port-interface-attributes {
leaf port-uuid {
description "The unique identifier of the OVSDB port";
@Override
public void onDataChanged(
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
- LOG.info("Received change to ovsdbNode: {}", changes);
+ LOG.debug("Received change to ovsdbNode: {}", changes);
for (Entry<InstanceIdentifier<?>, DataObject> created : changes.getCreatedData().entrySet()) {
// TODO validate we have the correct kind of InstanceIdentifier
if (created.getValue() instanceof OvsdbNodeAugmentation) {
package org.opendaylight.ovsdb.southbound;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeInternal;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypePatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeSystem;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeVxlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeTap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeGeneve;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeGre;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeIpsecGre;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeGre64;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeIpsecGre64;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeLisp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeDpdk;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeDpdkr;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeProtocolBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeProtocolOpenflow10;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeProtocolOpenflow11;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeProtocolOpenflow13;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeProtocolOpenflow14;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeProtocolOpenflow15;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbFailModeBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbFailModeSecure;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbFailModeStandalone;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathTypeBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathTypeSystem;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathTypeNetdev;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
import com.google.common.collect.ImmutableBiMap;
.put(OvsdbBridgeProtocolOpenflow14.class,"OpenFlow14")
.put(OvsdbBridgeProtocolOpenflow15.class,"OpenFlow15")
.build();
+
+ public static final ImmutableBiMap<Class<? extends OvsdbFailModeBase>,String> OVSDB_FAIL_MODE_MAP = new ImmutableBiMap.Builder<Class<? extends OvsdbFailModeBase>,String>()
+ .put(OvsdbFailModeStandalone.class,"standalone")
+ .put(OvsdbFailModeSecure.class,"secure")
+ .build();
+
+ public static final ImmutableBiMap<String, Class<? extends InterfaceTypeBase>> OVSDB_INTERFACE_TYPE_MAP = new ImmutableBiMap.Builder<String, Class<? extends InterfaceTypeBase>>()
+ .put("internal", InterfaceTypeInternal.class)
+ .put("vxlan", InterfaceTypeVxlan.class)
+ .put("patch", InterfaceTypePatch.class)
+ .put("system", InterfaceTypeSystem.class)
+ .put("tap", InterfaceTypeTap.class)
+ .put("geneve", InterfaceTypeGeneve.class)
+ .put("gre", InterfaceTypeGre.class)
+ .put("ipsec_gre", InterfaceTypeIpsecGre.class)
+ .put("gre64", InterfaceTypeGre64.class)
+ .put("ipsec_gre64", InterfaceTypeIpsecGre64.class)
+ .put("lisp", InterfaceTypeLisp.class)
+ .put("dpdk", InterfaceTypeDpdk.class)
+ .put("dpdkr", InterfaceTypeDpdkr.class)
+ .build();
+
+ public static final ImmutableBiMap<Class<? extends DatapathTypeBase>,String> DATAPATH_TYPE_MAP = new ImmutableBiMap.Builder<Class<? extends DatapathTypeBase>,String>()
+ .put(DatapathTypeSystem.class,"system")
+ .put(DatapathTypeNetdev.class,"netdev")
+ .build();
}
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathTypeSystem;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeName;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeProtocolBase;
}
}
+ public static String createDatapathType(OvsdbBridgeAugmentation mdsalbridge) {
+ String datapathtype = new String(SouthboundConstants.DATAPATH_TYPE_MAP.get(DatapathTypeSystem.class));
+
+ if (mdsalbridge.getDatapathType() != null) {
+ if (SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType()) != null) {
+ datapathtype = SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType());
+ } else {
+ throw new IllegalArgumentException("Unknown datapath type " + SouthboundConstants.DATAPATH_TYPE_MAP.get(mdsalbridge.getDatapathType()));
+ }
+ }
+ return datapathtype;
+ }
+
public static DatapathId createDatapathId(String dpid) {
Preconditions.checkNotNull(dpid);
DatapathId datapath;
return protocols;
}
+ public static Class<? extends InterfaceTypeBase> createInterfaceType(String type) {
+ Preconditions.checkNotNull(type);
+ return SouthboundConstants.OVSDB_INTERFACE_TYPE_MAP.get(type);
+ }
+
public static List<ProtocolEntry> createMdsalProtocols(Bridge bridge) {
Set<String> protocols = bridge.getProtocolsColumn().getData();
List<ProtocolEntry> protocolList = new ArrayList<ProtocolEntry>();
}
public static List<ControllerEntry> createControllerEntries(Bridge bridge,Map<UUID,Controller> updatedControllerRows) {
- LOG.info("Bridge: {}, updatedControllerRows: {}",bridge,updatedControllerRows);
+ LOG.debug("Bridge: {}, updatedControllerRows: {}",bridge,updatedControllerRows);
Set<UUID> controllerUUIDs = bridge.getControllerColumn().getData();
List<ControllerEntry> controllerEntries = new ArrayList<ControllerEntry>();
for(UUID controllerUUID : controllerUUIDs ) {
import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
import org.opendaylight.ovsdb.schema.openvswitch.Controller;
import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
+import org.opendaylight.ovsdb.southbound.SouthboundConstants;
import org.opendaylight.ovsdb.southbound.SouthboundMapper;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
// Bridge part
Bridge bridge = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), Bridge.class);
bridge.setName(ovsdbManagedNode.getBridgeName().getValue());
+ if(ovsdbManagedNode.getFailMode() != null &&
+ SouthboundConstants.OVSDB_FAIL_MODE_MAP.get(ovsdbManagedNode.getFailMode()) != null ) {
+ bridge.setFailMode(Sets.newHashSet(SouthboundConstants.OVSDB_FAIL_MODE_MAP.get(ovsdbManagedNode.getFailMode())));
+ }
String namedUuid = "Bridge_" + ovsdbManagedNode.getBridgeName().getValue();
- bridge.setName(ovsdbManagedNode.getBridgeName().getValue());
+ bridge.setDatapathType(SouthboundMapper.createDatapathType(ovsdbManagedNode));
if(SouthboundMapper.createOvsdbBridgeProtocols(ovsdbManagedNode) != null
&& SouthboundMapper.createOvsdbBridgeProtocols(ovsdbManagedNode).size() > 0){
bridge.setProtocols(SouthboundMapper.createOvsdbBridgeProtocols(ovsdbManagedNode));
package org.opendaylight.ovsdb.southbound.transactions.md;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Set;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
import org.opendaylight.ovsdb.schema.openvswitch.Controller;
import org.opendaylight.ovsdb.southbound.OvsdbClientKey;
+import org.opendaylight.ovsdb.southbound.SouthboundConstants;
import org.opendaylight.ovsdb.southbound.SouthboundMapper;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
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.OvsdbNodeAugmentationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ControllerEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ControllerEntryBuilder;
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.ManagedNodeEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
LOG.debug("Read Operational/DS for Node fail! {}", nodePath, e);
}
if(node.isPresent()){
- LOG.info("Node {} is present",node);
+ LOG.debug("Node {} is present",node);
NodeBuilder managedNodeBuilder = new NodeBuilder();
NodeId manageNodeId = SouthboundMapper.createManagedNodeId(getKey(), new OvsdbBridgeName(bridge.getName()));
managedNodeBuilder.setNodeId(manageNodeId);
if(!SouthboundMapper.createControllerEntries(bridge, updatedControllerRows).isEmpty()) {
ovsdbManagedNodeBuilder.setControllerEntry(SouthboundMapper.createControllerEntries(bridge, updatedControllerRows));
}
+
+ if(bridge.getFailModeColumn() != null &&
+ bridge.getFailModeColumn().getData() != null &&
+ !bridge.getFailModeColumn().getData().isEmpty()) {
+ String[] failmodeArray = new String[bridge.getFailModeColumn().getData().size()];
+ bridge.getFailModeColumn().getData().toArray(failmodeArray);
+ ovsdbManagedNodeBuilder.setFailMode(SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get(failmodeArray[0]));
+ }
ovsdbManagedNodeBuilder.setManagedBy(new OvsdbNodeRef(nodePath));
managedNodeBuilder.addAugmentation(OvsdbBridgeAugmentation.class, ovsdbManagedNodeBuilder.build());
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
+
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.ovsdb.lib.message.TableUpdates;
+import org.opendaylight.ovsdb.lib.notation.Column;
import org.opendaylight.ovsdb.lib.notation.UUID;
import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
+import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
+import org.opendaylight.ovsdb.schema.openvswitch.Interface;
import org.opendaylight.ovsdb.schema.openvswitch.Port;
import org.opendaylight.ovsdb.southbound.OvsdbClientKey;
import org.opendaylight.ovsdb.southbound.SouthboundMapper;
.setName(port.getName());
ovsdbTerminationPointBuilder.setPortUuid(new Uuid(
port.getUuid().toString()));
+ Column<GenericTableSchema, Set<UUID>> iface = port.getInterfacesColumn();
+ Set<UUID> ifUuid = iface.getData();
+ Collection<Interface> ifUpdateRows = TyperUtils.extractRowsUpdated(Interface.class, getUpdates(), getDbSchema()).values();
+ for (UUID ifIter : ifUuid) {
+ for (Interface interfIter : ifUpdateRows) {
+ Column<GenericTableSchema, String> typeColumn = interfIter.getTypeColumn();
+ String type = typeColumn.getData();
+ if ((interfIter.getUuid()).equals(ifIter)) {
+ ovsdbTerminationPointBuilder.setInterfaceUuid(new Uuid(interfIter.getUuid().toString()));
+ ovsdbTerminationPointBuilder.setInterfaceType(SouthboundMapper.createInterfaceType(type));
+ break;
+ }
+ }
+ }
entry.addAugmentation(
(Class<? extends Augmentation<TerminationPoint>>) OvsdbTerminationPointAugmentation.class,
ovsdbTerminationPointBuilder.build());