super.changes = changes;
}
+ @SuppressWarnings("unchecked")
@Override
public void execute() {
for (Entry<InstanceIdentifier<?>, DataObject> created : changes.entrySet()) {
.getConnectionInfo()
.getRemoteIp()
.equals(uniAugmentation.getIpAddress())) {
+ @SuppressWarnings("unchecked")
InstanceIdentifier<Node> ovsdbNodeIid = (InstanceIdentifier<Node>) created.getKey();
Optional<Node> ovsdbNode = UnimgrUtils.readNode(dataBroker,
LogicalDatastoreType.OPERATIONAL,
this.dataBroker = dataBroker;
this.invoker = invoker;
listeners = new HashSet<ListenerRegistration<DataChangeListener>>();
- listeners.add(dataBroker.registerDataChangeListener(
- LogicalDatastoreType.CONFIGURATION, UnimgrMapper.createUniIid()
- , this, DataChangeScope.SUBTREE));
- listeners.add(dataBroker.registerDataChangeListener(
- LogicalDatastoreType.CONFIGURATION, UnimgrMapper.createEvcIid()
- , this, DataChangeScope.SUBTREE));
- listeners.add(dataBroker.registerDataChangeListener(
- LogicalDatastoreType.OPERATIONAL, UnimgrMapper.getOvsdbTopologyIdentifier()
- , this, DataChangeScope.SUBTREE));
+ listeners.add(dataBroker.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
+ UnimgrMapper.createUniIid(),
+ this,
+ DataChangeScope.SUBTREE));
+ listeners.add(dataBroker.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
+ UnimgrMapper.createEvcIid(),
+ this,
+ DataChangeScope.SUBTREE));
+ listeners.add(dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+ UnimgrMapper.getOvsdbTopologyIdentifier(),
+ this,
+ DataChangeScope.SUBTREE));
}
@Override
- public void onDataChanged(
- AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
+ public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier<?>,
+ DataObject> change) {
create(change.getCreatedData());
update(change.getUpdatedData());
delete(change);
}
@Override
- public void create(Map<InstanceIdentifier<?>, DataObject> changes) {
+ public void create(Map<InstanceIdentifier<?>,
+ DataObject> changes) {
if (changes != null) {
List<Command> commands = new ArrayList<Command>();
commands.add(new UniCreateCommand(dataBroker, changes));
}
@Override
- public void update(Map<InstanceIdentifier<?>, DataObject> changes) {
+ public void update(Map<InstanceIdentifier<?>,
+ DataObject> changes) {
if (changes != null) {
List<Command> commands = new ArrayList<Command>();
commands.add(new UniUpdateCommand(dataBroker, changes));
}
@Override
- public void delete(
- AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
+ public void delete(AsyncDataChangeEvent<InstanceIdentifier<?>,
+ DataObject> changes) {
if (changes != null) {
List<Command> commands = new ArrayList<Command>();
commands.add(new UniDeleteCommand(dataBroker, changes));
public static InstanceIdentifier<Node> getOvsdbNodeIID(NodeId nodeId) {
InstanceIdentifier<Node> nodePath = InstanceIdentifier
- .create(NetworkTopology.class)
- .child(Topology.class, new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
- .child(Node.class,new NodeKey(nodeId));
+ .create(NetworkTopology.class)
+ .child(Topology.class,
+ new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
+ .child(Node.class,
+ new NodeKey(nodeId));
return nodePath;
}
- public static InstanceIdentifier<Node> getOvsdbBridgeNodeIID(NodeId ovsdbNode, String bridgeName) {
+ public static InstanceIdentifier<Node> getOvsdbBridgeNodeIID(NodeId ovsdbNode,
+ String bridgeName) {
NodeId bridgeNodeId = new NodeId(ovsdbNode + UnimgrConstants.DEFAULT_BRIDGE_NODE_ID_SUFFIX + bridgeName);
InstanceIdentifier<Node> nodePath = InstanceIdentifier
- .create(NetworkTopology.class)
- .child(Topology.class, new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
- .child(Node.class,new NodeKey(bridgeNodeId));
+ .create(NetworkTopology.class)
+ .child(Topology.class,
+ new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
+ .child(Node.class,
+ new NodeKey(bridgeNodeId));
return nodePath;
}
+ ":"
+ UnimgrConstants.OVSDB_PORT;
InstanceIdentifier<Node> nodePath = InstanceIdentifier
- .create(NetworkTopology.class)
- .child(Topology.class, new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
- .child(Node.class,new NodeKey(new NodeId(nodeId)));
+ .create(NetworkTopology.class)
+ .child(Topology.class,
+ new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
+ .child(Node.class,
+ new NodeKey(new NodeId(nodeId)));
return nodePath;
}
public static InstanceIdentifier<Node> getOvsdbTopologyIdentifier() {
InstanceIdentifier<Node> path = InstanceIdentifier
- .create(NetworkTopology.class)
- .child(Topology.class,
- new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
- .child(Node.class);
+ .create(NetworkTopology.class)
+ .child(Topology.class,
+ new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
+ .child(Node.class);
return path;
}
public static InstanceIdentifier<TerminationPoint> createTerminationPointInstanceIdentifier(
- Node bridgeNode, String portName) {
- InstanceIdentifier<TerminationPoint> terminationPointPath = InstanceIdentifier
- .create(NetworkTopology.class)
- .child(Topology.class, new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
- .child(Node.class,bridgeNode.getKey())
- .child(TerminationPoint.class, new TerminationPointKey(new TpId(portName)));
+ Node bridgeNode,
+ String portName) {
+ InstanceIdentifier<TerminationPoint> terminationPointPath =
+ InstanceIdentifier
+ .create(NetworkTopology.class)
+ .child(Topology.class,
+ new TopologyKey(UnimgrConstants.OVSDB_TOPOLOGY_ID))
+ .child(Node.class,bridgeNode.getKey())
+ .child(TerminationPoint.class,
+ new TerminationPointKey(new TpId(portName)));
LOG.debug("Termination point InstanceIdentifier generated : {}",terminationPointPath);
return terminationPointPath;
return iid;
}
- public static InstanceIdentifier<Node> createUniIid(DataBroker dataBroker, IpAddress ip) {
+ public static InstanceIdentifier<Node> createUniIid(DataBroker dataBroker,
+ IpAddress ip) {
List<Node> uniNodes = UnimgrUtils.getUniNodes(dataBroker);
for (Node node: uniNodes) {
UniAugmentation uniAugmentation = node.getAugmentation(UniAugmentation.class);
if (uniAugmentation.getIpAddress().equals(ip)) {
InstanceIdentifier<Node> uniNode = InstanceIdentifier
- .create(NetworkTopology.class)
- .child(Topology.class, new TopologyKey(UnimgrConstants.UNI_TOPOLOGY_ID))
- .child(Node.class, new NodeKey(node.getKey()));
+ .create(NetworkTopology.class)
+ .child(Topology.class,
+ new TopologyKey(UnimgrConstants.UNI_TOPOLOGY_ID))
+ .child(Node.class,
+ new NodeKey(node.getKey()));
return uniNode;
}
}
}
public static InstanceIdentifier<Node> createEvcIid() {
- InstanceIdentifier<Node> iid = InstanceIdentifier.create(NetworkTopology.class)
- .child(Topology.class, new TopologyKey(UnimgrConstants.EVC_TOPOLOGY_ID))
- .child(Node.class);
+ InstanceIdentifier<Node> iid = InstanceIdentifier
+ .create(NetworkTopology.class)
+ .child(Topology.class,
+ new TopologyKey(UnimgrConstants.EVC_TOPOLOGY_ID))
+ .child(Node.class);
return iid;
}
public static InstanceIdentifier<Topology> createTopologyIid() {
- InstanceIdentifier<Topology> iid = InstanceIdentifier.create(NetworkTopology.class)
- .child(Topology.class, new TopologyKey(UnimgrConstants.UNI_TOPOLOGY_ID));
+ InstanceIdentifier<Topology> iid = InstanceIdentifier
+ .create(NetworkTopology.class)
+ .child(Topology.class,
+ new TopologyKey(UnimgrConstants.UNI_TOPOLOGY_ID));
return iid;
}
public static InstanceIdentifier<Link> getEvcLinkIID(LinkId id) {
InstanceIdentifier<Link> linkPath = InstanceIdentifier
- .create(NetworkTopology.class)
- .child(Topology.class, new TopologyKey(UnimgrConstants.EVC_TOPOLOGY_ID))
- .child(Link.class,new LinkKey(id));
+ .create(NetworkTopology.class)
+ .child(Topology.class,
+ new TopologyKey(UnimgrConstants.EVC_TOPOLOGY_ID))
+ .child(Link.class,new LinkKey(id));
return linkPath;
}
}
public void onSessionInitiated(ProviderContext session) {
LOG.info("UnimgrProvider Session Initiated");
+ // Retrieve the data broker to create transactions
dataBroker = session.getSALService(DataBroker.class);
invoker = new TransactionInvoker();
+ // Register the unimgr OSGi CLI
BundleContext context = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
- unimgrConsoleRegistration = context.registerService(IUnimgrConsoleProvider.class, this, null);
+ unimgrConsoleRegistration = context.registerService(IUnimgrConsoleProvider.class,
+ this,
+ null);
+ // Register the uni data change listener
listener = new UnimgrDataChangeListener(dataBroker, invoker);
// Initialize operational and default config data in MD-SAL data store
- initDatastore(LogicalDatastoreType.CONFIGURATION, UnimgrConstants.UNI_TOPOLOGY_ID);
- initDatastore(LogicalDatastoreType.OPERATIONAL, UnimgrConstants.UNI_TOPOLOGY_ID);
- initDatastore(LogicalDatastoreType.CONFIGURATION, UnimgrConstants.EVC_TOPOLOGY_ID);
- initDatastore(LogicalDatastoreType.OPERATIONAL, UnimgrConstants.EVC_TOPOLOGY_ID);
+ initDatastore(LogicalDatastoreType.CONFIGURATION,
+ UnimgrConstants.UNI_TOPOLOGY_ID);
+ initDatastore(LogicalDatastoreType.OPERATIONAL,
+ UnimgrConstants.UNI_TOPOLOGY_ID);
+ initDatastore(LogicalDatastoreType.CONFIGURATION,
+ UnimgrConstants.EVC_TOPOLOGY_ID);
+ initDatastore(LogicalDatastoreType.OPERATIONAL,
+ UnimgrConstants.EVC_TOPOLOGY_ID);
}
@Override
listener.close();
}
- protected void initDatastore(final LogicalDatastoreType type, TopologyId topoId) {
+ protected void initDatastore(final LogicalDatastoreType type,
+ TopologyId topoId) {
InstanceIdentifier<Topology> path = InstanceIdentifier
- .create(NetworkTopology.class)
- .child(Topology.class, new TopologyKey(topoId));
+ .create(NetworkTopology.class)
+ .child(Topology.class,
+ new TopologyKey(topoId));
initializeTopology(type);
ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction();
- CheckedFuture<Optional<Topology>, ReadFailedException> unimgrTp = transaction.read(type, path);
+ CheckedFuture<Optional<Topology>, ReadFailedException> unimgrTp = transaction.read(type,
+ path);
try {
if (!unimgrTp.get().isPresent()) {
TopologyBuilder tpb = new TopologyBuilder();
@Override
public boolean addUni(Uni uni) {
- //TODO Uncomment
+ //TODO This code was left commented as an example
if (uni.getIpAddress() == null || uni.getMacAddress() == null) {
return false;
}
}
}
+ @SuppressWarnings("unchecked")
public static void createBridgeNode(DataBroker dataBroker,
Node ovsdbNode,
UniAugmentation uni,