Reduce number of parameters for pcep
[bgpcep.git] / pcep / topology / topology-provider / src / main / java / org / opendaylight / bgpcep / pcep / topology / provider / config / PCEPTopologyConfiguration.java
index 197fa0e5e87a95240f04214a110c43a55a4bb782..0554116f5850aaec70d678cacb9a612438348e78 100644 (file)
@@ -13,6 +13,7 @@ import java.net.InetSocketAddress;
 import javax.annotation.Nonnull;
 import org.opendaylight.protocol.concepts.KeyMapping;
 import org.opendaylight.protocol.pcep.SpeakerIdMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.config.rev171025.pcep.config.SessionConfig;
 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.TopologyId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
@@ -27,17 +28,14 @@ public final class PCEPTopologyConfiguration {
     private final SpeakerIdMapping speakerIds;
     private final InstanceIdentifier<Topology> topology;
 
-    public PCEPTopologyConfiguration(
-            @Nonnull final InetSocketAddress address,
-            @Nonnull final KeyMapping keys,
-            @Nonnull final SpeakerIdMapping speakerIds,
-            @Nonnull final TopologyId topologyId,
-            final short rpcTimeout) {
-        this.address = checkNotNull(address);
-        this.keys = checkNotNull(keys);
-        this.speakerIds = checkNotNull(speakerIds);
-        this.topologyId = checkNotNull(topologyId);
-        this.rpcTimeout = rpcTimeout;
+    public PCEPTopologyConfiguration(@Nonnull final SessionConfig config, @Nonnull final Topology topology) {
+        checkNotNull(topology);
+        this.address = PCEPTopologyProviderUtil
+                .getInetSocketAddress(checkNotNull(config.getListenAddress()), checkNotNull(config.getListenPort()));
+        this.keys = checkNotNull(PCEPTopologyProviderUtil.contructKeys(topology));
+        this.speakerIds = checkNotNull(PCEPTopologyProviderUtil.contructSpeakersId(topology));
+        this.topologyId = checkNotNull(topology.getTopologyId());
+        this.rpcTimeout = config.getRpcTimeout();
         this.topology = InstanceIdentifier.builder(NetworkTopology.class)
                 .child(Topology.class, new TopologyKey(this.topologyId)).build();
     }