Patch 2: implement code review comments.
Change-Id: I8c730fbb252d7462b43a4ffb28c3e06cf54aaee1
Signed-off-by: Flavio Fernandes <ffernand@redhat.com>
<ovsdb.plugin.compatibility.layer.version>1.1.0-SNAPSHOT</ovsdb.plugin.compatibility.layer.version>
<ovsdb.ovssfc.version>0.1.0-SNAPSHOT</ovsdb.ovssfc.version>
<ovsdb.utils.config.version>1.1.0-SNAPSHOT</ovsdb.utils.config.version>
+ <ovsdb.utils.mdsal.node.version>1.1.0-SNAPSHOT</ovsdb.utils.mdsal.node.version>
+ <ovsdb.utils.mdsal.openflow.version>1.1.0-SNAPSHOT</ovsdb.utils.mdsal.openflow.version>
<ovsdb.utils.servicehelper.version>1.1.0-SNAPSHOT</ovsdb.utils.servicehelper.version>
<plugin.shell.version>1.1.0-SNAPSHOT</plugin.shell.version>
<schema.hardwarevtep.version>1.1.0-SNAPSHOT</schema.hardwarevtep.version>
<schema.openvswitch.version>1.1.0-SNAPSHOT</schema.openvswitch.version>
- <utils.mdsal.openflow.version>1.1.0-SNAPSHOT</utils.mdsal.openflow.version>
<!-- Skip Coverage and IT by default -->
<skip.coverage>true</skip.coverage>
<skip.distribution>false</skip.distribution>
<artifactId>utils.config</artifactId>
<version>${ovsdb.utils.config.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <artifactId>utils.mdsal-node</artifactId>
+ <version>${ovsdb.utils.mdsal.node.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.ovsdb</groupId>
<artifactId>utils.mdsal-openflow</artifactId>
- <version>${utils.mdsal.openflow.version}</version>
+ <version>${ovsdb.utils.mdsal.openflow.version}</version>
</dependency>
<dependency>
<groupId>org.opendaylight.ovsdb</groupId>
<groupId>org.opendaylight.ovsdb</groupId>
<artifactId>schema.openvswitch</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <artifactId>utils.mdsal-node</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.ovsdb</groupId>
<artifactId>utils.mdsal-openflow</artifactId>
org.osgi.framework,
*
</Import-Package>-->
- <Embed-Dependency>utils.config,utils.mdsal-openflow;type=!pom;inline=false</Embed-Dependency>
+ <Embed-Dependency>utils.config,utils.mdsal-node,utils.mdsal-openflow;type=!pom;inline=false</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Bundle-Activator>org.opendaylight.ovsdb.openstack.netvirt.providers.Activator</Bundle-Activator>
</instructions>
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-//import org.opendaylight.ovsdb.openstack.netvirt.NodeUtils;
+import org.opendaylight.ovsdb.utils.mdsal.node.NodeUtils;
import org.opendaylight.ovsdb.openstack.netvirt.api.NetworkingProviderManager;
import org.opendaylight.ovsdb.openstack.netvirt.api.NodeCacheManager;
import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
+++ /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.openstack.netvirt.providers.openflow13;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.opendaylight.controller.sal.core.ConstructionException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-// TODO: Move this to org.opendaylight.ovsdb.utils
-
-public class NodeUtils {
- protected static final Logger LOG = LoggerFactory.getLogger(NodeUtils.class);
-
- public static String getId (String identifier) {
- String id = identifier;
-
- String[] pair = identifier.split("\\|");
- if (pair[0].equals("OVS")) {
- id = pair[1];
- }
- return id;
- }
-
- public static Node getOpenFlowNode (String identifier) {
- NodeId nodeId = new NodeId(identifier);
- NodeKey nodeKey = new NodeKey(nodeId);
- Node node = new NodeBuilder()
- .setId(nodeId)
- .setKey(nodeKey)
- .build();
-
- return node;
- }
-
- public static Node getMdsalNode (org.opendaylight.controller.sal.core.Node salNode) {
- String identifier = salNode.getNodeIDString();
-
- NodeId nodeId = new NodeId("OVS" + "|" + identifier);
- NodeKey nodeKey = new NodeKey(nodeId);
- Node node = new NodeBuilder()
- .setId(nodeId)
- .setKey(nodeKey)
- .build();
-
- return node;
- }
-
- public static org.opendaylight.controller.sal.core.Node getSalNode (Node mdsalNode) {
- String identifier = NodeUtils.getId(mdsalNode.getId().getValue());
- org.opendaylight.controller.sal.core.Node node = null;
-
- try {
- node = new org.opendaylight.controller.sal.core.Node("OVS", identifier);
- } catch (ConstructionException e) {
- LOG.error("Failed to allocate sal Node", e);
- }
-
- return node;
- }
-
- public static List<org.opendaylight.controller.sal.core.Node> getSalNodes (List<Node> mdsalNodes) {
- List<org.opendaylight.controller.sal.core.Node> nodes = new ArrayList<>();
-
- for (Node mdsalNode : mdsalNodes) {
- nodes.add(NodeUtils.getSalNode(mdsalNode));
- }
- return nodes;
- }
-}
<groupId>org.opendaylight.ovsdb</groupId>
<artifactId>utils.config</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <artifactId>utils.mdsal-node</artifactId>
+ </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
- <Embed-Dependency>utils.config;type=!pom;inline=false</Embed-Dependency>
+ <Embed-Dependency>utils.config,utils.mdsal-node;type=!pom;inline=false</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Export-Package>
org.opendaylight.ovsdb.openstack.netvirt.api
import org.opendaylight.ovsdb.openstack.netvirt.NodeCacheManagerEvent;
import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
import org.opendaylight.ovsdb.openstack.netvirt.api.NodeCacheManager;
+import org.opendaylight.ovsdb.utils.mdsal.node.NodeUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Override
public void nodeAdded(String nodeIdentifier) {
- logger.info("XXX >>>>> enqueue: Node added : {}", nodeIdentifier);
logger.debug(">>>>> enqueue: Node added : {}", nodeIdentifier);
enqueueEvent(new NodeCacheManagerEvent(nodeIdentifier, Action.ADD));
}
@Override
public void nodeRemoved(String nodeIdentifier) {
- logger.info("XXX >>>>> enqueue: Node removed : {}", nodeIdentifier);
logger.debug(">>>>> enqueue: Node removed : {}", nodeIdentifier);
enqueueEvent(new NodeCacheManagerEvent(nodeIdentifier, Action.DELETE));
}
return nodeCache;
}
- void doNodeAdded(Node node) {
+ private void _processNodeAdded(Node node) {
nodeCache.add(node);
- logger.info("XXXX added node {}. cache is now {}", node, nodeCache);
+ logger.info("XXXX added node {}. cache is now {}", node, nodeCache); // TODO: debug, remove
}
- void doNodeRemoved(Node node) {
+ private void _processNodeRemoved(Node node) {
nodeCache.remove(node);
- logger.info("XXXX removed node {}. cache is now {}", node, nodeCache);
+ logger.info("XXXX removed node {}. cache is now {}", node, nodeCache); // TODO: debug, remove
}
/**
logger.debug(">>>>> dequeue: {}", ev);
switch (ev.getAction()) {
case ADD:
- doNodeAdded(NodeUtils.getOpenFlowNode(ev.getNodeIdentifier()));
+ _processNodeAdded(NodeUtils.getOpenFlowNode(ev.getNodeIdentifier()));
break;
case DELETE:
- doNodeRemoved(NodeUtils.getOpenFlowNode(ev.getNodeIdentifier()));
+ _processNodeRemoved(NodeUtils.getOpenFlowNode(ev.getNodeIdentifier()));
break;
case UPDATE:
break;
--- /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>
+ <artifactId>commons</artifactId>
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <version>1.3.0-SNAPSHOT</version>
+ <relativePath>../../commons/parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>utils.mdsal-node</artifactId>
+ <name>${project.artifactId}</name>
+ <version>1.1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+ <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.opendaylight.controller</groupId>
+ <artifactId>sal</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.model</groupId>
+ <artifactId>model-inventory</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <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>
*
* Authors : Sam Hague
*/
-package org.opendaylight.ovsdb.openstack.netvirt.impl;
+package org.opendaylight.ovsdb.utils.mdsal.node;
+import java.util.ArrayList;
+import java.util.List;
import org.opendaylight.controller.sal.core.ConstructionException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.List;
-
-// TODO: Move this to org.opendaylight.ovsdb.utils
-
public class NodeUtils {
protected static final Logger LOG = LoggerFactory.getLogger(NodeUtils.class);
--- /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.utils.mdsal.node;
+
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+
+public class NodeUtilsTest {
+
+ @Test
+ public void testCreateNode () {
+ // TODO
+ assertTrue(true);
+ }
+}
+
</prerequisites>
<modules>
<module>config</module>
+ <module>mdsal-node</module>
<module>mdsal-openflow</module>
<module>servicehelper</module>
</modules>