diff options
author | Jozef Gloncak <jgloncak@cisco.com> | 2016-02-02 15:16:06 +0100 |
---|---|---|
committer | Jozef Gloncak <jgloncak@cisco.com> | 2016-02-02 15:37:20 +0100 |
commit | 95588dfe07b685ef6ccd3c9dc3697e7baab49712 (patch) | |
tree | 5fa6dfddabdd4d1a75213dd13e26bcc1038a3632 | |
parent | a03a2cb26606a9099f2ea8cfd589f7ef503f0374 (diff) |
Add VPP to bridge domain.
Request for adding VPP to bridge domain is received by
VPP application which send this requirement to mounted VPP.
It means that information about membership of VPP is
resend to VPP and stored to its datastore.
Change-Id: Idc44b4d0bd505597cfb89b537eb9d17eaac50391
Signed-off-by: Jozef Gloncak <jgloncak@cisco.com>
-rw-r--r-- | vbd/api/src/main/yang/vbridge-topology.yang | 2 | ||||
-rw-r--r-- | vbd/impl/pom.xml | 6 | ||||
-rw-r--r-- | vbd/impl/src/main/java/io/fd/honeycomb/vbd/impl/BridgeDomain.java | 61 |
3 files changed, 65 insertions, 4 deletions
diff --git a/vbd/api/src/main/yang/vbridge-topology.yang b/vbd/api/src/main/yang/vbridge-topology.yang index f105b5e41..901907387 100644 --- a/vbd/api/src/main/yang/vbridge-topology.yang +++ b/vbd/api/src/main/yang/vbridge-topology.yang @@ -91,8 +91,10 @@ module vbridge-topology { } augment "/nt:network-topology/nt:topology/nt:node" { + ext:augment-identifier "node-vbridge-augment"; when "../nt:topology-types/vbridge-topology"; + container bridge-member { presence "Indicates this node is part of the bridge domain"; diff --git a/vbd/impl/pom.xml b/vbd/impl/pom.xml index d4ac30d62..6f966b8c8 100644 --- a/vbd/impl/pom.xml +++ b/vbd/impl/pom.xml @@ -51,6 +51,12 @@ <artifactId>vbd-api</artifactId> </dependency> + <dependency> + <groupId>io.fd.honeycomb.v3po</groupId> + <artifactId>v3po-api</artifactId> + <version>1.0.0-SNAPSHOT</version> + </dependency> + <!-- Testing Dependencies --> <dependency> <groupId>junit</groupId> diff --git a/vbd/impl/src/main/java/io/fd/honeycomb/vbd/impl/BridgeDomain.java b/vbd/impl/src/main/java/io/fd/honeycomb/vbd/impl/BridgeDomain.java index 9cea6589f..e7652aa32 100644 --- a/vbd/impl/src/main/java/io/fd/honeycomb/vbd/impl/BridgeDomain.java +++ b/vbd/impl/src/main/java/io/fd/honeycomb/vbd/impl/BridgeDomain.java @@ -8,6 +8,7 @@ package io.fd.honeycomb.vbd.impl; +import com.google.common.base.Optional; import com.google.common.base.Preconditions; import java.util.Collection; import javax.annotation.concurrent.GuardedBy; @@ -18,15 +19,26 @@ import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.Mod import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; +import org.opendaylight.controller.md.sal.binding.api.MountPoint; import org.opendaylight.controller.md.sal.binding.api.MountPointService; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Vpp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.BridgeDomains; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomainKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomainBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vbridge.topology.rev160129.TopologyVbridgeAugment; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNode; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,12 +50,14 @@ import org.slf4j.LoggerFactory; final class BridgeDomain implements DataTreeChangeListener<Topology> { private static final Logger LOG = LoggerFactory.getLogger(BridgeDomain.class); private final KeyedInstanceIdentifier<Topology, TopologyKey> topology; - @GuardedBy("this") + private final BindingTransactionChain chain; private final ListenerRegistration<?> reg; private final MountPointService mountService; private TopologyVbridgeAugment config; + private final String bridgeDomainName; + private final InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomain> iiBridgeDomainOnVPP; private BridgeDomain(final DataBroker dataBroker, final MountPointService mountService, final KeyedInstanceIdentifier<Topology, TopologyKey> topology, final BindingTransactionChain chain) { @@ -51,6 +65,11 @@ final class BridgeDomain implements DataTreeChangeListener<Topology> { this.chain = Preconditions.checkNotNull(chain); this.mountService = mountService; + this.bridgeDomainName = topology.getKey().getTopologyId().getValue(); + this.iiBridgeDomainOnVPP = InstanceIdentifier.create(Vpp.class) + .child(BridgeDomains.class) + .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomain.class, new BridgeDomainKey(bridgeDomainName)); + reg = dataBroker.registerDataTreeChangeListener( new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, topology), this); } @@ -110,7 +129,7 @@ final class BridgeDomain implements DataTreeChangeListener<Topology> { LOG.debug("Topology {} modified child {}", topology, child); if (Node.class.isAssignableFrom(child.getDataType())) { - modifyNode((DataObjectModification<Node>) child); + modifyNode((DataObjectModification<Node>) child, newConfig.getDataAfter()); } } @@ -136,7 +155,7 @@ final class BridgeDomain implements DataTreeChangeListener<Topology> { } } - private void modifyNode(final DataObjectModification<Node> child) { + private void modifyNode(final DataObjectModification<Node> child, final TopologyVbridgeAugment topologyVbridgeAugment) { switch (child.getModificationType()) { case DELETE: LOG.debug("Topology {} node {} deleted", topology, child.getIdentifier()); @@ -148,7 +167,7 @@ final class BridgeDomain implements DataTreeChangeListener<Topology> { break; case WRITE: LOG.debug("Topology {} node {} created", topology, child.getIdentifier()); - // FIXME: do something + createNode(child.getDataAfter(), topologyVbridgeAugment); break; default: LOG.warn("Unhandled node modification {} in topology {}", child, topology); @@ -156,6 +175,40 @@ final class BridgeDomain implements DataTreeChangeListener<Topology> { } } + private void createNode(final Node node, final TopologyVbridgeAugment topologyVbridgeAugment) { + for (SupportingNode supportingNode : node.getSupportingNode()) { + final NodeId nodeMount = supportingNode.getNodeRef(); + final TopologyId topologyMount = supportingNode.getTopologyRef(); + + final KeyedInstanceIdentifier<Node, NodeKey> iiToMount = InstanceIdentifier + .create(NetworkTopology.class) + .child(Topology.class, new TopologyKey(topologyMount)) + .child(Node.class, new NodeKey(nodeMount)); + final Optional<MountPoint> vppMountOption = mountService.getMountPoint(iiToMount); + if (vppMountOption.isPresent()) { + final MountPoint vppMount = vppMountOption.get(); + addVppToBridgeDomain(topologyVbridgeAugment, vppMount); + } + } + } + + private void addVppToBridgeDomain(TopologyVbridgeAugment topologyVbridgeAugment, MountPoint vppMount) { + final Optional<DataBroker> dataBrokerOpt = vppMount.getService(DataBroker.class); + if (dataBrokerOpt.isPresent()) { + final DataBroker vppDataBroker = dataBrokerOpt.get(); + final WriteTransaction wTx = vppDataBroker.newWriteOnlyTransaction(); + wTx.put(LogicalDatastoreType.OPERATIONAL, iiBridgeDomainOnVPP, prepareNewBridgeDomainData(topologyVbridgeAugment)); + wTx.submit(); + } + } + + private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomain + prepareNewBridgeDomainData(TopologyVbridgeAugment topologyVbridgeAugment) { + final BridgeDomainBuilder bridgeDomainBuilder = new BridgeDomainBuilder(topologyVbridgeAugment); + bridgeDomainBuilder.setName(topology.getKey().getTopologyId().getValue()); + return bridgeDomainBuilder.build(); + } + private void setConfiguration(final TopologyVbridgeAugment config) { LOG.debug("Topology {} configuration set to {}", topology, config); |