1 package org.opendaylight.controller.protocol_plugins.stub.internal;
3 import java.net.InetAddress;
4 import java.net.UnknownHostException;
5 import java.util.ArrayList;
7 import java.util.Dictionary;
8 import java.util.HashMap;
9 import java.util.HashSet;
10 import java.util.List;
13 import java.util.concurrent.ConcurrentHashMap;
14 import java.util.concurrent.ConcurrentMap;
16 import org.apache.felix.dm.Component;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
20 import org.opendaylight.controller.sal.core.Actions;
21 import org.opendaylight.controller.sal.core.Bandwidth;
22 import org.opendaylight.controller.sal.core.Buffers;
23 import org.opendaylight.controller.sal.core.Capabilities;
24 import org.opendaylight.controller.sal.core.Capabilities.CapabilitiesType;
25 import org.opendaylight.controller.sal.core.Node;
26 import org.opendaylight.controller.sal.core.NodeConnector;
27 import org.opendaylight.controller.sal.core.Property;
28 import org.opendaylight.controller.sal.core.State;
29 import org.opendaylight.controller.sal.core.Tables;
30 import org.opendaylight.controller.sal.core.TimeStamp;
31 import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
32 import org.opendaylight.controller.sal.utils.NodeCreator;
33 import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
36 * Stub Implementation for IPluginInReadService used by SAL
40 public class InventoryService implements IPluginInInventoryService {
41 private static final Logger logger = LoggerFactory
42 .getLogger(InventoryService.class);
44 private ConcurrentMap<Node, Map<String, Property>> nodeProps; // properties are maintained in global container only
45 private ConcurrentMap<NodeConnector, Map<String, Property>> nodeConnectorProps; // properties are maintained in global container only
49 * Function called by the dependency manager when all the required
50 * dependencies are satisfied
54 nodeProps = new ConcurrentHashMap<Node, Map<String, Property>>();
55 nodeConnectorProps = new ConcurrentHashMap<NodeConnector, Map<String, Property>>();
60 * Function called by the dependency manager when at least one dependency
61 * become unsatisfied or when the component is shutting down because for
62 * example bundle is being stopped.
69 * Function called by dependency manager after "init ()" is called and after
70 * the services provided by the class are registered in the service registry
77 * Function called by the dependency manager before the services exported by
78 * the component are unregistered, this will be followed by a "destroy ()"
86 * Retrieve nodes from openflow
89 public ConcurrentMap<Node, Map<String, Property>> getNodeProps() {
92 Map<String, Property> propMap = new HashMap<String, Property>();
94 Tables t = new Tables((byte)1);
95 propMap.put(Tables.TablesPropName, t);
96 Capabilities c = new Capabilities((int)3);
97 propMap.put(Capabilities.CapabilitiesPropName, c);
98 Actions a = new Actions((int)2);
99 propMap.put(Actions.ActionsPropName, a);
100 Buffers b = new Buffers((int)1);
101 propMap.put(Buffers.BuffersPropName, b);
102 Long connectedSinceTime = 100000L;
103 TimeStamp timeStamp = new TimeStamp(connectedSinceTime,
105 propMap.put(TimeStamp.TimeStampPropName, timeStamp);
107 // setup property map for all nodes
109 node = NodeCreator.createOFNode(2L);
110 nodeProps.put(node, propMap);
116 * Retrieve nodeConnectors from openflow
119 public ConcurrentMap<NodeConnector, Map<String, Property>> getNodeConnectorProps(
122 // setup nodeConnectorProps
123 Map<String, Property> ncPropMap = new HashMap<String, Property>();
124 Capabilities cap = new Capabilities
125 (CapabilitiesType.FLOW_STATS_CAPABILITY.getValue());
126 ncPropMap.put(Capabilities.CapabilitiesPropName, cap);
127 Bandwidth bw = new Bandwidth (Bandwidth.BW1Gbps);
128 ncPropMap.put(Bandwidth.BandwidthPropName, bw);
129 State st = new State (State.EDGE_UP);
130 ncPropMap.put(State.StatePropName, st);
132 // setup property map for all node connectors
133 NodeConnector nc = NodeConnectorCreator.createOFNodeConnector
134 ((short)2, NodeCreator.createOFNode(3L));
135 nodeConnectorProps.put(nc, ncPropMap);
137 return nodeConnectorProps;