@Override
public void addNode(Node node, Set<Property> props) {
- pluginOvsdbInventoryService.addNode(NodeUtils.getMdsalNode(node), props);
}
@Override
@Override
public void addNodeProperty(Node node, UpdateType type, Set<Property> props) {
- pluginOvsdbInventoryService.addNodeProperty(NodeUtils.getMdsalNode(node), type, props);
}
@Override
<groupId>org.opendaylight.ovsdb</groupId>
<artifactId>plugin</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal</artifactId>
- </dependency>
</dependencies>
<build>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.dependencymanager</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.ovsdb</groupId>
<artifactId>library</artifactId>
package org.opendaylight.ovsdb.plugin.api;
import java.net.InetAddress;
-import java.util.Set;
import java.util.concurrent.ConcurrentMap;
-import org.opendaylight.controller.sal.core.Property;
-import org.opendaylight.controller.sal.core.UpdateType;
import org.opendaylight.ovsdb.lib.message.TableUpdates;
import org.opendaylight.ovsdb.lib.notation.Row;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
public void removeRow(Node n, String databaseName, String tableName, String uuid);
public void processTableUpdates(Node n, String databaseName,TableUpdates tableUpdates);
public void printCache(Node n);
- public void addNode(Node n, Set<Property> props);
public void notifyNodeAdded(Node n, InetAddress address, int port);
public void removeNode(Node n);
- public void addNodeProperty(Node node, UpdateType type, Set<Property> props);
}
\ No newline at end of file
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
-import org.opendaylight.controller.sal.core.Property;
import org.opendaylight.ovsdb.lib.MonitorCallBack;
import org.opendaylight.ovsdb.lib.OvsdbClient;
import org.opendaylight.ovsdb.lib.OvsdbConnection;
import org.opendaylight.ovsdb.plugin.api.ConnectionConstants;
import org.opendaylight.ovsdb.plugin.api.Status;
import org.opendaylight.ovsdb.plugin.api.StatusCode;
-import org.opendaylight.ovsdb.plugin.internal.IPAddressProperty;
-import org.opendaylight.ovsdb.plugin.internal.L4PortProperty;
import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryService;
import org.opendaylight.ovsdb.utils.config.ConfigProperties;
OvsdbClient client = connection.getClient();
InetAddress address = client.getConnectionInfo().getRemoteAddress();
int port = client.getConnectionInfo().getRemotePort();
- IPAddressProperty addressProp = new IPAddressProperty(address);
- L4PortProperty l4Port = new L4PortProperty(port);
- Set<Property> props = new HashSet<Property>();
- props.add(addressProp);
- props.add(l4Port);
- logger.info("Add node to ovsdb inventory service {}", connection.getNode().toString());
- ovsdbInventoryService.addNode(connection.getNode(), props);
List<String> databases = client.getDatabases().get();
if (databases == null) {
package org.opendaylight.ovsdb.plugin.impl;
import java.net.InetAddress;
-import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
-import org.opendaylight.controller.sal.core.Property;
-import org.opendaylight.controller.sal.core.UpdateType;
import org.opendaylight.ovsdb.lib.message.TableUpdate;
import org.opendaylight.ovsdb.lib.message.TableUpdates;
import org.opendaylight.ovsdb.lib.notation.Row;
public class InventoryServiceImpl implements OvsdbInventoryService {
private static final Logger logger = LoggerFactory
.getLogger(InventoryServiceImpl.class);
- private ConcurrentMap<Node, Map<String, Property>> nodeProps = new ConcurrentHashMap<Node, Map<String, Property>>();
private ConcurrentMap<Node, NodeDatabase> dbCache = Maps.newConcurrentMap();
private ScheduledExecutorService executor;
private OvsdbConfigurationService ovsdbConfigurationService;
}
}
- @Override
- public void addNode(Node node, Set<Property> props) {
- addNodeProperty(node, UpdateType.ADDED, props);
- }
-
@Override
public void notifyNodeAdded(Node node, InetAddress address, int port) {
if (!ovsdbInventoryListeners.isEmpty()) {
}
}
- @Override
- public void addNodeProperty(Node node, UpdateType type, Set<Property> props) {
- Map<String, Property> nProp = nodeProps.get(node);
- if (nProp == null) nProp = new HashMap<String, Property>();
- for (Property prop : props) {
- nProp.put(prop.getName(), prop);
- }
- nodeProps.put(node, nProp);
- /*
- * TODO: Remove following code. It updates to sal about newly added node and
- * it's property. To move this bundle to MD-SAL we need to store this data in
- * md-sal config/operational data store.
- for (IPluginOutInventoryService service : pluginOutInventoryServices) {
- service.updateNode(node, type, props);
- }
- */
- }
-
@Override
public void removeNode(Node node) {
if (!ovsdbInventoryListeners.isEmpty()) {
}
}
- /*
- * TODO: Remove following code. It updates to sal about newly added node and
- * it's property. To move this bundle to MD-SAL we need to store this data in
- * md-sal config/operational data store.
- for (IPluginOutInventoryService service : pluginOutInventoryServices) {
- service.updateNode(node, UpdateType.REMOVED, null);
- }
- */
- nodeProps.remove(node);
dbCache.remove(node);
}
+++ /dev/null
-/*
- * Copyright (C) 2013 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 : Madhu Venugopal, Brent Salisbury
- */
-
-package org.opendaylight.ovsdb.plugin.internal;
-import java.net.InetAddress;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.opendaylight.controller.sal.core.Property;
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.NONE)
-public class IPAddressProperty extends Property implements Cloneable {
- private static final long serialVersionUID = 1L;
- @XmlElement(name="value")
- private final InetAddress address;
- public static final String name = "IPAddress";
-
- /*
- * Private constructor used for JAXB mapping
- */
- private IPAddressProperty() {
- super(name);
- this.address = null;
- }
-
- public IPAddressProperty(InetAddress address) {
- super(name);
- this.address = address;
- }
-
- @Override
- public String getStringValue() {
- if (address == null) return null;
- return this.address.getHostAddress();
- }
-
- @Override
- public Property clone() {
- return new IPAddressProperty(this.address);
- }
-
- public InetAddress getAddress() {
- return address;
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2013 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 : Madhu Venugopal, Brent Salisbury
- */
-
-package org.opendaylight.ovsdb.plugin.internal;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.opendaylight.controller.sal.core.Property;
-
-@XmlRootElement
-@XmlAccessorType(XmlAccessType.NONE)
-public class L4PortProperty extends Property implements Cloneable {
- private static final long serialVersionUID = 1L;
- @XmlElement(name="value")
- private final int port;
- public static final String name = "Port";
-
- /*
- * Private constructor used for JAXB mapping
- */
- private L4PortProperty() {
- super(name);
- this.port = 0;
- }
-
- public L4PortProperty(int port) {
- super(name);
- this.port = port;
- }
-
- @Override
- public String getStringValue() {
- return port+"";
- }
-
- @Override
- public Property clone() {
- return new L4PortProperty(port);
- }
-
- public int getPort() {
- return port;
- }
-}