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.ConstructionException;
26 import org.opendaylight.controller.sal.core.Node;
27 import org.opendaylight.controller.sal.core.NodeConnector;
28 import org.opendaylight.controller.sal.core.Property;
29 import org.opendaylight.controller.sal.core.State;
30 import org.opendaylight.controller.sal.core.Tables;
31 import org.opendaylight.controller.sal.core.TimeStamp;
32 import org.opendaylight.controller.sal.inventory.IPluginInInventoryService;
33 import org.opendaylight.controller.sal.utils.NodeCreator;
34 import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
37 * Stub Implementation for IPluginInReadService used by SAL
41 public class InventoryService implements IPluginInInventoryService {
42 private static final Logger logger = LoggerFactory
43 .getLogger(InventoryService.class);
45 private ConcurrentMap<Node, Map<String, Property>> nodeProps; // properties are maintained in global container only
46 private ConcurrentMap<NodeConnector, Map<String, Property>> nodeConnectorProps; // properties are maintained in global container only
50 * Function called by the dependency manager when all the required
51 * dependencies are satisfied
55 nodeProps = new ConcurrentHashMap<Node, Map<String, Property>>();
56 nodeConnectorProps = new ConcurrentHashMap<NodeConnector, Map<String, Property>>();
57 Node.NodeIDType.registerIDType("STUB", Integer.class);
58 NodeConnector.NodeConnectorIDType.registerIDType("STUB", Integer.class, "STUB");
62 * Function called by the dependency manager when at least one dependency
63 * become unsatisfied or when the component is shutting down because for
64 * example bundle is being stopped.
71 * Function called by dependency manager after "init ()" is called and after
72 * the services provided by the class are registered in the service registry
79 * Function called by the dependency manager before the services exported by
80 * the component are unregistered, this will be followed by a "destroy ()"
88 * Retrieve nodes from openflow
91 public ConcurrentMap<Node, Map<String, Property>> getNodeProps() {
94 Map<String, Property> propMap = new HashMap<String, Property>();
96 Tables t = new Tables((byte)1);
97 propMap.put(Tables.TablesPropName, t);
98 Capabilities c = new Capabilities((int)3);
99 propMap.put(Capabilities.CapabilitiesPropName, c);
100 Actions a = new Actions((int)2);
101 propMap.put(Actions.ActionsPropName, a);
102 Buffers b = new Buffers((int)1);
103 propMap.put(Buffers.BuffersPropName, b);
104 Long connectedSinceTime = 100000L;
105 TimeStamp timeStamp = new TimeStamp(connectedSinceTime,
107 propMap.put(TimeStamp.TimeStampPropName, timeStamp);
109 // setup property map for all nodes
112 node = new Node("STUB", new Integer(0xCAFE));
113 }catch(ConstructionException e){
117 nodeProps.put(node, propMap);
120 node = new Node("STUB", 3366);
121 }catch(ConstructionException e){
124 nodeProps.put(node, propMap);
127 node = new Node("STUB", 4477);
128 }catch(ConstructionException e){
131 nodeProps.put(node, propMap);
137 * Retrieve nodeConnectors from openflow
140 public ConcurrentMap<NodeConnector, Map<String, Property>> getNodeConnectorProps(
143 // setup nodeConnectorProps
144 Map<String, Property> ncPropMap = new HashMap<String, Property>();
145 Capabilities cap = new Capabilities
146 (CapabilitiesType.FLOW_STATS_CAPABILITY.getValue());
147 ncPropMap.put(Capabilities.CapabilitiesPropName, cap);
148 Bandwidth bw = new Bandwidth (Bandwidth.BW1Gbps);
149 ncPropMap.put(Bandwidth.BandwidthPropName, bw);
150 State st = new State (State.EDGE_UP);
151 ncPropMap.put(State.StatePropName, st);
153 // setup property map for all node connectors
157 node = new Node("STUB", new Integer(0xCAFE));
158 nc = new NodeConnector("STUB", 0xCAFE, node);
159 }catch(ConstructionException e){
163 nodeConnectorProps.put(nc, ncPropMap);
166 node = new Node("STUB", 3366);
167 nc = new NodeConnector("STUB", 12, node);
168 } catch(ConstructionException e){
172 nodeConnectorProps.put(nc, ncPropMap);
175 node = new Node("STUB", 4477);
176 nc = new NodeConnector("STUB", 34, node);
177 }catch(ConstructionException e){
181 nodeConnectorProps.put(nc, ncPropMap);
183 return nodeConnectorProps;